Skip to content

Commit

Permalink
try to fix Dwarf reader for big projects
Browse files Browse the repository at this point in the history
as reported by #117
  • Loading branch information
Arnaud Bouchez committed Sep 13, 2022
1 parent 29ef1f0 commit c21ee77
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
13 changes: 6 additions & 7 deletions src/core/mormot.core.log.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,7 @@ TDwarfDebugAbbrev = record
Abbrev: array of TDwarfDebugAbbrev; // debug_abbrev content
Lines: TInt64DynArray; // store TDebugUnit.Addr[]/Line[]
dirs, files: TRawUtf8DynArray;
filesdir: TIntegerDynArray;
isdwarf64, debugtoconsole: boolean;
debug: TDebugFile;
map: TMemoryMap;
Expand Down Expand Up @@ -2317,15 +2318,14 @@ function TDwarfReader.ParseCompilationUnits(file_offset, file_size: QWord): QWor
prevaddr, prevfile, prevline: cardinal;
unitlen: QWord;
opcodeextlen, headerlen: PtrInt;
dirsn, filesn, linesn: integer;
dirsn, filedirsn, filesn, linesn: integer;
state: TDwarfMachineState;
c: ansichar;
unsorted: boolean;
header64: TDwarfLineInfoHeader64;
header32: TDwarfLineInfoHeader32;
u: PDebugUnit;
s: ShortString;
filesdir: array[0..15] of byte;
numoptable: array[1..255] of byte;
begin
// check if DWARF 32-bit or 64-bit format
Expand Down Expand Up @@ -2379,14 +2379,14 @@ function TDwarfReader.ParseCompilationUnits(file_offset, file_size: QWord): QWor
AddRawUtf8(dirs, dirsn, ShortStringToUtf8(s));
until false;
filesn := 0;
filedirsn := 0;
repeat
ReadString(s);
if s[0] = #0 then
break;
if filesn <= high(filesdir) then
filesdir[filesn] := read.VarUInt32;
read.VarNextInt(2); // we ignore the attributes
AddRawUtf8(files, filesn, ShortStringToUtf8(s));
AddInteger(filesdir, filedirsn, read.VarUInt32);
read.VarNextInt(2); // we ignore the attributes
until false;
// main decoding loop
ReadInit(file_offset + headerlen, unitlen - headerlen);
Expand Down Expand Up @@ -2499,8 +2499,7 @@ function TDwarfReader.ParseCompilationUnits(file_offset, file_size: QWord): QWor
u := debug.fUnits.NewPtr;
u^.Symbol.Name := StringToAnsi7(GetFileNameWithoutExt(
Ansi7ToString(files[prevfile])));
if (prevfile <= high(filesdir)) and
({%H-}filesdir[prevfile] > 0) then
if filesdir[prevfile] > 0 then
u^.FileName := dirs[filesdir[prevfile] - 1];
u^.FileName := u^.FileName + files[prevfile];
u^.Symbol.Start := state.address;
Expand Down
2 changes: 1 addition & 1 deletion src/mormot.commit.inc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
'2.0.4078'
'2.0.4079'

0 comments on commit c21ee77

Please sign in to comment.