Debugger: fix asm-stepping bring source-edit to front (work around) Issue #40415

This commit is contained in:
Martin 2023-08-06 08:58:58 +02:00
parent a0fddef59c
commit 478b6dcf4b

View File

@ -144,7 +144,7 @@ type
FDialogs: array[TDebugDialogType] of TDebuggerDlg; FDialogs: array[TDebugDialogType] of TDebuggerDlg;
FInStateChange: Boolean; FInStateChange: Boolean;
FPrevShownWindow: HWND; FPrevShownWindow: HWND;
FStepping: Boolean; FStepping, FAsmStepping: Boolean;
// keep track of the last reported location // keep track of the last reported location
FCurrentLocation: TDBGLocationRec; FCurrentLocation: TDBGLocationRec;
// last hit breakpoint // last hit breakpoint
@ -1704,6 +1704,7 @@ begin
a := FAsmWindowShouldAutoClose or (FDialogs[ddtAssembler] = nil) or (not FDialogs[ddtAssembler].Visible); a := FAsmWindowShouldAutoClose or (FDialogs[ddtAssembler] = nil) or (not FDialogs[ddtAssembler].Visible);
ViewDebugDialog(ddtAssembler); ViewDebugDialog(ddtAssembler);
FAsmWindowShouldAutoClose := a and EnvironmentDebugOpts.DebuggerAutoCloseAsm; FAsmWindowShouldAutoClose := a and EnvironmentDebugOpts.DebuggerAutoCloseAsm;
FAsmStepping := False;
exit; exit;
end; end;
if (FDialogs[ddtAssembler] <> nil) and FAsmWindowShouldAutoClose then if (FDialogs[ddtAssembler] <> nil) and FAsmWindowShouldAutoClose then
@ -1720,8 +1721,12 @@ begin
i := SrcLine; i := SrcLine;
if (Editor <> nil) then if (Editor <> nil) then
i := Editor.DebugToSourceLine(i); i := Editor.DebugToSourceLine(i);
if not (FAsmStepping and (FDialogs[ddtAssembler] <> nil) and
FDialogs[ddtAssembler].IsVisible and FDialogs[ddtAssembler].Active )
then
if MainIDE.DoJumpToCodePosition(nil,nil,NewSource,1,i,-1,-1,-1,Flags)<>mrOk if MainIDE.DoJumpToCodePosition(nil,nil,NewSource,1,i,-1,-1,-1,Flags)<>mrOk
then exit; then exit;
FAsmStepping := False;
// mark execution line // mark execution line
if (Editor = nil) and (SourceEditorManager <> nil) then if (Editor = nil) and (SourceEditorManager <> nil) then
@ -2818,6 +2823,7 @@ begin
end; end;
FStepping:=True; FStepping:=True;
FAsmStepping := False;
FDebugger.StepInto; FDebugger.StepInto;
Result := mrOk; Result := mrOk;
end; end;
@ -2833,6 +2839,7 @@ begin
end; end;
FStepping:=True; FStepping:=True;
FAsmStepping := False;
FDebugger.StepOver; FDebugger.StepOver;
Result := mrOk; Result := mrOk;
end; end;
@ -2848,6 +2855,7 @@ begin
end; end;
FStepping:=True; FStepping:=True;
FAsmStepping := True;
FDebugger.StepIntoInstr; FDebugger.StepIntoInstr;
Result := mrOk; Result := mrOk;
// Todo: move to DebuggerChangeState (requires the last run-command-type to be avail) // Todo: move to DebuggerChangeState (requires the last run-command-type to be avail)
@ -2865,6 +2873,7 @@ begin
end; end;
FStepping:=True; FStepping:=True;
FAsmStepping := True;
FDebugger.StepOverInstr; FDebugger.StepOverInstr;
Result := mrOk; Result := mrOk;
// Todo: move to DebuggerChangeState (requires the last run-command-type to be avail) // Todo: move to DebuggerChangeState (requires the last run-command-type to be avail)
@ -2888,6 +2897,7 @@ begin
end; end;
FStepping:=True; FStepping:=True;
FAsmStepping := False;
FDebugger.StepOut; FDebugger.StepOut;
Result := mrOk; Result := mrOk;
end; end;
@ -2899,6 +2909,7 @@ begin
FRunTimer.Enabled:=false; FRunTimer.Enabled:=false;
Exclude(FManagerStates,dmsWaitForRun); Exclude(FManagerStates,dmsWaitForRun);
Exclude(FManagerStates,dmsWaitForAttach); Exclude(FManagerStates,dmsWaitForAttach);
FAsmStepping := False;
SourceEditorManager.ClearExecutionLines; SourceEditorManager.ClearExecutionLines;
if (MainIDE.ToolStatus=itDebugger) and (FDebugger<>nil) and (not Destroying) if (MainIDE.ToolStatus=itDebugger) and (FDebugger<>nil) and (not Destroying)
@ -3050,6 +3061,7 @@ begin
end; end;
Include(FManagerStates,dmsRunning); Include(FManagerStates,dmsRunning);
FStepping:=False; FStepping:=False;
FAsmStepping := False;
try try
FDebugger.Run; FDebugger.Run;
finally finally
@ -3332,6 +3344,7 @@ begin
else UnitFilename:=BuildBoss.GetTestUnitFilename(ActiveUnitInfo); else UnitFilename:=BuildBoss.GetTestUnitFilename(ActiveUnitInfo);
FStepping:=True; FStepping:=True;
FAsmStepping := False;
FDebugger.RunTo(ExtractFilename(UnitFilename), FDebugger.RunTo(ExtractFilename(UnitFilename),
TSourceEditor(ActiveSrcEdit).EditorComponent.CaretY); TSourceEditor(ActiveSrcEdit).EditorComponent.CaretY);
@ -3397,6 +3410,7 @@ begin
end; end;
Include(FManagerStates,dmsRunning); Include(FManagerStates,dmsRunning);
FStepping:=False; FStepping:=False;
FAsmStepping := False;
try try
FDebugger.Attach(FAttachToID); FDebugger.Attach(FAttachToID);
finally finally