LazDebuggerFpLLDB/Gdbmi: Fix cached context

This commit is contained in:
Martin 2022-02-10 23:14:52 +01:00
parent 6fc2cb7173
commit 6cded56ae9
2 changed files with 10 additions and 11 deletions

View File

@ -933,6 +933,7 @@ function TFpGDBMIDebugger.GetInfoContextForContext(AThreadId,
var
Addr: TDBGPtr;
i, sa: Integer;
LocCtx: TFpDbgSimpleLocationContext;
begin
Result := nil;
if FDwarfInfo = nil then
@ -969,10 +970,9 @@ begin
sa := 4
else
sa := 8;
Result := FDwarfInfo.FindSymbolScope(
TFpDbgSimpleLocationContext.Create(FMemManager, Addr, sa, AThreadId, AStackFrame),
Addr
);
LocCtx := TFpDbgSimpleLocationContext.Create(FMemManager, Addr, sa, AThreadId, AStackFrame);
Result := FDwarfInfo.FindSymbolScope(LocCtx, Addr);
LocCtx.ReleaseReference;
if Result = nil then begin
debugln(DBG_VERBOSE, ['GetInfoContextForContext CTX NOT FOUND for ', AThreadId, ', ', AStackFrame]);
@ -980,7 +980,7 @@ begin
end;
ReleaseRefAndNil(FLastContext[MAX_CTX_CACHE-1]);
move(FLastContext[0], FLastContext[1], (MAX_CTX_CACHE-1) + SizeOf(FLastContext[0]));
move(FLastContext[0], FLastContext[1], (MAX_CTX_CACHE-1) * SizeOf(FLastContext[0]));
FLastContext[0] := Result;
// TODO Result.AddReference;
end;

View File

@ -1398,6 +1398,7 @@ function TFpLldbDebugger.GetInfoContextForContext(AThreadId,
var
Addr: TDBGPtr;
i, sa: Integer;
LocCtx: TFpDbgSimpleLocationContext;
begin
Result := nil;
if FDwarfInfo = nil then
@ -1435,11 +1436,9 @@ begin
sa := 4
else
sa := 8;
Result := FDwarfInfo.FindSymbolScope(
TFpDbgSimpleLocationContext.Create(FMemManager, Addr, sa, AThreadId, AStackFrame),
Addr
);
Result.LocationContext.ReleaseReference;
LocCtx := TFpDbgSimpleLocationContext.Create(FMemManager, Addr, sa, AThreadId, AStackFrame);
Result := FDwarfInfo.FindSymbolScope(LocCtx, Addr);
LocCtx.ReleaseReference;
if Result = nil then begin
debugln(DBG_VERBOSE, ['GetInfoContextForContext CTX NOT FOUND for ', AThreadId, ', ', AStackFrame]);
@ -1447,7 +1446,7 @@ begin
end;
ReleaseRefAndNil(FLastContext[MAX_CTX_CACHE-1]);
move(FLastContext[0], FLastContext[1], (MAX_CTX_CACHE-1) + SizeOf(FLastContext[0]));
move(FLastContext[0], FLastContext[1], (MAX_CTX_CACHE-1) * SizeOf(FLastContext[0]));
FLastContext[0] := Result;
Result.AddReference;
end;