Bladeren bron

+ support for writing JVM line number information

  * moved emitting line information from agjasmin to dbgjasm (+ it now
    also works if -al is not used)

git-svn-id: branches/jvmbackend@18355 -
Jonas Maebe 14 jaren geleden
bovenliggende
commit
e20919f065
3 gewijzigde bestanden met toevoegingen van 54 en 5 verwijderingen
  1. 2 2
      compiler/aasmtai.pas
  2. 2 3
      compiler/agjasmin.pas
  3. 50 0
      compiler/jvm/dbgjasm.pas

+ 2 - 2
compiler/aasmtai.pas

@@ -295,7 +295,7 @@ interface
         asd_reference,asd_no_dead_strip,asd_weak_reference,asd_lazy_reference,
         asd_weak_definition,
         { for Jasmin }
-        asd_jclass,asd_jinterface,asd_jsuper,asd_jfield,asd_jlimit
+        asd_jclass,asd_jinterface,asd_jsuper,asd_jfield,asd_jlimit,asd_jline
       );
 
     const
@@ -307,7 +307,7 @@ interface
         'extern','nasm_import', 'tc', 'reference',
         'no_dead_strip','weak_reference','lazy_reference','weak_definition',
         { for Jasmin }
-        'class','interface','super','field','limit'
+        'class','interface','super','field','limit','line'
       );
 
     type

+ 2 - 3
compiler/agjasmin.pas

@@ -164,9 +164,7 @@ implementation
         last_align := 2;
         InlineLevel:=0;
         { lineinfo is only needed for al_procedures (PFV) }
-        do_line:=(cs_asm_source in current_settings.globalswitches) or
-                 ((cs_lineinfo in current_settings.moduleswitches)
-                   and (p=current_asmdata.asmlists[al_procedures]));
+        do_line:=(cs_asm_source in current_settings.globalswitches);
         hp:=tai(p.first);
         while assigned(hp) do
          begin
@@ -193,6 +191,7 @@ implementation
                      { be sure to change line !! }
                      lastfileinfo.line:=-1;
                    end;
+
                 { write source }
                   if (cs_asm_source in current_settings.globalswitches) and
                      assigned(infile) then

+ 50 - 0
compiler/jvm/dbgjasm.pas

@@ -130,7 +130,57 @@ implementation
     end;
 
   procedure TDebugInfoJasmin.insertlineinfo(list: TAsmList);
+    var
+      currfileinfo,
+      lastfileinfo : tfileposinfo;
+      nolineinfolevel : Integer;
+      currfuncname : pshortstring;
+      hp : tai;
     begin
+      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;
+
+          { Java does 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_jline,tostr(currfileinfo.line)),hp);
+                end;
+              lastfileinfo:=currfileinfo;
+            end;
+
+          hp:=tai(hp.next);
+        end;
     end;