FpDebug: Separate Context and SearchScope

git-svn-id: trunk@63784 -
This commit is contained in:
martin 2020-08-18 23:12:46 +00:00
parent 93c1ca640f
commit 1ba76474e3
13 changed files with 216 additions and 228 deletions

View File

@ -578,7 +578,7 @@ public
function FindProcSymbol(const AName, ALibraryName: String; IsFullLibName: Boolean = True): TFpSymbol; overload;
function FindProcSymbol(AAdress: TDbgPtr): TFpSymbol; overload;
function FindSymbolScope(AThreadId, AStackFrame: Integer): TFpDbgSymbolScope;
function ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgSymbolScope; inline;
function ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgLocationContext; inline; deprecated 'use TFpDbgSimpleLocationContext.Create';
function GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
property LastLibraryLoaded: TDbgLibrary read GetLastLibraryLoaded;
property LastLibraryUnloaded: TDbgLibrary read FLastLibraryUnloaded write SetLastLibraryUnloadedNil;
@ -1116,7 +1116,6 @@ end;
function TDbgCallstackEntry.GetFunctionName: string;
var
Symbol: TFpSymbol;
offs: TDBGPtr;
begin
Symbol := GetProcSymbol;
if assigned(Symbol) then begin
@ -1137,7 +1136,7 @@ function TDbgCallstackEntry.GetParamsAsString(
APrettyPrinter: TFpPascalPrettyPrinter): string;
var
ProcVal: TFpValue;
AContext: TFpDbgSymbolScope;
AContext: TFpDbgLocationContext;
m: TFpValue;
v: String;
i: Integer;
@ -1147,7 +1146,8 @@ begin
if assigned(ProcSymbol) then begin
ProcVal := ProcSymbol.Value;
if (ProcVal <> nil) then begin
AContext := FThread.Process.ContextFromProc(FThread.ID, Index, ProcSymbol);
AContext := TFpDbgSimpleLocationContext.Create(FThread.Process.MemManager,
LocToAddrOrNil(ProcSymbol.Address), DBGPTRSIZE[FThread.Process.Mode], FThread.ID, Index);
if AContext <> nil then begin
OldContext := AContext.MemManager.DefaultContext;
@ -1424,7 +1424,7 @@ end;
procedure TDbgAsmDecoder.ReverseDisassemble(var AAddress: Pointer; out
ACodeBytes: String; out ACode: String);
var
i, instrLen: integer;
instrLen: integer;
tmpAddress: PtrUint;
begin
// Decode max instruction length backwards,
@ -1723,8 +1723,10 @@ var
Thread: TDbgThread;
Frame: TDbgCallstackEntry;
Addr: TDBGPtr;
Ctx: TFpDbgSimpleLocationContext;
begin
Result := nil;
Ctx := TFpDbgSimpleLocationContext.Create(MemManager, Addr, DBGPTRSIZE[Mode], AThreadId, AStackFrame);
if not GetThread(AThreadId, Thread) then
exit;
if AStackFrame = 0 then
@ -1741,16 +1743,18 @@ begin
end;
if Addr = 0 then
exit;
Result := FDbgInfo.FindSymbolScope(AThreadId, AStackFrame, Addr);
Result := FDbgInfo.FindSymbolScope(Ctx, Addr);
// SymbolTableInfo.FindSymbolScope()
if Result = nil then
Result := TFpDbgSimpleLocationContext.Create(MemManager, Addr, DBGPTRSIZE[Mode], AThreadId, AStackFrame);
Result := TFpDbgSymbolScope.Create(Ctx);
Ctx.ReleaseReference;
end;
function TDbgProcess.ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgSymbolScope;
function TDbgProcess.ContextFromProc(AThreadId, AStackFrame: Integer;
AProcSym: TFpSymbol): TFpDbgLocationContext;
begin
Result := FDbgInfo.SymbolScopeFromProc(AThreadId, AStackFrame, AProcSym);
Result := TFpDbgSimpleLocationContext.Create(MemManager, LocToAddrOrNil(AProcSym.Address), DBGPTRSIZE[Mode], AThreadId, AStackFrame);
end;
function TDbgProcess.GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
@ -2645,7 +2649,6 @@ var
R: TDbgRegisterValue;
nIP, nBP, nSP: String;
NextIdx: LongInt;
AReadSize: Cardinal;
OutSideFrame: Boolean;
StackPtr: TDBGPtr;
begin

View File

@ -302,7 +302,7 @@ type
procedure StepOverInstr;
procedure Next;
procedure Step;
function Call(const FunctionAddress: TFpDbgMemLocation; const ABaseContext: TFpDbgSymbolScope; const AMemReader: TFpDbgMemReaderBase; const AMemConverter: TFpDbgMemConvertor): TFpDbgInfoCallContext;
function Call(const FunctionAddress: TFpDbgMemLocation; const ABaseContext: TFpDbgInfoCallContext; const AMemReader: TFpDbgMemReaderBase; const AMemConverter: TFpDbgMemConvertor): TFpDbgInfoCallContext;
procedure StepOut(AForceStoreStepInfo: Boolean = False);
function Pause: boolean;
function Detach: boolean;
@ -1851,7 +1851,10 @@ begin
FNextOnlyStopOnStartLine := true;
end;
function TDbgController.Call(const FunctionAddress: TFpDbgMemLocation; const ABaseContext: TFpDbgSymbolScope; const AMemReader: TFpDbgMemReaderBase; const AMemConverter: TFpDbgMemConvertor): TFpDbgInfoCallContext;
function TDbgController.Call(const FunctionAddress: TFpDbgMemLocation;
const ABaseContext: TFpDbgInfoCallContext;
const AMemReader: TFpDbgMemReaderBase; const AMemConverter: TFpDbgMemConvertor
): TFpDbgInfoCallContext;
var
Context: TFpDbgInfoCallContext;
begin

View File

