Browse Source

+ generate .debug_aranges sections for dwarf debug info: enables faster address to debug info translation

git-svn-id: trunk@33454 -
florian 9 years ago
parent
commit
90b284e169

+ 2 - 0
compiler/aasmbase.pas

@@ -103,6 +103,8 @@ interface
          sec_debug_info,
          sec_debug_line,
          sec_debug_abbrev,
+         sec_debug_aranges,
+         sec_debug_ranges,
          { Yury: "sec_fpc is intended for storing fpc specific data
                   which must be recognized and processed specially by linker.
                   Currently fpc version string, dummy links to stab sections

+ 4 - 0
compiler/aasmdata.pas

@@ -62,6 +62,8 @@ interface
         al_dwarf_info,
         al_dwarf_abbrev,
         al_dwarf_line,
+        al_dwarf_aranges,
+        al_dwarf_ranges,
         al_picdata,
         al_indirectpicdata,
         al_resourcestrings,
@@ -114,6 +116,8 @@ interface
         'al_dwarf_info',
         'al_dwarf_abbrev',
         'al_dwarf_line',
+        'al_dwarf_aranges',
+        'al_dwarf_ranges',
         'al_picdata',
         'al_indirectpicdata',
         'al_resourcestrings',

+ 15 - 3
compiler/aggas.pas

@@ -232,7 +232,7 @@ implementation
           '.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
+          '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
           '.fpc',
           '.toc',
           '.init',
@@ -291,7 +291,7 @@ implementation
           '.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
+          '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
           '.fpc',
           '.toc',
           '.init',
@@ -416,7 +416,7 @@ implementation
             result:='r';
 
           sec_stab,sec_stabstr,
-          sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev:
+          sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges:
             result:='n';
         else
           result:='';  { defaults to data+load }
@@ -1631,6 +1631,16 @@ implementation
                  result := '.section __DWARF,__debug_abbrev,regular,debug';
                  exit;
                end;
+            sec_debug_aranges:
+               begin
+                 result := '.section __DWARF,__debug_aranges,regular,debug';
+                 exit;
+               end;
+            sec_debug_ranges:
+               begin
+                 result := '.section __DWARF,__debug_ranges,regular,debug';
+                 exit;
+               end;
             sec_rodata:
               begin
                 result := '.const_data';
@@ -1744,6 +1754,8 @@ implementation
          sec_debug_info,
          sec_debug_line,
          sec_debug_abbrev,
+         sec_debug_aranges,
+         sec_debug_ranges,
          { ELF resources (+ references to stabs debug information sections) }
          sec_code (* sec_fpc *),
          { Table of contents section }

+ 41 - 1
compiler/dbgdwarf.pas

@@ -2231,6 +2231,11 @@ implementation
 
             append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(procentry));
             append_labelentry(DW_AT_high_pc,procendlabel);
+
+            current_asmdata.asmlists[al_dwarf_aranges].Concat(
+              tai_const.create_type_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry)));
+            current_asmdata.asmlists[al_dwarf_aranges].Concat(
+              tai_const.Create_rel_sym(aitconst_ptr_unaligned,current_asmdata.RefAsmSymbol(procentry),procendlabel));
           end;
 
         { Don't write the funcretsym explicitly, it's also in the
@@ -3152,7 +3157,7 @@ implementation
 
       var
         storefilepos  : tfileposinfo;
-        lenstartlabel : tasmlabel;
+        lenstartlabel,arangestartlabel: tasmlabel;
         i : longint;
         def: tdef;
         dbgname: string;
@@ -3192,6 +3197,36 @@ implementation
         { start abbrev section }
         new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0);
 
+        { start aranges section }
+        new_section(current_asmdata.asmlists[al_dwarf_aranges],sec_debug_aranges,'',0);
+
+        current_asmdata.getlabel(arangestartlabel,alt_dbgfile);
+
+        if use_64bit_headers then
+          current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_32bit_unaligned(longint($FFFFFFFF)));
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
+          arangestartlabel,current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'earanges0',AB_LOCAL,AT_DATA)));
+
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_label.create(arangestartlabel));
+
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_16bit_unaligned(2));
+
+        if not(tf_dwarf_relative_addresses in target_info.flags) then
+          current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_type_sym(offsetabstype,
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_DATA)))
+        else
+          current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_rel_sym(offsetreltype,
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_infosection0',AB_LOCAL,AT_DATA),
+            current_asmdata.DefineAsmSymbol(target_asm.labelprefix+'debug_info0',AB_LOCAL,AT_DATA)));
+
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(sizeof(pint)));
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_8bit(0));
+        { alignment }
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.create_32bit_unaligned(0));
+
+        { start ranges section }
+        new_section(current_asmdata.asmlists[al_dwarf_ranges],sec_debug_ranges,'',0);
+
         { debug info header }
         current_asmdata.getlabel(lenstartlabel,alt_dbgfile);
         { size }
@@ -3286,6 +3321,11 @@ implementation
         { end of abbrev table }
         current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0));
 
+        { end of aranges table }
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_const.Create_aint(0));
+        current_asmdata.asmlists[al_dwarf_aranges].concat(tai_symbol.createname(target_asm.labelprefix+'earanges0',AT_DATA,0));
+
         { reset all def debug states }
         for i:=0 to defnumberlist.count-1 do
           begin

