From edfb65a32a5c9736a033db4e49b09338464a2f30 Mon Sep 17 00:00:00 2001 From: Siegfried Pammer Date: Sun, 17 May 2026 08:22:31 +0200 Subject: [PATCH] DebugStepCommand calls Debugger.Launch if not attached Stepper.Step's break-at-step-limit relies on Debugger.Break(), which is a silent no-op when no debugger is attached. The wiring (command -> RestartDecompileWithStepLimit -> DecompilationOptions.IsDebug -> context.Stepper.IsDebug -> Stepper.Step) was all correct, but the common-case "user runs from a terminal" left the gesture invisible. Assisted-by: Claude:claude-opus-4-7:Claude Code --- ILSpy/ViewModels/DebugStepsPaneModel.cs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ILSpy/ViewModels/DebugStepsPaneModel.cs b/ILSpy/ViewModels/DebugStepsPaneModel.cs index 2d1dceae8..00edda824 100644 --- a/ILSpy/ViewModels/DebugStepsPaneModel.cs +++ b/ILSpy/ViewModels/DebugStepsPaneModel.cs @@ -97,7 +97,20 @@ namespace ILSpy.ViewModels Title = "Debug Steps"; ShowStateBeforeCommand = new RelayCommand(() => RequestRedecompile(SelectedStep?.BeginStep ?? int.MaxValue, isDebug: false)); ShowStateAfterCommand = new RelayCommand(() => RequestRedecompile(SelectedStep?.EndStep ?? int.MaxValue, isDebug: false)); - DebugStepCommand = new RelayCommand(() => RequestRedecompile(SelectedStep?.BeginStep ?? int.MaxValue, isDebug: true)); + DebugStepCommand = new RelayCommand(() => { + // "Debug this step" relies on Stepper.Step calling Debugger.Break() when + // step == StepLimit — which is a silent no-op without a debugger attached. + // Attempt to attach one first so the gesture actually does something for the + // common case of running ILSpy from a terminal. On Windows this pops + // the JIT-debugger prompt; on Linux/macOS Debugger.Launch is a no-op so the + // break is still silent — log a hint so the user knows why. + if (!System.Diagnostics.Debugger.IsAttached) + { + if (!System.Diagnostics.Debugger.Launch()) + AppEnv.AppLog.Mark("DebugStep: Debugger.Launch returned false; the upcoming Stepper.Step break is a no-op without a debugger attached."); + } + RequestRedecompile(SelectedStep?.BeginStep ?? int.MaxValue, isDebug: true); + }); } [ImportingConstructor]