Skip to content

Commit a25c5b7

Browse files
committed
Add option to not auto-update debug start settings when selected assembly changes
1 parent d6bf16f commit a25c5b7

File tree

6 files changed

+65
-21
lines changed

6 files changed

+65
-21
lines changed

Extensions/dnSpy.Debugger/dnSpy.Debugger/DbgUI/StartDebuggingOptionsProvider.cs

+6-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ sealed class StartDebuggingOptionsProvider {
4343
readonly Lazy<StartDebuggingOptionsPageProvider>[] startDebuggingOptionsPageProviders;
4444
readonly Lazy<DbgProcessStarterService> dbgProcessStarterService;
4545
readonly Lazy<GenericDebugEngineGuidProvider, IGenericDebugEngineGuidProviderMetadata>[] genericDebugEngineGuidProviders;
46+
readonly Lazy<Settings.DebuggerSettingsImpl> debuggerSettingsImpl;
4647
readonly StartDebuggingOptionsMru mru;
4748

4849
[ImportingConstructor]
49-
StartDebuggingOptionsProvider(IAppWindow appWindow, IDocumentTabService documentTabService, Lazy<DbgProcessStarterService> dbgProcessStarterService, [ImportMany] IEnumerable<Lazy<StartDebuggingOptionsPageProvider>> startDebuggingOptionsPageProviders, [ImportMany] IEnumerable<Lazy<GenericDebugEngineGuidProvider, IGenericDebugEngineGuidProviderMetadata>> genericDebugEngineGuidProviders) {
50+
StartDebuggingOptionsProvider(IAppWindow appWindow, IDocumentTabService documentTabService, Lazy<DbgProcessStarterService> dbgProcessStarterService, [ImportMany] IEnumerable<Lazy<StartDebuggingOptionsPageProvider>> startDebuggingOptionsPageProviders, [ImportMany] IEnumerable<Lazy<GenericDebugEngineGuidProvider, IGenericDebugEngineGuidProviderMetadata>> genericDebugEngineGuidProviders, Lazy<Settings.DebuggerSettingsImpl> debuggerSettingsImpl) {
51+
this.debuggerSettingsImpl = debuggerSettingsImpl;
5052
this.appWindow = appWindow;
5153
this.documentTabService = documentTabService;
5254
this.dbgProcessStarterService = dbgProcessStarterService;
@@ -87,6 +89,9 @@ string GetCurrentFilename() {
8789

8890
var oldOptions = mru.TryGetOptions(filename);
8991
var lastOptions = mru.TryGetLastOptions();
92+
if (oldOptions == null && lastOptions.HasValue && lastOptions!.Value.options != null && debuggerSettingsImpl.Value.DontAutoUpdateDebugLaunchSettings)
93+
oldOptions = lastOptions.Value;
94+
9095
foreach (var page in pages) {
9196
if (oldOptions?.pageGuid == page.Guid)
9297
page.InitializePreviousOptions(WithBreakKind(oldOptions!.Value.options, defaultBreakKind));

Extensions/dnSpy.Debugger/dnSpy.Debugger/Properties/dnSpy.Debugger.Resources.Designer.cs

+9
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Extensions/dnSpy.Debugger/dnSpy.Debugger/Properties/dnSpy.Debugger.Resources.resx

+3
Original file line numberDiff line numberDiff line change
@@ -1554,4 +1554,7 @@ Do you wish to continue?</value>
15541554
<data name="Column_LoadModule" xml:space="preserve">
15551555
<value>Load</value>
15561556
</data>
1557+
<data name="DbgSettings_DontAutoUpdateDebugLaunchSettings" xml:space="preserve">
1558+
<value>Don't auto update debugger launch settings unless first time since dnSpy launch</value>
1559+
</data>
15571560
</root>

Extensions/dnSpy.Debugger/dnSpy.Debugger/Settings/DebuggerSettingsImpl.cs

+20
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,23 @@ public override bool HideDeprecatedError {
471471
}
472472
bool hideDeprecatedError = false;
473473

474+
public override bool DontAutoUpdateDebugLaunchSettings {
475+
get {
476+
lock (lockObj)
477+
return dontAutoUpdateDebugLaunchSettings;
478+
}
479+
set {
480+
bool modified;
481+
lock (lockObj) {
482+
modified = dontAutoUpdateDebugLaunchSettings != value;
483+
dontAutoUpdateDebugLaunchSettings = value;
484+
}
485+
if (modified)
486+
OnPropertyChanged(nameof(DontAutoUpdateDebugLaunchSettings));
487+
}
488+
}
489+
bool dontAutoUpdateDebugLaunchSettings = false;
490+
474491
public override bool SuppressJITOptimization_SystemModules {
475492
get {
476493
lock (lockObj)
@@ -707,6 +724,7 @@ public DebuggerSettingsBase CopyTo(DebuggerSettingsBase other) {
707724
other.SuppressJITOptimization_SystemModules = SuppressJITOptimization_SystemModules;
708725
other.SuppressJITOptimization_ProgramModules = SuppressJITOptimization_ProgramModules;
709726
other.FocusActiveProcess = FocusActiveProcess;
727+
other.DontAutoUpdateDebugLaunchSettings = DontAutoUpdateDebugLaunchSettings;
710728
other.FocusDebuggerWhenProcessBreaks = FocusDebuggerWhenProcessBreaks;
711729
other.ShowReturnValues = ShowReturnValues;
712730
other.RedirectGuiConsoleOutput = RedirectGuiConsoleOutput;
@@ -761,6 +779,7 @@ sealed class DebuggerSettingsImpl : DebuggerSettingsBase {
761779
SuppressJITOptimization_SystemModules = sect.Attribute<bool?>(nameof(SuppressJITOptimization_SystemModules)) ?? SuppressJITOptimization_SystemModules;
762780
SuppressJITOptimization_ProgramModules = sect.Attribute<bool?>(nameof(SuppressJITOptimization_ProgramModules)) ?? SuppressJITOptimization_ProgramModules;
763781
FocusActiveProcess = sect.Attribute<bool?>(nameof(FocusActiveProcess)) ?? FocusActiveProcess;
782+
DontAutoUpdateDebugLaunchSettings = sect.Attribute<bool?>(nameof(DontAutoUpdateDebugLaunchSettings)) ?? DontAutoUpdateDebugLaunchSettings;
764783
FocusDebuggerWhenProcessBreaks = sect.Attribute<bool?>(nameof(FocusDebuggerWhenProcessBreaks)) ?? FocusDebuggerWhenProcessBreaks;
765784
ShowReturnValues = sect.Attribute<bool?>(nameof(ShowReturnValues)) ?? ShowReturnValues;
766785
RedirectGuiConsoleOutput = sect.Attribute<bool?>(nameof(RedirectGuiConsoleOutput)) ?? RedirectGuiConsoleOutput;
@@ -804,6 +823,7 @@ void DebuggerSettingsImpl_PropertyChanged(object? sender, PropertyChangedEventAr
804823
sect.Attribute(nameof(SuppressJITOptimization_SystemModules), SuppressJITOptimization_SystemModules);
805824
sect.Attribute(nameof(SuppressJITOptimization_ProgramModules), SuppressJITOptimization_ProgramModules);
806825
sect.Attribute(nameof(FocusActiveProcess), FocusActiveProcess);
826+
sect.Attribute(nameof(DontAutoUpdateDebugLaunchSettings), DontAutoUpdateDebugLaunchSettings);
807827
sect.Attribute(nameof(FocusDebuggerWhenProcessBreaks), FocusDebuggerWhenProcessBreaks);
808828
sect.Attribute(nameof(ShowReturnValues), ShowReturnValues);
809829
sect.Attribute(nameof(RedirectGuiConsoleOutput), RedirectGuiConsoleOutput);

Extensions/dnSpy.Debugger/dnSpy.Debugger/Themes/wpf.styles.templates.xaml

+22-20
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
<RowDefinition Height="Auto" />
6464
<RowDefinition Height="Auto" />
6565
<RowDefinition Height="Auto" />
66+
<RowDefinition Height="Auto" />
6667
</Grid.RowDefinitions>
6768
<GroupBox Grid.Row="0" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_DisableDebuggerDetection}">
6869
<Grid>
@@ -90,13 +91,14 @@
9091
<CheckBox Grid.Row="9" Margin="0 5 0 0" IsChecked="{Binding Settings.FocusActiveProcess}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_FocusActiveProcess}" />
9192
<CheckBox Grid.Row="10" Margin="0 5 0 0" IsChecked="{Binding Settings.FocusDebuggerWhenProcessBreaks}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_FocusDebuggerWhenProcessBreaks}" />
9293
<CheckBox Grid.Row="11" Margin="0 5 0 0" IsChecked="{Binding Settings.RedirectGuiConsoleOutput}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_RedirectGuiConsoleOutput}" />
93-
<CheckBox Grid.Row="12" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableManagedDebuggingAssistants}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableManagedDebuggingAssistants}" />
94-
<CheckBox Grid.Row="13" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableJustMyCodeDebugging}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableJustMyCodeDebugging}" />
95-
<CheckBox Grid.Row="14" Margin="0 5 0 0" IsChecked="{Binding Settings.StepOverCodeInSystemModules}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_StepOverCodeInSystemModules}" IsEnabled="{Binding Settings.EnableJustMyCodeDebugging}" />
96-
<CheckBox Grid.Row="15" Margin="0 5 0 0" IsChecked="{Binding Settings.OnlyStepIntoCodeInPrimaryModule}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_OnlyStepIntoCodeInPrimaryModule}" IsEnabled="{Binding Settings.EnableJustMyCodeDebugging}" />
97-
<CheckBox Grid.Row="16" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawStructureOfObjects}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawStructureOfObjects}" />
98-
<CheckBox Grid.Row="17" Margin="0 5 0 0" IsChecked="{Binding Settings.IgnoreUnhandledExceptions}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_IgnoreUnhandledExceptions}" />
99-
<GroupBox Grid.Row="18" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SuppressJITOptimization}">
94+
<CheckBox Grid.Row="12" Margin="0 5 0 0" IsChecked="{Binding Settings.DontAutoUpdateDebugLaunchSettings}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_DontAutoUpdateDebugLaunchSettings}" />
95+
<CheckBox Grid.Row="13" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableManagedDebuggingAssistants}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableManagedDebuggingAssistants}" />
96+
<CheckBox Grid.Row="14" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableJustMyCodeDebugging}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableJustMyCodeDebugging}" />
97+
<CheckBox Grid.Row="15" Margin="0 5 0 0" IsChecked="{Binding Settings.StepOverCodeInSystemModules}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_StepOverCodeInSystemModules}" IsEnabled="{Binding Settings.EnableJustMyCodeDebugging}" />
98+
<CheckBox Grid.Row="16" Margin="0 5 0 0" IsChecked="{Binding Settings.OnlyStepIntoCodeInPrimaryModule}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_OnlyStepIntoCodeInPrimaryModule}" IsEnabled="{Binding Settings.EnableJustMyCodeDebugging}" />
99+
<CheckBox Grid.Row="17" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawStructureOfObjects}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawStructureOfObjects}" />
100+
<CheckBox Grid.Row="18" Margin="0 5 0 0" IsChecked="{Binding Settings.IgnoreUnhandledExceptions}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_IgnoreUnhandledExceptions}" />
101+
<GroupBox Grid.Row="19" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SuppressJITOptimization}">
100102
<Grid>
101103
<Grid.RowDefinitions>
102104
<RowDefinition Height="Auto" />
@@ -106,19 +108,19 @@
106108
<CheckBox Grid.Row="1" Margin="0 5 0 0" IsChecked="{Binding Settings.SuppressJITOptimization_ProgramModules}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SuppressJITOptimization_ProgramModules}" />
107109
</Grid>
108110
</GroupBox>
109-
<CheckBox Grid.Row="19" Margin="0 5 0 0" IsChecked="{Binding Settings.HideCompilerGeneratedMembers}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideCompilerGeneratedMembers}" />
110-
<CheckBox Grid.Row="20" Margin="0 5 0 0" IsChecked="{Binding Settings.RespectHideMemberAttributes}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_RespectHideMemberAttributes}" />
111-
<CheckBox Grid.Row="21" Margin="0 5 0 0" IsChecked="{Binding Settings.HideDeprecatedError}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideDeprecatedError}" />
112-
<CheckBox Grid.Row="22" Margin="0 5 0 0" IsChecked="{Binding Settings.SortParameters}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortParameters}" />
113-
<CheckBox Grid.Row="23" Margin="0 5 0 0" IsChecked="{Binding Settings.SortLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortLocals}" />
114-
<CheckBox Grid.Row="24" Margin="0 5 0 0" IsChecked="{Binding Settings.GroupParametersAndLocalsTogether}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_GroupParametersAndLocalsTogether}" />
115-
<CheckBox Grid.Row="25" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowCompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowCompilerGeneratedVariables}" />
116-
<CheckBox Grid.Row="26" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowDecompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowDecompilerGeneratedVariables}" />
117-
<CheckBox Grid.Row="27" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawLocals}" />
118-
<CheckBox Grid.Row="28" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowReturnValues}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowReturnValues}" />
119-
<CheckBox Grid.Row="29" Margin="0 5 0 0" IsChecked="{Binding Settings.HighlightChangedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HighlightChangedVariables}" />
120-
<CheckBox Grid.Row="30" Margin="0 5 0 0" IsChecked="{Binding Settings.SyntaxHighlight}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SyntaxHighlight}" />
121-
<GroupBox Grid.Row="31" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_Language}">
111+
<CheckBox Grid.Row="20" Margin="0 5 0 0" IsChecked="{Binding Settings.HideCompilerGeneratedMembers}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideCompilerGeneratedMembers}" />
112+
<CheckBox Grid.Row="21" Margin="0 5 0 0" IsChecked="{Binding Settings.RespectHideMemberAttributes}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_RespectHideMemberAttributes}" />
113+
<CheckBox Grid.Row="22" Margin="0 5 0 0" IsChecked="{Binding Settings.HideDeprecatedError}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideDeprecatedError}" />
114+
<CheckBox Grid.Row="23" Margin="0 5 0 0" IsChecked="{Binding Settings.SortParameters}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortParameters}" />
115+
<CheckBox Grid.Row="24" Margin="0 5 0 0" IsChecked="{Binding Settings.SortLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortLocals}" />
116+
<CheckBox Grid.Row="25" Margin="0 5 0 0" IsChecked="{Binding Settings.GroupParametersAndLocalsTogether}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_GroupParametersAndLocalsTogether}" />
117+
<CheckBox Grid.Row="26" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowCompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowCompilerGeneratedVariables}" />
118+
<CheckBox Grid.Row="27" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowDecompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowDecompilerGeneratedVariables}" />
119+
<CheckBox Grid.Row="28" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawLocals}" />
120+
<CheckBox Grid.Row="29" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowReturnValues}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowReturnValues}" />
121+
<CheckBox Grid.Row="30" Margin="0 5 0 0" IsChecked="{Binding Settings.HighlightChangedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HighlightChangedVariables}" />
122+
<CheckBox Grid.Row="31" Margin="0 5 0 0" IsChecked="{Binding Settings.SyntaxHighlight}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SyntaxHighlight}" />
123+
<GroupBox Grid.Row="32" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_Language}">
122124
<Grid>
123125
<Grid.RowDefinitions>
124126
<RowDefinition Height="Auto" />

dnSpy/dnSpy.Contracts.Debugger/DebuggerSettings.cs

+5
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,11 @@ public abstract class DebuggerSettings : INotifyPropertyChanged {
168168
/// </summary>
169169
public abstract bool HideDeprecatedError { get; set; }
170170

171+
/// <summary>
172+
/// Reuse the last launch debug settings unless first time since dnSpy launch
173+
/// </summary>
174+
public abstract bool DontAutoUpdateDebugLaunchSettings { get; set; }
175+
171176
/// <summary>
172177
/// Suppress JIT optimization on module load (system modules). If false, the code will be optimized and
173178
/// much more difficult to debug (it will be like when attaching to a process).

0 commit comments

Comments
 (0)