FP Debugger: fix range checks / do not use arbitrary large static arrays (gdb dislikes the debuginfo)

git-svn-id: trunk@58399 -
This commit is contained in:
martin 2018-06-24 22:56:20 +00:00
parent d1d1d58a04
commit 23d5c0bdc7

View File

@ -55,8 +55,7 @@ uses
FpDbgLoader; FpDbgLoader;
type type
PnlistArray = ^TnlistArray; PnlistArray = ^nlist; // ^array[0..infinite] of nlist;
TnlistArray = array[0..maxSmallint] of nlist;
const const
// Symbol-map section name // Symbol-map section name
@ -198,13 +197,13 @@ begin
SymbolCount := PDbgImageSectionEx(p)^.Sect.Size div sizeof(nlist); SymbolCount := PDbgImageSectionEx(p)^.Sect.Size div sizeof(nlist);
for i := 0 to SymbolCount-1 do for i := 0 to SymbolCount-1 do
begin begin
if (SymbolArr^[i].n_type and $e0)<>0 then if (SymbolArr[i].n_type and $e0)<>0 then
// This is a stabs-entry. Ignore. // This is a stabs-entry. Ignore.
Continue; Continue;
if (SymbolArr^[i].n_type and $0e)=$e then if (SymbolArr[i].n_type and $0e)=$e then
begin begin
// Section-index is ignored for now... // Section-index is ignored for now...
AfpSymbolInfo.AddObject(pchar(SymbolStr+SymbolArr^[i].n_un.n_strx), TObject(PtrUInt(SymbolArr^[i].n_value))); AfpSymbolInfo.AddObject(pchar(SymbolStr+SymbolArr[i].n_un.n_strx), TObject(PtrUInt(SymbolArr[i].n_value)));
end end
end; end;
end; end;
@ -583,20 +582,20 @@ begin
case state of case state of
dtsEnd: dtsEnd:
begin begin
if SymbolArr^[i].n_type = N_SO then if SymbolArr[i].n_type = N_SO then
begin begin
if assigned(DwarfDebugMap) then if assigned(DwarfDebugMap) then
DwarfDebugMap.Free; DwarfDebugMap.Free;
DwarfDebugMap := TAppleDwarfDebugMap.Create; DwarfDebugMap := TAppleDwarfDebugMap.Create;
DwarfDebugMap.Dir := pchar(SymbolStr+SymbolArr^[i].n_un.n_strx); DwarfDebugMap.Dir := pchar(SymbolStr+SymbolArr[i].n_un.n_strx);
state := dtsDir; state := dtsDir;
end; end;
end; end;
dtsDir: dtsDir:
begin begin
if SymbolArr^[i].n_type = N_SO then if SymbolArr[i].n_type = N_SO then
begin begin
DwarfDebugMap.SourceFile:=pchar(SymbolStr+SymbolArr^[i].n_un.n_strx); DwarfDebugMap.SourceFile:=pchar(SymbolStr+SymbolArr[i].n_un.n_strx);
inc(state); inc(state);
end end
else else
@ -604,27 +603,27 @@ begin
end; end;
dtsSource: dtsSource:
begin begin
if SymbolArr^[i].n_type = N_OSO then if SymbolArr[i].n_type = N_OSO then
begin begin
DwarfDebugMap.ObjectFile:=pchar(SymbolStr+SymbolArr^[i].n_un.n_strx); DwarfDebugMap.ObjectFile:=pchar(SymbolStr+SymbolArr[i].n_un.n_strx);
DwarfDebugMap.ObjFileAge:=SymbolArr^[i].n_value; DwarfDebugMap.ObjFileAge:=SymbolArr[i].n_value;
inc(state); inc(state);
end; end;
end; end;
dtsObjectFile: dtsObjectFile:
begin begin
if (SymbolArr^[i].n_type = N_BNSYM) then if (SymbolArr[i].n_type = N_BNSYM) then
begin begin
inc(state); inc(state);
end end
else if (SymbolArr^[i].n_type = N_STSYM) then else if (SymbolArr[i].n_type = N_STSYM) then
begin begin
AddressMap.NewAddr:=SymbolArr^[i].n_value; AddressMap.NewAddr:=SymbolArr[i].n_value;
AddressMap.OrgAddr:=0; AddressMap.OrgAddr:=0;
AddressMap.Length:=0; AddressMap.Length:=0;
DwarfDebugMap.GlobalList.Add(pchar(SymbolStr+SymbolArr^[i].n_un.n_strx), AddressMap); DwarfDebugMap.GlobalList.Add(pchar(SymbolStr+SymbolArr[i].n_un.n_strx), AddressMap);
end end
else if (SymbolArr^[i].n_type = N_SO) and (SymbolArr^[i].n_sect=1) then else if (SymbolArr[i].n_type = N_SO) and (SymbolArr[i].n_sect=1) then
begin begin
state := dtsEnd; state := dtsEnd;
SubFiles.AddObject(DwarfDebugMap.ObjectFile, DwarfDebugMap); SubFiles.AddObject(DwarfDebugMap.ObjectFile, DwarfDebugMap);
@ -633,24 +632,24 @@ begin
end; end;
dtsProc: dtsProc:
begin begin
if (SymbolArr^[i].n_type = N_FUN) and (SymbolArr^[i].n_sect=1) then if (SymbolArr[i].n_type = N_FUN) and (SymbolArr[i].n_sect=1) then
begin begin
AddressMap.NewAddr:=SymbolArr^[i].n_value; AddressMap.NewAddr:=SymbolArr[i].n_value;
ProcName:=pchar(SymbolStr+SymbolArr^[i].n_un.n_strx); ProcName:=pchar(SymbolStr+SymbolArr[i].n_un.n_strx);
inc(state); inc(state);
end; end;
end; end;
dtsProcLen: dtsProcLen:
begin begin
if (SymbolArr^[i].n_type = N_FUN) and (SymbolArr^[i].n_sect=0) then if (SymbolArr[i].n_type = N_FUN) and (SymbolArr[i].n_sect=0) then
begin begin
AddressMap.Length:=SymbolArr^[i].n_value; AddressMap.Length:=SymbolArr[i].n_value;
inc(state); inc(state);
end; end;
end; end;
dtsProcEnd: dtsProcEnd:
begin begin
if (SymbolArr^[i].n_type = N_ENSYM) and (SymbolArr^[i].n_sect=1) then if (SymbolArr[i].n_type = N_ENSYM) and (SymbolArr[i].n_sect=1) then
begin begin
DwarfDebugMap.GlobalList.Add(ProcName, AddressMap); DwarfDebugMap.GlobalList.Add(ProcName, AddressMap);
state := dtsObjectFile; state := dtsObjectFile;
@ -684,25 +683,25 @@ begin
SymbolCount := PDbgImageSectionEx(p)^.Sect.Size div sizeof(nlist); SymbolCount := PDbgImageSectionEx(p)^.Sect.Size div sizeof(nlist);
for i := 0 to SymbolCount-1 do for i := 0 to SymbolCount-1 do
begin begin
if SymbolArr^[i].n_type = N_SECT then if SymbolArr[i].n_type = N_SECT then
begin begin
s := pchar(SymbolStr+SymbolArr^[i].n_un.n_strx); s := pchar(SymbolStr+SymbolArr[i].n_un.n_strx);
ind := MainDwarfDebugMap.GlobalList.Find(s); ind := MainDwarfDebugMap.GlobalList.Find(s);
if assigned(ind) then if assigned(ind) then
begin begin
AddressMap:=MainDwarfDebugMap.GlobalList.Items[s]; AddressMap:=MainDwarfDebugMap.GlobalList.Items[s];
AddressMap.OrgAddr:=SymbolArr^[i].n_value; AddressMap.OrgAddr:=SymbolArr[i].n_value;
AddressMapList.Add(AddressMap); AddressMapList.Add(AddressMap);
end; end;
end; end;
if SymbolArr^[i].n_type = N_SECT+N_EXT then if SymbolArr[i].n_type = N_SECT+N_EXT then
begin begin
s := pchar(SymbolStr+SymbolArr^[i].n_un.n_strx); s := pchar(SymbolStr+SymbolArr[i].n_un.n_strx);
ind := MainDwarfDebugMap.GlobalList.Find(s); ind := MainDwarfDebugMap.GlobalList.Find(s);
if assigned(ind) then if assigned(ind) then
begin begin
AddressMap:=MainDwarfDebugMap.GlobalList.Items[s]; AddressMap:=MainDwarfDebugMap.GlobalList.Items[s];
AddressMap.OrgAddr:=SymbolArr^[i].n_value; AddressMap.OrgAddr:=SymbolArr[i].n_value;
AddressMapList.Add(AddressMap); AddressMapList.Add(AddressMap);
end; end;
end; end;