Browse Source

+ introduce asd_omf_linnum_line directives; they will be used for writing LINNUM
entries in the OMF object format

git-svn-id: trunk@39007 -

nickysn 7 năm trước cách đây
mục cha
commit
61e6d2afec

+ 6 - 2
compiler/aasmtai.pas

@@ -357,7 +357,9 @@ interface
           available on the specified CPU; this represents directives such as
           available on the specified CPU; this represents directives such as
           NASM's 'CPU 686' or MASM/TASM's '.686p'. Might not be supported by
           NASM's 'CPU 686' or MASM/TASM's '.686p'. Might not be supported by
           all assemblers. }
           all assemblers. }
-        asd_cpu
+        asd_cpu,
+        { for the OMF object format }
+        asd_omf_linnum_line
       );
       );
 
 
       TAsmSehDirective=(
       TAsmSehDirective=(
@@ -395,7 +397,9 @@ interface
         { ARM }
         { ARM }
         'thumb_func',
         'thumb_func',
         'code',
         'code',
-        'cpu'
+        'cpu',
+        { for the OMF object format }
+        'omf_line'
       );
       );
       sehdirectivestr : array[TAsmSehDirective] of string[16]=(
       sehdirectivestr : array[TAsmSehDirective] of string[16]=(
         '.seh_proc','.seh_endproc',
         '.seh_proc','.seh_endproc',

+ 10 - 0
compiler/assemble.pas

@@ -1630,6 +1630,11 @@ Implementation
                              break;
                              break;
                            end;
                            end;
                      end;
                      end;
+{$ifdef OMFOBJSUPPORT}
+                   asd_omf_linnum_line:
+                     { ignore for now, but should be added}
+                     ;
+{$endif OMFOBJSUPPORT}
 {$ifdef ARM}
 {$ifdef ARM}
                    asd_thumb_func:
                    asd_thumb_func:
                      ObjData.ThumbFunc:=true;
                      ObjData.ThumbFunc:=true;
@@ -1783,6 +1788,11 @@ Implementation
                    asd_code:
                    asd_code:
                      { ignore for now, but should be added}
                      { ignore for now, but should be added}
                      ;
                      ;
+{$ifdef OMFOBJSUPPORT}
+                   asd_omf_linnum_line:
+                     { ignore for now, but should be added}
+                     ;
+{$endif OMFOBJSUPPORT}
                    asd_cpu:
                    asd_cpu:
                      begin
                      begin
                        ObjData.CPUType:=cpu_none;
                        ObjData.CPUType:=cpu_none;

+ 54 - 2
compiler/dbgcodeview.pas

@@ -191,6 +191,10 @@ interface
 implementation
 implementation
 
 
     uses
     uses
+      globtype,
+      cutils,
+      aasmtai,
+      fmodule,
       systems;
       systems;
 
 
 {****************************************************************************
 {****************************************************************************
@@ -198,9 +202,57 @@ implementation
 ****************************************************************************}
 ****************************************************************************}
 
 
     procedure TDebugInfoCodeView.insertlineinfo(list: TAsmList);
     procedure TDebugInfoCodeView.insertlineinfo(list: TAsmList);
+      var
+        currfileinfo,
+        lastfileinfo : tfileposinfo;
+        nolineinfolevel : Integer;
+        currfuncname : pshortstring;
+        hp : tai;
       begin
       begin
-        { todo: implement }
-        inherited insertlineinfo(list);
+        FillChar(lastfileinfo,sizeof(lastfileinfo),0);
+        hp:=Tai(list.first);
+        nolineinfolevel:=0;
+        while assigned(hp) do
+          begin
+            case hp.typ of
+              ait_function_name :
+                begin
+                  currfuncname:=tai_function_name(hp).funcname;
+                  list.concat(tai_comment.Create(strpnew('function: '+currfuncname^)));
+                end;
+              ait_force_line :
+                begin
+                  lastfileinfo.line:=-1;
+                end;
+              ait_marker :
+                begin
+                  case tai_marker(hp).kind of
+                    mark_NoLineInfoStart:
+                      inc(nolineinfolevel);
+                    mark_NoLineInfoEnd:
+                      dec(nolineinfolevel);
+                  end;
+                end;
+            end;
+
+            { OMF LINNUM records do not support multiple source files }
+            if (hp.typ=ait_instruction) and
+               (nolineinfolevel=0) and
+               (tailineinfo(hp).fileinfo.fileindex=main_module.unit_index) then
+              begin
+                currfileinfo:=tailineinfo(hp).fileinfo;
+
+                { line changed ? }
+                if (lastfileinfo.line<>currfileinfo.line) and (currfileinfo.line<>0) then
+                  begin
+                    { line directive }
+                    list.insertbefore(tai_directive.Create(asd_omf_linnum_line,tostr(currfileinfo.line)),hp);
+                  end;
+                lastfileinfo:=currfileinfo;
+              end;
+
+            hp:=tai(hp.next);
+          end;
       end;
       end;
 
 
 {****************************************************************************
 {****************************************************************************

+ 1 - 0
compiler/fpcdefs.inc

@@ -67,6 +67,7 @@
   {$define VOLATILE_ES}
   {$define VOLATILE_ES}
   {$define SUPPORT_GET_FRAME}
   {$define SUPPORT_GET_FRAME}
   {$define cpucg64shiftsupport}
   {$define cpucg64shiftsupport}
+  {$define OMFOBJSUPPORT}
 {$endif i8086}
 {$endif i8086}
 
 
 {$ifdef i386}
 {$ifdef i386}

+ 4 - 0
compiler/x86/agx86nsm.pas

@@ -1225,6 +1225,10 @@ interface
                            end;
                            end;
                        end;
                        end;
                    end;
                    end;
+{$ifdef OMFOBJSUPPORT}
+                 asd_omf_linnum_line :
+                   writer.AsmWriteLn('; OMF LINNUM Line '+tai_directive(hp).name);
+{$endif OMFOBJSUPPORT}
                  else
                  else
                    internalerror(200509191);
                    internalerror(200509191);
                end;
                end;