From f11d2744db0028c00d3c63cb03e61fe7a86b5751 Mon Sep 17 00:00:00 2001 From: ccrause Date: Sat, 20 Nov 2021 13:17:42 +0200 Subject: [PATCH] Cleaned up breakpoint creation. --- components/fpdebug/app/fpd/fpdcommand.pas | 75 ++++++----------------- 1 file changed, 18 insertions(+), 57 deletions(-) diff --git a/components/fpdebug/app/fpd/fpdcommand.pas b/components/fpdebug/app/fpd/fpdcommand.pas index 7ddd9cac02..a87be63cf3 100644 --- a/components/fpdebug/app/fpd/fpdcommand.pas +++ b/components/fpdebug/app/fpd/fpdcommand.pas @@ -214,10 +214,6 @@ var e, Id: Integer; Line: Cardinal; bp: TFpInternalBreakpoint; - - AContext: TFpDbgSymbolScope; - AValue: TFpValue; - begin CallProcessLoop:=false; if GController.MainProcess = nil @@ -250,6 +246,7 @@ begin // current addr P := ''; Address := GController.CurrentThread.GetInstructionPointerRegisterValue; + bp := GController.CurrentProcess.AddBreak(Address); end else begin P := GetPart([], [':'], S); @@ -259,43 +256,13 @@ begin then begin if P <> '' then begin - // address given + // Try to convert parameter to address Val(P, Address, e); - if e <> 0 - then begin - AContext := GController.CurrentProcess.SymbolTableInfo.FindSymbolScope( - GController.DefaultContext, - GController.CurrentThread.GetInstructionPointerRegisterValue - ); - if AContext = nil then begin - Writeln('Invalid context'); - exit; - end; - AValue := AContext.FindSymbol(P); - if not assigned(AValue) then begin - WriteLN('Illegal address/unknown symbol: ', P); - Exit; - end; - Address:=AValue.Address.Address; - AValue.ReleaseReference; - end; + if e = 0 then + bp := GController.CurrentProcess.AddBreak(Address) + else // Assume it is a proc/func name + bp := GController.CurrentProcess.AddBreak(P); end; - //if Remove - //then begin - // if GController.CurrentProcess.RemoveBreak(Address) - // then WriteLn(format(sRemoveBreakpoint,[FormatAddress(Address)])) - // else WriteLn(Format(sRemoveBreakpointFailed, [FormatAddress(Address)])); - //end - //else begin - bp := GController.CurrentProcess.AddBreak(Address); - if bp <> nil then begin - inc(CurBreakId); - BreakPointIdMap.Add(CurBreakId, bp); - WriteLn(format(sAddBreakpoint, [CurBreakId, FormatAddress(Address)])); - end - else - WriteLn(Format(sAddBreakpointFailed, [FormatAddress(Address)])); - //end; end else begin S := GetPart([':'], [], S); @@ -305,25 +272,19 @@ begin WriteLN('Illegal line: ', S); Exit; end; - //if Remove - //then begin - // if TDbgInstance(GController.CurrentProcess).RemoveBreak(P, Line) - // then WriteLn('breakpoint removed') - // else WriteLn('remove breakpoint failed'); - // Exit; - //end; - bp := TDbgInstance(GController.CurrentProcess).AddBreak(P, Line); - if bp = nil - then begin - WriteLn(Format(sAddBreakpointFailed, [S])); - Exit; - end; - - inc(CurBreakId); - BreakPointIdMap.Add(CurBreakId, bp); - WriteLn(format(sAddBreakpoint, [CurBreakId, ''])); // FormatAddress(bp.Location)])) - end; + bp := GController.CurrentProcess.AddBreak(P, Line); + end; + + if bp = nil + then begin + WriteLn(Format(sAddBreakpointFailed, [S])); + Exit; + end; + + inc(CurBreakId); + BreakPointIdMap.Add(CurBreakId, bp); + WriteLn(format(sAddBreakpoint, [CurBreakId, ''])); // FormatAddress(bp.Location)])) end; procedure HandleContinue(AParams: String; out CallProcessLoop: boolean);