FpDebug: Improve calling methods in watches, search SymbolTable for mangled method name to get address.

This commit is contained in:
Martin 2024-08-11 17:59:11 +02:00
parent f235b30e44
commit 59f3382161
9 changed files with 320 additions and 91 deletions

View File

@ -2700,6 +2700,7 @@ begin
Ctx := TFpDbgSimpleLocationContext.Create(MemManager, Addr, DBGPTRSIZE[Mode], AThreadId, AStackFrame); Ctx := TFpDbgSimpleLocationContext.Create(MemManager, Addr, DBGPTRSIZE[Mode], AThreadId, AStackFrame);
Ctx.SetFrameBaseCallback(@DoGetFrameBase); Ctx.SetFrameBaseCallback(@DoGetFrameBase);
Ctx.SetCfaFrameBaseCallback(@DoGetCfiFrameBase); Ctx.SetCfaFrameBaseCallback(@DoGetCfiFrameBase);
Ctx.SymbolTableInfo := SymbolTableInfo;
Frame.Context := Ctx; Frame.Context := Ctx;
end; end;
sym := Frame.ProcSymbol; sym := Frame.ProcSymbol;

View File

@ -69,7 +69,7 @@ type
public public
//function CanHandleCompUnit(ACU: TDwarfCompilationUnit): Boolean; override; //function CanHandleCompUnit(ACU: TDwarfCompilationUnit): Boolean; override;
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override; function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override; function CreateScopeForSymbol(ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit; function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; override; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; override;
function CreateUnitSymbol(ACompilationUnit: TDwarfCompilationUnit; function CreateUnitSymbol(ACompilationUnit: TDwarfCompilationUnit;
@ -136,7 +136,7 @@ type
InfoEntry: TDwarfInformationEntry; out ADbgValue: TFpValue): Boolean; virtual; InfoEntry: TDwarfInformationEntry; out ADbgValue: TFpValue): Boolean; virtual;
procedure Init; virtual; procedure Init; virtual;
public public
constructor Create(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo); constructor Create(ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol; ADwarf: TFpDwarfInfo);
destructor Destroy; override; destructor Destroy; override;
function FindSymbol(const AName: String; const OnlyUnitName: String = ''; function FindSymbol(const AName: String; const OnlyUnitName: String = '';
AFindFlags: TFindExportedSymbolsFlags = []): TFpValue; override; AFindFlags: TFindExportedSymbolsFlags = []): TFpValue; override;
@ -155,11 +155,11 @@ type
TFpValueDwarfBase = class(TFpValue) TFpValueDwarfBase = class(TFpValue)
strict private strict private
FLocContext: TFpDbgLocationContext; FLocContext: TFpDbgSimpleLocationContext;
procedure SetContext(AValue: TFpDbgLocationContext); procedure SetContext(AValue: TFpDbgSimpleLocationContext);
public public
destructor Destroy; override; destructor Destroy; override;
property Context: TFpDbgLocationContext read FLocContext write SetContext; property Context: TFpDbgSimpleLocationContext read FLocContext write SetContext;
end; end;
{ TFpValueDwarfTypeDefinition } { TFpValueDwarfTypeDefinition }
@ -1103,8 +1103,8 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
public public
constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo = nil); overload; constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo = nil); overload;
destructor Destroy; override; destructor Destroy; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; override; function CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext): TFpDbgSymbolScope; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override; function CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
// TODO members = locals ? // TODO members = locals ?
function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpValueDwarf; function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpValueDwarf;
function GetFrameBase(AContext: TFpDbgLocationContext; out AnError: TFpError): TDbgPtr; function GetFrameBase(AContext: TFpDbgLocationContext; out AnError: TFpError): TDbgPtr;
@ -1173,8 +1173,8 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
public public
constructor Create(const AName: String; AnInformationEntry: TDwarfInformationEntry; ADbgInfo: TFpDwarfInfo = nil); overload; constructor Create(const AName: String; AnInformationEntry: TDwarfInformationEntry; ADbgInfo: TFpDwarfInfo = nil); overload;
destructor Destroy; override; destructor Destroy; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; override; function CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext): TFpDbgSymbolScope; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override; function CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; override;
end; end;
{%endregion Symbol objects } {%endregion Symbol objects }
@ -1192,7 +1192,7 @@ end;
{ TFpValueDwarfBase } { TFpValueDwarfBase }
procedure TFpValueDwarfBase.SetContext(AValue: TFpDbgLocationContext); procedure TFpValueDwarfBase.SetContext(AValue: TFpDbgSimpleLocationContext);
begin begin
if FLocContext = AValue then Exit; if FLocContext = AValue then Exit;
if FLocContext <> nil then if FLocContext <> nil then
@ -1318,7 +1318,7 @@ begin
end; end;
function TFpDwarfDefaultSymbolClassMap.CreateScopeForSymbol( function TFpDwarfDefaultSymbolClassMap.CreateScopeForSymbol(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope;
begin begin
Result := TFpDwarfInfoSymbolScope.Create(ALocationContext,ASymbol, ADwarf); Result := TFpDwarfInfoSymbolScope.Create(ALocationContext,ASymbol, ADwarf);
@ -1727,7 +1727,7 @@ begin
end; end;
constructor TFpDwarfInfoSymbolScope.Create( constructor TFpDwarfInfoSymbolScope.Create(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo); ADwarf: TFpDwarfInfo);
begin begin
assert((ASymbol=nil) or (ASymbol is TFpSymbolDwarf), 'TFpDwarfInfoSymbolScope.Create: (ASymbol=nil) or (ASymbol is TFpSymbolDwarf)'); assert((ASymbol=nil) or (ASymbol is TFpSymbolDwarf), 'TFpDwarfInfoSymbolScope.Create: (ASymbol=nil) or (ASymbol is TFpSymbolDwarf)');
@ -6733,7 +6733,7 @@ begin
end; end;
function TFpSymbolDwarfDataProc.CreateSymbolScope( function TFpSymbolDwarfDataProc.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; ALocationContext: TFpDbgSimpleLocationContext): TFpDbgSymbolScope;
begin begin
Result := nil; Result := nil;
if FDwarf <> nil then if FDwarf <> nil then
@ -6742,7 +6742,7 @@ begin
end; end;
function TFpSymbolDwarfDataProc.CreateSymbolScope( function TFpSymbolDwarfDataProc.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo ALocationContext: TFpDbgSimpleLocationContext; ADwarfInfo: TFpDwarfInfo
): TFpDbgSymbolScope; ): TFpDbgSymbolScope;
begin begin
Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol
@ -7298,7 +7298,7 @@ begin
end; end;
function TFpSymbolDwarfUnit.CreateSymbolScope( function TFpSymbolDwarfUnit.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; ALocationContext: TFpDbgSimpleLocationContext): TFpDbgSymbolScope;
begin begin
Result := nil; Result := nil;
if FDwarf <> nil then if FDwarf <> nil then
@ -7307,7 +7307,7 @@ begin
end; end;
function TFpSymbolDwarfUnit.CreateSymbolScope( function TFpSymbolDwarfUnit.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo ALocationContext: TFpDbgSimpleLocationContext; ADwarfInfo: TFpDwarfInfo
): TFpDbgSymbolScope; ): TFpDbgSymbolScope;
begin begin
Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol Result := CompilationUnit.DwarfSymbolClassMap.CreateScopeForSymbol

