mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-31 17:20:37 +02:00
FpDebug: Rework TFpValueDwarfPointer.GetDataAddress, the data address is the pointer, not the deref-address.
git-svn-id: trunk@61746 -
This commit is contained in:
parent
c66f2fd121
commit
c69090c512
@ -293,6 +293,7 @@ type
|
|||||||
private
|
private
|
||||||
FLastAddrMember: TFpValue;
|
FLastAddrMember: TFpValue;
|
||||||
FPointetToAddr: TFpDbgMemLocation;
|
FPointetToAddr: TFpDbgMemLocation;
|
||||||
|
function GetDerefAddress: TFpDbgMemLocation;
|
||||||
protected
|
protected
|
||||||
function GetAsCardinal: QWord; override;
|
function GetAsCardinal: QWord; override;
|
||||||
function GetFieldFlags: TFpValueFieldFlags; override;
|
function GetFieldFlags: TFpValueFieldFlags; override;
|
||||||
@ -2032,11 +2033,27 @@ end;
|
|||||||
|
|
||||||
{ TFpValueDwarfPointer }
|
{ TFpValueDwarfPointer }
|
||||||
|
|
||||||
|
function TFpValueDwarfPointer.GetDerefAddress: TFpDbgMemLocation;
|
||||||
|
begin
|
||||||
|
if doneAddr in FEvaluated then begin
|
||||||
|
Result := FPointetToAddr;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
Include(FEvaluated, doneAddr);
|
||||||
|
|
||||||
|
if (FSize <= 0) then
|
||||||
|
Result := InvalidLoc
|
||||||
|
else
|
||||||
|
if not MemManager.ReadAddress(OrdOrDataAddr, Context.SizeOfAddress, Result) then
|
||||||
|
FLastError := MemManager.LastError;
|
||||||
|
FPointetToAddr := Result;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFpValueDwarfPointer.GetAsCardinal: QWord;
|
function TFpValueDwarfPointer.GetAsCardinal: QWord;
|
||||||
var
|
var
|
||||||
a: TFpDbgMemLocation;
|
a: TFpDbgMemLocation;
|
||||||
begin
|
begin
|
||||||
a := GetDataAddress;
|
a := GetDerefAddress;
|
||||||
if IsTargetAddr(a) then
|
if IsTargetAddr(a) then
|
||||||
Result := LocToAddr(a)
|
Result := LocToAddr(a)
|
||||||
else
|
else
|
||||||
@ -2053,27 +2070,17 @@ begin
|
|||||||
|
|
||||||
t := TypeInfo;
|
t := TypeInfo;
|
||||||
if (t <> nil) then t := t.TypeInfo;
|
if (t <> nil) then t := t.TypeInfo;
|
||||||
if (t <> nil) and (t.Kind = skChar) and IsReadableMem(DataAddress) then // pchar
|
if (t <> nil) and (t.Kind = skChar) and IsReadableMem(GetDerefAddress) then // pchar
|
||||||
Result := Result + [svfString]; // data address
|
Result := Result + [svfString]; // data address
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFpValueDwarfPointer.GetDataAddress: TFpDbgMemLocation;
|
function TFpValueDwarfPointer.GetDataAddress: TFpDbgMemLocation;
|
||||||
begin
|
begin
|
||||||
if doneAddr in FEvaluated then begin
|
|
||||||
Result := FPointetToAddr;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
Include(FEvaluated, doneAddr);
|
|
||||||
|
|
||||||
if (FSize <= 0) then
|
if (FSize <= 0) then
|
||||||
Result := InvalidLoc
|
Result := InvalidLoc
|
||||||
else
|
else
|
||||||
begin
|
if not GetDwarfDataAddress(Result, Owner) then
|
||||||
if not MemManager.ReadAddress(OrdOrDataAddr, FSize, Result) then
|
Result := InvalidLoc;
|
||||||
FLastError := MemManager.LastError;
|
|
||||||
end;
|
|
||||||
|
|
||||||
FPointetToAddr := Result;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFpValueDwarfPointer.GetAsString: AnsiString;
|
function TFpValueDwarfPointer.GetAsString: AnsiString;
|
||||||
@ -2086,10 +2093,10 @@ begin
|
|||||||
if t.Size = 2 then
|
if t.Size = 2 then
|
||||||
Result := GetAsWideString
|
Result := GetAsWideString
|
||||||
else
|
else
|
||||||
if (MemManager <> nil) and (t <> nil) and (t.Kind = skChar) and IsReadableMem(DataAddress) then begin // pchar
|
if (MemManager <> nil) and (t <> nil) and (t.Kind = skChar) and IsReadableMem(GetDerefAddress) then begin // pchar
|
||||||
SetLength(Result, 2000);
|
SetLength(Result, 2000);
|
||||||
i := 2000;
|
i := 2000;
|
||||||
while (i > 0) and (not MemManager.ReadMemory(DataAddress, i, @Result[1])) do
|
while (i > 0) and (not MemManager.ReadMemory(GetDerefAddress, i, @Result[1])) do
|
||||||
i := i div 2;
|
i := i div 2;
|
||||||
SetLength(Result,i);
|
SetLength(Result,i);
|
||||||
i := pos(#0, Result);
|
i := pos(#0, Result);
|
||||||
@ -2108,10 +2115,10 @@ begin
|
|||||||
t := TypeInfo;
|
t := TypeInfo;
|
||||||
if (t <> nil) then t := t.TypeInfo;
|
if (t <> nil) then t := t.TypeInfo;
|
||||||
// skWideChar ???
|
// skWideChar ???
|
||||||
if (MemManager <> nil) and (t <> nil) and (t.Kind = skChar) and IsReadableMem(DataAddress) then begin // pchar
|
if (MemManager <> nil) and (t <> nil) and (t.Kind = skChar) and IsReadableMem(GetDerefAddress) then begin // pchar
|
||||||
SetLength(Result, 2000);
|
SetLength(Result, 2000);
|
||||||
i := 4000; // 2000 * 16 bit
|
i := 4000; // 2000 * 16 bit
|
||||||
while (i > 0) and (not MemManager.ReadMemory(DataAddress, i, @Result[1])) do
|
while (i > 0) and (not MemManager.ReadMemory(GetDerefAddress, i, @Result[1])) do
|
||||||
i := i div 2;
|
i := i div 2;
|
||||||
SetLength(Result, i div 2);
|
SetLength(Result, i div 2);
|
||||||
i := pos(#0, Result);
|
i := pos(#0, Result);
|
||||||
@ -2142,7 +2149,7 @@ begin
|
|||||||
{$PUSH}{$R-}{$Q-} // TODO: check overflow
|
{$PUSH}{$R-}{$Q-} // TODO: check overflow
|
||||||
if ti <> nil then
|
if ti <> nil then
|
||||||
AIndex := AIndex * ti.Size;
|
AIndex := AIndex * ti.Size;
|
||||||
addr := DataAddress;
|
addr := GetDerefAddress;
|
||||||
if not IsTargetAddr(addr) then begin
|
if not IsTargetAddr(addr) then begin
|
||||||
FLastError := CreateError(fpErrAnyError, ['Internal dereference error']);
|
FLastError := CreateError(fpErrAnyError, ['Internal dereference error']);
|
||||||
exit;
|
exit;
|
||||||
@ -3982,6 +3989,8 @@ function TFpSymbolDwarfTypePointer.GetDataAddressNext(AValueObj: TFpValueDwarf;
|
|||||||
var
|
var
|
||||||
t: TFpDbgMemLocation;
|
t: TFpDbgMemLocation;
|
||||||
begin
|
begin
|
||||||
|
if not IsInternalPointer then exit(True);
|
||||||
|
|
||||||
t := AValueObj.DataAddressCache[ATargetCacheIndex];
|
t := AValueObj.DataAddressCache[ATargetCacheIndex];
|
||||||
if IsInitializedLoc(t) then begin
|
if IsInitializedLoc(t) then begin
|
||||||
AnAddress := t;
|
AnAddress := t;
|
||||||
|
@ -757,6 +757,8 @@ end;
|
|||||||
function TFpPasParserValueDerefPointer.GetAddress: TFpDbgMemLocation;
|
function TFpPasParserValueDerefPointer.GetAddress: TFpDbgMemLocation;
|
||||||
begin
|
begin
|
||||||
Result := FValue.DataAddress;
|
Result := FValue.DataAddress;
|
||||||
|
Result := Context.MemManager.ReadAddress(Result, Context.SizeOfAddress);
|
||||||
|
|
||||||
if FAddressOffset <> 0 then begin
|
if FAddressOffset <> 0 then begin
|
||||||
assert(IsTargetAddr(Result ), 'TFpPasParserValueDerefPointer.GetAddress: TargetLoc(Result)');
|
assert(IsTargetAddr(Result ), 'TFpPasParserValueDerefPointer.GetAddress: TargetLoc(Result)');
|
||||||
if IsTargetAddr(Result) then
|
if IsTargetAddr(Result) then
|
||||||
|
Loading…
Reference in New Issue
Block a user