diff --git a/compiler/aasmbase.pas b/compiler/aasmbase.pas index 0fa8d67bba..7c1ac7d00c 100644 --- a/compiler/aasmbase.pas +++ b/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' ); diff --git a/compiler/aggas.pas b/compiler/aggas.pas index 59f2c09f65..737ea77220 100644 --- a/compiler/aggas.pas +++ b/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' ); diff --git a/compiler/dbgdwarf.pas b/compiler/dbgdwarf.pas index bab6d43069..6a117afe73 100644 --- a/compiler/dbgdwarf.pas +++ b/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. diff --git a/compiler/dwarf.pas b/compiler/dwarf.pas index a57afe771d..ea5cf3ce0a 100644 --- a/compiler/dwarf.pas +++ b/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 diff --git a/compiler/i386/ag386nsm.pas b/compiler/i386/ag386nsm.pas index 91836b0b44..de4d8033ec 100644 --- a/compiler/i386/ag386nsm.pas +++ b/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; diff --git a/compiler/ogcoff.pas b/compiler/ogcoff.pas index 007fd9f749..c7ea0c728e 100644 --- a/compiler/ogcoff.pas +++ b/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', '' ); diff --git a/compiler/ogelf.pas b/compiler/ogelf.pas index 402fdc820c..faf1ebc644 100644 --- a/compiler/ogelf.pas +++ b/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', '' ); diff --git a/compiler/x86/agx86int.pas b/compiler/x86/agx86int.pas index e725250830..28cb8bf835 100644 --- a/compiler/x86/agx86int.pas +++ b/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;