FpDebug: move "self" to pascal specific

git-svn-id: trunk@44603 -
This commit is contained in:
martin 2014-04-04 18:54:48 +00:00
parent d1a92f8e05
commit 9fbc114aa7
2 changed files with 17 additions and 13 deletions

View File

@ -76,6 +76,7 @@ type
property Dwarf: TDbgDwarf read FDwarf;
function SymbolToValue(ASym: TFpDbgSymbol): TFpDbgValue; inline;
procedure AddRefToVal(AVal: TFpDbgValue); inline;
function FindExportedSymbolInUnits(const AName: String; PNameUpper, PNameLower: PChar;
SkipCompUnit: TDwarfCompilationUnit): TFpDbgValue; inline;
@ -791,7 +792,6 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
procedure KindNeeded; override;
procedure SizeNeeded; override;
function GetFlags: TDbgSymbolFlags; override;
function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpDbgDwarfValue;
function GetColumn: Cardinal; override;
function GetFile: String; override;
@ -801,6 +801,7 @@ DECL = DW_AT_decl_column, DW_AT_decl_file, DW_AT_decl_line
constructor Create(ACompilationUnit: TDwarfCompilationUnit; AInfo: PDwarfAddressInfo; AAddress: TDbgPtr); overload;
destructor Destroy; override;
// TODO members = locals ?
function GetSelfParameter(AnAddress: TDbgPtr = 0): TFpDbgDwarfValue;
end;
{ TDbgDwarfIdentifierVariable }
@ -940,6 +941,11 @@ begin
ASym.ReleaseReference;
end;
procedure TDbgDwarfInfoAddressContext.AddRefToVal(AVal: TFpDbgValue);
begin
AVal.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(@FlastResult, 'FindSymbol'){$ENDIF};
end;
function TDbgDwarfInfoAddressContext.FindExportedSymbolInUnits(const AName: String;
PNameUpper, PNameLower: PChar; SkipCompUnit: TDwarfCompilationUnit): TFpDbgValue;
var
@ -1107,17 +1113,6 @@ begin
CU := SubRoutine.CompilationUnit;
InfoEntry := SubRoutine.InformationEntry.Clone;
// special: search "self" // depends on dwarf version
// Todo nested procs
// TODO: Move to FindLocal
if NameLower = 'self' then begin
Result := SubRoutine.GetSelfParameter(FAddress);
if Result <> nil then begin
Result.AddReference{$IFDEF WITH_REFCOUNT_DEBUG}(@FlastResult, 'FindSymbol'){$ENDIF};
exit;
end;
end;
while InfoEntry.HasValidScope do begin
//debugln(FPDBG_DWARF_SEARCH, ['TDbgDwarf.FindIdentifier Searching ', dbgs(InfoEntry.FScope, CU)]);
StartScopeIdx := InfoEntry.ScopeIndex;

View File

@ -5,7 +5,7 @@ unit FpDbgDwarfFreePascal;
interface
uses
Classes, SysUtils, FpDbgDwarfDataClasses, FpDbgDwarf, FpDbgInfo, DbgIntfBaseTypes;
Classes, SysUtils, FpDbgDwarfDataClasses, FpDbgDwarf, FpDbgInfo, FpDbgUtil, DbgIntfBaseTypes;
type
@ -54,9 +54,18 @@ function TFpDwarfFreePascalAddressContext.FindLocalSymbol(const AName: String; P
PNameLower: PChar; InfoEntry: TDwarfInformationEntry): TFpDbgValue;
const
parentfp: string = 'parentfp';
selfname: string = 'self';
var
StartScopeIdx: Integer;
begin
if (Length(AName) = length(selfname)) and (CompareUtf8BothCase(PNameUpper, PNameLower, @selfname[1])) then begin
Result := TDbgDwarfProcSymbol(Symbol).GetSelfParameter(Address);
if Result <> nil then begin
AddRefToVal(Result);
exit;
end;
end;
StartScopeIdx := InfoEntry.ScopeIndex;
Result := inherited FindLocalSymbol(AName, PNameUpper, PNameLower, InfoEntry);
if Result <> nil then