@ -68,8 +68,7 @@ type
public
//function CanHandleCompUnit(ACU: TDwarfCompilationUnit): Boolean; override;
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override;
function CreateScopeForSymbol(AThreadId, AStackFrame: Integer; AnAddress:
TDbgPtr; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr): TDbgDwarfSymbolBase; override;
function CreateUnitSymbol(ACompilationUnit: TDwarfCompilationUnit;
@ -85,23 +84,16 @@ type
private
FSymbol: TFpSymbolDwarf;
FSelfParameter: TFpValueDwarf;
FAddress: TDBGPtr;
FThreadId, FStackFrame: Integer;
FAddress: TDBGPtr; // same as LocationContext.Address
FDwarf: TFpDwarfInfo;
protected
function GetSymbolAtAddress: TFpSymbol; override;
function GetProcedureAtAddress: TFpValue; override;
function GetAddress: TDbgPtr; override;
function GetThreadId: Integer; override;
function GetStackFrame: Integer; override;
function GetSizeOfAddress: Integer; override;
function GetMemManager: TFpDbgMemManager; override;
property Symbol: TFpSymbolDwarf read FSymbol;
property Dwarf: TFpDwarfInfo read FDwarf;
property Address: TDBGPtr read FAddress write FAddress;
property ThreadId: Integer read FThreadId write FThreadId;
property StackFrame: Integer read FStackFrame write FStackFrame;
procedure ApplyContext(AVal: TFpValue); inline;
function SymbolToValue(ASym: TFpSymbolDwarf): TFpValue; inline;
@ -115,7 +107,7 @@ type
function FindLocalSymbol(const AName: String; PNameUpper, PNameLower: PChar;
InfoEntry: TDwarfInformationEntry; out ADbgValue: TFpValue): Boolean; virtual;
public
constructor Create(AThreadId, AStackFrame: Integer; AnAddress: TDbgPtr; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo);
constructor Create(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo);
destructor Destroy; override;
function FindSymbol(const AName: String): TFpValue; override;
end;
@ -133,9 +125,9 @@ type
TFpValueDwarfBase = class(TFpValue)
private
FContext: TFpDbgSymbolScope;
FContext: TFpDbgLocationContext;
public
property Context: TFpDbgSymbolScope read FContext write FContext;
property Context: TFpDbgLocationContext read FContext write FContext;
end;
{ TFpValueDwarfTypeDefinition }
@ -939,7 +931,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 CreateSymbolScope(AThreadId, AStackFrame: Integer; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
// TODO members = locals ?
function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpValueDwarf;
// Contineous (sub-)part of the line
@ -1002,7 +994,7 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
function GetNestedSymbolExByName(AIndex: String; out AnParentTypeSymbol: TFpSymbolDwarfType): TFpSymbol; override;
public
destructor Destroy; override;
function CreateSymbolScope(AThreadId, AStackFrame: Integer; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
end;
{%endregion Symbol objects }
@ -1136,11 +1128,11 @@ begin
end;
end;
function TFpDwarfDefaultSymbolClassMap.CreateScopeForSymbol(AThreadId,
AStackFrame: Integer; AnAddress: TDbgPtr; ASymbol: TFpSymbol;
function TFpDwarfDefaultSymbolClassMap.CreateScopeForSymbol(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope;
begin
Result := TFpDwarfInfoSymbolScope.Create(AThreadId, AStackFrame, AnAddress, ASymbol, ADwarf);
Result := TFpDwarfInfoSymbolScope.Create(ALocationContext,ASymbol, ADwarf);
end;
function TFpDwarfDefaultSymbolClassMap.CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
@ -1169,21 +1161,6 @@ begin
ApplyContext(Result);
end;
function TFpDwarfInfoSymbolScope.GetAddress: TDbgPtr;
begin
Result := FAddress;
end;
function TFpDwarfInfoSymbolScope.GetThreadId: Integer;
begin
Result := FThreadId;
end;
function TFpDwarfInfoSymbolScope.GetStackFrame: Integer;
begin
Result := FStackFrame;
end;
function TFpDwarfInfoSymbolScope.GetSizeOfAddress: Integer;
begin
if Symbol = nil then begin
@ -1208,7 +1185,7 @@ end;
procedure TFpDwarfInfoSymbolScope.ApplyContext(AVal: TFpValue);
begin
if (AVal <> nil) and (TFpValueDwarfBase(AVal).FContext = nil) then
TFpValueDwarfBase(AVal).FContext := Self;
TFpValueDwarfBase(AVal).FContext := Self.LocationContext;
end;
function TFpDwarfInfoSymbolScope.SymbolToValue(ASym: TFpSymbolDwarf): TFpValue;
@ -1236,7 +1213,7 @@ begin
exit;
Result := TFpSymbolDwarfDataProc(FSymbol).GetSelfParameter(FAddress);
if (Result <> nil) then
Result.FContext := Self;
Result.FContext := Self.LocationContext;
FSelfParameter := Result;
end;
@ -1369,17 +1346,15 @@ begin
Result := ADbgValue <> nil;
end;
constructor TFpDwarfInfoSymbolScope.Create(AThreadId, AStackFrame: Integer;
AnAddress: TDbgPtr; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo);
constructor TFpDwarfInfoSymbolScope.Create(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo);
begin
assert((ASymbol=nil) or (ASymbol is TFpSymbolDwarf), 'TFpDwarfInfoSymbolScope.Create: (ASymbol=nil) or (ASymbol is TFpSymbolDwarf)');
inherited Create;
AddReference;
FAddress := AnAddress;
FThreadId := AThreadId;
FStackFrame := AStackFrame;
inherited Create(ALocationContext);
FDwarf := ADwarf;
FSymbol := TFpSymbolDwarf(ASymbol);
FAddress := LocationContext.Address; // for quick access
if FSymbol <> nil then
FSymbol.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(@FSymbol, 'Context to Symbol'){$ENDIF};
end;
@ -5261,11 +5236,12 @@ begin
inherited Destroy;
end;
function TFpSymbolDwarfDataProc.CreateSymbolScope(AThreadId, AStackFrame: Integer;
ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope;
function TFpSymbolDwarfDataProc.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo
): TFpDbgSymbolScope;
begin
Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol
(AThreadId, AStackFrame, Address.Address, Self, ADwarfInfo);
(ALocationContext, Self, ADwarfInfo);
end;
function TFpSymbolDwarfDataProc.GetColumn: Cardinal;
@ -5689,11 +5665,12 @@ begin
inherited Destroy;
end;
function TFpSymbolDwarfUnit.CreateSymbolScope(AThreadId, AStackFrame: Integer;
ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope;
function TFpSymbolDwarfUnit.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo
): TFpDbgSymbolScope;
begin
Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol
(AThreadId, AStackFrame, Address.Address, Self, ADwarfInfo);
(ALocationContext, Self, ADwarfInfo);
end;
initialization

View File

@ -449,7 +449,7 @@ type
AKind: TDbgSymbolKind; AAddress: TFpDbgMemLocation);
destructor Destroy; override;
function CreateSymbolScope(AThreadId, AStackFrame: Integer; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; virtual;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; virtual;
property CompilationUnit: TDwarfCompilationUnit read FCU;
property InformationEntry: TDwarfInformationEntry read FInformationEntry;
@ -476,7 +476,7 @@ type
public
constructor Create(ACU: TDwarfCompilationUnit; AHelperData: Pointer); virtual;
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; virtual; abstract;
function CreateScopeForSymbol(AThreadId, AStackFrame: Integer; AnAddress: TDbgPtr; ASymbol: TFpSymbol;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; virtual; abstract;
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr): TDbgDwarfSymbolBase; virtual; abstract;
@ -656,8 +656,7 @@ type
public
constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager); override;
destructor Destroy; override;
function FindSymbolScope(AThreadId, AStackFrame: Integer; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override;
function SymbolScopeFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgSymbolScope; override;
function FindSymbolScope(ALocationContext: TFpDbgLocationContext; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override;
function FindDwarfProcSymbol(AAddress: TDbgPtr): TDbgDwarfSymbolBase; inline;
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; override; overload;
//function FindSymbol(const AName: String): TDbgSymbol; override; overload;
@ -3200,7 +3199,7 @@ begin
inherited Destroy;
end;
function TFpDwarfInfo.FindSymbolScope(AThreadId, AStackFrame: Integer;
function TFpDwarfInfo.FindSymbolScope(ALocationContext: TFpDbgLocationContext;
AAddress: TDbgPtr): TFpDbgSymbolScope;
var
Proc, UnitSym: TDbgDwarfSymbolBase;
@ -3208,32 +3207,21 @@ begin
Result := nil;
Proc := FindDwarfProcSymbol(AAddress); // TFpSymbolDwarfDataProc
if Proc <> nil then begin
Result := Proc.CreateSymbolScope(AThreadId, AStackFrame, Self);
Result := Proc.CreateSymbolScope(ALocationContext, Self);
Proc.ReleaseReference;
exit;
end;
UnitSym := FindDwarfUnitSymbol(AAddress);
if UnitSym <> nil then begin
Result := UnitSym.CreateSymbolScope(AThreadId, AStackFrame, Self);
Result := UnitSym.CreateSymbolScope(ALocationContext, Self);
UnitSym.ReleaseReference;
exit;
end;
if CompilationUnitsCount > 0 then
Result := CompilationUnits[0].DwarfSymbolClassMap.CreateScopeForSymbol
(AThreadId, AStackFrame, AAddress, nil, Self);
end;
function TFpDwarfInfo.SymbolScopeFromProc(AThreadId, AStackFrame: Integer;
AProcSym: TFpSymbol): TFpDbgSymbolScope;
begin
if not (AProcSym is TDbgDwarfSymbolBase) then begin
Result := inherited SymbolScopeFromProc(AThreadId, AStackFrame, AProcSym);
exit;
end;
Result := TDbgDwarfSymbolBase(AProcSym).CreateSymbolScope(AThreadId, AStackFrame, Self);
(ALocationContext, nil, Self);
end;
function TFpDwarfInfo.GetCompilationUnit(AIndex: Integer): TDwarfCompilationUnit;
@ -3472,8 +3460,9 @@ begin
inherited Destroy;
end;
function TDbgDwarfSymbolBase.CreateSymbolScope(AThreadId, AStackFrame: Integer;
ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope;
function TDbgDwarfSymbolBase.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo
): TFpDbgSymbolScope;
begin
Result := nil;
end;

View File

@ -32,7 +32,7 @@ type
public
constructor Create(ACU: TDwarfCompilationUnit; AHelperData: Pointer); override;
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override;
function CreateScopeForSymbol(AThreadId, AStackFrame: Integer; AnAddress: TDBGPtr; ASymbol: TFpSymbol;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
//class function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
// AInfo: PDwarfAddressInfo; AAddress: TDbgPtr): TDbgDwarfSymbolBase; override;
@ -355,11 +355,11 @@ begin
end;
end;
function TFpDwarfFreePascalSymbolClassMap.CreateScopeForSymbol(AThreadId,
AStackFrame: Integer; AnAddress: TDBGPtr; ASymbol: TFpSymbol;
function TFpDwarfFreePascalSymbolClassMap.CreateScopeForSymbol(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope;
begin
Result := TFpDwarfFreePascalSymbolScope.Create(AThreadId, AStackFrame, AnAddress, ASymbol, ADwarf);
Result := TFpDwarfFreePascalSymbolScope.Create(ALocationContext, ASymbol, ADwarf);
end;
function TFpDwarfFreePascalSymbolClassMap.GetInstanceClassNameFromPVmt(
@ -448,6 +448,34 @@ begin
end;
end;
type
{ TFpDbgDwarfSimpleLocationContext }
TFpDbgDwarfSimpleLocationContext = class(TFpDbgSimpleLocationContext)
protected
FStackFrame: Integer;
function GetStackFrame: Integer; override;
public
constructor Create(AMemManager: TFpDbgMemManager; AnAddress: TDbgPtr;
AnSizeOfAddr, AThreadId: Integer; AStackFrame: Integer);
end;
{ TFpDbgDwarfSimpleLocationContext }
constructor TFpDbgDwarfSimpleLocationContext.Create(
AMemManager: TFpDbgMemManager; AnAddress: TDbgPtr; AnSizeOfAddr,
AThreadId: Integer; AStackFrame: Integer);
begin
inherited Create(AMemManager, AnAddress, AnSizeOfAddr, AThreadId, AStackFrame);
FStackFrame := AStackFrame;
end;
function TFpDbgDwarfSimpleLocationContext.GetStackFrame: Integer;
begin
Result := FStackFrame;
end;
{ TFpDwarfFreePascalSymbolScope }
function TFpDwarfFreePascalSymbolScope.FindLocalSymbol(const AName: String; PNameUpper,
@ -464,10 +492,11 @@ const
var
StartScopeIdx, RegFp, RegPc: Integer;
ParentFpVal: TFpValue;
SearchCtx: TFpDwarfFreePascalSymbolScope;
SearchCtx: TFpDbgDwarfSimpleLocationContext;
par_fp, cur_fp, prev_fp, pc: TDbgPtr;
d, i: Integer;
ParentFpSym: TFpSymbolDwarf;
Ctx: TFpDbgSimpleLocationContext;
begin
Result := False;
if not(Symbol is TFpSymbolDwarfDataProc) then
@ -539,17 +568,17 @@ begin
end;
// TODO: FindCallStackEntryByBasePointer, once all evaluates run in thread.
i := StackFrame + 1;
SearchCtx := TFpDwarfFreePascalSymbolScope.Create(ThreadId, i, 0, Symbol, Dwarf);
i := LocationContext.StackFrame + 1;
SearchCtx := TFpDbgDwarfSimpleLocationContext.Create(MemManager, 0, SizeOfAddress, LocationContext.ThreadId, i);
cur_fp := 0;
if MemManager.ReadRegister(RegFp, cur_fp, Self) then begin
if MemManager.ReadRegister(RegFp, cur_fp, Self.LocationContext) then begin
if cur_fp > par_fp then
d := -1 // cur_fp must go down
else
d := 1; // cur_fp must go up
while not (cur_fp = par_fp) do begin
SearchCtx.StackFrame := i;
SearchCtx.FStackFrame := i;
// TODO: get reg num via memreader name-to-num
prev_fp := cur_fp;
if not MemManager.ReadRegister(RegFp, cur_fp, SearchCtx) then
@ -557,7 +586,7 @@ begin
inc(i);
if (cur_fp = prev_fp) or ((cur_fp < prev_fp) xor (d = -1)) then
break; // wrong direction
if i > StackFrame + 200 then break; // something wrong? // TODO better check
if i > LocationContext.StackFrame + 200 then break; // something wrong? // TODO better check
end;
dec(i);
end;
@ -573,7 +602,9 @@ begin
SearchCtx.ReleaseReference;
FOuterNestContext := Dwarf.FindSymbolScope(ThreadId, i, pc);
Ctx := TFpDbgSimpleLocationContext.Create(MemManager, pc, SizeOfAddress, LocationContext.ThreadId, i);
FOuterNestContext := Dwarf.FindSymbolScope(Ctx, pc);
Ctx.ReleaseReference;
ADbgValue := FOuterNestContext.FindSymbol(AName); // TODO: pass upper/lower
Result := True; // self, global was done by outer

View File

@ -173,13 +173,13 @@ type
private
FTypeSymbol: TFpSymbol;
FDataSymbol: TFpSymbol;
FContext: TFpDbgSymbolScope;
FContext: TFpDbgLocationContext;
// Cached:
FDataAddress: TFpDbgMemLocation;
FStructureValue: TDbgHardcodedVariableValue;
procedure SetStructureValue(AValue: TDbgHardcodedVariableValue);
procedure SetContext(AValue: TFpDbgSymbolScope);
procedure SetContext(AValue: TFpDbgLocationContext);
protected
function GetAsString: AnsiString; override;
function GetAddress: TFpDbgMemLocation; override;
@ -189,7 +189,7 @@ type
destructor Destroy; override;
procedure SetDataSymbol(AValueSymbol: TFpSymbol);
property Context: TFpDbgSymbolScope read FContext write SetContext;
property Context: TFpDbgLocationContext read FContext write SetContext;
end;
{ TDbgHardcodedFPCClassValue }
@ -207,16 +207,6 @@ type
// Just a hack to simulate a real context, when FindSymbolScope does not return
// a context.
TFpDbgHardcodedContext = class(TFpDbgSymbolScope)
private
FMemManager: TFpDbgMemManager;
FAddressSize: Integer;
FThreadId: Integer;
protected
function GetMemManager: TFpDbgMemManager; override;
function GetSizeOfAddress: Integer; override;
function GetThreadId: Integer; override;
function GetStackFrame: Integer; override;
function GetAddress: TDbgPtr; override;
public
constructor Create(AMemManager: TFpDbgMemManager; AnAdressSize: Integer; AThreadId: Integer);
end;
@ -257,7 +247,7 @@ end;
function TDbgHardcodedFPCAnsistringTypeSymbol.GetDataAddress(AValueObj: TDbgHardcodedVariableValue; var AnAddress: TFpDbgMemLocation): Boolean;
var
Context: TFpDbgSymbolScope;
Context: TFpDbgLocationContext;
begin
// Dereference the pointer that points to the real string-data
Context := AValueObj.Context;
@ -282,7 +272,7 @@ end;
function TDbgHardcodedFPCClassMember.DoReadDataAddress(const AValueObj: TDbgHardcodedVariableValue; out AnAddress: TFpDbgMemLocation): Boolean;
var
Context: TFpDbgSymbolScope;
Context: TFpDbgLocationContext;
begin
Context := (AValueObj as TDbgHardcodedVariableValue).Context;
AnAddress := AValueObj.FStructureValue.DataAddress + (SizeVal(Context.SizeOfAddress) * FFieldIndex);
@ -325,36 +315,10 @@ end;
constructor TFpDbgHardcodedContext.Create(AMemManager: TFpDbgMemManager; AnAdressSize: Integer; AThreadId: Integer);
begin
inherited Create;
AddReference;
FMemManager := AMemManager;
FAddressSize := AnAdressSize;
FThreadId := AThreadId;
end;
function TFpDbgHardcodedContext.GetMemManager: TFpDbgMemManager;
begin
Result := FMemManager;
end;
function TFpDbgHardcodedContext.GetSizeOfAddress: Integer;
begin
Result := FAddressSize;
end;
function TFpDbgHardcodedContext.GetThreadId: Integer;
begin
Result := FThreadId;
end;
function TFpDbgHardcodedContext.GetStackFrame: Integer;
begin
Result := 0;
end;
function TFpDbgHardcodedContext.GetAddress: TDbgPtr;
begin
raise Exception.Create('It is not possible to get the address of this context');
inherited Create(
TFpDbgSimpleLocationContext.Create(AMemManager, 0, AnAdressSize, AThreadId, 0)
);
LocationContext.ReleaseReference;
end;
{ TDbgHardcodedFPCShortstringTypeSymbol }
@ -529,7 +493,7 @@ begin
FStructureValue := AValue;
end;
procedure TDbgHardcodedVariableValue.SetContext(AValue: TFpDbgSymbolScope);
procedure TDbgHardcodedVariableValue.SetContext(AValue: TFpDbgLocationContext);
begin
if FContext = AValue then
exit;
@ -646,7 +610,7 @@ end;
function TDbgHardcodedFPCClassTypeSymbol.GetDataAddress(AValueObj: TDbgHardcodedVariableValue; var AnAddress: TFpDbgMemLocation): Boolean;
var
Context: TFpDbgSymbolScope;
Context: TFpDbgLocationContext;
begin
// Dereference the pointer that points to the real class-data
Context := AValueObj.Context;

View File

@ -474,22 +474,29 @@ type
{ TFpDbgSymbolScope }
TFpDbgSymbolScope = class(TFpDbgLocationContext)
TFpDbgSymbolScope = class(TRefCountedObject)
private
FLocationContext: TFpDbgLocationContext;
protected
function GetSymbolAtAddress: TFpSymbol; virtual;
function GetProcedureAtAddress: TFpValue; virtual;
function GetMemManager: TFpDbgMemManager; virtual;
function GetSizeOfAddress: Integer; virtual;
public
constructor Create(ALocationContext: TFpDbgLocationContext);
destructor Destroy; override;
property SymbolAtAddress: TFpSymbol read GetSymbolAtAddress;
property ProcedureAtAddress: TFpValue read GetProcedureAtAddress;
// search this, and all parent context
function FindSymbol(const {%H-}AName: String): TFpValue; virtual;
property MemManager: TFpDbgMemManager read GetMemManager;
property SizeOfAddress: Integer read GetSizeOfAddress;
property LocationContext: TFpDbgLocationContext read FLocationContext;
end;
{ TFpDbgSimpleLocationContext }
TFpDbgSimpleLocationContext = class(TFpDbgSymbolScope)
TFpDbgSimpleLocationContext = class(TFpDbgLocationContext)
private
FMemManager: TFpDbgMemManager;
FAddress: TDbgPtr;
@ -534,9 +541,9 @@ type
// The special addition to make this work is that it is possible to set a
// register-value by calling SetRegisterValue. Further this class is an empty
// wrapper.
TFpDbgInfoCallContext = class(TFpDbgSymbolScope)
TFpDbgInfoCallContext = class(TFpDbgLocationContext)
private
FBaseContext: TFpDbgSymbolScope;
FBaseContext: TFpDbgLocationContext;
FMemManager: TFpDbgMemManager;
FMemReader: TFpDbgCallMemReader;
FIsValid: Boolean;
@ -548,7 +555,7 @@ type
function GetStackFrame: Integer; override;
function GetSizeOfAddress: Integer; override;
public
constructor Create(const ABaseContext: TFpDbgSymbolScope; AMemReader: TFpDbgMemReaderBase; AMemConverter: TFpDbgMemConvertor);
constructor Create(const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase; AMemConverter: TFpDbgMemConvertor);
destructor Destroy; override;
procedure SetRegisterValue(ARegNum: Cardinal; AValue: TDbgPtr);
procedure SetError(Message: string);
@ -572,8 +579,7 @@ type
However a different Address may be froced.
TODO: for now address may be needed, as stack decoding is not done yet
*)
function FindSymbolScope(AThreadId, AStackFrame: Integer; {%H-}AAddress: TDbgPtr = 0): TFpDbgSymbolScope; virtual;
function SymbolScopeFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgSymbolScope; virtual;
function FindSymbolScope(ALocationContext: TFpDbgLocationContext; {%H-}AAddress: TDbgPtr = 0): TFpDbgSymbolScope; virtual;
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; virtual; overload;
function FindProcSymbol(const {%H-}AName: String): TFpSymbol; virtual; overload;
property HasInfo: Boolean read FHasInfo;
@ -648,7 +654,9 @@ end;
{ TFpDbgInfoCallContext }
constructor TFpDbgInfoCallContext.Create(const ABaseContext: TFpDbgSymbolScope; AMemReader: TFpDbgMemReaderBase; AMemConverter: TFpDbgMemConvertor);
constructor TFpDbgInfoCallContext.Create(
const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase;
AMemConverter: TFpDbgMemConvertor);
begin
FBaseContext:=ABaseContext;
FBaseContext.AddReference;
@ -671,7 +679,7 @@ end;
function TFpDbgInfoCallContext.GetAddress: TDbgPtr;
begin
Result := FBaseContext.GetAddress;
Result := FBaseContext.Address;
end;
function TFpDbgInfoCallContext.GetMemManager: TFpDbgMemManager;
@ -681,17 +689,17 @@ end;
function TFpDbgInfoCallContext.GetSizeOfAddress: Integer;
begin
Result := FBaseContext.GetSizeOfAddress;
Result := FBaseContext.SizeOfAddress;
end;
function TFpDbgInfoCallContext.GetStackFrame: Integer;
begin
Result := FBaseContext.GetSizeOfAddress;
Result := FBaseContext.StackFrame;
end;
function TFpDbgInfoCallContext.GetThreadId: Integer;
begin
Result := FBaseContext.GetThreadId;
Result := FBaseContext.ThreadId;
end;
procedure TFpDbgInfoCallContext.SetRegisterValue(ARegNum: Cardinal; AValue: TDbgPtr);
@ -1117,7 +1125,21 @@ end;
function TFpDbgSymbolScope.GetMemManager: TFpDbgMemManager;
begin
Result := nil;
Result := LocationContext.MemManager;
end;
constructor TFpDbgSymbolScope.Create(ALocationContext: TFpDbgLocationContext);
begin
FLocationContext := ALocationContext;
FLocationContext.AddReference;
inherited Create;
AddReference;
end;
destructor TFpDbgSymbolScope.Destroy;
begin
inherited Destroy;
FLocationContext.ReleaseReference;
end;
function TFpDbgSymbolScope.GetProcedureAtAddress: TFpValue;
@ -1125,6 +1147,11 @@ begin
Result := SymbolAtAddress.Value;
end;
function TFpDbgSymbolScope.GetSizeOfAddress: Integer;
begin
Result := LocationContext.SizeOfAddress;
end;
function TFpDbgSymbolScope.GetSymbolAtAddress: TFpSymbol;
begin
Result := nil;
@ -1163,6 +1190,7 @@ end;
constructor TFpDbgSimpleLocationContext.Create(AMemManager: TFpDbgMemManager;
AnAddress: TDbgPtr; AnSizeOfAddr, AThreadId: Integer; AStackFrame: Integer);
begin
inherited Create;
AddReference;
FMemManager := AMemManager;
FAddress := AnAddress;
@ -1650,14 +1678,8 @@ begin
inherited Create;
end;
function TDbgInfo.FindSymbolScope(AThreadId, AStackFrame: Integer;
function TDbgInfo.FindSymbolScope(ALocationContext: TFpDbgLocationContext;
AAddress: TDbgPtr): TFpDbgSymbolScope;
begin
Result := nil;;
end;
function TDbgInfo.SymbolScopeFromProc(AThreadId, AStackFrame: Integer;
AProcSym: TFpSymbol): TFpDbgSymbolScope;
begin
Result := nil;
end;

View File

@ -33,12 +33,9 @@ type
FFpSymbolInfo: TFpSymbolInfo;
FSizeOfAddress: integer;
protected
function GetAddress: TDbgPtr; override;
function GetStackFrame: Integer; override;
function GetThreadId: Integer; override;
function GetSizeOfAddress: Integer; override;
public
constructor Create(AFpSymbolInfo: TFpSymbolInfo);
constructor Create(ALocationContext: TFpDbgLocationContext; AFpSymbolInfo: TFpSymbolInfo);
function FindSymbol(const AName: String): TFpValue; override;
end;
@ -47,13 +44,12 @@ type
TFpSymbolInfo = class(TDbgInfo)
private
FSymbolList: TfpSymbolList;
FContext: TFpSymbolContext;
FLibName: String;
public
constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager); override;
constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; ALibName: String);
destructor Destroy; override;
function FindSymbolScope(AThreadId, AStackFrame: Integer; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override;
function FindSymbolScope(ALocationContext: TFpDbgLocationContext; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override;
function FindProcSymbol(const AName: String): TFpSymbol; override; overload;
function FindProcSymbol(AnAdress: TDbgPtr): TFpSymbol; overload;
end;
@ -72,34 +68,16 @@ end;
{ TFpSymbolContext }
function TFpSymbolContext.GetAddress: TDbgPtr;
begin
result := 0;
end;
function TFpSymbolContext.GetStackFrame: Integer;
begin
result := 0;
end;
function TFpSymbolContext.GetThreadId: Integer;
begin
result := 1;
end;
function TFpSymbolContext.GetSizeOfAddress: Integer;
begin
result := FSizeOfAddress;
end;
constructor TFpSymbolContext.Create(AFpSymbolInfo: TFpSymbolInfo);
constructor TFpSymbolContext.Create(ALocationContext: TFpDbgLocationContext;
AFpSymbolInfo: TFpSymbolInfo);
begin
inherited create;
inherited create(ALocationContext);
FFpSymbolInfo:=AFpSymbolInfo;
if AFpSymbolInfo.TargetInfo.bitness = b64 then
FSizeOfAddress:=8
else
FSizeOfAddress:=4;
end;
function TFpSymbolContext.FindSymbol(const AName: String): TFpValue;
@ -128,7 +106,6 @@ var
i: Integer;
begin
inherited Create(ALoaderList, AMemManager);
FContext := TFpSymbolContext.Create(self);
FSymbolList := TfpSymbolList.Create;
for i := 0 to ALoaderList.Count-1 do
@ -148,15 +125,14 @@ end;
destructor TFpSymbolInfo.Destroy;
begin
FSymbolList.Free;
FContext.Free;
inherited Destroy;
end;
function TFpSymbolInfo.FindSymbolScope(AThreadId, AStackFrame: Integer;
function TFpSymbolInfo.FindSymbolScope(ALocationContext: TFpDbgLocationContext;
AAddress: TDbgPtr): TFpDbgSymbolScope;
begin
assert(False, 'TFpSymbolInfo.FindSymbolScope: False');
Result:=FContext; // TODO: nil
Result := TFpSymbolContext.Create(ALocationContext, Self);
end;
function TFpSymbolInfo.FindProcSymbol(const AName: String): TFpSymbol;

View File

@ -67,17 +67,21 @@ type
end;
PFpDbgMemLocation = ^TFpDbgMemLocation;
TFpDbgMemManager = class;
TFpDbgLocationContext = class(TRefCountedObject)
protected
function GetAddress: TDbgPtr; virtual; abstract;
function GetStackFrame: Integer; virtual; abstract;
function GetThreadId: Integer; virtual; abstract;
function GetSizeOfAddress: Integer; virtual; abstract;
function GetMemManager: TFpDbgMemManager; virtual; abstract;
public
property Address: TDbgPtr read GetAddress;
property ThreadId: Integer read GetThreadId;
property StackFrame: Integer read GetStackFrame;
property SizeOfAddress: Integer read GetSizeOfAddress;
property MemManager: TFpDbgMemManager read GetMemManager;
end;

View File

@ -465,14 +465,14 @@ type
private
FPointerLevels: Integer;
FPointedTo: TFpSymbol;
FContext: TFpDbgSymbolScope;
FContext: TFpDbgLocationContext;
protected
// NameNeeded // "^TPointedTo"
procedure TypeInfoNeeded; override;
function DoReadSize(const AValueObj: TFpValue; out ASize: TFpDbgValueSize): Boolean; override;
public
constructor Create(const APointedTo: TFpSymbol; AContext: TFpDbgSymbolScope; APointerLevels: Integer);
constructor Create(const APointedTo: TFpSymbol; AContext: TFpDbgSymbolScope);
constructor Create(const APointedTo: TFpSymbol; AContext: TFpDbgLocationContext; APointerLevels: Integer);
constructor Create(const APointedTo: TFpSymbol; AContext: TFpDbgLocationContext);
destructor Destroy; override;
function TypeCastValue(AValue: TFpValue): TFpValue; override;
end;
@ -499,12 +499,12 @@ type
TFpPasParserValue = class(TFpValue)
private
FContext: TFpDbgSymbolScope;
FContext: TFpDbgLocationContext;
protected
function DebugText(AIndent: String): String; virtual;
public
constructor Create(AContext: TFpDbgSymbolScope);
property Context: TFpDbgSymbolScope read FContext;
constructor Create(AContext: TFpDbgLocationContext);
property Context: TFpDbgLocationContext read FContext;
end;
{ TFpPasParserValueCastToPointer
@ -526,7 +526,7 @@ type
function GetDataAddress: TFpDbgMemLocation; override;
function GetMember(AIndex: Int64): TFpValue; override;
public
constructor Create(AValue: TFpValue; ATypeInfo: TFpSymbol; AContext: TFpDbgSymbolScope);
constructor Create(AValue: TFpValue; ATypeInfo: TFpSymbol; AContext: TFpDbgLocationContext);
destructor Destroy; override;
end;
@ -541,7 +541,7 @@ type
protected
function GetDbgSymbol: TFpSymbol; override; // returns a TPasParserSymbolPointer
public
constructor Create(ATypeInfo: TFpSymbol; AContext: TFpDbgSymbolScope);
constructor Create(ATypeInfo: TFpSymbol; AContext: TFpDbgLocationContext);
destructor Destroy; override;
procedure IncRefLevel;
function GetTypeCastedValue(ADataVal: TFpValue): TFpValue; override;
@ -566,8 +566,8 @@ type
function GetAsCardinal: QWord; override; // reads men
function GetTypeInfo: TFpSymbol; override; // TODO: Cardinal? Why? // TODO: does not handle AOffset
public
constructor Create(AValue: TFpValue; AContext: TFpDbgSymbolScope);
constructor Create(AValue: TFpValue; AContext: TFpDbgSymbolScope; AOffset: Int64);
constructor Create(AValue: TFpValue; AContext: TFpDbgLocationContext);
constructor Create(AValue: TFpValue; AContext: TFpDbgLocationContext; AOffset: Int64);
destructor Destroy; override;
end;
@ -591,7 +591,7 @@ type
function GetAsString: AnsiString; override;
function GetAsWideString: WideString; override;
public
constructor Create(AValue: TFpValue; AContext: TFpDbgSymbolScope);
constructor Create(AValue: TFpValue; AContext: TFpDbgLocationContext);
destructor Destroy; override;
property PointedToValue: TFpValue read GetPointedToValue;
end;
@ -619,7 +619,7 @@ begin
Result := AIndent + DbgSName(Self) + ' DbsSym='+DbgSName(DbgSymbol)+' Type='+DbgSName(TypeInfo) + LineEnding;
end;
constructor TFpPasParserValue.Create(AContext: TFpDbgSymbolScope);
constructor TFpPasParserValue.Create(AContext: TFpDbgLocationContext);
begin
FContext := AContext;
inherited Create;
@ -723,7 +723,7 @@ begin
end;
constructor TFpPasParserValueCastToPointer.Create(AValue: TFpValue;
ATypeInfo: TFpSymbol; AContext: TFpDbgSymbolScope);
ATypeInfo: TFpSymbol; AContext: TFpDbgLocationContext);
begin
inherited Create(AContext);
FValue := AValue;
@ -760,7 +760,7 @@ begin
end;
constructor TFpPasParserValueMakeReftype.Create(ATypeInfo: TFpSymbol;
AContext: TFpDbgSymbolScope);
AContext: TFpDbgLocationContext);
begin
inherited Create(AContext);
FSourceTypeSymbol := ATypeInfo;
@ -848,7 +848,7 @@ function TFpPasParserValueDerefPointer.GetAsCardinal: QWord;
var
m: TFpDbgMemManager;
Addr: TFpDbgMemLocation;
Ctx: TFpDbgSymbolScope;
Ctx: TFpDbgLocationContext;
AddrSize: Integer;
begin
Result := FCardinal;
@ -883,13 +883,13 @@ begin
end;
constructor TFpPasParserValueDerefPointer.Create(AValue: TFpValue;
AContext: TFpDbgSymbolScope);
AContext: TFpDbgLocationContext);
begin
Create(AValue, AContext, 0);
end;
constructor TFpPasParserValueDerefPointer.Create(AValue: TFpValue;
AContext: TFpDbgSymbolScope; AOffset: Int64);
AContext: TFpDbgLocationContext; AOffset: Int64);
begin
inherited Create(AContext);
FValue := AValue;
@ -1013,7 +1013,7 @@ begin
end;
constructor TFpPasParserValueAddressOf.Create(AValue: TFpValue;
AContext: TFpDbgSymbolScope);
AContext: TFpDbgLocationContext);
begin
inherited Create(AContext);
FValue := AValue;
@ -1074,7 +1074,7 @@ begin
end;
constructor TPasParserSymbolPointer.Create(const APointedTo: TFpSymbol;
AContext: TFpDbgSymbolScope; APointerLevels: Integer);
AContext: TFpDbgLocationContext; APointerLevels: Integer);
begin
inherited Create('');
FContext := AContext;
@ -1088,7 +1088,7 @@ begin
end;
constructor TPasParserSymbolPointer.Create(const APointedTo: TFpSymbol;
AContext: TFpDbgSymbolScope);
AContext: TFpDbgLocationContext);
begin
Create(APointedTo, AContext, 1);
end;
@ -1536,7 +1536,7 @@ begin
s := LowerCase(s);
if s = 'nil' then begin
tmp := TFpValueConstAddress.Create(NilLoc);
Result := TFpPasParserValueAddressOf.Create(tmp, Expression.Context);
Result := TFpPasParserValueAddressOf.Create(tmp, Expression.Context.LocationContext);
tmp.ReleaseReference;
{$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue');{$ENDIF}
end
@ -2006,6 +2006,7 @@ constructor TFpPascalExpression.Create(ATextExpression: String;
AContext: TFpDbgSymbolScope);
begin
FContext := AContext;
FContext.AddReference;
FTextExpression := ATextExpression;
FError := NoError;
FValid := True;
@ -2015,6 +2016,7 @@ end;
destructor TFpPascalExpression.Destroy;
begin
FreeAndNil(FExpressionPart);
FContext.ReleaseReference;
inherited Destroy;
end;
@ -2558,7 +2560,7 @@ begin
if (tmp = nil) or not IsTargetAddr(tmp.Address) then
exit;
Result := TFpPasParserValueAddressOf.Create(tmp, Expression.Context);
Result := TFpPasParserValueAddressOf.Create(tmp, Expression.Context.LocationContext);
{$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue');{$ENDIF}
end;
@ -2601,7 +2603,7 @@ begin
if (tmp.DbgSymbol = nil) or (tmp.DbgSymbol.SymbolType <> stType) then
exit;
Result := TFpPasParserValueMakeReftype.Create(tmp.DbgSymbol, Expression.Context);
Result := TFpPasParserValueMakeReftype.Create(tmp.DbgSymbol, Expression.Context.LocationContext);
{$IFDEF WITH_REFCOUNT_DEBUG}Result.DbgRenameReference(nil, 'DoGetResultValue'){$ENDIF};
end;
@ -2759,7 +2761,7 @@ function TFpPascalExpressionPartOperatorPlusMinus.DoGetResultValue: TFpValue;
SetError('Error dereferencing'); // TODO: set correct error
exit;
end;
Result := TFpPasParserValueAddressOf.Create(TmpVal, Expression.Context);
Result := TFpPasParserValueAddressOf.Create(TmpVal, Expression.Context.LocationContext);
TmpVal.ReleaseReference;
end;
function AddValueToInt(AIntVal, AOtherVal: TFpValue): TFpValue;

View File

@ -2863,7 +2863,7 @@ function TFpDebugDebugger.GetContextForEvaluate(const ThreadId,
begin
Result := FindSymbolScope(ThreadId, StackFrame);
if Result <> nil then
Result.MemManager.DefaultContext := Result;
Result.MemManager.DefaultContext := Result.LocationContext;
end;
function TFpDebugDebugger.GetClassInstanceName(AnAddr: TDBGPtr): string;

View File

@ -12,10 +12,12 @@ uses
{$IFdef WithWinMemReader}
windows,
{$ENDIF}
Classes, sysutils, math, FpdMemoryTools, FpDbgInfo, FpDbgClasses, GDBMIDebugger,
DbgIntfBaseTypes, DbgIntfDebuggerBase, GDBMIMiscClasses, GDBTypeInfo, LCLProc, Forms,
FpDbgLoader, FpDbgDwarf, LazLoggerBase, LazLoggerProfiling, LazClasses, FpPascalParser,
FpPascalBuilder, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarfFreePascal, MenuIntf;
Classes, sysutils, math, FpdMemoryTools, FpDbgInfo, FpDbgClasses,
GDBMIDebugger, DbgIntfBaseTypes, DbgIntfDebuggerBase, GDBMIMiscClasses,
GDBTypeInfo, LCLProc, Forms, FpDbgLoader, FpDbgDwarf, LazLoggerBase,
LazLoggerProfiling, LazClasses, FpPascalParser, FpPascalBuilder,
FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarfFreePascal, FpDbgCommon,
MenuIntf;
type
@ -901,7 +903,7 @@ function TFpGDBMIDebugger.GetInfoContextForContext(AThreadId,
AStackFrame: Integer): TFpDbgSymbolScope;
var
Addr: TDBGPtr;
i: Integer;
i, sa: Integer;
begin
Result := nil;
if FDwarfInfo = nil then
@ -922,7 +924,7 @@ begin
i := MAX_CTX_CACHE - 1;
while (i >= 0) and
( (FLastContext[i] = nil) or
(FLastContext[i].ThreadId <> AThreadId) or (FLastContext[i].StackFrame <> AStackFrame)
(FLastContext[i].LocationContext.ThreadId <> AThreadId) or (FLastContext[i].LocationContext.StackFrame <> AStackFrame)
)
do
dec(i);
@ -934,7 +936,14 @@ begin
end;
DebugLn(DBG_VERBOSE, ['* FDwarfInfo.FindSymbolScope ', dbgs(Addr)]);
Result := FDwarfInfo.FindSymbolScope(AThreadId, AStackFrame, Addr);
if FDwarfInfo.TargetInfo.bitness = b32 then
sa := 4
else
sa := 8;
Result := FDwarfInfo.FindSymbolScope(
TFpDbgSimpleLocationContext.Create(FMemManager, Addr, sa, AThreadId, AStackFrame),
Addr
);
if Result = nil then begin
debugln(DBG_VERBOSE, ['GetInfoContextForContext CTX NOT FOUND for ', AThreadId, ', ', AStackFrame]);
@ -1017,7 +1026,7 @@ begin
end;
if Ctx = nil then exit;
FMemManager.DefaultContext := Ctx;
FMemManager.DefaultContext := Ctx.LocationContext;
FPrettyPrinter.AddressSize := ctx.SizeOfAddress;
FPrettyPrinter.MemManager := ctx.MemManager;

View File

@ -1358,7 +1358,7 @@ function TFpLldbDebugger.GetInfoContextForContext(AThreadId,
AStackFrame: Integer): TFpDbgSymbolScope;
var
Addr: TDBGPtr;
i: Integer;
i, sa: Integer;
begin
Result := nil;
if FDwarfInfo = nil then
@ -1379,7 +1379,8 @@ begin
i := MAX_CTX_CACHE - 1;
while (i >= 0) and
( (FLastContext[i] = nil) or
(FLastContext[i].ThreadId <> AThreadId) or (FLastContext[i].StackFrame <> AStackFrame)
(FLastContext[i].LocationContext.ThreadId <> AThreadId) or
(FLastContext[i].LocationContext.StackFrame <> AStackFrame)
)
do
dec(i);
@ -1391,7 +1392,15 @@ begin
end;
DebugLn(DBG_VERBOSE, ['* FDwarfInfo.FindSymbolScope ', dbgs(Addr)]);
Result := FDwarfInfo.FindSymbolScope(AThreadId, AStackFrame, Addr);
if FDwarfInfo.TargetInfo.bitness = b32 then
sa := 4
else
sa := 8;
Result := FDwarfInfo.FindSymbolScope(
TFpDbgSimpleLocationContext.Create(FMemManager, Addr, sa, AThreadId, AStackFrame),
Addr
);
Result.LocationContext.ReleaseReference;
if Result = nil then begin
debugln(DBG_VERBOSE, ['GetInfoContextForContext CTX NOT FOUND for ', AThreadId, ', ', AStackFrame]);
@ -1459,9 +1468,8 @@ begin
RepeatCnt := -1;
end;
if Ctx = nil then exit;
debugln(['TFpLldbDebugger.EvaluateExpression ctx ', Ctx.Address]);
FMemManager.DefaultContext := Ctx;
FMemManager.DefaultContext := Ctx.LocationContext;
FPrettyPrinter.AddressSize := ctx.SizeOfAddress;
FPrettyPrinter.MemManager := ctx.MemManager;