FpDebug: Fix watching local/param with name "this". Variables with "this" as name were hidden by the "self" param (that fpc encodes as "this")

This commit is contained in:
Martin 2023-02-04 13:24:56 +01:00
parent 60d221f23a
commit dd5d291621
2 changed files with 17 additions and 5 deletions

View File

@ -1640,7 +1640,7 @@ begin
ADbgValue := nil;
if not(Symbol is TFpSymbolDwarfDataProc) then
exit;
if not InfoEntry.GoNamedChildEx(ANameInfo) then
if not InfoEntry.GoNamedChildEx(ANameInfo, True) then
exit;
if InfoEntry.IsAddressInStartScope(FAddress) and not InfoEntry.IsArtificial then begin
ADbgValue := SymbolToValue(TFpSymbolDwarf.CreateSubClass(AName, InfoEntry));
@ -1747,7 +1747,7 @@ begin
// If this is a type with a pointer or ref, need to find the pointer or ref.
InfoEntry.GoParent;
if InfoEntry.HasValidScope and
InfoEntry.GoNamedChildEx(NameInfo)
InfoEntry.GoNamedChildEx(NameInfo, True)
then begin
if InfoEntry.IsAddressInStartScope(FAddress) and not InfoEntry.IsArtificial then begin
Result := SymbolToValue(TFpSymbolDwarf.CreateSubClass(AName, InfoEntry));
@ -1779,7 +1779,7 @@ begin
// TODO: nested subroutine
else
if InfoEntry.GoNamedChildEx(NameInfo) then begin
if InfoEntry.GoNamedChildEx(NameInfo, True) then begin
if InfoEntry.IsAddressInStartScope(FAddress) and not InfoEntry.IsArtificial then begin
Result := SymbolToValue(TFpSymbolDwarf.CreateSubClass(AName, InfoEntry));
exit;
@ -6442,6 +6442,8 @@ begin
if (tg = DW_TAG_class_type) or (tg = DW_TAG_structure_type) then begin
InfoEntry.ScopeIndex := InformationEntry.ScopeIndex;
found := InfoEntry.GoNamedChildEx(ThisNameInfo);
if found then
found := InfoEntry.IsArtificial;
if not found then begin
InfoEntry.ScopeIndex := InformationEntry.ScopeIndex;
found := InfoEntry.GoNamedChildEx(SelfNameInfo);

View File

@ -368,7 +368,7 @@ type
function GoNamedChild(const AName: String): Boolean;
// find in enum too // TODO: control search with a flags param, if needed
function GoNamedChildEx(const ANameInfo: TNameSearchInfo): Boolean;
function GoNamedChildEx(const ANameInfo: TNameSearchInfo; ASkipArtificial: Boolean = False): Boolean;
// GoNamedChildMatchCaseEx will use
// - UpperName for Hash
// - LowerName for compare
@ -2872,8 +2872,10 @@ begin
end;
end;
function TDwarfInformationEntry.GoNamedChildEx(const ANameInfo: TNameSearchInfo): Boolean;
function TDwarfInformationEntry.GoNamedChildEx(
const ANameInfo: TNameSearchInfo; ASkipArtificial: Boolean): Boolean;
var
Val: Integer;
EntryName: PChar;
InEnum: Boolean;
ParentScopIdx: Integer;
@ -2901,6 +2903,14 @@ begin
Continue;
end;
if ASkipArtificial then begin
if ReadValue(DW_AT_artificial, Val) and (Val <> 0) then begin
GoNext;
Continue;
end;
end;
if (sc^.NameHash = ANameInfo.NameHash) then begin
if not ReadValue(DW_AT_name, EntryName) then begin
GoNext;