mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-06 07:40:36 +01:00
FpDebug: Use available symbol from stack to create SearchScope
git-svn-id: trunk@63835 -
This commit is contained in:
parent
c15f2179e9
commit
cb9e09de9e
@ -1704,30 +1704,36 @@ var
|
||||
Frame: TDbgCallstackEntry;
|
||||
Addr: TDBGPtr;
|
||||
Ctx: TFpDbgSimpleLocationContext;
|
||||
sym: TFpSymbol;
|
||||
begin
|
||||
Result := nil;
|
||||
Ctx := TFpDbgSimpleLocationContext.Create(MemManager, Addr, DBGPTRSIZE[Mode], AThreadId, AStackFrame);
|
||||
if not GetThread(AThreadId, Thread) then
|
||||
exit;
|
||||
if AStackFrame = 0 then
|
||||
Addr := Thread.GetInstructionPointerRegisterValue
|
||||
else
|
||||
begin
|
||||
|
||||
if GetThread(AThreadId, Thread) then begin
|
||||
Thread.PrepareCallStackEntryList(AStackFrame + 1);
|
||||
if AStackFrame >= Thread.CallStackEntryList.Count then
|
||||
exit;
|
||||
Frame := Thread.CallStackEntryList[AStackFrame];
|
||||
if Frame = nil then
|
||||
exit;
|
||||
Addr := Frame.AnAddress;
|
||||
|
||||
if AStackFrame < Thread.CallStackEntryList.Count then begin
|
||||
Frame := Thread.CallStackEntryList[AStackFrame];
|
||||
|
||||
if Frame <> nil then begin
|
||||
sym := Frame.ProcSymbol;
|
||||
if sym <> nil then
|
||||
Result := sym.CreateSymbolScope(Ctx);
|
||||
|
||||
if Result = nil then begin
|
||||
Addr := Frame.AnAddress;
|
||||
if Addr <> 0 then
|
||||
Result := FDbgInfo.FindSymbolScope(Ctx, Addr);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
// SymbolTableInfo.FindSymbolScope()
|
||||
end;
|
||||
if Addr = 0 then
|
||||
exit;
|
||||
Result := FDbgInfo.FindSymbolScope(Ctx, Addr);
|
||||
// SymbolTableInfo.FindSymbolScope()
|
||||
|
||||
if Result = nil then
|
||||
Result := TFpDbgSymbolScope.Create(Ctx);
|
||||
|
||||
Ctx.ReleaseReference;
|
||||
end;
|
||||
|
||||
|
||||
@ -70,9 +70,9 @@ type
|
||||
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override;
|
||||
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
|
||||
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
|
||||
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr): TDbgDwarfSymbolBase; override;
|
||||
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; override;
|
||||
function CreateUnitSymbol(ACompilationUnit: TDwarfCompilationUnit;
|
||||
AInfoEntry: TDwarfInformationEntry): TDbgDwarfSymbolBase; override;
|
||||
AInfoEntry: TDwarfInformationEntry; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; override;
|
||||
end;
|
||||
|
||||
TFpValueDwarf = class;
|
||||
@ -934,6 +934,7 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
|
||||
FAddressInfo: PDwarfAddressInfo;
|
||||
FStateMachine: TDwarfLineInfoStateMachine;
|
||||
FFrameBaseParser: TDwarfLocationExpression;
|
||||
FDwarf: TFpDwarfInfo;
|
||||
function GetLineEndAddress: TDBGPtr;
|
||||
function GetLineStartAddress: TDBGPtr;
|
||||
function GetLineUnfixed: TDBGPtr;
|
||||
@ -952,8 +953,9 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
|
||||
function GetValueAddress(AValueObj: TFpValueDwarf; out
|
||||
AnAddress: TFpDbgMemLocation): Boolean; override;
|
||||
public
|
||||
constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr); overload;
|
||||
constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo = nil); overload;
|
||||
destructor Destroy; override;
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; override;
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
|
||||
// TODO members = locals ?
|
||||
function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpValueDwarf;
|
||||
@ -1012,11 +1014,14 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
|
||||
TFpSymbolDwarfUnit = class(TFpSymbolDwarf)
|
||||
private
|
||||
FLastChildByName: TFpSymbol;
|
||||
FDwarf: TFpDwarfInfo;
|
||||
protected
|
||||
procedure Init; override;
|
||||
function GetNestedSymbolExByName(const AIndex: String; out AnParentTypeSymbol: TFpSymbolDwarfType): TFpSymbol; override;
|
||||
public
|
||||
constructor Create(const AName: String; AnInformationEntry: TDwarfInformationEntry; ADbgInfo: TFpDwarfInfo = nil); overload;
|
||||
destructor Destroy; override;
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; override;
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
|
||||
end;
|
||||
{%endregion Symbol objects }
|
||||
@ -1178,17 +1183,18 @@ begin
|
||||
Result := TFpDwarfInfoSymbolScope.Create(ALocationContext,ASymbol, ADwarf);
|
||||
end;
|
||||
|
||||
function TFpDwarfDefaultSymbolClassMap.CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
|
||||
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr): TDbgDwarfSymbolBase;
|
||||
function TFpDwarfDefaultSymbolClassMap.CreateProcSymbol(
|
||||
ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo;
|
||||
AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase;
|
||||
begin
|
||||
Result := TFpSymbolDwarfDataProc.Create(ACompilationUnit, AInfo, AAddress);
|
||||
Result := TFpSymbolDwarfDataProc.Create(ACompilationUnit, AInfo, AAddress, ADbgInfo);
|
||||
end;
|
||||
|
||||
function TFpDwarfDefaultSymbolClassMap.CreateUnitSymbol(
|
||||
ACompilationUnit: TDwarfCompilationUnit; AInfoEntry: TDwarfInformationEntry
|
||||
): TDbgDwarfSymbolBase;
|
||||
ACompilationUnit: TDwarfCompilationUnit; AInfoEntry: TDwarfInformationEntry;
|
||||
ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase;
|
||||
begin
|
||||
Result := TFpSymbolDwarfUnit.Create(ACompilationUnit.UnitName, AInfoEntry);
|
||||
Result := TFpSymbolDwarfUnit.Create(ACompilationUnit.UnitName, AInfoEntry, ADbgInfo);
|
||||
end;
|
||||
|
||||
{ TFpThreadWorkerFindSymbolInUnits }
|
||||
@ -5390,13 +5396,15 @@ end;
|
||||
|
||||
{ TDbgDwarfSymbol }
|
||||
|
||||
constructor TFpSymbolDwarfDataProc.Create(ACompilationUnit: TDwarfCompilationUnit;
|
||||
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr);
|
||||
constructor TFpSymbolDwarfDataProc.Create(
|
||||
ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo;
|
||||
AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo);
|
||||
var
|
||||
InfoEntry: TDwarfInformationEntry;
|
||||
begin
|
||||
FAddress := AAddress;
|
||||
FAddressInfo := AInfo;
|
||||
FDwarf := ADbgInfo;
|
||||
|
||||
InfoEntry := TDwarfInformationEntry.Create(ACompilationUnit, nil);
|
||||
InfoEntry.ScopeIndex := AInfo^.ScopeIndex;
|
||||
@ -5420,6 +5428,15 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TFpSymbolDwarfDataProc.CreateSymbolScope(
|
||||
ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope;
|
||||
begin
|
||||
Result := nil;
|
||||
if FDwarf <> nil then
|
||||
Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol
|
||||
(ALocationContext, Self, FDwarf);
|
||||
end;
|
||||
|
||||
function TFpSymbolDwarfDataProc.CreateSymbolScope(
|
||||
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo
|
||||
): TFpDbgSymbolScope;
|
||||
@ -5840,12 +5857,28 @@ begin
|
||||
FLastChildByName := Result;
|
||||
end;
|
||||
|
||||
constructor TFpSymbolDwarfUnit.Create(const AName: String;
|
||||
AnInformationEntry: TDwarfInformationEntry; ADbgInfo: TFpDwarfInfo);
|
||||
begin
|
||||
FDwarf := ADbgInfo;
|
||||
inherited Create(AName, AnInformationEntry);
|
||||
end;
|
||||
|
||||
destructor TFpSymbolDwarfUnit.Destroy;
|
||||
begin
|
||||
ReleaseRefAndNil(FLastChildByName);
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
function TFpSymbolDwarfUnit.CreateSymbolScope(
|
||||
ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope;
|
||||
begin
|
||||
Result := nil;
|
||||
if FDwarf <> nil then
|
||||
Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol
|
||||
(ALocationContext, Self, FDwarf);
|
||||
end;
|
||||
|
||||
function TFpSymbolDwarfUnit.CreateSymbolScope(
|
||||
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo
|
||||
): TFpDbgSymbolScope;
|
||||
|
||||
@ -470,7 +470,7 @@ type
|
||||
AKind: TDbgSymbolKind; AAddress: TFpDbgMemLocation);
|
||||
destructor Destroy; override;
|
||||
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; virtual;
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; virtual; overload;
|
||||
|
||||
property CompilationUnit: TDwarfCompilationUnit read FCU;
|
||||
property InformationEntry: TDwarfInformationEntry read FInformationEntry;
|
||||
@ -500,9 +500,9 @@ type
|
||||
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol;
|
||||
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; virtual; abstract;
|
||||
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
|
||||
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr): TDbgDwarfSymbolBase; virtual; abstract;
|
||||
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; virtual; abstract;
|
||||
function CreateUnitSymbol(ACompilationUnit: TDwarfCompilationUnit;
|
||||
AInfoEntry: TDwarfInformationEntry): TDbgDwarfSymbolBase; virtual; abstract;
|
||||
AInfoEntry: TDwarfInformationEntry; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; virtual; abstract;
|
||||
end;
|
||||
TFpSymbolDwarfClassMapClass = class of TFpSymbolDwarfClassMap;
|
||||
|
||||
@ -3474,7 +3474,7 @@ begin
|
||||
then Continue;
|
||||
|
||||
// TDbgDwarfProcSymbol
|
||||
Result := Cu.DwarfSymbolClassMap.CreateProcSymbol(CU, Iter.DataPtr, AAddress);
|
||||
Result := Cu.DwarfSymbolClassMap.CreateProcSymbol(CU, Iter.DataPtr, AAddress, Self);
|
||||
if Result<>nil then
|
||||
break;
|
||||
finally
|
||||
@ -3504,7 +3504,7 @@ begin
|
||||
if not CU.LocateEntry(DW_TAG_compile_unit, Scope) then
|
||||
break;
|
||||
|
||||
Result := Cu.DwarfSymbolClassMap.CreateUnitSymbol(CU, TDwarfInformationEntry.Create(CU, Scope));
|
||||
Result := Cu.DwarfSymbolClassMap.CreateUnitSymbol(CU, TDwarfInformationEntry.Create(CU, Scope), Self);
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -327,6 +327,8 @@ type
|
||||
destructor Destroy; override;
|
||||
end;
|
||||
|
||||
TFpDbgSymbolScope = class;
|
||||
|
||||
{ TFpSymbol }
|
||||
|
||||
TFpSymbol = class(TRefCountedObject)
|
||||
@ -441,6 +443,8 @@ type
|
||||
// TypeCastValue| only fon stType symbols, may return nil
|
||||
// Returns a reference to caller / caller must release
|
||||
function TypeCastValue({%H-}AValue: TFpValue): TFpValue; virtual;
|
||||
|
||||
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; virtual;
|
||||
end;
|
||||
|
||||
{ TFpSymbolForwarder }
|
||||
@ -1263,6 +1267,12 @@ begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TFpSymbol.CreateSymbolScope(ALocationContext: TFpDbgLocationContext
|
||||
): TFpDbgSymbolScope;
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
function TFpSymbol.GetAddress: TFpDbgMemLocation;
|
||||
begin
|
||||
if not(sfiAddress in FEvaluatedFields) then
|
||||
|
||||
Loading…
Reference in New Issue
Block a user