Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to not auto-update debug start settings when selected assembly changes #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@ sealed class StartDebuggingOptionsProvider {
readonly Lazy<StartDebuggingOptionsPageProvider>[] startDebuggingOptionsPageProviders;
readonly Lazy<DbgProcessStarterService> dbgProcessStarterService;
readonly Lazy<GenericDebugEngineGuidProvider, IGenericDebugEngineGuidProviderMetadata>[] genericDebugEngineGuidProviders;
readonly Lazy<Settings.DebuggerSettingsImpl> debuggerSettingsImpl;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure we don't actually need the DebuggerSettingsImpl and we could just DI the base DebuggerSettings class instead.

readonly StartDebuggingOptionsMru mru;

[ImportingConstructor]
StartDebuggingOptionsProvider(IAppWindow appWindow, IDocumentTabService documentTabService, Lazy<DbgProcessStarterService> dbgProcessStarterService, [ImportMany] IEnumerable<Lazy<StartDebuggingOptionsPageProvider>> startDebuggingOptionsPageProviders, [ImportMany] IEnumerable<Lazy<GenericDebugEngineGuidProvider, IGenericDebugEngineGuidProviderMetadata>> genericDebugEngineGuidProviders) {
StartDebuggingOptionsProvider(IAppWindow appWindow, IDocumentTabService documentTabService, Lazy<DbgProcessStarterService> dbgProcessStarterService, [ImportMany] IEnumerable<Lazy<StartDebuggingOptionsPageProvider>> startDebuggingOptionsPageProviders, [ImportMany] IEnumerable<Lazy<GenericDebugEngineGuidProvider, IGenericDebugEngineGuidProviderMetadata>> genericDebugEngineGuidProviders, Lazy<Settings.DebuggerSettingsImpl> debuggerSettingsImpl) {
this.debuggerSettingsImpl = debuggerSettingsImpl;
Comment on lines +50 to +51
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as before, I am pretty sure we don't actually need the DebuggerSettingsImpl and we could just DI the base DebuggerSettings class instead.

this.appWindow = appWindow;
this.documentTabService = documentTabService;
this.dbgProcessStarterService = dbgProcessStarterService;
Expand Down Expand Up @@ -87,6 +89,9 @@ sealed class StartDebuggingOptionsProvider {

var oldOptions = mru.TryGetOptions(filename);
var lastOptions = mru.TryGetLastOptions();
if (oldOptions == null && lastOptions.HasValue && lastOptions!.Value.options != null && debuggerSettingsImpl.Value.DontAutoUpdateDebugLaunchSettings)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lastOptions!.Value.options != null is redundant here as options element in the tuple is not marked as nullable and thus should never be null.

oldOptions = lastOptions.Value;

foreach (var page in pages) {
if (oldOptions?.pageGuid == page.Guid)
page.InitializePreviousOptions(WithBreakKind(oldOptions!.Value.options, defaultBreakKind));
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -1554,4 +1554,7 @@ Do you wish to continue?</value>
<data name="Column_LoadModule" xml:space="preserve">
<value>Load</value>
</data>
<data name="DbgSettings_DontAutoUpdateDebugLaunchSettings" xml:space="preserve">
<value>Don't auto update debugger launch settings unless first time since dnSpy launch</value>
</data>
</root>
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,23 @@ class DebuggerSettingsBase : DebuggerSettings {
}
bool hideDeprecatedError = false;

public override bool DontAutoUpdateDebugLaunchSettings {
get {
lock (lockObj)
return dontAutoUpdateDebugLaunchSettings;
}
set {
bool modified;
lock (lockObj) {
modified = dontAutoUpdateDebugLaunchSettings != value;
dontAutoUpdateDebugLaunchSettings = value;
}
if (modified)
OnPropertyChanged(nameof(DontAutoUpdateDebugLaunchSettings));
}
}
bool dontAutoUpdateDebugLaunchSettings = false;

public override bool SuppressJITOptimization_SystemModules {
get {
lock (lockObj)
Expand Down Expand Up @@ -707,6 +724,7 @@ class DebuggerSettingsBase : DebuggerSettings {
other.SuppressJITOptimization_SystemModules = SuppressJITOptimization_SystemModules;
other.SuppressJITOptimization_ProgramModules = SuppressJITOptimization_ProgramModules;
other.FocusActiveProcess = FocusActiveProcess;
other.DontAutoUpdateDebugLaunchSettings = DontAutoUpdateDebugLaunchSettings;
other.FocusDebuggerWhenProcessBreaks = FocusDebuggerWhenProcessBreaks;
other.ShowReturnValues = ShowReturnValues;
other.RedirectGuiConsoleOutput = RedirectGuiConsoleOutput;
Expand Down Expand Up @@ -761,6 +779,7 @@ sealed class DebuggerSettingsImpl : DebuggerSettingsBase {
SuppressJITOptimization_SystemModules = sect.Attribute<bool?>(nameof(SuppressJITOptimization_SystemModules)) ?? SuppressJITOptimization_SystemModules;
SuppressJITOptimization_ProgramModules = sect.Attribute<bool?>(nameof(SuppressJITOptimization_ProgramModules)) ?? SuppressJITOptimization_ProgramModules;
FocusActiveProcess = sect.Attribute<bool?>(nameof(FocusActiveProcess)) ?? FocusActiveProcess;
DontAutoUpdateDebugLaunchSettings = sect.Attribute<bool?>(nameof(DontAutoUpdateDebugLaunchSettings)) ?? DontAutoUpdateDebugLaunchSettings;
FocusDebuggerWhenProcessBreaks = sect.Attribute<bool?>(nameof(FocusDebuggerWhenProcessBreaks)) ?? FocusDebuggerWhenProcessBreaks;
ShowReturnValues = sect.Attribute<bool?>(nameof(ShowReturnValues)) ?? ShowReturnValues;
RedirectGuiConsoleOutput = sect.Attribute<bool?>(nameof(RedirectGuiConsoleOutput)) ?? RedirectGuiConsoleOutput;
Expand Down Expand Up @@ -804,6 +823,7 @@ sealed class DebuggerSettingsImpl : DebuggerSettingsBase {
sect.Attribute(nameof(SuppressJITOptimization_SystemModules), SuppressJITOptimization_SystemModules);
sect.Attribute(nameof(SuppressJITOptimization_ProgramModules), SuppressJITOptimization_ProgramModules);
sect.Attribute(nameof(FocusActiveProcess), FocusActiveProcess);
sect.Attribute(nameof(DontAutoUpdateDebugLaunchSettings), DontAutoUpdateDebugLaunchSettings);
sect.Attribute(nameof(FocusDebuggerWhenProcessBreaks), FocusDebuggerWhenProcessBreaks);
sect.Attribute(nameof(ShowReturnValues), ShowReturnValues);
sect.Attribute(nameof(RedirectGuiConsoleOutput), RedirectGuiConsoleOutput);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<GroupBox Grid.Row="0" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_DisableDebuggerDetection}">
<Grid>
Expand Down Expand Up @@ -90,13 +91,14 @@
<CheckBox Grid.Row="9" Margin="0 5 0 0" IsChecked="{Binding Settings.FocusActiveProcess}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_FocusActiveProcess}" />
<CheckBox Grid.Row="10" Margin="0 5 0 0" IsChecked="{Binding Settings.FocusDebuggerWhenProcessBreaks}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_FocusDebuggerWhenProcessBreaks}" />
<CheckBox Grid.Row="11" Margin="0 5 0 0" IsChecked="{Binding Settings.RedirectGuiConsoleOutput}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_RedirectGuiConsoleOutput}" />
<CheckBox Grid.Row="12" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableManagedDebuggingAssistants}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableManagedDebuggingAssistants}" />
<CheckBox Grid.Row="13" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableJustMyCodeDebugging}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableJustMyCodeDebugging}" />
<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}" />
<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}" />
<CheckBox Grid.Row="16" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawStructureOfObjects}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawStructureOfObjects}" />
<CheckBox Grid.Row="17" Margin="0 5 0 0" IsChecked="{Binding Settings.IgnoreUnhandledExceptions}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_IgnoreUnhandledExceptions}" />
<GroupBox Grid.Row="18" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SuppressJITOptimization}">
<CheckBox Grid.Row="12" Margin="0 5 0 0" IsChecked="{Binding Settings.DontAutoUpdateDebugLaunchSettings}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_DontAutoUpdateDebugLaunchSettings}" />
<CheckBox Grid.Row="13" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableManagedDebuggingAssistants}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableManagedDebuggingAssistants}" />
<CheckBox Grid.Row="14" Margin="0 5 0 0" IsChecked="{Binding Settings.EnableJustMyCodeDebugging}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_EnableJustMyCodeDebugging}" />
<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}" />
<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}" />
<CheckBox Grid.Row="17" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawStructureOfObjects}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawStructureOfObjects}" />
<CheckBox Grid.Row="18" Margin="0 5 0 0" IsChecked="{Binding Settings.IgnoreUnhandledExceptions}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_IgnoreUnhandledExceptions}" />
<GroupBox Grid.Row="19" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SuppressJITOptimization}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand All @@ -106,19 +108,19 @@
<CheckBox Grid.Row="1" Margin="0 5 0 0" IsChecked="{Binding Settings.SuppressJITOptimization_ProgramModules}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SuppressJITOptimization_ProgramModules}" />
</Grid>
</GroupBox>
<CheckBox Grid.Row="19" Margin="0 5 0 0" IsChecked="{Binding Settings.HideCompilerGeneratedMembers}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideCompilerGeneratedMembers}" />
<CheckBox Grid.Row="20" Margin="0 5 0 0" IsChecked="{Binding Settings.RespectHideMemberAttributes}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_RespectHideMemberAttributes}" />
<CheckBox Grid.Row="21" Margin="0 5 0 0" IsChecked="{Binding Settings.HideDeprecatedError}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideDeprecatedError}" />
<CheckBox Grid.Row="22" Margin="0 5 0 0" IsChecked="{Binding Settings.SortParameters}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortParameters}" />
<CheckBox Grid.Row="23" Margin="0 5 0 0" IsChecked="{Binding Settings.SortLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortLocals}" />
<CheckBox Grid.Row="24" Margin="0 5 0 0" IsChecked="{Binding Settings.GroupParametersAndLocalsTogether}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_GroupParametersAndLocalsTogether}" />
<CheckBox Grid.Row="25" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowCompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowCompilerGeneratedVariables}" />
<CheckBox Grid.Row="26" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowDecompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowDecompilerGeneratedVariables}" />
<CheckBox Grid.Row="27" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawLocals}" />
<CheckBox Grid.Row="28" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowReturnValues}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowReturnValues}" />
<CheckBox Grid.Row="29" Margin="0 5 0 0" IsChecked="{Binding Settings.HighlightChangedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HighlightChangedVariables}" />
<CheckBox Grid.Row="30" Margin="0 5 0 0" IsChecked="{Binding Settings.SyntaxHighlight}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SyntaxHighlight}" />
<GroupBox Grid.Row="31" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_Language}">
<CheckBox Grid.Row="20" Margin="0 5 0 0" IsChecked="{Binding Settings.HideCompilerGeneratedMembers}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideCompilerGeneratedMembers}" />
<CheckBox Grid.Row="21" Margin="0 5 0 0" IsChecked="{Binding Settings.RespectHideMemberAttributes}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_RespectHideMemberAttributes}" />
<CheckBox Grid.Row="22" Margin="0 5 0 0" IsChecked="{Binding Settings.HideDeprecatedError}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HideDeprecatedError}" />
<CheckBox Grid.Row="23" Margin="0 5 0 0" IsChecked="{Binding Settings.SortParameters}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortParameters}" />
<CheckBox Grid.Row="24" Margin="0 5 0 0" IsChecked="{Binding Settings.SortLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SortLocals}" />
<CheckBox Grid.Row="25" Margin="0 5 0 0" IsChecked="{Binding Settings.GroupParametersAndLocalsTogether}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_GroupParametersAndLocalsTogether}" />
<CheckBox Grid.Row="26" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowCompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowCompilerGeneratedVariables}" />
<CheckBox Grid.Row="27" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowDecompilerGeneratedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowDecompilerGeneratedVariables}" />
<CheckBox Grid.Row="28" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowRawLocals}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowRawLocals}" />
<CheckBox Grid.Row="29" Margin="0 5 0 0" IsChecked="{Binding Settings.ShowReturnValues}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_ShowReturnValues}" />
<CheckBox Grid.Row="30" Margin="0 5 0 0" IsChecked="{Binding Settings.HighlightChangedVariables}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_HighlightChangedVariables}" />
<CheckBox Grid.Row="31" Margin="0 5 0 0" IsChecked="{Binding Settings.SyntaxHighlight}" Content="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_SyntaxHighlight}" />
<GroupBox Grid.Row="32" Margin="0 5 0 0" Header="{x:Static p:dnSpy_Debugger_Resources.DbgSettings_Language}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
Expand Down
5 changes: 5 additions & 0 deletions dnSpy/dnSpy.Contracts.Debugger/DebuggerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,11 @@ public abstract class DebuggerSettings : INotifyPropertyChanged {
/// </summary>
public abstract bool HideDeprecatedError { get; set; }

/// <summary>
/// Reuse the last launch debug settings unless first time since dnSpy launch
/// </summary>
public abstract bool DontAutoUpdateDebugLaunchSettings { get; set; }

/// <summary>
/// Suppress JIT optimization on module load (system modules). If false, the code will be optimized and
/// much more difficult to debug (it will be like when attaching to a process).
Expand Down