From e20919f065805beac0eaaa99a68adf2e8ac62588 Mon Sep 17 00:00:00 2001 From: Jonas Maebe Date: Sat, 20 Aug 2011 07:50:46 +0000 Subject: [PATCH] + 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 - --- compiler/aasmtai.pas | 4 ++-- compiler/agjasmin.pas | 5 ++-- compiler/jvm/dbgjasm.pas | 50 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 54 insertions(+), 5 deletions(-) diff --git a/compiler/aasmtai.pas b/compiler/aasmtai.pas index df1380be5f..817a399aa9 100644 --- a/compiler/aasmtai.pas +++ b/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 diff --git a/compiler/agjasmin.pas b/compiler/agjasmin.pas index e4384b8191..841601e9db 100644 --- a/compiler/agjasmin.pas +++ b/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 diff --git a/compiler/jvm/dbgjasm.pas b/compiler/jvm/dbgjasm.pas index 5156ce28f5..19a8784b42 100644 --- a/compiler/jvm/dbgjasm.pas +++ b/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;