2
0
Эх сурвалжийг харах

+ added more dwarf sections

git-svn-id: trunk@2318 -
florian 19 жил өмнө
parent
commit
aa176601fb

+ 10 - 4
compiler/aasmbase.pas

@@ -48,9 +48,12 @@ interface
 
        TAsmSectionType=(sec_none,
          sec_code,sec_data,sec_rodata,sec_bss,sec_threadvar,
-         sec_common, { used for executable creation }
-         sec_custom, { custom section, no prefix }
-         sec_stub,   { used for darwin import stubs }
+         { used for executable creation }
+         sec_common,
+         { custom section, no prefix }
+         sec_custom,
+         { used for darwin import stubs }
+         sec_stub,
          { stabs }
          sec_stab,sec_stabstr,
          { win32 }
@@ -59,6 +62,9 @@ interface
          sec_eh_frame,
          { dwarf }
          sec_debug_frame,
+         sec_debug_info,
+         sec_debug_line,
+         sec_debug_abrev,
          { ELF resources }
          sec_fpc,
          { Table of contents section }
@@ -589,7 +595,7 @@ implementation
           'stab','stabstr',
           'idata2','idata4','idata5','idata6','idata7','edata',
           'eh_frame',
-          'debug_frame',
+          'debug_frame','debug_info','debug_line','debug_abrev',
           'fpc',
           'toc'
         );

+ 2 - 2
compiler/aggas.pas

@@ -212,7 +212,7 @@ implementation
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame',
+          '.debug_frame','.debug_info','.debug_line','.debug_abrev',
           'fpc.resptrs',
           '.toc'
         );
@@ -224,7 +224,7 @@ implementation
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame',
+          '.debug_frame','.debug_info','.debug_line','.debug_abrev',
           'fpc.resptrs',
           '.toc'
         );

+ 77 - 0
compiler/dbgdwarf.pas

@@ -26,10 +26,12 @@ unit dbgdwarf;
 interface
 
     uses
+      aasmtai,
       DbgBase;
 
     type
       TDebugInfoDwarf=class(TDebugInfo)
+        procedure insertlineinfo(list:taasmoutput);override;
       end;
 
 implementation
@@ -44,6 +46,81 @@ implementation
            idtxt  : 'DWARF';
          );
 
+    procedure tdebuginfodwarf.insertlineinfo(list:taasmoutput);
+      begin
+      end;
+      {
+      var
+        currfileinfo,
+        lastfileinfo : tfileposinfo;
+        currfuncname : pstring;
+        currsectype  : tasmsectiontype;
+        hlabel       : tasmlabel;
+        hp : tai;
+        infile : tinputfile;
+      begin
+        FillChar(lastfileinfo,sizeof(lastfileinfo),0);
+        currfuncname:=nil;
+        currsectype:=sec_code;
+        hp:=Tai(list.first);
+        while assigned(hp) do
+          begin
+            case hp.typ of
+              ait_section :
+                currsectype:=tai_section(hp).sectype;
+              ait_function_name :
+                currfuncname:=tai_function_name(hp).funcname;
+              ait_force_line :
+                lastfileinfo.line:=-1;
+            end;
+
+            if (currsectype=sec_code) and
+               (hp.typ=ait_instruction) then
+              begin
+                currfileinfo:=tailineinfo(hp).fileinfo;
+                { file changed ? (must be before line info) }
+                if (currfileinfo.fileindex<>0) and
+                   (lastfileinfo.fileindex<>currfileinfo.fileindex) then
+                  begin
+                    infile:=current_module.sourcefiles.get_file(currfileinfo.fileindex);
+                    if assigned(infile) then
+                      begin
+                        objectlibrary.getlabel(hlabel,alt_dbgfile);
+                        { emit stabs }
+                        if (infile.path^<>'') then
+                          list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+BsToSlash(FixPath(infile.path^,false))+'",'+tostr(n_includefile)+
+                                            ',0,0,'+hlabel.name),hp);
+                        list.insertbefore(Tai_stab.Create_str(stab_stabs,'"'+FixFileName(infile.name^)+'",'+tostr(n_includefile)+
+                                          ',0,0,'+hlabel.name),hp);
+                        list.insertbefore(tai_label.create(hlabel),hp);
+                        { force new line info }
+                        lastfileinfo.line:=-1;
+                      end;
+                  end;
+
+                { line changed ? }
+                if (lastfileinfo.line<>currfileinfo.line) and (currfileinfo.line<>0) then
+                  begin
+                     if assigned(currfuncname) and
+                        (tf_use_function_relative_addresses in target_info.flags) then
+                      begin
+                        objectlibrary.getlabel(hlabel,alt_dbgline);
+                        list.insertbefore(Tai_stab.Create_str(stab_stabn,tostr(n_textline)+',0,'+tostr(currfileinfo.line)+','+
+                                          hlabel.name+' - '+{$IFDEF POWERPC64}'.'+{$ENDIF POWERPC64}currfuncname^),hp);
+                        list.insertbefore(tai_label.create(hlabel),hp);
+                      end
+                     else
+                      list.insertbefore(Tai_stab.Create_str(stab_stabd,tostr(n_textline)+',0,'+tostr(currfileinfo.line)),hp);
+                  end;
+                lastfileinfo:=currfileinfo;
+              end;
+
+            hp:=tai(hp.next);
+          end;
+      end;
+    }
+
+
 initialization
   RegisterDebugInfo(dbg_dwarf_info,TDebugInfoDwarf);
 end.

