From 614ed865a738b26b45044435ad881b0a45d71f34 Mon Sep 17 00:00:00 2001 From: Eusebiu Marcu Date: Tue, 23 Nov 2010 01:30:35 +0200 Subject: [PATCH] add module names and line number to callstack --- data/resources/StringResources.resx | 12 +++++ .../Options/DebuggingOptions.cs | 2 + .../Debugger.AddIn/Pads/CallStackPad.xaml.cs | 54 ++++++++++++++++--- .../Debugger/Debugger.Core/StackFrame.cs | 2 +- 4 files changed, 62 insertions(+), 8 deletions(-) diff --git a/data/resources/StringResources.resx b/data/resources/StringResources.resx index ac4d13f4e8..32061a65b5 100644 --- a/data/resources/StringResources.resx +++ b/data/resources/StringResources.resx @@ -5741,6 +5741,15 @@ Unable to find 'WelcomeDialogId' in Dialogs.wxs Show external methods + + Show line numbers + + + Show module names + + + Line + Ask @@ -5937,6 +5946,9 @@ Shows the full callstack of the error. Object Graph + + Parallel Stack + Run to cursor diff --git a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs index f44e5e1583..e7883de063 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Options/DebuggingOptions.cs @@ -23,6 +23,8 @@ namespace ICSharpCode.SharpDevelop.Services public bool ShowArgumentNames; public bool ShowArgumentValues; public bool ShowExternalMethods; + public bool ShowLineNumbers; + public bool ShowModuleNames; // Properties for the DebuggerExceptionForm public FormWindowState DebuggerEventWindowState = FormWindowState.Normal; diff --git a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs index b2a0e3bc53..15b403f223 100644 --- a/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs +++ b/src/AddIns/Debugger/Debugger.AddIn/Pads/CallStackPad.xaml.cs @@ -32,6 +32,22 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads ContextMenu CreateMenu() { + MenuItem extMethodsItem = new MenuItem(); + extMethodsItem.Header = ResourceService.GetString("MainWindow.Windows.Debug.CallStack.ShowExternalMethods"); + extMethodsItem.IsChecked = DebuggingOptions.Instance.ShowExternalMethods; + extMethodsItem.Click += delegate { + extMethodsItem.IsChecked = DebuggingOptions.Instance.ShowExternalMethods = !DebuggingOptions.Instance.ShowExternalMethods; + RefreshPad(); + }; + + MenuItem moduleItem = new MenuItem(); + moduleItem.Header = ResourceService.GetString("MainWindow.Windows.Debug.CallStack.ShowModuleNames"); + moduleItem.IsChecked = DebuggingOptions.Instance.ShowModuleNames; + moduleItem.Click += delegate { + moduleItem.IsChecked = DebuggingOptions.Instance.ShowModuleNames = !DebuggingOptions.Instance.ShowModuleNames; + RefreshPad(); + }; + MenuItem argNamesItem = new MenuItem(); argNamesItem.Header = ResourceService.GetString("MainWindow.Windows.Debug.CallStack.ShowArgumentNames"); argNamesItem.IsChecked = DebuggingOptions.Instance.ShowArgumentNames; @@ -48,19 +64,22 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads RefreshPad(); }; - MenuItem extMethodsItem = new MenuItem(); - extMethodsItem.Header = ResourceService.GetString("MainWindow.Windows.Debug.CallStack.ShowExternalMethods"); - extMethodsItem.IsChecked = DebuggingOptions.Instance.ShowExternalMethods; - extMethodsItem.Click += delegate { - extMethodsItem.IsChecked = DebuggingOptions.Instance.ShowExternalMethods = !DebuggingOptions.Instance.ShowExternalMethods; + MenuItem lineItem = new MenuItem(); + lineItem.Header = ResourceService.GetString("MainWindow.Windows.Debug.CallStack.ShowLineNumber"); + lineItem.IsChecked = DebuggingOptions.Instance.ShowLineNumbers; + lineItem.Click += delegate { + lineItem.IsChecked = DebuggingOptions.Instance.ShowLineNumbers = !DebuggingOptions.Instance.ShowLineNumbers; RefreshPad(); }; return new ContextMenu() { Items = { + extMethodsItem, + new Separator(), + moduleItem, argNamesItem, argValuesItem, - extMethodsItem + lineItem } }; } @@ -164,12 +183,21 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } } - string GetFullName(StackFrame frame) + internal static string GetFullName(StackFrame frame) { bool showArgumentNames = DebuggingOptions.Instance.ShowArgumentNames; bool showArgumentValues = DebuggingOptions.Instance.ShowArgumentValues; + bool showLineNumber = DebuggingOptions.Instance.ShowLineNumbers; + bool showModuleNames = DebuggingOptions.Instance.ShowModuleNames; StringBuilder name = new StringBuilder(); + + // show modules names + if (showModuleNames) { + name.Append(frame.MethodInfo.DebugModule.ToString()); + name.Append("!"); + } + name.Append(frame.MethodInfo.DeclaringType.Name); name.Append('.'); name.Append(frame.MethodInfo.Name); @@ -209,6 +237,18 @@ namespace ICSharpCode.SharpDevelop.Gui.Pads } name.Append(")"); } + + // line number + if (showLineNumber) { + var segmentCode = frame.GetSegmentForOffet(0); + if (segmentCode != null) { + name.Append(ResourceService.GetString("MainWindow.Windows.Debug.CallStack.LineString")); + name.Append(segmentCode.StartLine.ToString()); + name.Append("->"); + name.Append(frame.NextStatement.StartLine.ToString()); + } + } + return name.ToString(); } } diff --git a/src/AddIns/Debugger/Debugger.Core/StackFrame.cs b/src/AddIns/Debugger/Debugger.Core/StackFrame.cs index 2f0858c23f..44dc1c3ae6 100644 --- a/src/AddIns/Debugger/Debugger.Core/StackFrame.cs +++ b/src/AddIns/Debugger/Debugger.Core/StackFrame.cs @@ -139,7 +139,7 @@ namespace Debugger } } - SourcecodeSegment GetSegmentForOffet(int offset) + public SourcecodeSegment GetSegmentForOffet(int offset) { return SourcecodeSegment.Resolve(this.MethodInfo.DebugModule, corFunction, offset); }