FpDebug, LazDebuggerFp: Use FindProc instead of FindContext to get SymbolInfo entries

git-svn-id: trunk@62339 -
This commit is contained in:
martin 2019-12-08 00:18:09 +00:00
parent cc3e23afb0
commit 9cd1e928d5
3 changed files with 62 additions and 20 deletions

View File

@ -432,6 +432,12 @@ public
function AddWatch(const ALocation: TDBGPtr; ASize: Cardinal; AReadWrite: TDBGWatchPointKind;
AScope: TDBGWatchPointScope): TFpInternalWatchpoint;
property WatchPointData: TFpWatchPointData read FWatchPointData;
(* FindProcSymbol(Address)
Search the program and all libraries.
FindProcSymbol(Name)
Search ONLY the program.
Names can be ambigious, as dll can have the same names.
*)
function FindProcSymbol(const AName: String): TFpSymbol;
function FindProcSymbol(AAdress: TDbgPtr): TFpSymbol;
function FindContext(AThreadId, AStackFrame: Integer): TFpDbgInfoContext;
@ -1283,7 +1289,8 @@ end;
function TDbgProcess.FindProcSymbol(const AName: String): TFpSymbol;
begin
Result := FDbgInfo.FindProcSymbol(AName);
// SymbolTableInfo.FindProcSymbol()
if Result = nil then
Result := SymbolTableInfo.FindProcSymbol(AName);
end;
function TDbgProcess.FindProcSymbol(AAdress: TDbgPtr): TFpSymbol;
@ -1298,7 +1305,6 @@ begin
if Result <> nil then Exit;
end;
Result := nil;
// SymbolTableInfo.FindProcSymbol()
end;
function TDbgProcess.FindContext(AThreadId, AStackFrame: Integer): TFpDbgInfoContext;

View File

@ -16,6 +16,13 @@ uses
type
{ TFpSymbolTableProc }
TFpSymbolTableProc = class(TFpSymbol)
public
constructor Create(const AName: String; AnAddr: TDbgPtr);
end;
TFpSymbolInfo = class;
{ TFpSymbolContext }
@ -47,11 +54,22 @@ type
function FindContext(AThreadId, AStackFrame: Integer; AAddress: TDbgPtr = 0): TFpDbgInfoContext; override;
function FindContext(AAddress: TDbgPtr): TFpDbgInfoContext; override;
function FindProcSymbol(const AName: String): TFpSymbol; override; overload;
function FindProcSymbol(AnAdress: TDbgPtr): TFpSymbol; overload;
property Image64Bit: boolean read FImage64Bit;
end;
implementation
{ TFpSymbolTableProc }
constructor TFpSymbolTableProc.Create(const AName: String; AnAddr: TDbgPtr);
begin
inherited Create(AName);
SetAddress(TargetLoc(AnAddr));
SetKind(skProcedure);
SetSymbolType(stType);
end;
{ TFpSymbolContext }
function TFpSymbolContext.GetAddress: TDbgPtr;
@ -129,18 +147,40 @@ end;
function TFpSymbolInfo.FindContext(AThreadId, AStackFrame: Integer;
AAddress: TDbgPtr): TFpDbgInfoContext;
begin
Result:=FContext;
assert(False, 'TFpSymbolInfo.FindContext: False');
Result:=FContext; // TODO: nil
end;
function TFpSymbolInfo.FindContext(AAddress: TDbgPtr): TFpDbgInfoContext;
begin
Result:=FContext;
assert(False, 'TFpSymbolInfo.FindContext: False');
Result:=FContext; // TODO: nil
end;
function TFpSymbolInfo.FindProcSymbol(const AName: String): TFpSymbol;
var
i: integer;
begin
result := nil;
//Result:=FContext.FindSymbol(AName);
i := FSymbolList.IndexOf(AName);
if i >= 0 then
Result := TFpSymbolTableProc.Create(AName, FSymbolList.Data[i])
else
result := nil;
end;
function TFpSymbolInfo.FindProcSymbol(AnAdress: TDbgPtr): TFpSymbol;
var
i: integer;
begin
Result := nil;
i := FSymbolList.Count - 1;
while i >= 0 do begin
if FSymbolList.Data[i] = AnAdress then begin
Result := TFpSymbolTableProc.Create(FSymbolList.Keys[i], FSymbolList.Data[i]);
exit;
end;
dec(i);
end;
end;
end.

View File

@ -1701,26 +1701,22 @@ end;
function TFpDebugDebugger.SetSoftwareExceptionBreakpoint: boolean;
var
AContext: TFpDbgInfoContext;
AValue: TFpValue;
AnAddr: TDBGPtr;
AProc: TFpSymbol;
begin
result := false;
if assigned(FDbgController.CurrentProcess.SymbolTableInfo) then
begin
AContext := FDbgController.CurrentProcess.SymbolTableInfo.FindContext(0);
if Assigned(AContext) then
AProc := FDbgController.CurrentProcess.FindProcSymbol('FPC_RAISEEXCEPTION');
if AProc <> nil then
begin
AValue := AContext.FindSymbol('FPC_RAISEEXCEPTION');
if assigned(AValue) then
begin
AnAddr:=AValue.Address.Address;
AValue.ReleaseReference;
debuglnEnter(DBG_BREAKPOINTS, ['>> TFpDebugDebugger.SetSoftwareExceptionBreakpoint FPC_RAISEEXCEPTION' ]);
FRaiseExceptionBreakpoint := AddBreak(AnAddr);
debuglnExit(DBG_BREAKPOINTS, ['<< TFpDebugDebugger.SetSoftwareExceptionBreakpoint ' ]);
if assigned(FRaiseExceptionBreakpoint) then
result := True;
end;
AnAddr:=AProc.Address.Address;
AProc.ReleaseReference;
debuglnEnter(DBG_BREAKPOINTS, ['>> TFpDebugDebugger.SetSoftwareExceptionBreakpoint FPC_RAISEEXCEPTION' ]);
FRaiseExceptionBreakpoint := AddBreak(AnAddr);
debuglnExit(DBG_BREAKPOINTS, ['<< TFpDebugDebugger.SetSoftwareExceptionBreakpoint ' ]);
if assigned(FRaiseExceptionBreakpoint) then
result := True;
end;
end;
end;