Cleaned up breakpoint creation.

This commit is contained in:
ccrause 2021-11-20 13:17:42 +02:00 committed by Martin
parent eade19d2bd
commit f11d2744db

View File

@ -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);