mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-14 03:19:32 +02:00
FpDebug: Allow to create contexct from known ProcSym / Updated TDbgCallstackEntry.GetParamsAsString / Avoid double look-up of proc-symbol
git-svn-id: trunk@62172 -
This commit is contained in:
parent
a4e3cbb35e
commit
5f2f41dd34
@ -103,7 +103,7 @@ type
|
||||
public
|
||||
constructor create(AThread: TDbgThread; AnIndex: integer; AFrameAddress, AnAddress: TDBGPtr);
|
||||
destructor Destroy; override;
|
||||
function GetParamsAsString: string;
|
||||
function GetParamsAsString(APrettyPrinter: TFpPascalPrettyPrinter): string;
|
||||
property AnAddress: TDBGPtr read FAnAddress;
|
||||
property FrameAdress: TDBGPtr read FFrameAdress;
|
||||
property SourceFile: string read GetSourceFile;
|
||||
@ -435,6 +435,7 @@ public
|
||||
function FindProcSymbol(AAdress: TDbgPtr): TFpSymbol;
|
||||
function FindContext(AThreadId, AStackFrame: Integer): TFpDbgInfoContext;
|
||||
function FindContext(AAddress: TDbgPtr): TFpDbgInfoContext; deprecated 'use FindContext(thread,stack)';
|
||||
function ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgInfoContext; inline;
|
||||
function GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
|
||||
function GetThread(const AID: Integer; out AThread: TDbgThread): Boolean;
|
||||
procedure RemoveBreak(const ABreakPoint: TFpDbgBreakpoint);
|
||||
@ -837,43 +838,40 @@ begin
|
||||
result := '';
|
||||
end;
|
||||
|
||||
function TDbgCallstackEntry.GetParamsAsString: string;
|
||||
function TDbgCallstackEntry.GetParamsAsString(
|
||||
APrettyPrinter: TFpPascalPrettyPrinter): string;
|
||||
var
|
||||
ProcVal: TFpValue;
|
||||
InstrPointerValue: TDBGPtr;
|
||||
AContext: TFpDbgInfoContext;
|
||||
APrettyPrinter: TFpPascalPrettyPrinter;
|
||||
m: TFpValue;
|
||||
v: String;
|
||||
i: Integer;
|
||||
OldContext: TFpDbgAddressContext;
|
||||
begin
|
||||
result := '';
|
||||
if assigned(ProcSymbol) then begin
|
||||
ProcVal := ProcSymbol.Value;
|
||||
if (ProcVal <> nil) then begin
|
||||
InstrPointerValue := AnAddress;
|
||||
if InstrPointerValue <> 0 then begin
|
||||
AContext := FThread.Process.DbgInfo.FindContext(FThread.ID, Index, InstrPointerValue);
|
||||
if AContext <> nil then begin
|
||||
AContext.MemManager.DefaultContext := AContext;
|
||||
TFpValueDwarf(ProcVal).Context := AContext;
|
||||
APrettyPrinter:=TFpPascalPrettyPrinter.Create(DBGPTRSIZE[FThread.Process.Mode]);
|
||||
try
|
||||
for i := 0 to ProcVal.MemberCount - 1 do begin
|
||||
m := ProcVal.Member[i];
|
||||
if (m <> nil) and (sfParameter in m.DbgSymbol.Flags) then begin
|
||||
APrettyPrinter.PrintValue(v, m, wdfDefault, -1, [ppoStackParam]);
|
||||
if result <> '' then result := result + ', ';
|
||||
result := result + v;
|
||||
end;
|
||||
m.ReleaseReference;
|
||||
end;
|
||||
finally
|
||||
APrettyPrinter.Free;
|
||||
AContext := FThread.Process.ContextFromProc(FThread.ID, Index, ProcSymbol);
|
||||
|
||||
if AContext <> nil then begin
|
||||
OldContext := AContext.MemManager.DefaultContext;
|
||||
AContext.MemManager.DefaultContext := AContext;
|
||||
TFpValueDwarf(ProcVal).Context := AContext;
|
||||
APrettyPrinter.MemManager := AContext.MemManager;
|
||||
APrettyPrinter.AddressSize := AContext.SizeOfAddress;
|
||||
for i := 0 to ProcVal.MemberCount - 1 do begin
|
||||
m := ProcVal.Member[i];
|
||||
if (m <> nil) and (sfParameter in m.DbgSymbol.Flags) then begin
|
||||
APrettyPrinter.PrintValue(v, m, wdfDefault, -1, [ppoStackParam]);
|
||||
if result <> '' then result := result + ', ';
|
||||
result := result + v;
|
||||
end;
|
||||
TFpValueDwarf(ProcVal).Context := nil;
|
||||
AContext.ReleaseReference;
|
||||
m.ReleaseReference;
|
||||
end;
|
||||
TFpValueDwarf(ProcVal).Context := nil;
|
||||
AContext.MemManager.DefaultContext := OldContext;
|
||||
AContext.ReleaseReference;
|
||||
end;
|
||||
ProcVal.ReleaseReference;
|
||||
end;
|
||||
@ -1327,6 +1325,11 @@ begin
|
||||
// SymbolTableInfo.FindContext()
|
||||
end;
|
||||
|
||||
function TDbgProcess.ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgInfoContext;
|
||||
begin
|
||||
Result := FDbgInfo.ContextFromProc(AThreadId, AStackFrame, AProcSym);
|
||||
end;
|
||||
|
||||
function TDbgProcess.GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
|
||||
var
|
||||
Iterator: TMapIterator;
|
||||
|
@ -74,12 +74,13 @@ type
|
||||
end;
|
||||
|
||||
TFpValueDwarf = class;
|
||||
TFpSymbolDwarfDataProc = class;
|
||||
|
||||
{ TFpDwarfInfoAddressContext }
|
||||
|
||||
TFpDwarfInfoAddressContext = class(TFpDbgInfoContext)
|
||||
private
|
||||
FSymbol: TFpSymbol;
|
||||
FSymbol: TFpSymbolDwarfDataProc;
|
||||
FSelfParameter: TFpValueDwarf;
|
||||
FAddress: TDBGPtr;
|
||||
FThreadId, FStackFrame: Integer;
|
||||
@ -93,7 +94,7 @@ type
|
||||
function GetSizeOfAddress: Integer; override;
|
||||
function GetMemManager: TFpDbgMemManager; override;
|
||||
|
||||
property Symbol: TFpSymbol read FSymbol;
|
||||
property Symbol: TFpSymbolDwarfDataProc read FSymbol;
|
||||
property Dwarf: TFpDwarfInfo read FDwarf;
|
||||
property Address: TDBGPtr read FAddress write FAddress;
|
||||
property ThreadId: Integer read FThreadId write FThreadId;
|
||||
@ -912,6 +913,7 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
|
||||
public
|
||||
constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr); overload;
|
||||
destructor Destroy; override;
|
||||
function CreateContext(AThreadId, AStackFrame: Integer; ADwarfInfo: TFpDwarfInfo): TFpDbgInfoContext; override;
|
||||
// TODO members = locals ?
|
||||
function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpValueDwarf;
|
||||
end;
|
||||
@ -1305,13 +1307,14 @@ end;
|
||||
constructor TFpDwarfInfoAddressContext.Create(AThreadId, AStackFrame: Integer;
|
||||
AnAddress: TDbgPtr; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo);
|
||||
begin
|
||||
assert(ASymbol is TFpSymbolDwarfDataProc, 'TFpDwarfInfoAddressContext.Create: ASymbol is TFpSymbolDwarfDataProc');
|
||||
inherited Create;
|
||||
AddReference;
|
||||
FAddress := AnAddress;
|
||||
FThreadId := AThreadId;
|
||||
FStackFrame := AStackFrame;
|
||||
FDwarf := ADwarf;
|
||||
FSymbol := ASymbol;
|
||||
FSymbol := TFpSymbolDwarfDataProc(ASymbol);
|
||||
FSymbol.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(@FSymbol, 'Context to Symbol'){$ENDIF};
|
||||
end;
|
||||
|
||||
@ -5066,6 +5069,13 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TFpSymbolDwarfDataProc.CreateContext(AThreadId, AStackFrame: Integer;
|
||||
ADwarfInfo: TFpDwarfInfo): TFpDbgInfoContext;
|
||||
begin
|
||||
Result := CompilationUnit.DwarfSymbolClassMap.CreateContext
|
||||
(AThreadId, AStackFrame, Address.Address, Self, ADwarfInfo);
|
||||
end;
|
||||
|
||||
function TFpSymbolDwarfDataProc.GetColumn: Cardinal;
|
||||
begin
|
||||
if StateMachineValid
|
||||
|
@ -448,6 +448,8 @@ type
|
||||
AKind: TDbgSymbolKind; AAddress: TFpDbgMemLocation);
|
||||
destructor Destroy; override;
|
||||
|
||||
function CreateContext(AThreadId, AStackFrame: Integer; ADwarfInfo: TFpDwarfInfo): TFpDbgInfoContext; virtual;
|
||||
|
||||
property CompilationUnit: TDwarfCompilationUnit read FCU;
|
||||
property InformationEntry: TDwarfInformationEntry read FInformationEntry;
|
||||
end;
|
||||
@ -559,7 +561,7 @@ type
|
||||
|
||||
FLineNumberMap: TStringList;
|
||||
|
||||
FAddressMap: TMap; // Holds a key for each DW_TAG_subprogram, stores TDwarfAddressInfo
|
||||
FAddressMap: TMap; // Holds a key for each DW_TAG_subprogram / TFpSymbolDwarfDataProc, stores TDwarfAddressInfo
|
||||
FAddressMapBuild: Boolean;
|
||||
|
||||
FMinPC: QWord; // the min and max PC value found in this unit.
|
||||
@ -654,6 +656,7 @@ type
|
||||
destructor Destroy; override;
|
||||
function FindContext(AThreadId, AStackFrame: Integer; AAddress: TDbgPtr = 0): TFpDbgInfoContext; override;
|
||||
function FindContext(AAddress: TDbgPtr): TFpDbgInfoContext; override;
|
||||
function ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgInfoContext; override;
|
||||
function FindDwarfProcSymbol(AAddress: TDbgPtr): TDbgDwarfSymbolBase; inline;
|
||||
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; override; overload;
|
||||
//function FindSymbol(const AName: String): TDbgSymbol; override; overload;
|
||||
@ -3203,12 +3206,11 @@ var
|
||||
Proc: TDbgDwarfSymbolBase;
|
||||
begin
|
||||
Result := nil;
|
||||
Proc := FindDwarfProcSymbol(AAddress);
|
||||
Proc := FindDwarfProcSymbol(AAddress); // TFpSymbolDwarfDataProc
|
||||
if Proc = nil then
|
||||
exit;
|
||||
|
||||
Result := Proc.CompilationUnit.DwarfSymbolClassMap.CreateContext
|
||||
(AThreadId, AStackFrame, AAddress, Proc, Self);
|
||||
Result := Proc.CreateContext(AThreadId, AStackFrame, Self);
|
||||
Proc.ReleaseReference;
|
||||
end;
|
||||
|
||||
@ -3217,6 +3219,17 @@ begin
|
||||
result := FindContext(1, 0, AAddress);
|
||||
end;
|
||||
|
||||
function TFpDwarfInfo.ContextFromProc(AThreadId, AStackFrame: Integer;
|
||||
AProcSym: TFpSymbol): TFpDbgInfoContext;
|
||||
begin
|
||||
if not (AProcSym is TDbgDwarfSymbolBase) then begin
|
||||
Result := inherited ContextFromProc(AThreadId, AStackFrame, AProcSym);
|
||||
exit;
|
||||
end;
|
||||
|
||||
Result := TDbgDwarfSymbolBase(AProcSym).CreateContext(AThreadId, AStackFrame, Self);
|
||||
end;
|
||||
|
||||
function TFpDwarfInfo.GetCompilationUnit(AIndex: Integer): TDwarfCompilationUnit;
|
||||
begin
|
||||
Result := TDwarfCompilationUnit(FCompilationUnits[Aindex]);
|
||||
@ -3428,6 +3441,12 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TDbgDwarfSymbolBase.CreateContext(AThreadId, AStackFrame: Integer;
|
||||
ADwarfInfo: TFpDwarfInfo): TFpDbgInfoContext;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
{ TDwarfLineInfoStateMachine }
|
||||
|
||||
function TDwarfLineInfoStateMachine.Clone: TDwarfLineInfoStateMachine;
|
||||
|
@ -488,6 +488,7 @@ type
|
||||
*)
|
||||
function FindContext(AThreadId, AStackFrame: Integer; {%H-}AAddress: TDbgPtr = 0): TFpDbgInfoContext; virtual;
|
||||
function FindContext({%H-}AAddress: TDbgPtr): TFpDbgInfoContext; virtual; deprecated 'use FindContext(thread,stack,address)';
|
||||
function ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgInfoContext; virtual;
|
||||
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; virtual; overload;
|
||||
function FindProcSymbol(const {%H-}AName: String): TFpSymbol; virtual; overload;
|
||||
property HasInfo: Boolean read FHasInfo;
|
||||
@ -1389,6 +1390,12 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TDbgInfo.ContextFromProc(AThreadId, AStackFrame: Integer;
|
||||
AProcSym: TFpSymbol): TFpDbgInfoContext;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TDbgInfo.FindProcSymbol(AAddress: TDbgPtr): TFpSymbol;
|
||||
begin
|
||||
Result := nil;
|
||||
|
Loading…
Reference in New Issue
Block a user