+ 3 - 1
compiler/ogbase.pas

@@ -1169,6 +1169,8 @@ implementation
           {debug_info} [oso_Data,oso_debug],
           {debug_line} [oso_Data,oso_debug],
           {debug_abbrev} [oso_Data,oso_debug],
+          {debug_aranges} [oso_Data,oso_debug],
+          {debug_ranges} [oso_Data,oso_debug],
           {fpc} [oso_Data,oso_load,oso_write],
           {toc} [oso_Data,oso_load],
           {init} [oso_Data,oso_load,oso_executable],
@@ -1218,7 +1220,7 @@ implementation
     function TObjData.sectiontype2align(atype:TAsmSectiontype):shortint;
       begin
         case atype of
-          sec_stabstr,sec_debug_info,sec_debug_line,sec_debug_abbrev:
+          sec_stabstr,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges:
             result:=1;
           sec_code,
           sec_bss,

+ 1 - 1
compiler/ogcoff.pas

@@ -507,7 +507,7 @@ implementation
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
+          '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
           '.fpc',
           '',
           '.init',

+ 1 - 1
compiler/ogelf.pas

@@ -759,7 +759,7 @@ implementation
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
+          '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
           '.fpc',
           '.toc',
           '.init',

+ 5 - 3
compiler/ogmacho.pas

@@ -180,8 +180,8 @@ uses
 
   function TmachoObjData.sectionname(atype: TAsmSectiontype; const aname: string; aorder: TAsmSectionOrder): string;
     const
-      DwarfSect : array [sec_debug_frame..sec_debug_abbrev] of string
-        = ('sec_debug_frame','__debug_info','__debug_line','__debug_abbrev');
+      DwarfSect : array [sec_debug_frame..sec_debug_ranges] of string
+        = ('sec_debug_frame','__debug_info','__debug_line','__debug_abbrev','__debug_aranges','__debug_ranges');
     begin
       case atype of
         sec_user: Result:=aname;
@@ -243,7 +243,9 @@ uses
         sec_debug_frame,
         sec_debug_info,
         sec_debug_line,
-        sec_debug_abbrev:
+        sec_debug_abbrev,
+        sec_debug_aranges,
+        sec_debug_ranges:
           Result:=MakeSectionName(seg_DWARF, DwarfSect[atype])
 
       else

+ 1 - 1
compiler/ogomf.pas

@@ -549,7 +549,7 @@ implementation
         TOmfObjSection(Result).FClassName:=sectiontype2class(atype);
         if atype=sec_stack then
           TOmfObjSection(Result).FCombination:=scStack
-        else if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev] then
+        else if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges] then
           TOmfObjSection(Result).FUse:=suUse32;
         if section_belongs_to_dgroup(atype) then
           TOmfObjSection(Result).FPrimaryGroup:='DGROUP';

+ 4 - 2
compiler/omfbase.pas

@@ -46,7 +46,7 @@ interface
       'stabstr',
       'idata2','idata4','idata5','idata6','idata7','edata',
       'eh_frame',
-      'debug_frame','debug_info','debug_line','debug_abbrev',
+      'debug_frame','debug_info','debug_line','debug_abbrev','debug_aranges','debug_ranges',
       'fpc',
       '',
       'init',
@@ -2250,6 +2250,8 @@ implementation
         {debug_info} 'DWARF',
         {debug_line} 'DWARF',
         {debug_abbrev} 'DWARF',
+        {debug_aranges} 'DWARF',
+        {debug_ranges} 'DWARF',
         {fpc} 'DATA',
         {toc} 'DATA',
         {init} 'CODE',
@@ -2320,7 +2322,7 @@ implementation
           be packed without gaps. }
         sec_idata2,sec_idata4,sec_idata5,sec_idata6,sec_idata7,sec_pdata:
           result:=4;
-        sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev:
+        sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges:
           result:=4;
         sec_stack,
         sec_heap:

+ 2 - 2
compiler/x86/agx86int.pas

@@ -68,7 +68,7 @@ implementation
         '',
         '',
         '',
-        '','','','',
+        '','','','','','',
         '',
         '',
         '',
@@ -120,7 +120,7 @@ implementation
         '',
         '',
         '',
-        '','','','',
+        '','','','','','',
         '',
         '',
         '',

+ 2 - 2
compiler/x86/agx86nsm.pas

@@ -523,7 +523,7 @@ interface
           '.stabstr',
           '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
           '.eh_frame',
-          '.debug_frame','.debug_info','.debug_line','.debug_abbrev',
+          '.debug_frame','.debug_info','.debug_line','.debug_abbrev','.debug_aranges','.debug_ranges',
           '.fpc',
           '',
           '.init',
@@ -596,7 +596,7 @@ interface
                 { yes -> write the section attributes as well }
                 if atype=sec_stack then
                   writer.AsmWrite(' stack');
-                if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev] then
+                if atype in [sec_debug_frame,sec_debug_info,sec_debug_line,sec_debug_abbrev,sec_debug_aranges,sec_debug_ranges] then
                   writer.AsmWrite(' use32')
                 else
                   writer.AsmWrite(' use16');