+ 20 - 0
compiler/dwarf.pas

@@ -117,6 +117,26 @@ implementation
       DW_CFA_start_frame = $f0;
       DW_CFA_end_frame   = $f1;
 
+      DW_LNS_copy            = $01;
+      DW_LNS_advance_pc      = $02;
+      DW_LNS_advance_line    = $03;
+      DW_LNS_set_file        = $04;
+      DW_LNS_set_column      = $05;
+      DW_LNS_negate_stmt     = $06;
+      DW_LNS_set_basic_block = $07;
+      DW_LNS_const_add_pc    = $08;
+
+      DW_LNS_fixed_advance_pc   = $09;
+      DW_LNS_set_prologue_end   = $0a;
+      DW_LNS_set_epilogue_begin = $0b;
+      DW_LNS_set_isa            = $0c;
+
+      DW_LNE_end_sequence = $01;
+      DW_LNE_set_address  = $02;
+      DW_LNE_define_file  = $03;
+      DW_LNE_lo_user      = $80;
+      DW_LNE_hi_user      = $ff;
+
 
 {****************************************************************************
                                   Helpers

+ 2 - 2
compiler/i386/ag386nsm.pas

@@ -362,9 +362,9 @@ interface
           '.stab','.stabstr',
           '.idata2','.idata4','.idata5','.idata6','.idata7','.edata',
           '.eh_frame',
-          '.debug_frame',
+          '.debug_frame','.debug_info','.debug_line','.debug_abrev',
           '.fpc',
-		  ''
+          ''
         );
       begin
         AsmLn;

+ 1 - 1
compiler/ogcoff.pas

@@ -560,7 +560,7 @@ const go32v2stub : array[0..2047] of byte=(
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame',
+          '.debug_frame','.debug_info','.debug_line','.debug_abrev',
           '.fpc',
 		  ''
         );

+ 1 - 1
compiler/ogelf.pas

@@ -355,7 +355,7 @@ implementation
           '.stab','.stabstr',
           '.idata$2','.idata$4','.idata$5','.idata$6','.idata$7','.edata',
           '.eh_frame',
-          '.debug_frame',
+          '.debug_frame','.debug_info','.debug_line','.debug_abrev',
           'fpc',
 		  ''
         );

+ 9 - 3
compiler/x86/agx86int.pas

@@ -61,15 +61,21 @@ implementation
       secnames : array[TAsmSectionType] of string[4] = ('',
         'CODE','DATA','DATA','BSS','',
         '','','','','','','',
-        '','','','','','','',
-		''
+        '','','','',
+        '',
+        '','','','',
+        '',
+	''
       );
 
       secnamesml64 : array[TAsmSectionType] of string[7] = ('',
         '_TEXT','_DATE','_DATA','_BSS','',
         '','','','','',
         'idata$2','idata$4','idata$5','idata$6','idata$7','edata',
-        '','','',''
+        '',
+        '','','','',
+        '',
+        ''
       );
 
     function single2str(d : single) : string;