View File

@ -527,7 +527,7 @@ type
AKind: TDbgSymbolKind; const AAddress: TFpDbgMemLocation); overload; AKind: TDbgSymbolKind; const AAddress: TFpDbgMemLocation); overload;
destructor Destroy; override; destructor Destroy; override;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; virtual; overload; function CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext; ADwarfInfo: TFpDwarfInfo): TFpDbgSymbolScope; virtual; overload;
function IsEqual(AnOther: TFpSymbol): Boolean; override; function IsEqual(AnOther: TFpSymbol): Boolean; override;
@ -577,7 +577,7 @@ type
constructor Create(ACU: TDwarfCompilationUnit; AHelperData: Pointer); virtual; constructor Create(ACU: TDwarfCompilationUnit; AHelperData: Pointer); virtual;
function IgnoreCfiStackEnd: boolean; virtual; function IgnoreCfiStackEnd: boolean; virtual;
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; virtual; abstract; function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; virtual; abstract;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; function CreateScopeForSymbol(ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; virtual; abstract; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; virtual; abstract;
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit; function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; virtual; abstract; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo): TDbgDwarfSymbolBase; virtual; abstract;
@ -822,7 +822,7 @@ type
public public
constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel); override; constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel); override;
destructor Destroy; override; destructor Destroy; override;
function FindSymbolScope(ALocationContext: TFpDbgLocationContext; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override; function FindSymbolScope(ALocationContext: TFpDbgSimpleLocationContext; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override;
function FindDwarfProcSymbol(AAddress: TDbgPtr): TDbgDwarfSymbolBase; inline; function FindDwarfProcSymbol(AAddress: TDbgPtr): TDbgDwarfSymbolBase; inline;
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; override; overload; function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; override; overload;
function FindProcStartEndPC(const AAddress: TDbgPtr; out AStartPC, AEndPC: TDBGPtr): boolean; override; function FindProcStartEndPC(const AAddress: TDbgPtr; out AStartPC, AEndPC: TDBGPtr): boolean; override;
@ -3847,7 +3847,7 @@ begin
inherited Destroy; inherited Destroy;
end; end;
function TFpDwarfInfo.FindSymbolScope(ALocationContext: TFpDbgLocationContext; function TFpDwarfInfo.FindSymbolScope(ALocationContext: TFpDbgSimpleLocationContext;
AAddress: TDbgPtr): TFpDbgSymbolScope; AAddress: TDbgPtr): TFpDbgSymbolScope;
var var
Proc, UnitSym: TDbgDwarfSymbolBase; Proc, UnitSym: TDbgDwarfSymbolBase;
@ -4495,7 +4495,7 @@ begin
end; end;
function TDbgDwarfSymbolBase.CreateSymbolScope( function TDbgDwarfSymbolBase.CreateSymbolScope(
ALocationContext: TFpDbgLocationContext; ADwarfInfo: TFpDwarfInfo ALocationContext: TFpDbgSimpleLocationContext; ADwarfInfo: TFpDwarfInfo
): TFpDbgSymbolScope; ): TFpDbgSymbolScope;
begin begin
Result := nil; Result := nil;

View File

@ -7,10 +7,9 @@ unit FpDbgDwarfFreePascal;
interface interface
uses uses
Classes, SysUtils, Types, math, Classes, SysUtils, Types, math, FpDbgDwarfDataClasses, FpDbgDwarf, FpDbgInfo, FpDbgUtil,
FpDbgDwarfDataClasses, FpDbgDwarf, FpDbgInfo, FpDbgDwarfConst, FpErrorMessages, FpdMemoryTools, FpDbgClasses, FpPascalParser, FpDbgDisasX86,
FpDbgUtil, FpDbgDwarfConst, FpErrorMessages, FpdMemoryTools, FpDbgClasses, FpPascalParser, FpDbgDisasX86, fpDbgSymTableContext, DbgIntfBaseTypes,
DbgIntfBaseTypes,
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}, {$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
LazStringUtils, LazClasses; LazStringUtils, LazClasses;
@ -37,7 +36,7 @@ type
constructor Create(ACU: TDwarfCompilationUnit; AHelperData: Pointer); override; constructor Create(ACU: TDwarfCompilationUnit; AHelperData: Pointer); override;
function IgnoreCfiStackEnd: boolean; override; function IgnoreCfiStackEnd: boolean; override;
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override; function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; function CreateScopeForSymbol(ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit; function CreateProcSymbol(ACompilationUnit: TDwarfCompilationUnit;
AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo AInfo: PDwarfAddressInfo; AAddress: TDbgPtr; ADbgInfo: TFpDwarfInfo
@ -80,7 +79,7 @@ type
class function ClassCanHandleCompUnit(ACU: TDwarfCompilationUnit): Boolean; override; class function ClassCanHandleCompUnit(ACU: TDwarfCompilationUnit): Boolean; override;
public public
function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override; function GetDwarfSymbolClass(ATag: Cardinal): TDbgDwarfSymbolBaseClass; override;
function CreateScopeForSymbol(ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; function CreateScopeForSymbol(ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
//class function CreateSymbolScope(AThreadId, AStackFrame: Integer; AnAddress: TDBGPtr; ASymbol: TFpSymbol; //class function CreateSymbolScope(AThreadId, AStackFrame: Integer; AnAddress: TDBGPtr; ASymbol: TFpSymbol;
// ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override; // ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; override;
@ -327,6 +326,19 @@ type
property DynamicCodePage: TSystemCodePage read GetCodePage; property DynamicCodePage: TSystemCodePage read GetCodePage;
end; end;
{ TFpValueDwarfFreePascalSubroutine }
TFpValueDwarfFreePascalSubroutine = class(TFpValueDwarfSubroutine)
protected
function GetMangledArguments: String;
function GetMangledMethodName(AClassName, AnUnitName: String): String;
function GetMangledFunctionName(AnUnitName: String): String;
function GetEntryPCAddress: TFpDbgMemLocation; override;
public
function GetMangledAddress: TFpDbgMemLocation;
end;
{ TFpSymbolDwarfFreePascalDataProc } { TFpSymbolDwarfFreePascalDataProc }
TFpSymbolDwarfFreePascalDataProc = class(TFpSymbolDwarfDataProc) TFpSymbolDwarfFreePascalDataProc = class(TFpSymbolDwarfDataProc)
@ -336,6 +348,7 @@ type
function GetLine: Cardinal; override; function GetLine: Cardinal; override;
function GetColumn: Cardinal; override; function GetColumn: Cardinal; override;
// Todo: LineStartAddress, ... // Todo: LineStartAddress, ...
function GetValueObject: TFpValue; override;
public public
destructor Destroy; override; destructor Destroy; override;
function ResolveInternalFinallySymbol(Process: Pointer): TFpSymbol; override; function ResolveInternalFinallySymbol(Process: Pointer): TFpSymbol; override;
@ -527,7 +540,7 @@ begin
end; end;
function TFpDwarfFreePascalSymbolClassMap.CreateScopeForSymbol( function TFpDwarfFreePascalSymbolClassMap.CreateScopeForSymbol(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope;
begin begin
Result := TFpDwarfFreePascalSymbolScope.Create(ALocationContext, ASymbol, ADwarf); Result := TFpDwarfFreePascalSymbolScope.Create(ALocationContext, ASymbol, ADwarf);
@ -635,7 +648,7 @@ begin
end; end;
function TFpDwarfFreePascalSymbolClassMapDwarf3.CreateScopeForSymbol( function TFpDwarfFreePascalSymbolClassMapDwarf3.CreateScopeForSymbol(
ALocationContext: TFpDbgLocationContext; ASymbol: TFpSymbol; ALocationContext: TFpDbgSimpleLocationContext; ASymbol: TFpSymbol;
ADwarf: TFpDwarfInfo): TFpDbgSymbolScope; ADwarf: TFpDwarfInfo): TFpDbgSymbolScope;
begin begin
Result := TFpDwarfFreePascalSymbolScopeDwarf3.Create(ALocationContext, ASymbol, ADwarf); Result := TFpDwarfFreePascalSymbolScopeDwarf3.Create(ALocationContext, ASymbol, ADwarf);
@ -2329,6 +2342,133 @@ begin
Result := True; Result := True;
end; end;
{ TFpValueDwarfFreePascalSubroutine }
function TFpValueDwarfFreePascalSubroutine.GetMangledArguments: String;
var
i: Integer;
m: TFpValue;
n: String;
begin
Result := '';
// First argument is SELF, and must be skipped
for i := 1 to MemberCount - 1 do begin
m := Member[i];
if (m.TypeInfo = nil) then
exit('');
n := m.TypeInfo.Name;
if n = '' then
exit('');
Result := Result + '$' + n;
end;
if Kind = skFunction then begin
if (TypeInfo = nil) or (TypeInfo.TypeInfo = nil) then
exit('');
n := TypeInfo.TypeInfo.Name;
if n = '' then
exit('');
Result := Result + '$$' + n;
end;
end;
function TFpValueDwarfFreePascalSubroutine.GetMangledMethodName(AClassName, AnUnitName: String
): String;
var
i: Integer;
m: TFpValue;
n: String;
begin
Result := '';
if (AClassName = '') or (AnUnitName = '') or (Name = '') then
exit;
UniqueString(AClassName);
i := pos('.', AClassName);
while i > 0 do begin
AClassName[i] := '_';
Insert('_$', AClassName, i);
i := pos('.', AClassName);
end;
Result := AnUnitName + '$_$' + AClassName + '_$__$$_' + Name + GetMangledArguments;
end;
function TFpValueDwarfFreePascalSubroutine.GetMangledFunctionName(AnUnitName: String): String;
var
i: Integer;
m: TFpValue;
n: String;
begin
Result := '';
if (AnUnitName = '') or (Name = '') then
exit;
Result := AnUnitName + '_$$_' + Name + GetMangledArguments;
end;
function TFpValueDwarfFreePascalSubroutine.GetEntryPCAddress: TFpDbgMemLocation;
begin
Result := inherited GetEntryPCAddress;
if IsValidLoc(Result) then
exit;
Result := GetMangledAddress;
end;
function TFpValueDwarfFreePascalSubroutine.GetMangledAddress: TFpDbgMemLocation;
var
ParentIdx: Integer;
TheClassName, TheUnitName, n: String;
SymTbl: TDbgInfo;
SymProc: TFpSymbol;
s: TFpValueDwarf;
begin
Result := InvalidLoc;
if (Context = nil) or (Context.SymbolTableInfo = nil) or
(not (DbgSymbol is TFpSymbolDwarfDataProc))
then
exit;
SymTbl := Context.SymbolTableInfo;
n := '';
s := StructureValue;
if s = nil then begin
s := TFpSymbolDwarfDataProc(DbgSymbol).GetSelfParameter(Context.Address);
if s <> nil then
s.Context := Context;
end
else
s.AddReference;
if (s <> nil) then begin
ParentIdx := 0;
// TODO: we need the structure parent in which we were found
while s.GetInstanceClassName(@TheClassName, @TheUnitName, ParentIdx) do begin
// if TheClassName = '' then TheClassName := 'P$'+ProjecName;
n := GetMangledMethodName(TheClassName, TheUnitName);
SymProc := SymTbl.FindProcSymbol(n, True);
if SymProc <> nil then begin
Result := SymProc.Address;
SymProc.ReleaseReference;
DebugLn(FPDBG_DWARF_VERBOSE, 'Using mangled address for method "%s": %s', [n, dbgs(Result)]);
s.ReleaseReference;
exit;
end;
inc(ParentIdx);
if ParentIdx > 100 then break; // safety net
end;
s.ReleaseReference;
end
else begin
n := GetMangledFunctionName(TFpSymbolDwarfDataProc(DbgSymbol).CompilationUnit.UnitName);
SymProc := SymTbl.FindProcSymbol(n, True);
if SymProc <> nil then begin
Result := SymProc.Address;
SymProc.ReleaseReference;
DebugLn(FPDBG_DWARF_VERBOSE, 'Using mangled address for function "%s": %s', [n, dbgs(Result)]);
end;
end;
end;
{ TFpSymbolDwarfFreePascalDataProc } { TFpSymbolDwarfFreePascalDataProc }
function TFpSymbolDwarfFreePascalDataProc.GetLine: Cardinal; function TFpSymbolDwarfFreePascalDataProc.GetLine: Cardinal;
@ -2347,6 +2487,13 @@ begin
Result := inherited GetColumn; Result := inherited GetColumn;
end; end;
function TFpSymbolDwarfFreePascalDataProc.GetValueObject: TFpValue;
begin
assert(TypeInfo is TFpSymbolDwarfType, 'TFpSymbolDwarfDataProc.GetValueObject: TypeInfo is TFpSymbolDwarfType');
Result := TFpValueDwarfFreePascalSubroutine.Create(TFpSymbolDwarfType(TypeInfo)); // TODO: GetTypedValueObject;
TFpValueDwarf(Result).SetDataSymbol(self);
end;
destructor TFpSymbolDwarfFreePascalDataProc.Destroy; destructor TFpSymbolDwarfFreePascalDataProc.Destroy;
begin begin
inherited Destroy; inherited Destroy;

View File

@ -114,6 +114,9 @@ type
TFindExportedSymbolsFlag = (fsfIgnoreEnumVals, fsfMatchUnitName); TFindExportedSymbolsFlag = (fsfIgnoreEnumVals, fsfMatchUnitName);
TFindExportedSymbolsFlags = set of TFindExportedSymbolsFlag; TFindExportedSymbolsFlags = set of TFindExportedSymbolsFlag;
TDbgInfo = class;
TFpDbgSimpleLocationContext = class;
{ TFpValue } { TFpValue }
TFpValue = class(TRefCountedObject) TFpValue = class(TRefCountedObject)
@ -576,7 +579,7 @@ type
// Returns a reference to caller / caller must release // Returns a reference to caller / caller must release
function TypeCastValue({%H-}AValue: TFpValue): TFpValue; virtual; function TypeCastValue({%H-}AValue: TFpValue): TFpValue; virtual;
function CreateSymbolScope(ALocationContext: TFpDbgLocationContext): TFpDbgSymbolScope; virtual; function CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext): TFpDbgSymbolScope; virtual;
function IsEqual(AnOther: TFpSymbol): Boolean; virtual; function IsEqual(AnOther: TFpSymbol): Boolean; virtual;
end; end;
@ -646,7 +649,7 @@ type
TFpDbgSymbolScope = class(TRefCountedObject) TFpDbgSymbolScope = class(TRefCountedObject)
private private
FLocationContext: TFpDbgLocationContext; FLocationContext: TFpDbgSimpleLocationContext;
protected protected
function GetSymbolAtAddress: TFpSymbol; virtual; function GetSymbolAtAddress: TFpSymbol; virtual;
function GetProcedureAtAddress: TFpValue; virtual; function GetProcedureAtAddress: TFpValue; virtual;
@ -654,7 +657,7 @@ type
function GetMemModel: TFpDbgMemModel; virtual; function GetMemModel: TFpDbgMemModel; virtual;
function GetSizeOfAddress: Integer; virtual; function GetSizeOfAddress: Integer; virtual;
public public
constructor Create(ALocationContext: TFpDbgLocationContext); constructor Create(ALocationContext: TFpDbgSimpleLocationContext);
destructor Destroy; override; destructor Destroy; override;
property SymbolAtAddress: TFpSymbol read GetSymbolAtAddress; property SymbolAtAddress: TFpSymbol read GetSymbolAtAddress;
property ProcedureAtAddress: TFpValue read GetProcedureAtAddress; property ProcedureAtAddress: TFpValue read GetProcedureAtAddress;
@ -664,7 +667,7 @@ type
property MemManager: TFpDbgMemManager read GetMemManager; property MemManager: TFpDbgMemManager read GetMemManager;
property MemModel: TFpDbgMemModel read GetMemModel; property MemModel: TFpDbgMemModel read GetMemModel;
property SizeOfAddress: Integer read GetSizeOfAddress; property SizeOfAddress: Integer read GetSizeOfAddress;
property LocationContext: TFpDbgLocationContext read FLocationContext; property LocationContext: TFpDbgSimpleLocationContext read FLocationContext;
end; end;
{ TFpDbgSimpleLocationContext } { TFpDbgSimpleLocationContext }
@ -674,6 +677,7 @@ type
FMemManager: TFpDbgMemManager; FMemManager: TFpDbgMemManager;
FMemModel: TFpDbgMemModel; FMemModel: TFpDbgMemModel;
FAddress: TDbgPtr; FAddress: TDbgPtr;
FSymbolTableInfo: TDbgInfo;
FThreadId: Integer; FThreadId: Integer;
FStackFrame: Integer; FStackFrame: Integer;
FSizeOfAddr: Integer; FSizeOfAddr: Integer;
@ -686,6 +690,7 @@ type
function GetSizeOfAddress: Integer; override; function GetSizeOfAddress: Integer; override;
public public
constructor Create(AMemManager: TFpDbgMemManager; AnAddress: TDbgPtr; AnSizeOfAddr, AThreadId: Integer; AStackFrame: Integer); constructor Create(AMemManager: TFpDbgMemManager; AnAddress: TDbgPtr; AnSizeOfAddr, AThreadId: Integer; AStackFrame: Integer);
property SymbolTableInfo: TDbgInfo read FSymbolTableInfo write FSymbolTableInfo;
end; end;
{ TFpDbgCallMemReader } { TFpDbgCallMemReader }
@ -720,21 +725,12 @@ type
{ TFpDbgAbstractCallContext } { TFpDbgAbstractCallContext }
TFpDbgAbstractCallContext = class(TFpDbgLocationContext) TFpDbgAbstractCallContext = class(TFpDbgSimpleLocationContext)
private private
FBaseContext: TFpDbgLocationContext; FBaseContext: TFpDbgLocationContext;
FMemManager: TFpDbgMemManager;
FMemModel: TFpDbgMemModel;
FMemReader: TFpDbgCallMemReader; FMemReader: TFpDbgCallMemReader;
FIsValid: Boolean; FIsValid: Boolean;
FMessage: string; FMessage: string;
protected
function GetMemManager: TFpDbgMemManager; override;
function GetMemModel: TFpDbgMemModel; override;
function GetAddress: TDbgPtr; override;
function GetThreadId: Integer; override;
function GetStackFrame: Integer; override;
function GetSizeOfAddress: Integer; override;
public public
constructor Create(const ABaseContext: TFpDbgLocationContext; constructor Create(const ABaseContext: TFpDbgLocationContext;
AMemReader: TFpDbgMemReaderBase; AMemModel: TFpDbgMemModel; AMemConverter: TFpDbgMemConvertor); AMemReader: TFpDbgMemReaderBase; AMemModel: TFpDbgMemModel; AMemConverter: TFpDbgMemConvertor);
@ -764,7 +760,7 @@ type
However a different Address may be froced. However a different Address may be froced.
TODO: for now address may be needed, as stack decoding is not done yet TODO: for now address may be needed, as stack decoding is not done yet
*) *)
function FindSymbolScope(ALocationContext: TFpDbgLocationContext; {%H-}AAddress: TDbgPtr = 0): TFpDbgSymbolScope; virtual; function FindSymbolScope(ALocationContext: TFpDbgSimpleLocationContext; {%H-}AAddress: TDbgPtr = 0): TFpDbgSymbolScope; virtual;
function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; virtual; overload; function FindProcSymbol(AAddress: TDbgPtr): TFpSymbol; virtual; overload;
function FindProcSymbol(const {%H-}AName: String; AIgnoreCase: Boolean = False): TFpSymbol; virtual; overload; function FindProcSymbol(const {%H-}AName: String; AIgnoreCase: Boolean = False): TFpSymbol; virtual; overload;
function FindLineInfo(AAddress: TDbgPtr): TFpSymbol; virtual; function FindLineInfo(AAddress: TDbgPtr): TFpSymbol; virtual;
@ -859,13 +855,11 @@ begin
FBaseContext:=ABaseContext; FBaseContext:=ABaseContext;
FBaseContext.AddReference; FBaseContext.AddReference;
FMemModel := AMemModel;
FMemReader := TFpDbgCallMemReader.Create(AMemReader); FMemReader := TFpDbgCallMemReader.Create(AMemReader);
FMemManager := TFpDbgMemManager.Create(FMemReader, AMemConverter, FMemModel);
FIsValid := True; FIsValid := True;
Inherited Create; Inherited Create(TFpDbgMemManager.Create(FMemReader, AMemConverter, AMemModel),
FBaseContext.Address, FBaseContext.SizeOfAddress, FBaseContext.ThreadId, FBaseContext.StackFrame);
end; end;
destructor TFpDbgAbstractCallContext.Destroy; destructor TFpDbgAbstractCallContext.Destroy;
@ -876,36 +870,6 @@ begin
inherited Destroy; inherited Destroy;
end; end;
function TFpDbgAbstractCallContext.GetAddress: TDbgPtr;
begin
Result := FBaseContext.Address;
end;
function TFpDbgAbstractCallContext.GetMemManager: TFpDbgMemManager;
begin
Result := FMemManager;
end;
function TFpDbgAbstractCallContext.GetMemModel: TFpDbgMemModel;
begin
Result := FMemModel;
end;
function TFpDbgAbstractCallContext.GetSizeOfAddress: Integer;
begin
Result := FBaseContext.SizeOfAddress;
end;
function TFpDbgAbstractCallContext.GetStackFrame: Integer;
begin
Result := FBaseContext.StackFrame;
end;
function TFpDbgAbstractCallContext.GetThreadId: Integer;
begin
Result := FBaseContext.ThreadId;
end;
procedure TFpDbgAbstractCallContext.SetRegisterValue(ARegNum: Cardinal; AValue: TDbgPtr); procedure TFpDbgAbstractCallContext.SetRegisterValue(ARegNum: Cardinal; AValue: TDbgPtr);
begin begin
FMemReader.SetRegisterValue(ARegNum, AValue); FMemReader.SetRegisterValue(ARegNum, AValue);
@ -1755,7 +1719,7 @@ begin
Result := LocationContext.MemModel; Result := LocationContext.MemModel;
end; end;
constructor TFpDbgSymbolScope.Create(ALocationContext: TFpDbgLocationContext); constructor TFpDbgSymbolScope.Create(ALocationContext: TFpDbgSimpleLocationContext);
begin begin
FLocationContext := ALocationContext; FLocationContext := ALocationContext;
FLocationContext.AddReference; FLocationContext.AddReference;
@ -1901,7 +1865,7 @@ begin
Result := nil; Result := nil;
end; end;
function TFpSymbol.CreateSymbolScope(ALocationContext: TFpDbgLocationContext function TFpSymbol.CreateSymbolScope(ALocationContext: TFpDbgSimpleLocationContext
): TFpDbgSymbolScope; ): TFpDbgSymbolScope;
begin begin
Result := nil; Result := nil;
@ -2358,7 +2322,7 @@ begin
inherited Create; inherited Create;
end; end;
function TDbgInfo.FindSymbolScope(ALocationContext: TFpDbgLocationContext; function TDbgInfo.FindSymbolScope(ALocationContext: TFpDbgSimpleLocationContext;
AAddress: TDbgPtr): TFpDbgSymbolScope; AAddress: TDbgPtr): TFpDbgSymbolScope;
begin begin
Result := nil; Result := nil;

View File

@ -46,7 +46,7 @@ type
protected protected
function GetSizeOfAddress: Integer; override; function GetSizeOfAddress: Integer; override;
public public
constructor Create(ALocationContext: TFpDbgLocationContext; AFpSymbolInfo: TFpSymbolInfo); constructor Create(ALocationContext: TFpDbgSimpleLocationContext; AFpSymbolInfo: TFpSymbolInfo);
function FindSymbol(const AName: String; const OnlyUnitName: String = ''; function FindSymbol(const AName: String; const OnlyUnitName: String = '';
AFindFlags: TFindExportedSymbolsFlags = []): TFpValue; override; AFindFlags: TFindExportedSymbolsFlags = []): TFpValue; override;
end; end;
@ -57,13 +57,18 @@ type
private private
FSymbolList: TfpSymbolList; FSymbolList: TfpSymbolList;
FLibName: String; FLibName: String;
function GetSymbols(AnIndex: integer): TFpSymbol;
public public
constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel); override; overload; constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel); override; overload;
constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; ALibName: String; AMemModel: TFpDbgMemModel); overload; constructor Create(ALoaderList: TDbgImageLoaderList; AMemManager: TFpDbgMemManager; ALibName: String; AMemModel: TFpDbgMemModel); overload;
destructor Destroy; override; destructor Destroy; override;
function FindSymbolScope(ALocationContext: TFpDbgLocationContext; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override; function FindSymbolScope(ALocationContext: TFpDbgSimpleLocationContext; AAddress: TDbgPtr = 0): TFpDbgSymbolScope; override;
function FindProcSymbol(const AName: String; AIgnoreCase: Boolean = False): TFpSymbol; override; overload; function FindProcSymbol(const AName: String; AIgnoreCase: Boolean = False): TFpSymbol; override; overload;
function FindProcSymbol(AnAdress: TDbgPtr): TFpSymbol; overload; function FindProcSymbol(AnAdress: TDbgPtr): TFpSymbol; overload;
// for debugdump
function SymbolCount: integer;
property Symbols[AnIndex: integer]: TFpSymbol read GetSymbols;
end; end;
implementation implementation
@ -133,7 +138,7 @@ begin
result := FSizeOfAddress; result := FSizeOfAddress;
end; end;
constructor TFpSymbolContext.Create(ALocationContext: TFpDbgLocationContext; constructor TFpSymbolContext.Create(ALocationContext: TFpDbgSimpleLocationContext;
AFpSymbolInfo: TFpSymbolInfo); AFpSymbolInfo: TFpSymbolInfo);
begin begin
inherited create(ALocationContext); inherited create(ALocationContext);
@ -160,6 +165,11 @@ end;
{ TFpSymbolInfo } { TFpSymbolInfo }
function TFpSymbolInfo.GetSymbols(AnIndex: integer): TFpSymbol;
begin
Result := TFpSymbolTableProc.Create(FSymbolList.Keys[AnIndex], FSymbolList.DataPtr[AnIndex]^.Addr);
end;
constructor TFpSymbolInfo.Create(ALoaderList: TDbgImageLoaderList; constructor TFpSymbolInfo.Create(ALoaderList: TDbgImageLoaderList;
AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel); AMemManager: TFpDbgMemManager; AMemModel: TFpDbgMemModel);
@ -189,7 +199,7 @@ begin
inherited Destroy; inherited Destroy;
end; end;
function TFpSymbolInfo.FindSymbolScope(ALocationContext: TFpDbgLocationContext; function TFpSymbolInfo.FindSymbolScope(ALocationContext: TFpDbgSimpleLocationContext;
AAddress: TDbgPtr): TFpDbgSymbolScope; AAddress: TDbgPtr): TFpDbgSymbolScope;
begin begin
assert(False, 'TFpSymbolInfo.FindSymbolScope: False'); assert(False, 'TFpSymbolInfo.FindSymbolScope: False');
@ -259,5 +269,10 @@ begin
end; end;
end; end;
function TFpSymbolInfo.SymbolCount: integer;
begin
Result := FSymbolList.Count;
end;
end. end.

View File

@ -120,7 +120,7 @@ function GetParamsAsString(
var var
ProcVal: TFpValue; ProcVal: TFpValue;
ProcSymbol: TFpSymbol; ProcSymbol: TFpSymbol;
AContext: TFpDbgLocationContext; AContext: TFpDbgSimpleLocationContext;
m: TFpValue; m: TFpValue;
v: String; v: String;
i: Integer; i: Integer;

View File

@ -826,13 +826,13 @@ type
TFpPasParserValue = class(TFpValue) TFpPasParserValue = class(TFpValue)
private private
FContext: TFpDbgLocationContext; FContext: TFpDbgSimpleLocationContext;
FExpressionPart: TFpPascalExpressionPart; FExpressionPart: TFpPascalExpressionPart;
protected protected
function DebugText(AIndent: String): String; virtual; function DebugText(AIndent: String): String; virtual;
public public
constructor Create(AnExpressionPart: TFpPascalExpressionPart); constructor Create(AnExpressionPart: TFpPascalExpressionPart);
property Context: TFpDbgLocationContext read FContext; property Context: TFpDbgSimpleLocationContext read FContext;
end; end;
{ TFpPasParserValueSlicedArray } { TFpPasParserValueSlicedArray }

View File

@ -9,7 +9,7 @@ uses
FpDebugDebugger, TestDbgControl, TestDbgTestSuites, TestOutputLogger, FpDebugDebugger, TestDbgControl, TestDbgTestSuites, TestOutputLogger,
TTestWatchUtilities, TestCommonSources, TestDbgConfig, LazDebuggerIntf, TTestWatchUtilities, TestCommonSources, TestDbgConfig, LazDebuggerIntf,
LazDebuggerIntfBaseTypes, LazDebuggerValueConverter, DbgIntfDebuggerBase, LazDebuggerIntfBaseTypes, LazDebuggerValueConverter, DbgIntfDebuggerBase,
DbgIntfBaseTypes, FpDbgInfo, FpPascalParser, FpDbgCommon, DbgIntfBaseTypes, FpDbgInfo, FpPascalParser, FpDbgCommon, FpDbgDwarfFreePascal, FpdMemoryTools,
IdeDebuggerWatchValueIntf, Forms, IdeDebuggerBase, IdeDebuggerWatchResult, IdeDebuggerWatchValueIntf, Forms, IdeDebuggerBase, IdeDebuggerWatchResult,
IdeDebuggerBackendValueConv, FpDebugStringConstants, FpDebugDebuggerUtils; IdeDebuggerBackendValueConv, FpDebugStringConstants, FpDebugDebuggerUtils;
@ -39,6 +39,7 @@ type
procedure TestWatchesModify; procedure TestWatchesModify;
procedure TestWatchesErrors; procedure TestWatchesErrors;
procedure TestClassRtti; procedure TestClassRtti;
procedure TestClassMangled;
end; end;
implementation implementation
@ -47,7 +48,7 @@ var
ControlTestWatch, ControlTestWatchScope, ControlTestWatchValue, ControlTestWatchIntrinsic, ControlTestWatchIntrinsic2, ControlTestWatch, ControlTestWatchScope, ControlTestWatchValue, ControlTestWatchIntrinsic, ControlTestWatchIntrinsic2,
ControlTestWatchFunct, ControlTestWatchFunct2, ControlTestWatchFunctStr, ControlTestWatchFunctRec, ControlTestWatchFunct, ControlTestWatchFunct2, ControlTestWatchFunctStr, ControlTestWatchFunctRec,
ControlTestWatchFunctVariant, ControlTestWatchAddressOf, ControlTestWatchTypeCast, ControlTestModify, ControlTestWatchFunctVariant, ControlTestWatchAddressOf, ControlTestWatchTypeCast, ControlTestModify,
ControlTestExpression, ControlTestErrors, ControlTestRTTI: Pointer; ControlTestExpression, ControlTestErrors, ControlTestRTTI, ControlTestMangled: Pointer;
procedure TTestWatches.RunToPause(var ABrk: TDBGBreakPoint; procedure TTestWatches.RunToPause(var ABrk: TDBGBreakPoint;
ADisableBreak: Boolean); ADisableBreak: Boolean);
@ -4869,6 +4870,106 @@ begin
end; end;
end; end;
procedure TTestWatches.TestClassMangled;
var
ExeName: String;
Src: TCommonSource;
BrkPrg: TDBGBreakPoint;
fp: TFpDebugDebugger;
AnExpressionScope: TFpDbgSymbolScope;
APasExpr: TFpPascalExpression;
ResValue: TFpValue;
InstClass, AnUnitName: String;
r: Boolean;
a: TFpDbgMemLocation;
begin
if SkipTest then exit;
if not TestControlCanTest(ControlTestMangled) then exit;
if Compiler.Version < 030000 then exit;
Src := GetCommonSourceFor('WatchesScopePrg.pas');
TestCompile(Src, ExeName);
AssertTrue('Start debugger', Debugger.StartDebugger(AppDir, ExeName));
AnExpressionScope := nil;
try
BrkPrg := Debugger.SetBreakPoint(Src, 'WatchesScopeUnit2.pas', 'MethodMainBaseBase');
AssertDebuggerNotInErrorState;
RunToPause(BrkPrg);
{$IFDEF FPDEBUG_THREAD_CHECK}
ClearCurrentFpDebugThreadIdForAssert;
{$ENDIF}
fp := TFpDebugDebugger(Debugger.LazDebugger);
AnExpressionScope := fp.DbgController.CurrentProcess.FindSymbolScope(fp.DbgController.CurrentThread.ID, 0);
TestTrue('got scope', AnExpressionScope <> nil);
if AnExpressionScope <> nil then begin
APasExpr := TFpPascalExpression.Create('MethodMainBaseBase', AnExpressionScope);
ResValue := APasExpr.ResultValue;
TestTrue('got inst class ', ResValue is TFpValueDwarfFreePascalSubroutine);
if ResValue is TFpValueDwarfFreePascalSubroutine then begin
a := TFpValueDwarfFreePascalSubroutine(ResValue).GetMangledAddress;
TestTrue('method - got addr ' + dbgs(a), IsTargetAddr(a) );
end;
APasExpr.Free;
APasExpr := TFpPascalExpression.Create('Self.MethodMainBaseBase', AnExpressionScope);
ResValue := APasExpr.ResultValue;
TestTrue('got inst class ', ResValue is TFpValueDwarfFreePascalSubroutine);
if ResValue is TFpValueDwarfFreePascalSubroutine then begin
a := TFpValueDwarfFreePascalSubroutine(ResValue).GetMangledAddress;
TestTrue('self - got addr ' + dbgs(a), IsTargetAddr(a) );
end;
APasExpr.Free;
APasExpr := TFpPascalExpression.Create('MethodMainBase', AnExpressionScope);
ResValue := APasExpr.ResultValue;
TestTrue('got inst class ', ResValue is TFpValueDwarfFreePascalSubroutine);
if ResValue is TFpValueDwarfFreePascalSubroutine then begin
a := TFpValueDwarfFreePascalSubroutine(ResValue).GetMangledAddress;
TestTrue('method other - got addr ' + dbgs(a), IsTargetAddr(a) );
end;
APasExpr.Free;
APasExpr := TFpPascalExpression.Create('Self.MethodMainBase', AnExpressionScope);
ResValue := APasExpr.ResultValue;
TestTrue('got inst class ', ResValue is TFpValueDwarfFreePascalSubroutine);
if ResValue is TFpValueDwarfFreePascalSubroutine then begin
a := TFpValueDwarfFreePascalSubroutine(ResValue).GetMangledAddress;
TestTrue('self other - got addr ' + dbgs(a), IsTargetAddr(a) );
end;
APasExpr.Free;
APasExpr := TFpPascalExpression.Create('Unit2Init', AnExpressionScope);
ResValue := APasExpr.ResultValue;
TestTrue('got inst class ', ResValue is TFpValueDwarfFreePascalSubroutine);
if ResValue is TFpValueDwarfFreePascalSubroutine then begin
a := TFpValueDwarfFreePascalSubroutine(ResValue).GetMangledAddress;
TestTrue('function - got addr '+dbgs(a), IsTargetAddr(a) );
end;
APasExpr.Free;
end
else
TestTrue('scope ', False);
finally
AnExpressionScope.ReleaseReference;
Debugger.RunToNextPause(dcStop);
Debugger.ClearDebuggerMonitors;
Debugger.FreeDebugger;
AssertTestErrors;
end;
end;
initialization initialization
RegisterDbgTest(TTestWatches); RegisterDbgTest(TTestWatches);
@ -4888,6 +4989,7 @@ initialization
ControlTestExpression := TestControlRegisterTest('Expression', ControlTestWatch); ControlTestExpression := TestControlRegisterTest('Expression', ControlTestWatch);
ControlTestErrors := TestControlRegisterTest('Errors', ControlTestWatch); ControlTestErrors := TestControlRegisterTest('Errors', ControlTestWatch);
ControlTestRTTI := TestControlRegisterTest('Rtti', ControlTestWatch); ControlTestRTTI := TestControlRegisterTest('Rtti', ControlTestWatch);
ControlTestMangled := TestControlRegisterTest('Mangled', ControlTestWatch);
end. end.