Debugger: Implement changing breakpoint location (line num in brk-property dialog).

- Update source editor marks
- Update FpDebug
This commit is contained in:
Martin 2023-07-27 12:32:36 +02:00
parent 0e1f76f481
commit d3c5d91ce9
4 changed files with 51 additions and 23 deletions

View File

@ -573,6 +573,7 @@ type
FThreadWorker: TFpThreadWorkerBreakPoint; FThreadWorker: TFpThreadWorkerBreakPoint;
FSetBreakFlag: boolean; FSetBreakFlag: boolean;
FResetBreakFlag: boolean; FResetBreakFlag: boolean;
FLocationChanged: boolean;
FInternalBreakpoint: FpDbgClasses.TFpDbgBreakpoint; FInternalBreakpoint: FpDbgClasses.TFpDbgBreakpoint;
FIsSet: boolean; FIsSet: boolean;
FBrkLogStackLimit: Integer; FBrkLogStackLimit: Integer;
@ -587,7 +588,7 @@ type
procedure DoLogExpression(const AnExpression: String); override; procedure DoLogExpression(const AnExpression: String); override;
procedure DoLogCallStack(const Limit: Integer); override; procedure DoLogCallStack(const Limit: Integer); override;
procedure DoStateChange(const AOldState: TDBGState); override; procedure DoStateChange(const AOldState: TDBGState); override;
procedure DoEnableChange; override; procedure DoPropertiesChanged(AChanged: TDbgBpChangeIndicators); override;
procedure DoChanged; override; procedure DoChanged; override;
property Validity: TValidState write SetValid; property Validity: TValidState write SetValid;
public public
@ -1889,12 +1890,16 @@ end;
procedure TFPBreakpoint.SetBreak; procedure TFPBreakpoint.SetBreak;
begin begin
debuglnEnter(DBG_BREAKPOINTS, ['>> TFPBreakpoint.SetBreak ADD ',FSource,':',FLine,'/',dbghex(Address),' ' ]); debuglnEnter(DBG_BREAKPOINTS, ['>> TFPBreakpoint.SetBreak ADD ',FSource,':',FLine,'/',dbghex(Address),' ' ]);
assert(FThreadWorker = nil, 'TFPBreakpoint.SetBreak: FThreadWorker = nil');
assert((FThreadWorker = nil) or ( (FThreadWorker is TFpThreadWorkerBreakPointSetUpdate) and (TFpThreadWorkerBreakPointSetUpdate(FThreadWorker).DbgBreakPoint = nil) ), 'TFPBreakpoint.SetBreak: (FThreadWorker = nil) or ( (FThreadWorker is TFpThreadWorkerBreakPointSetUpdate) and (TFpThreadWorkerBreakPointSetUpdate(FThreadWorker).DbgBreakPoint = nil) )'); assert((FThreadWorker = nil) or ( (FThreadWorker is TFpThreadWorkerBreakPointSetUpdate) and (TFpThreadWorkerBreakPointSetUpdate(FThreadWorker).DbgBreakPoint = nil) ), 'TFPBreakpoint.SetBreak: (FThreadWorker = nil) or ( (FThreadWorker is TFpThreadWorkerBreakPointSetUpdate) and (TFpThreadWorkerBreakPointSetUpdate(FThreadWorker).DbgBreakPoint = nil) )');
assert(FInternalBreakpoint=nil); assert((FInternalBreakpoint=nil) or FLocationChanged, 'TFPBreakpoint.SetBreak: (FInternalBreakpoint=nil) or FLocationChanged');
MaybeAbortWorker; MaybeAbortWorker;
FThreadWorker := TFpThreadWorkerBreakPointSetUpdate.Create(TFpDebugDebugger(Debugger), Self); FThreadWorker := TFpThreadWorkerBreakPointSetUpdate.Create(TFpDebugDebugger(Debugger), Self);
if FLocationChanged then begin
TFpThreadWorkerBreakPointSetUpdate(FThreadWorker).InternalBreakpoint := FInternalBreakpoint;
FInternalBreakpoint := nil;
FLocationChanged := False;
end;
TFpDebugDebugger(Debugger).FWorkQueue.PushItem(FThreadWorker); TFpDebugDebugger(Debugger).FWorkQueue.PushItem(FThreadWorker);
FValid := vsUnknown; FValid := vsUnknown;
@ -2033,7 +2038,7 @@ begin
(TFpDebugDebugger(Debugger).FSendingEvents and (Debugger.State in [dsRun, dsInit])) (TFpDebugDebugger(Debugger).FSendingEvents and (Debugger.State in [dsRun, dsInit]))
then then
begin begin
if Enabled and not FIsSet then if (Enabled and not FIsSet) or FLocationChanged then
begin begin
FSetBreakFlag:=true; FSetBreakFlag:=true;
Changed; Changed;
@ -2051,26 +2056,44 @@ begin
inherited DoStateChange(AOldState); inherited DoStateChange(AOldState);
end; end;
procedure TFPBreakpoint.DoEnableChange; procedure TFPBreakpoint.DoPropertiesChanged(AChanged: TDbgBpChangeIndicators);
var var
ADebugger: TFpDebugDebugger; ADebugger: TFpDebugDebugger;
begin begin
ADebugger := TFpDebugDebugger(Debugger); ADebugger := TFpDebugDebugger(Debugger);
if (ADebugger.State in [dsPause, dsInternalPause, dsInit]) or TFpDebugDebugger(Debugger).FSendingEvents then
begin if ciLocation in AChanged then begin
if Enabled and not FIsSet then if Enabled then begin
FSetBreakFlag := True FLocationChanged := True;
else if not Enabled and FIsSet then if (ADebugger.State in [dsPause, dsInternalPause, dsInit]) or TFpDebugDebugger(Debugger).FSendingEvents then begin
FResetBreakFlag := True; FSetBreakFlag := True;
end end
else if (ADebugger.State = dsRun) then begin else if (ADebugger.State = dsRun) then begin
if Enabled and (not FIsSet) then ADebugger.QuickPause;
ADebugger.QuickPause end;
else end;
if (not Enabled) and FIsSet then
ADebugger.FRunQuickPauseTasks := True;
end; end;
inherited;
if ciEnabled in AChanged then begin
if (ADebugger.State in [dsPause, dsInternalPause, dsInit]) or TFpDebugDebugger(Debugger).FSendingEvents then begin
if Enabled and not FIsSet then begin
FSetBreakFlag := True;
end
else if not Enabled and FIsSet then begin
FResetBreakFlag := True;
FLocationChanged := False;
end;
end
else if (ADebugger.State = dsRun) then begin
if Enabled and (not FIsSet) then
ADebugger.QuickPause
else
if (not Enabled) and FIsSet then
ADebugger.FRunQuickPauseTasks := True;
end;
end;
Changed;
end; end;
procedure TFPBreakpoint.DoChanged; procedure TFPBreakpoint.DoChanged;

