mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-12-04 13:37:22 +01:00
FpDebug: Ensure that the Context is passed on to new Value-objects. Fix crash on nil pointer
git-svn-id: trunk@61900 -
This commit is contained in:
parent
fa3be90f84
commit
e2590a7c19
@ -1356,12 +1356,14 @@ begin
|
||||
then begin
|
||||
if InfoEntry.IsAddressInStartScope(FAddress) and not InfoEntry.IsArtificial then begin
|
||||
Result := SymbolToValue(TFpSymbolDwarf.CreateSubClass(AName, InfoEntry));
|
||||
ApplyContext(Result);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
|
||||
InfoEntry.ScopeIndex := StartScopeIdx;
|
||||
Result := SymbolToValue(TFpSymbolDwarf.CreateSubClass(AName, InfoEntry));
|
||||
ApplyContext(Result);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -1369,15 +1371,19 @@ begin
|
||||
|
||||
tg := InfoEntry.AbbrevTag;
|
||||
if (tg = DW_TAG_class_type) or (tg = DW_TAG_structure_type) then begin
|
||||
if FindSymbolInStructure(AName,PNameUpper, PNameLower, InfoEntry, Result) then
|
||||
if FindSymbolInStructure(AName,PNameUpper, PNameLower, InfoEntry, Result) then begin
|
||||
ApplyContext(Result);
|
||||
exit; // TODO: check error
|
||||
end;
|
||||
//InfoEntry.ScopeIndex := StartScopeIdx;
|
||||
end
|
||||
|
||||
else
|
||||
if (StartScopeIdx = SubRoutine.InformationEntry.ScopeIndex) then begin // searching in subroutine
|
||||
if FindLocalSymbol(AName,PNameUpper, PNameLower, InfoEntry, Result) then
|
||||
if FindLocalSymbol(AName,PNameUpper, PNameLower, InfoEntry, Result) then begin
|
||||
ApplyContext(Result);
|
||||
exit; // TODO: check error
|
||||
end;
|
||||
//InfoEntry.ScopeIndex := StartScopeIdx;
|
||||
end
|
||||
// TODO: nested subroutine
|
||||
@ -1386,6 +1392,7 @@ begin
|
||||
if InfoEntry.GoNamedChildEx(PNameUpper, PNameLower) then begin
|
||||
if InfoEntry.IsAddressInStartScope(FAddress) and not InfoEntry.IsArtificial then begin
|
||||
Result := SymbolToValue(TFpSymbolDwarf.CreateSubClass(AName, InfoEntry));
|
||||
ApplyContext(Result);
|
||||
exit;
|
||||
end;
|
||||
end;
|
||||
@ -1696,6 +1703,9 @@ begin
|
||||
m := FDataSymbol.NestedSymbolByName[AIndex];
|
||||
if m <> nil then
|
||||
Result := m.Value;
|
||||
assert((Result = nil) or (Result is TFpValueDwarfBase), 'Result is TFpValueDwarfBase');
|
||||
if Result <> nil then
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end;
|
||||
SetLastMember(TFpValueDwarf(Result));
|
||||
end;
|
||||
@ -1709,6 +1719,9 @@ begin
|
||||
m := FDataSymbol.NestedSymbol[AIndex];
|
||||
if m <> nil then
|
||||
Result := m.Value;
|
||||
assert((Result = nil) or (Result is TFpValueDwarfBase), 'Result is TFpValueDwarfBase');
|
||||
if Result <> nil then
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end;
|
||||
SetLastMember(TFpValueDwarf(Result));
|
||||
end;
|
||||
@ -2199,8 +2212,11 @@ end;
|
||||
function TFpValueDwarfEnum.GetMember(AIndex: Int64): TFpValue;
|
||||
begin
|
||||
InitMemberIndex;
|
||||
if (FMemberIndex >= 0) and (AIndex = 0) then
|
||||
Result := FOwner.NestedSymbol[FMemberIndex].Value
|
||||
if (FMemberIndex >= 0) and (AIndex = 0) then begin
|
||||
Result := FOwner.NestedSymbol[FMemberIndex].Value;
|
||||
assert(Result is TFpValueDwarfBase, 'Result is TFpValueDwarfBase');
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end
|
||||
else
|
||||
Result := nil;
|
||||
end;
|
||||
@ -2360,6 +2376,8 @@ begin
|
||||
|
||||
if t.Kind = skEnum then begin
|
||||
Result := t.NestedSymbol[FMemberMap[AIndex]].Value;
|
||||
assert(Result is TFpValueDwarfBase, 'Result is TFpValueDwarfBase');
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end
|
||||
else begin
|
||||
if (FNumValue = nil) or (FNumValue.RefCount > 1) then begin // refcount 1 by FTypedNumValue
|
||||
@ -2375,7 +2393,9 @@ begin
|
||||
|
||||
if (FTypedNumValue = nil) or (FTypedNumValue.RefCount > 1) then begin
|
||||
FTypedNumValue.ReleaseReference;
|
||||
FTypedNumValue := t.TypeCastValue(FNumValue)
|
||||
FTypedNumValue := t.TypeCastValue(FNumValue);
|
||||
assert((FTypedNumValue is TFpValueDwarf), 'is TFpValueDwarf');
|
||||
TFpValueDwarf(FTypedNumValue).FContext := FContext;
|
||||
end
|
||||
else
|
||||
TFpValueDwarf(FTypedNumValue).SetTypeCastInfo(TFpSymbolDwarfType(t), FNumValue); // update
|
||||
@ -2595,6 +2615,8 @@ begin
|
||||
FMembers.Add(tmp);
|
||||
|
||||
Result := tmp.Value;
|
||||
assert(Result is TFpValueDwarfBase, 'Result is TFpValueDwarfBase');
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end;
|
||||
SetLastMember(TFpValueDwarf(Result));
|
||||
end;
|
||||
@ -2616,6 +2638,8 @@ begin
|
||||
FMembers.Add(tmp);
|
||||
|
||||
Result := tmp.Value;
|
||||
assert(Result is TFpValueDwarfBase, 'Result is TFpValueDwarfBase');
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end;
|
||||
SetLastMember(TFpValueDwarf(Result));
|
||||
end;
|
||||
@ -2992,6 +3016,7 @@ var
|
||||
RefSymbol: TFpSymbolDwarfData;
|
||||
InitLocParserData: TInitLocParserData;
|
||||
t: TFpDbgMemLocation;
|
||||
ValObj: TFpValue;
|
||||
begin
|
||||
Form := InformationEntry.AttribForm[AnAttribData.Idx];
|
||||
Result := False;
|
||||
@ -3021,7 +3046,10 @@ begin
|
||||
NewInfo.ReleaseReference;
|
||||
Result := RefSymbol <> nil;
|
||||
if Result then begin
|
||||
AValue := RefSymbol.Value.AsInteger;
|
||||
ValObj := RefSymbol.Value;
|
||||
assert(ValObj is TFpValueDwarfBase, 'Result is TFpValueDwarfBase');
|
||||
TFpValueDwarfBase(ValObj).Context := AValueObj.Context;
|
||||
AValue := ValObj.AsInteger;
|
||||
Result := not IsError(RefSymbol.LastError);
|
||||
// TODO: copy the error
|
||||
if ADataSymbol <> nil then
|
||||
|
||||
@ -414,6 +414,7 @@ begin
|
||||
if (Length(AName) = length(selfname)) and (CompareUtf8BothCase(PNameUpper, PNameLower, @selfname[1])) then begin
|
||||
ADbgValue := GetSelfParameter;
|
||||
if ADbgValue <> nil then begin
|
||||
ApplyContext(ADbgValue);
|
||||
AddRefToVal(ADbgValue);
|
||||
Result := True;
|
||||
exit;
|
||||
|
||||
@ -731,7 +731,7 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
|
||||
s := proc.Name;
|
||||
par := nil;
|
||||
if (proc is TFpSymbolDwarfDataProc) then
|
||||
par := TFpSymbolDwarfDataProc(proc).GetSelfParameter;
|
||||
par := TFpSymbolDwarfDataProc(proc).GetSelfParameter; // TODO: needs Context set ?
|
||||
if (par <> nil) and (par.TypeInfo <> nil) then
|
||||
s := par.TypeInfo.Name + '.' + s;
|
||||
APrintedValue := APrintedValue + ' = ' + s; // TODO: offset to startaddress
|
||||
|
||||
@ -29,8 +29,8 @@ unit FpPascalParser;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes, sysutils, math, DbgIntfBaseTypes, FpDbgInfo, FpdMemoryTools, FpErrorMessages,
|
||||
LazLoggerBase, LazClasses;
|
||||
Classes, sysutils, math, DbgIntfBaseTypes, FpDbgInfo, FpdMemoryTools,
|
||||
FpErrorMessages, FpDbgDwarf, LazLoggerBase, LazClasses;
|
||||
|
||||
type
|
||||
|
||||
@ -657,6 +657,8 @@ begin
|
||||
Tmp := TFpValueConstAddress.Create(addr);
|
||||
if ti <> nil then begin
|
||||
Result := ti.TypeCastValue(Tmp);
|
||||
if (Result <> nil) and (Result is TFpValueDwarfBase) then
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
Tmp.ReleaseReference;
|
||||
end
|
||||
else
|
||||
@ -726,6 +728,8 @@ end;
|
||||
function TFpPasParserValueMakeReftype.GetTypeCastedValue(ADataVal: TFpValue): TFpValue;
|
||||
begin
|
||||
Result := DbgSymbol.TypeCastValue(ADataVal);
|
||||
if (Result <> nil) and (Result is TFpValueDwarfBase) then
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
end;
|
||||
|
||||
|
||||
@ -918,6 +922,8 @@ begin
|
||||
Tmp := TFpValueConstAddress.Create(addr);
|
||||
if ti <> nil then begin
|
||||
Result := ti.TypeCastValue(Tmp);
|
||||
if (Result <> nil) and (Result is TFpValueDwarfBase) then
|
||||
TFpValueDwarfBase(Result).Context := Context;
|
||||
Tmp.ReleaseReference;
|
||||
end
|
||||
else
|
||||
|
||||
Loading…
Reference in New Issue
Block a user