Browse Source

+ pass a segment (0 on non-i8086) to all ParseCompilationUnit* functions in unit
lnfodwrf

git-svn-id: trunk@39063 -

nickysn 7 years ago
parent
commit
875330d84f
1 changed files with 23 additions and 7 deletions
  1. 23 7
      rtl/inc/lnfodwrf.pp

+ 23 - 7
rtl/inc/lnfodwrf.pp

@@ -67,6 +67,12 @@ uses
 { some type definitions }
 { some type definitions }
 type
 type
   Bool8 = ByteBool;
   Bool8 = ByteBool;
+{$ifdef CPUI8086}
+  TOffset = Word;
+{$else CPUI8086}
+  TOffset = PtrUInt;
+{$endif CPUI8086}
+  TSegment = Word;
 
 
 const
 const
   EBUF_SIZE = 100;
   EBUF_SIZE = 100;
@@ -654,7 +660,7 @@ begin
 end;
 end;
 
 
 
 
-function ParseCompilationUnit(const addr : PtrUInt; const file_offset : QWord;
+function ParseCompilationUnit(const addr : TOffset; const segment : TSegment; const file_offset : QWord;
   var source : String; var line : longint; var found : Boolean) : QWord;
   var source : String; var line : longint; var found : Boolean) : QWord;
 var
 var
   state : TMachineState;
   state : TMachineState;
@@ -968,7 +974,7 @@ procedure ReadAbbrevTable;
   end;
   end;
 
 
 
 
-function ParseCompilationUnitForDebugInfoOffset(const addr : PtrUInt; const file_offset : QWord;
+function ParseCompilationUnitForDebugInfoOffset(const addr : TOffset; const segment : TSegment; const file_offset : QWord;
   var debug_info_offset : QWord; var found : Boolean) : QWord;
   var debug_info_offset : QWord; var found : Boolean) : QWord;
 var
 var
   { we need both headers on the stack, although we only use the 64 bit one internally }
   { we need both headers on the stack, although we only use the 64 bit one internally }
@@ -1041,7 +1047,7 @@ begin
     end;
     end;
 end;
 end;
 
 
-function ParseCompilationUnitForFunctionName(const addr : PtrUInt; const file_offset : QWord;
+function ParseCompilationUnitForFunctionName(const addr : TOffset; const segment : TSegment; const file_offset : QWord;
   var func : String; var found : Boolean) : QWord;
   var func : String; var found : Boolean) : QWord;
 var
 var
   { we need both headers on the stack, although we only use the 64 bit one internally }
   { we need both headers on the stack, although we only use the 64 bit one internally }
@@ -1264,6 +1270,7 @@ function GetLineInfo(addr : codeptruint; var func, source : string; var line : l
 var
 var
   current_offset,
   current_offset,
   end_offset, debug_info_offset_from_aranges : QWord;
   end_offset, debug_info_offset_from_aranges : QWord;
+  segment : Word = 0;
 
 
   found, found_aranges : Boolean;
   found, found_aranges : Boolean;
 
 
@@ -1272,6 +1279,15 @@ begin
   source := '';
   source := '';
   GetLineInfo:=false;
   GetLineInfo:=false;
 
 
+{$ifdef CPUI8086}
+  {$if defined(FPC_MM_MEDIUM) or defined(FPC_MM_LARGE) or defined(FPC_MM_HUGE)}
+    segment := addr shr 16;
+    addr := Word(addr);
+  {$else}
+    segment := CSeg;
+  {$endif}
+{$endif CPUI8086}
+
   if not OpenDwarf(codepointer(addr)) then
   if not OpenDwarf(codepointer(addr)) then
     exit;
     exit;
 
 
@@ -1283,7 +1299,7 @@ begin
   found := false;
   found := false;
   while (current_offset < end_offset) and (not found) do begin
   while (current_offset < end_offset) and (not found) do begin
     Init(current_offset, end_offset - current_offset);
     Init(current_offset, end_offset - current_offset);
-    current_offset := ParseCompilationUnit(addr, current_offset,
+    current_offset := ParseCompilationUnit(addr, segment, current_offset,
       source, line, found);
       source, line, found);
   end;
   end;
 
 
@@ -1293,7 +1309,7 @@ begin
   found_aranges := false;
   found_aranges := false;
   while (current_offset < end_offset) and (not found_aranges) do begin
   while (current_offset < end_offset) and (not found_aranges) do begin
     Init(current_offset, end_offset - current_offset);
     Init(current_offset, end_offset - current_offset);
-    current_offset := ParseCompilationUnitForDebugInfoOffset(addr, current_offset, debug_info_offset_from_aranges, found_aranges);
+    current_offset := ParseCompilationUnitForDebugInfoOffset(addr, segment, current_offset, debug_info_offset_from_aranges, found_aranges);
   end;
   end;
 
 
   { no function name found yet }
   { no function name found yet }
@@ -1308,7 +1324,7 @@ begin
       DEBUG_WRITELN('Reading .debug_info at section offset $',hexStr(current_offset-Dwarf_Debug_Info_Section_Offset,16));
       DEBUG_WRITELN('Reading .debug_info at section offset $',hexStr(current_offset-Dwarf_Debug_Info_Section_Offset,16));
 
 
       Init(current_offset, end_offset - current_offset);
       Init(current_offset, end_offset - current_offset);
-      current_offset := ParseCompilationUnitForFunctionName(addr, current_offset, func, found);
+      current_offset := ParseCompilationUnitForFunctionName(addr, segment, current_offset, func, found);
       if found then
       if found then
         DEBUG_WRITELN('Found .debug_info entry by using .debug_aranges information');
         DEBUG_WRITELN('Found .debug_info entry by using .debug_aranges information');
     end
     end
@@ -1322,7 +1338,7 @@ begin
     DEBUG_WRITELN('Reading .debug_info at section offset $',hexStr(current_offset-Dwarf_Debug_Info_Section_Offset,16));
     DEBUG_WRITELN('Reading .debug_info at section offset $',hexStr(current_offset-Dwarf_Debug_Info_Section_Offset,16));
 
 
     Init(current_offset, end_offset - current_offset);
     Init(current_offset, end_offset - current_offset);
-    current_offset := ParseCompilationUnitForFunctionName(addr, current_offset, func, found);
+    current_offset := ParseCompilationUnitForFunctionName(addr, segment, current_offset, func, found);
   end;
   end;
 
 
   if not AllowReuseOfLineInfoData then
   if not AllowReuseOfLineInfoData then