View File

@ -325,7 +325,7 @@ type
constructor Create(ADebugger: TFpDebugDebuggerBase; constructor Create(ADebugger: TFpDebugDebuggerBase;
AWatchData: String; AWatchScope: TDBGWatchPointScope; AWatchKind: TDBGWatchPointKind; AWatchData: String; AWatchScope: TDBGWatchPointScope; AWatchKind: TDBGWatchPointKind;
AStackFrame, AThreadId: Integer); AStackFrame, AThreadId: Integer);
property InternalBreakpoint: FpDbgClasses.TFpDbgBreakpoint read FInternalBreakpoint; property InternalBreakpoint: FpDbgClasses.TFpDbgBreakpoint read FInternalBreakpoint write FInternalBreakpoint;
end; end;
{ TFpThreadWorkerBreakPointRemove } { TFpThreadWorkerBreakPointRemove }
@ -1405,6 +1405,11 @@ var
R: TFpValue; R: TFpValue;
s: TFpDbgValueSize; s: TFpDbgValueSize;
begin begin
if (FInternalBreakpoint <> nil) then begin
FDebugger.DbgController.CurrentProcess.RemoveBreak(FInternalBreakpoint);
FreeAndNil(FInternalBreakpoint);
end;
if InterlockedExchange(FResetBreakPoint, 0) = 0 then begin if InterlockedExchange(FResetBreakPoint, 0) = 0 then begin
case FKind of case FKind of
bpkAddress: bpkAddress:

View File

@ -760,6 +760,7 @@ begin
Img := SourceEditorMarks.UnknownDisabledBreakPointImg; Img := SourceEditorMarks.UnknownDisabledBreakPointImg;
end; end;
SourceMark.ImageIndex := Img; SourceMark.ImageIndex := Img;
SourceMark.Visible := True;
end; end;
procedure TManagedBreakPoint.UpdateSourceMarkLineColor; procedure TManagedBreakPoint.UpdateSourceMarkLineColor;

View File

@ -11716,9 +11716,8 @@ begin
if Editor = nil then if Editor = nil then
Exit; Exit;
if ( AMark.IsBreakPoint and (Editor.FSharedValues.ExecutionMark <> nil) and if ( AMark.IsBreakPoint and (Editor.FSharedValues.ExecutionMark <> nil) ) or
(AMark.Line = Editor.ExecutionLine) ( AMark = Editor.FSharedValues.ExecutionMark )
) or (AMark = Editor.FSharedValues.ExecutionMark)
then then
Editor.UpdateExecutionSourceMark; Editor.UpdateExecutionSourceMark;
end; end;