dbgdwarf.pas 81 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083
  1. {
  2. Copyright (c) 2003-2006 by Peter Vreman and Florian Klaempfl
  3. This units contains support for DWARF debug info generation
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. ****************************************************************************
  16. }
  17. {
  18. This units contains support for DWARF debug info generation.
  19. Currently a lot of code looks like being mergable with dbgstabs. This might
  20. change however when improved dwarf info is generated, so the stuff shouldn't be
  21. merged yet. (FK)
  22. The easiest way to debug dwarf debug info generation is the usage of
  23. readelf --debug-dump <executable>
  24. This works only with elf targets though.
  25. }
  26. unit dbgdwarf;
  27. {$i fpcdefs.inc}
  28. interface
  29. uses
  30. cclasses,
  31. aasmbase,aasmtai,aasmdata,
  32. symbase,symtype,symdef,
  33. DbgBase;
  34. type
  35. { Tag names and codes. }
  36. tdwarf_tag = (DW_TAG_padding := $00,DW_TAG_array_type := $01,
  37. DW_TAG_class_type := $02,DW_TAG_entry_point := $03,
  38. DW_TAG_enumeration_type := $04,DW_TAG_formal_parameter := $05,
  39. DW_TAG_imported_declaration := $08,DW_TAG_label := $0a,
  40. DW_TAG_lexical_block := $0b,DW_TAG_member := $0d,
  41. DW_TAG_pointer_type := $0f,DW_TAG_reference_type := $10,
  42. DW_TAG_compile_unit := $11,DW_TAG_string_type := $12,
  43. DW_TAG_structure_type := $13,DW_TAG_subroutine_type := $15,
  44. DW_TAG_typedef := $16,DW_TAG_union_type := $17,
  45. DW_TAG_unspecified_parameters := $18,
  46. DW_TAG_variant := $19,DW_TAG_common_block := $1a,
  47. DW_TAG_common_inclusion := $1b,DW_TAG_inheritance := $1c,
  48. DW_TAG_inlined_subroutine := $1d,DW_TAG_module := $1e,
  49. DW_TAG_ptr_to_member_type := $1f,DW_TAG_set_type := $20,
  50. DW_TAG_subrange_type := $21,DW_TAG_with_stmt := $22,
  51. DW_TAG_access_declaration := $23,DW_TAG_base_type := $24,
  52. DW_TAG_catch_block := $25,DW_TAG_const_type := $26,
  53. DW_TAG_constant := $27,DW_TAG_enumerator := $28,
  54. DW_TAG_file_type := $29,DW_TAG_friend := $2a,
  55. DW_TAG_namelist := $2b,DW_TAG_namelist_item := $2c,
  56. DW_TAG_packed_type := $2d,DW_TAG_subprogram := $2e,
  57. DW_TAG_template_type_param := $2f,DW_TAG_template_value_param := $30,
  58. DW_TAG_thrown_type := $31,DW_TAG_try_block := $32,
  59. DW_TAG_variant_part := $33,DW_TAG_variable := $34,
  60. DW_TAG_volatile_type := $35,
  61. { DWARF 3. }
  62. DW_TAG_dwarf_procedure := $36,
  63. DW_TAG_restrict_type := $37,DW_TAG_interface_type := $38,
  64. DW_TAG_namespace := $39,DW_TAG_imported_module := $3a,
  65. DW_TAG_unspecified_type := $3b,DW_TAG_partial_unit := $3c,
  66. DW_TAG_imported_unit := $3d,
  67. { SGI/MIPS Extensions. }
  68. DW_TAG_MIPS_loop := $4081,
  69. { HP extensions. See: ftp://ftp.hp.com/pub/lang/tools/WDB/wdb-4.0.tar.gz . }
  70. DW_TAG_HP_array_descriptor := $4090,
  71. { GNU extensions. }
  72. { For FORTRAN 77 and Fortran 90. }
  73. DW_TAG_format_label := $4101,
  74. { For C++. }
  75. DW_TAG_function_template := $4102,DW_TAG_class_template := $4103,
  76. DW_TAG_GNU_BINCL := $4104,DW_TAG_GNU_EINCL := $4105,
  77. { Extensions for UPC. See: http://upc.gwu.edu/~upc. }
  78. DW_TAG_upc_shared_type := $8765,DW_TAG_upc_strict_type := $8766,
  79. DW_TAG_upc_relaxed_type := $8767,
  80. { PGI (STMicroelectronics) extensions. No documentation available. }
  81. DW_TAG_PGI_kanji_type := $A000,
  82. DW_TAG_PGI_interface_block := $A020);
  83. { Attribute names and codes. }
  84. tdwarf_attribute = (DW_AT_sibling := $01,DW_AT_location := $02,
  85. DW_AT_name := $03,DW_AT_ordering := $09,
  86. DW_AT_subscr_data := $0a,DW_AT_byte_size := $0b,
  87. DW_AT_bit_offset := $0c,DW_AT_bit_size := $0d,
  88. DW_AT_element_list := $0f,DW_AT_stmt_list := $10,
  89. DW_AT_low_pc := $11,DW_AT_high_pc := $12,
  90. DW_AT_language := $13,DW_AT_member := $14,
  91. DW_AT_discr := $15,DW_AT_discr_value := $16,
  92. DW_AT_visibility := $17,DW_AT_import := $18,
  93. DW_AT_string_length := $19,DW_AT_common_reference := $1a,
  94. DW_AT_comp_dir := $1b,DW_AT_const_value := $1c,
  95. DW_AT_containing_type := $1d,DW_AT_default_value := $1e,
  96. DW_AT_inline := $20,DW_AT_is_optional := $21,
  97. DW_AT_lower_bound := $22,DW_AT_producer := $25,
  98. DW_AT_prototyped := $27,DW_AT_return_addr := $2a,
  99. DW_AT_start_scope := $2c,DW_AT_stride_size := $2e,
  100. DW_AT_upper_bound := $2f,DW_AT_abstract_origin := $31,
  101. DW_AT_accessibility := $32,DW_AT_address_class := $33,
  102. DW_AT_artificial := $34,DW_AT_base_types := $35,
  103. DW_AT_calling_convention := $36,DW_AT_count := $37,
  104. DW_AT_data_member_location := $38,DW_AT_decl_column := $39,
  105. DW_AT_decl_file := $3a,DW_AT_decl_line := $3b,
  106. DW_AT_declaration := $3c,DW_AT_discr_list := $3d,
  107. DW_AT_encoding := $3e,DW_AT_external := $3f,
  108. DW_AT_frame_base := $40,DW_AT_friend := $41,
  109. DW_AT_identifier_case := $42,DW_AT_macro_info := $43,
  110. DW_AT_namelist_items := $44,DW_AT_priority := $45,
  111. DW_AT_segment := $46,DW_AT_specification := $47,
  112. DW_AT_static_link := $48,DW_AT_type := $49,
  113. DW_AT_use_location := $4a,DW_AT_variable_parameter := $4b,
  114. DW_AT_virtuality := $4c,DW_AT_vtable_elem_location := $4d,
  115. { DWARF 3 values. }
  116. DW_AT_allocated := $4e,DW_AT_associated := $4f,
  117. DW_AT_data_location := $50,DW_AT_stride := $51,
  118. DW_AT_entry_pc := $52,DW_AT_use_UTF8 := $53,
  119. DW_AT_extension := $54,DW_AT_ranges := $55,
  120. DW_AT_trampoline := $56,DW_AT_call_column := $57,
  121. DW_AT_call_file := $58,DW_AT_call_line := $59,
  122. { SGI/MIPS extensions. }
  123. DW_AT_MIPS_fde := $2001,DW_AT_MIPS_loop_begin := $2002,
  124. DW_AT_MIPS_tail_loop_begin := $2003,DW_AT_MIPS_epilog_begin := $2004,
  125. DW_AT_MIPS_loop_unroll_factor := $2005,
  126. DW_AT_MIPS_software_pipeline_depth := $2006,
  127. DW_AT_MIPS_linkage_name := $2007,DW_AT_MIPS_stride := $2008,
  128. DW_AT_MIPS_abstract_name := $2009,DW_AT_MIPS_clone_origin := $200a,
  129. DW_AT_MIPS_has_inlines := $200b,
  130. { HP extensions. }
  131. DW_AT_HP_block_index := $2000,
  132. DW_AT_HP_unmodifiable := $2001,DW_AT_HP_actuals_stmt_list := $2010,
  133. DW_AT_HP_proc_per_section := $2011,DW_AT_HP_raw_data_ptr := $2012,
  134. DW_AT_HP_pass_by_reference := $2013,DW_AT_HP_opt_level := $2014,
  135. DW_AT_HP_prof_version_id := $2015,DW_AT_HP_opt_flags := $2016,
  136. DW_AT_HP_cold_region_low_pc := $2017,DW_AT_HP_cold_region_high_pc := $2018,
  137. DW_AT_HP_all_variables_modifiable := $2019,
  138. DW_AT_HP_linkage_name := $201a,DW_AT_HP_prof_flags := $201b,
  139. { GNU extensions. }
  140. DW_AT_sf_names := $2101,DW_AT_src_info := $2102,
  141. DW_AT_mac_info := $2103,DW_AT_src_coords := $2104,
  142. DW_AT_body_begin := $2105,DW_AT_body_end := $2106,
  143. DW_AT_GNU_vector := $2107,
  144. { VMS extensions. }
  145. DW_AT_VMS_rtnbeg_pd_address := $2201,
  146. { UPC extension. }
  147. DW_AT_upc_threads_scaled := $3210,
  148. { PGI (STMicroelectronics) extensions. }
  149. DW_AT_PGI_lbase := $3a00,
  150. DW_AT_PGI_soffset := $3a01,DW_AT_PGI_lstride := $3a02
  151. );
  152. { Form names and codes. }
  153. Tdwarf_form = (DW_FORM_addr := $01,DW_FORM_block2 := $03,
  154. DW_FORM_block4 := $04,DW_FORM_data2 := $05,
  155. DW_FORM_data4 := $06,DW_FORM_data8 := $07,
  156. DW_FORM_string := $08,DW_FORM_block := $09,
  157. DW_FORM_block1 := $0a,DW_FORM_data1 := $0b,
  158. DW_FORM_flag := $0c,DW_FORM_sdata := $0d,
  159. DW_FORM_strp := $0e,DW_FORM_udata := $0f,
  160. DW_FORM_ref_addr := $10,DW_FORM_ref1 := $11,
  161. DW_FORM_ref2 := $12,DW_FORM_ref4 := $13,
  162. DW_FORM_ref8 := $14,DW_FORM_ref_udata := $15,
  163. DW_FORM_indirect := $16);
  164. TDebugInfoDwarf = class(TDebugInfo)
  165. private
  166. currabbrevnumber : longint;
  167. { collect all defs in one list so we can reset them easily }
  168. nextdefnumber : longint;
  169. defnumberlist : TFPObjectList;
  170. isdwarf64,
  171. writing_def_dwarf : boolean;
  172. { use this defs to create info for variants and file handles }
  173. vardatadef,
  174. filerecdef,
  175. textrecdef : tdef;
  176. procedure append_entry(tag : tdwarf_tag;has_children : boolean;data : array of const);
  177. procedure append_labelentry(attr : tdwarf_attribute;sym : tasmsymbol);
  178. procedure append_labelentry_ref(attr : tdwarf_attribute;sym : tasmsymbol);
  179. procedure append_labelentry_data(attr : tdwarf_attribute;sym : tasmsymbol);
  180. procedure finish_entry;
  181. procedure finish_children;
  182. procedure field_add_dwarftag(p:Tnamedindexitem;arg:pointer);
  183. procedure method_add_dwarftag(p:Tnamedindexitem;arg:pointer);
  184. procedure append_procdef(list:TAsmList;pd:tprocdef);
  185. procedure append_dwarftag(list:TAsmList;def:tdef);
  186. procedure insertsym(list:TAsmList;sym:tsym);
  187. procedure write_symtable_syms(list:TAsmList;st:tsymtable);
  188. function def_dwarf_lab(def:tdef) : tasmsymbol;
  189. public
  190. procedure insertdef(list:TAsmList;def:tdef);override;
  191. procedure insertmoduleinfo;override;
  192. procedure inserttypeinfo;override;
  193. procedure referencesections(list:TAsmList);override;
  194. procedure insertlineinfo(list:TAsmList);override;
  195. procedure write_symtable_defs(list:TAsmList;st:tsymtable);override;
  196. end;
  197. implementation
  198. uses
  199. version,
  200. cutils,
  201. globtype,
  202. globals,
  203. verbose,
  204. systems,
  205. cpubase,
  206. cgbase,
  207. finput,
  208. fmodule,
  209. defutil,
  210. symconst,symtable,symsym
  211. ;
  212. const
  213. DW_TAG_lo_user = $4080;
  214. DW_TAG_hi_user = $ffff;
  215. { Flag that tells whether entry has a child or not. }
  216. DW_children_no = 0;
  217. DW_children_yes = 1;
  218. const
  219. { Implementation-defined range start. }
  220. DW_AT_lo_user = $2000;
  221. { Implementation-defined range end. }
  222. DW_AT_hi_user = $3ff0;
  223. type
  224. { Source language names and codes. }
  225. tdwarf_source_language = (DW_LANG_C89 := $0001,DW_LANG_C := $0002,DW_LANG_Ada83 := $0003,
  226. DW_LANG_C_plus_plus := $0004,DW_LANG_Cobol74 := $0005,
  227. DW_LANG_Cobol85 := $0006,DW_LANG_Fortran77 := $0007,
  228. DW_LANG_Fortran90 := $0008,DW_LANG_Pascal83 := $0009,
  229. DW_LANG_Modula2 := $000a,DW_LANG_Java := $000b,
  230. { DWARF 3. }
  231. DW_LANG_C99 := $000c,DW_LANG_Ada95 := $000d,
  232. DW_LANG_Fortran95 := $000e,
  233. { MIPS. }
  234. DW_LANG_Mips_Assembler := $8001,
  235. { UPC. }
  236. DW_LANG_Upc := $8765
  237. );
  238. const
  239. { Implementation-defined range start. }
  240. DW_LANG_lo_user = $8000;
  241. { Implementation-defined range start. }
  242. DW_LANG_hi_user = $ffff;
  243. type
  244. { Names and codes for macro information. }
  245. tdwarf_macinfo_record_type = (DW_MACINFO_define := 1,DW_MACINFO_undef := 2,
  246. DW_MACINFO_start_file := 3,DW_MACINFO_end_file := 4,
  247. DW_MACINFO_vendor_ext := 255);
  248. type
  249. { Type encodings. }
  250. Tdwarf_type = (DW_ATE_void := $0,DW_ATE_address := $1,
  251. DW_ATE_boolean := $2,DW_ATE_complex_float := $3,
  252. DW_ATE_float := $4,DW_ATE_signed := $5,
  253. DW_ATE_signed_char := $6,DW_ATE_unsigned := $7,
  254. DW_ATE_unsigned_char := $8,DW_ATE_imaginary_float := $9,
  255. { HP extensions. }
  256. DW_ATE_HP_float80 := $80,DW_ATE_HP_complex_float80 := $81,
  257. DW_ATE_HP_float128 := $82,DW_ATE_HP_complex_float128 := $83,
  258. DW_ATE_HP_floathpintel := $84,DW_ATE_HP_imaginary_float80 := $85,
  259. DW_ATE_HP_imaginary_float128 := $86
  260. );
  261. const
  262. DW_ATE_lo_user = $80;
  263. DW_ATE_hi_user = $ff;
  264. type
  265. Tdwarf_array_dim_ordering = (DW_ORD_row_major := 0,DW_ORD_col_major := 1
  266. );
  267. { Access attribute. }
  268. Tdwarf_access_attribute = (DW_ACCESS_public := 1,DW_ACCESS_protected := 2,
  269. DW_ACCESS_private := 3);
  270. { Visibility. }
  271. Tdwarf_visibility_attribute = (DW_VIS_local := 1,DW_VIS_exported := 2,
  272. DW_VIS_qualified := 3);
  273. { Virtuality. }
  274. Tdwarf_virtuality_attribute = (DW_VIRTUALITY_none := 0,DW_VIRTUALITY_virtual := 1,
  275. DW_VIRTUALITY_pure_virtual := 2);
  276. { Case sensitivity. }
  277. Tdwarf_id_case = (DW_ID_case_sensitive := 0,DW_ID_up_case := 1,
  278. DW_ID_down_case := 2,DW_ID_case_insensitive := 3
  279. );
  280. { Calling convention. }
  281. Tdwarf_calling_convention = (DW_CC_normal := $1,DW_CC_program := $2,
  282. DW_CC_nocall := $3,DW_CC_GNU_renesas_sh := $40
  283. );
  284. { Location atom names and codes. }
  285. Tdwarf_location_atom = (DW_OP_addr := $03,DW_OP_deref := $06,DW_OP_const1u := $08,
  286. DW_OP_const1s := $09,DW_OP_const2u := $0a,
  287. DW_OP_const2s := $0b,DW_OP_const4u := $0c,
  288. DW_OP_const4s := $0d,DW_OP_const8u := $0e,
  289. DW_OP_const8s := $0f,DW_OP_constu := $10,
  290. DW_OP_consts := $11,DW_OP_dup := $12,DW_OP_drop := $13,
  291. DW_OP_over := $14,DW_OP_pick := $15,DW_OP_swap := $16,
  292. DW_OP_rot := $17,DW_OP_xderef := $18,DW_OP_abs := $19,
  293. DW_OP_and := $1a,DW_OP_div := $1b,DW_OP_minus := $1c,
  294. DW_OP_mod := $1d,DW_OP_mul := $1e,DW_OP_neg := $1f,
  295. DW_OP_not := $20,DW_OP_or := $21,DW_OP_plus := $22,
  296. DW_OP_plus_uconst := $23,DW_OP_shl := $24,
  297. DW_OP_shr := $25,DW_OP_shra := $26,DW_OP_xor := $27,
  298. DW_OP_bra := $28,DW_OP_eq := $29,DW_OP_ge := $2a,
  299. DW_OP_gt := $2b,DW_OP_le := $2c,DW_OP_lt := $2d,
  300. DW_OP_ne := $2e,DW_OP_skip := $2f,DW_OP_lit0 := $30,
  301. DW_OP_lit1 := $31,DW_OP_lit2 := $32,DW_OP_lit3 := $33,
  302. DW_OP_lit4 := $34,DW_OP_lit5 := $35,DW_OP_lit6 := $36,
  303. DW_OP_lit7 := $37,DW_OP_lit8 := $38,DW_OP_lit9 := $39,
  304. DW_OP_lit10 := $3a,DW_OP_lit11 := $3b,
  305. DW_OP_lit12 := $3c,DW_OP_lit13 := $3d,
  306. DW_OP_lit14 := $3e,DW_OP_lit15 := $3f,
  307. DW_OP_lit16 := $40,DW_OP_lit17 := $41,
  308. DW_OP_lit18 := $42,DW_OP_lit19 := $43,
  309. DW_OP_lit20 := $44,DW_OP_lit21 := $45,
  310. DW_OP_lit22 := $46,DW_OP_lit23 := $47,
  311. DW_OP_lit24 := $48,DW_OP_lit25 := $49,
  312. DW_OP_lit26 := $4a,DW_OP_lit27 := $4b,
  313. DW_OP_lit28 := $4c,DW_OP_lit29 := $4d,
  314. DW_OP_lit30 := $4e,DW_OP_lit31 := $4f,
  315. DW_OP_reg0 := $50,DW_OP_reg1 := $51,DW_OP_reg2 := $52,
  316. DW_OP_reg3 := $53,DW_OP_reg4 := $54,DW_OP_reg5 := $55,
  317. DW_OP_reg6 := $56,DW_OP_reg7 := $57,DW_OP_reg8 := $58,
  318. DW_OP_reg9 := $59,DW_OP_reg10 := $5a,DW_OP_reg11 := $5b,
  319. DW_OP_reg12 := $5c,DW_OP_reg13 := $5d,
  320. DW_OP_reg14 := $5e,DW_OP_reg15 := $5f,
  321. DW_OP_reg16 := $60,DW_OP_reg17 := $61,
  322. DW_OP_reg18 := $62,DW_OP_reg19 := $63,
  323. DW_OP_reg20 := $64,DW_OP_reg21 := $65,
  324. DW_OP_reg22 := $66,DW_OP_reg23 := $67,
  325. DW_OP_reg24 := $68,DW_OP_reg25 := $69,
  326. DW_OP_reg26 := $6a,DW_OP_reg27 := $6b,
  327. DW_OP_reg28 := $6c,DW_OP_reg29 := $6d,
  328. DW_OP_reg30 := $6e,DW_OP_reg31 := $6f,
  329. DW_OP_breg0 := $70,DW_OP_breg1 := $71,
  330. DW_OP_breg2 := $72,DW_OP_breg3 := $73,
  331. DW_OP_breg4 := $74,DW_OP_breg5 := $75,
  332. DW_OP_breg6 := $76,DW_OP_breg7 := $77,
  333. DW_OP_breg8 := $78,DW_OP_breg9 := $79,
  334. DW_OP_breg10 := $7a,DW_OP_breg11 := $7b,
  335. DW_OP_breg12 := $7c,DW_OP_breg13 := $7d,
  336. DW_OP_breg14 := $7e,DW_OP_breg15 := $7f,
  337. DW_OP_breg16 := $80,DW_OP_breg17 := $81,
  338. DW_OP_breg18 := $82,DW_OP_breg19 := $83,
  339. DW_OP_breg20 := $84,DW_OP_breg21 := $85,
  340. DW_OP_breg22 := $86,DW_OP_breg23 := $87,
  341. DW_OP_breg24 := $88,DW_OP_breg25 := $89,
  342. DW_OP_breg26 := $8a,DW_OP_breg27 := $8b,
  343. DW_OP_breg28 := $8c,DW_OP_breg29 := $8d,
  344. DW_OP_breg30 := $8e,DW_OP_breg31 := $8f,
  345. DW_OP_regx := $90,DW_OP_fbreg := $91,DW_OP_bregx := $92,
  346. DW_OP_piece := $93,DW_OP_deref_size := $94,
  347. DW_OP_xderef_size := $95,DW_OP_nop := $96,
  348. { DWARF 3 extensions. }
  349. DW_OP_push_object_address := $97,DW_OP_call2 := $98,
  350. DW_OP_call4 := $99,DW_OP_call_ref := $9a,
  351. { GNU extensions. }
  352. DW_OP_GNU_push_tls_address := $e0,
  353. { HP extensions. }
  354. DW_OP_HP_unknown := $e0,
  355. DW_OP_HP_is_value := $e1,DW_OP_HP_fltconst4 := $e2,
  356. DW_OP_HP_fltconst8 := $e3,DW_OP_HP_mod_range := $e4,
  357. DW_OP_HP_unmod_range := $e5,DW_OP_HP_tls := $e6
  358. );
  359. const
  360. { Implementation-defined range start. }
  361. DW_OP_lo_user = $e0;
  362. { Implementation-defined range end. }
  363. DW_OP_hi_user = $ff;
  364. {****************************************************************************
  365. TDebugInfoDwarf
  366. ****************************************************************************}
  367. function TDebugInfoDwarf.def_dwarf_lab(def:tdef) : tasmsymbol;
  368. begin
  369. { procdefs only need a number, mark them as already written
  370. so they won't be written implicitly }
  371. if (def.deftype=procdef) then
  372. def.dbg_state:=dbg_state_written;
  373. { dwarf must already be written, or we must be busy writing it }
  374. if writing_def_dwarf and
  375. not(def.dbg_state in [dbg_state_writing,dbg_state_written]) then
  376. internalerror(200601241);
  377. { Keep track of used dwarf entries, this info is only usefull for dwarf entries
  378. referenced by the symbols. Definitions will always include all
  379. required stabs }
  380. if def.dbg_state=dbg_state_unused then
  381. def.dbg_state:=dbg_state_used;
  382. { Need a new label? }
  383. if def.dwarf_lab=nil then
  384. begin
  385. current_asmdata.getdatalabel(def.dwarf_lab);
  386. if nextdefnumber>=defnumberlist.count then
  387. defnumberlist.count:=nextdefnumber+250;
  388. defnumberlist[nextdefnumber]:=def;
  389. inc(nextdefnumber);
  390. end;
  391. result:=def.dwarf_lab;
  392. end;
  393. { writing the data through a few simply procedures allows to create easily extra information
  394. for debugging of debug info }
  395. procedure TDebugInfoDwarf.append_entry(tag : tdwarf_tag;has_children : boolean;data : array of const);
  396. var
  397. i : longint;
  398. begin
  399. inc(currabbrevnumber);
  400. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_comment.Create(strpnew('Abbrev '+tostr(currabbrevnumber))));
  401. { abbrev number }
  402. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(currabbrevnumber));
  403. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(currabbrevnumber));
  404. { tag }
  405. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(tag)));
  406. { children? }
  407. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(ord(has_children)));
  408. i:=0;
  409. while i<=high(data) do
  410. begin
  411. { attribute }
  412. if data[i].VType=vtInteger then
  413. begin
  414. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(data[i].VInteger));
  415. end
  416. else
  417. internalerror(200601261);
  418. inc(i);
  419. { form }
  420. if data[i].VType=vtInteger then
  421. begin
  422. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(data[i].VInteger));
  423. end
  424. else
  425. internalerror(200601262);
  426. inc(i);
  427. { info itself }
  428. case tdwarf_form(data[i-1].VInteger) of
  429. DW_FORM_string:
  430. case data[i].VType of
  431. vtChar:
  432. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(data[i].VChar));
  433. vtString:
  434. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(data[i].VString^));
  435. vtAnsistring:
  436. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(Ansistring(data[i].VAnsiString)));
  437. else
  438. internalerror(200601264);
  439. end;
  440. DW_FORM_flag:
  441. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(byte(data[i].VBoolean)));
  442. DW_FORM_data1:
  443. case data[i].VType of
  444. vtInteger:
  445. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(data[i].VInteger));
  446. vtInt64:
  447. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(data[i].VInt64^));
  448. vtQWord:
  449. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(data[i].VQWord^));
  450. else
  451. internalerror(200602143);
  452. end;
  453. DW_FORM_data2:
  454. case data[i].VType of
  455. vtInteger:
  456. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_16bit(data[i].VInteger));
  457. vtInt64:
  458. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_16bit(data[i].VInt64^));
  459. vtQWord:
  460. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_16bit(data[i].VQWord^));
  461. else
  462. internalerror(200602144);
  463. end;
  464. DW_FORM_data4:
  465. case data[i].VType of
  466. vtInteger:
  467. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(data[i].VInteger));
  468. vtInt64:
  469. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(data[i].VInt64^));
  470. vtQWord:
  471. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(data[i].VQWord^));
  472. else
  473. internalerror(200602145);
  474. end;
  475. DW_FORM_data8:
  476. case data[i].VType of
  477. vtInteger:
  478. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(data[i].VInteger));
  479. vtInt64:
  480. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(data[i].VInt64^));
  481. vtQWord:
  482. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(data[i].VQWord^));
  483. else
  484. internalerror(200602146);
  485. end;
  486. DW_FORM_sdata:
  487. case data[i].VType of
  488. vtInteger:
  489. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sleb128bit(data[i].VInteger));
  490. vtInt64:
  491. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sleb128bit(data[i].VInt64^));
  492. vtQWord:
  493. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sleb128bit(data[i].VQWord^));
  494. else
  495. internalerror(200601285);
  496. end;
  497. DW_FORM_udata:
  498. case data[i].VType of
  499. vtInteger:
  500. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(data[i].VInteger));
  501. vtInt64:
  502. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(data[i].VInt64^));
  503. vtQWord:
  504. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(data[i].VQWord^));
  505. else
  506. internalerror(200601284);
  507. end;
  508. { block gets only the size, the rest is appended manually by the caller }
  509. DW_FORM_block1:
  510. case data[i].VType of
  511. vtInteger:
  512. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(data[i].VInteger));
  513. vtInt64:
  514. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(data[i].VInt64^));
  515. vtQWord:
  516. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(data[i].VQWord^));
  517. else
  518. internalerror(200602141);
  519. end;
  520. else
  521. internalerror(200601263);
  522. end;
  523. inc(i);
  524. end;
  525. end;
  526. procedure TDebugInfoDwarf.append_labelentry(attr : tdwarf_attribute;sym : tasmsymbol);
  527. begin
  528. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(attr)));
  529. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_addr)));
  530. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sym(sym));
  531. end;
  532. procedure TDebugInfoDwarf.append_labelentry_ref(attr : tdwarf_attribute;sym : tasmsymbol);
  533. begin
  534. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(attr)));
  535. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_ref_addr)));
  536. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sym(sym));
  537. end;
  538. procedure TDebugInfoDwarf.append_labelentry_data(attr : tdwarf_attribute;sym : tasmsymbol);
  539. begin
  540. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(attr)));
  541. {$ifdef cpu64bit}
  542. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data8)));
  543. {$else cpu64bit}
  544. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data4)));
  545. {$endif cpu64bit}
  546. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sym(sym));
  547. end;
  548. procedure TDebugInfoDwarf.finish_entry;
  549. begin
  550. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0));
  551. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_8bit(0));
  552. end;
  553. procedure TDebugInfoDwarf.finish_children;
  554. begin
  555. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  556. end;
  557. procedure TDebugInfoDwarf.field_add_dwarftag(p:Tnamedindexitem;arg:pointer);
  558. begin
  559. { static variables from objects are like global objects }
  560. if (tsym(p).typ=fieldvarsym) and
  561. not(sp_static in Tsym(p).symoptions) then
  562. begin
  563. append_entry(DW_TAG_member,false,[
  564. DW_AT_name,DW_FORM_string,tsym(p).name+#0,
  565. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(tfieldvarsym(p).fieldoffset)
  566. ]);
  567. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  568. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(tfieldvarsym(p).fieldoffset));
  569. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tfieldvarsym(p).vartype.def));
  570. finish_entry;
  571. end;
  572. end;
  573. procedure TDebugInfoDwarf.method_add_dwarftag(p:Tnamedindexitem;arg:pointer);
  574. begin
  575. end;
  576. procedure TDebugInfoDwarf.append_dwarftag(list:TAsmList;def:tdef);
  577. procedure append_dwarftag_orddef(def:torddef);
  578. begin
  579. case def.typ of
  580. s8bit,
  581. s16bit,
  582. s32bit :
  583. begin
  584. { we should generate a subrange type here }
  585. if assigned(def.typesym) then
  586. append_entry(DW_TAG_base_type,false,[
  587. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  588. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  589. DW_AT_byte_size,DW_FORM_data1,def.size
  590. ])
  591. else
  592. append_entry(DW_TAG_base_type,false,[
  593. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  594. DW_AT_byte_size,DW_FORM_data1,def.size
  595. ]);
  596. finish_entry;
  597. end;
  598. u8bit,
  599. u16bit,
  600. u32bit :
  601. begin
  602. { we should generate a subrange type here }
  603. if assigned(def.typesym) then
  604. append_entry(DW_TAG_base_type,false,[
  605. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  606. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  607. DW_AT_byte_size,DW_FORM_data1,def.size
  608. ])
  609. else
  610. append_entry(DW_TAG_base_type,false,[
  611. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  612. DW_AT_byte_size,DW_FORM_data1,def.size
  613. ]);
  614. finish_entry;
  615. end;
  616. uvoid :
  617. begin
  618. { gdb 6.4 doesn't support DW_TAG_unspecified_type so we
  619. replace it with a unsigned type with size 0 (FK)
  620. }
  621. append_entry(DW_TAG_base_type,false,[
  622. DW_AT_name,DW_FORM_string,'Void'#0,
  623. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  624. DW_AT_byte_size,DW_FORM_data1,0
  625. ]);
  626. finish_entry;
  627. end;
  628. uchar :
  629. begin
  630. append_entry(DW_TAG_base_type,false,[
  631. DW_AT_name,DW_FORM_string,'Char'#0,
  632. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned_char,
  633. DW_AT_byte_size,DW_FORM_data1,1
  634. ]);
  635. finish_entry;
  636. end;
  637. uwidechar :
  638. begin
  639. append_entry(DW_TAG_base_type,false,[
  640. DW_AT_name,DW_FORM_string,'WideChar'#0,
  641. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned_char,
  642. DW_AT_byte_size,DW_FORM_data1,2
  643. ]);
  644. finish_entry;
  645. end;
  646. bool8bit :
  647. begin
  648. append_entry(DW_TAG_base_type,false,[
  649. DW_AT_name,DW_FORM_string,'Boolean'#0,
  650. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned_char,
  651. DW_AT_byte_size,DW_FORM_data1,1
  652. ]);
  653. finish_entry;
  654. end;
  655. bool16bit :
  656. begin
  657. append_entry(DW_TAG_base_type,false,[
  658. DW_AT_name,DW_FORM_string,'WordBool'#0,
  659. DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
  660. DW_AT_byte_size,DW_FORM_data1,2
  661. ]);
  662. finish_entry;
  663. end;
  664. bool32bit :
  665. begin
  666. append_entry(DW_TAG_base_type,false,[
  667. DW_AT_name,DW_FORM_string,'LongBool'#0,
  668. DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
  669. DW_AT_byte_size,DW_FORM_data1,4
  670. ]);
  671. finish_entry;
  672. end;
  673. bool64bit :
  674. begin
  675. append_entry(DW_TAG_base_type,false,[
  676. DW_AT_name,DW_FORM_string,'QWordBool'#0,
  677. DW_AT_encoding,DW_FORM_data1,DW_ATE_boolean,
  678. DW_AT_byte_size,DW_FORM_data1,8
  679. ]);
  680. finish_entry;
  681. end;
  682. u64bit :
  683. begin
  684. append_entry(DW_TAG_base_type,false,[
  685. DW_AT_name,DW_FORM_string,'QWord'#0,
  686. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  687. DW_AT_byte_size,DW_FORM_data1,8
  688. ]);
  689. finish_entry;
  690. end;
  691. scurrency :
  692. begin
  693. { we should use DW_ATE_signed_fixed, however it isn't supported yet by GDB (FK) }
  694. append_entry(DW_TAG_base_type,false,[
  695. DW_AT_name,DW_FORM_string,'Currency'#0,
  696. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  697. DW_AT_byte_size,DW_FORM_data1,8
  698. ]);
  699. finish_entry;
  700. end;
  701. s64bit :
  702. begin
  703. append_entry(DW_TAG_base_type,false,[
  704. DW_AT_name,DW_FORM_string,'Int64'#0,
  705. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  706. DW_AT_byte_size,DW_FORM_data1,8
  707. ]);
  708. finish_entry;
  709. end;
  710. else
  711. internalerror(200601287);
  712. end;
  713. end;
  714. procedure append_dwarftag_floatdef(def:tfloatdef);
  715. begin
  716. case def.typ of
  717. s32real,
  718. s64real,
  719. s80real:
  720. if assigned(def.typesym) then
  721. append_entry(DW_TAG_base_type,false,[
  722. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  723. DW_AT_encoding,DW_FORM_data1,DW_ATE_float,
  724. DW_AT_byte_size,DW_FORM_data1,def.size
  725. ])
  726. else
  727. append_entry(DW_TAG_base_type,false,[
  728. DW_AT_encoding,DW_FORM_data1,DW_ATE_float,
  729. DW_AT_byte_size,DW_FORM_data1,def.size
  730. ]);
  731. s64currency:
  732. { we should use DW_ATE_signed_fixed, however it isn't supported yet by GDB (FK) }
  733. if assigned(def.typesym) then
  734. append_entry(DW_TAG_base_type,false,[
  735. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  736. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  737. DW_AT_byte_size,DW_FORM_data1,8
  738. ])
  739. else
  740. append_entry(DW_TAG_base_type,false,[
  741. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  742. DW_AT_byte_size,DW_FORM_data1,8
  743. ]);
  744. s64comp:
  745. if assigned(def.typesym) then
  746. append_entry(DW_TAG_base_type,false,[
  747. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  748. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  749. DW_AT_byte_size,DW_FORM_data1,8
  750. ])
  751. else
  752. append_entry(DW_TAG_base_type,false,[
  753. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  754. DW_AT_byte_size,DW_FORM_data1,8
  755. ]);
  756. else
  757. internalerror(200601289);
  758. end;
  759. finish_entry;
  760. end;
  761. procedure append_dwarftag_enumdef(def:tenumdef);
  762. var
  763. hp : tenumsym;
  764. begin
  765. if assigned(def.typesym) then
  766. append_entry(DW_TAG_enumeration_type,true,[
  767. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  768. DW_AT_byte_size,DW_FORM_data1,def.size
  769. ])
  770. else
  771. append_entry(DW_TAG_enumeration_type,true,[
  772. DW_AT_byte_size,DW_FORM_data1,def.size
  773. ]);
  774. if assigned(def.basedef) then
  775. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.basedef));
  776. finish_entry;
  777. { write enum symbols }
  778. hp:=tenumsym(def.firstenum);
  779. while assigned(hp) do
  780. begin
  781. append_entry(DW_TAG_enumerator,false,[
  782. DW_AT_name,DW_FORM_string,hp.name+#0,
  783. DW_AT_const_value,DW_FORM_data4,hp.value
  784. ]);
  785. finish_entry;
  786. hp:=tenumsym(hp).nextenum;
  787. end;
  788. finish_children;
  789. end;
  790. procedure append_dwarftag_arraydef(def:tarraydef);
  791. var
  792. size : aint;
  793. elesize : aint;
  794. begin
  795. if is_special_array(def) then
  796. size:=def.elesize
  797. else
  798. size:=def.size;
  799. if not is_packed_array(def) then
  800. elesize := def.elesize*8
  801. else
  802. elesize := def.elepackedbitsize;
  803. if assigned(def.typesym) then
  804. append_entry(DW_TAG_array_type,true,[
  805. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  806. DW_AT_byte_size,DW_FORM_udata,size,
  807. DW_AT_stride_size,DW_FORM_udata,elesize
  808. ])
  809. else
  810. append_entry(DW_TAG_array_type,true,[
  811. DW_AT_byte_size,DW_FORM_udata,size,
  812. DW_AT_stride_size,DW_FORM_udata,elesize
  813. ]);
  814. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.elementtype.def));
  815. if is_dynamic_array(def) then
  816. begin
  817. { !!! FIXME !!! }
  818. { gdb's dwarf implementation sucks, so we can't use DW_OP_push_object here (FK)
  819. { insert location attribute manually }
  820. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(DW_AT_data_location));
  821. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(DW_FORM_block1));
  822. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(1));
  823. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(DW_OP_push_object));
  824. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(DW_OP_deref));
  825. }
  826. finish_entry;
  827. { to simplify things, we don't write a multidimensional array here }
  828. append_entry(DW_TAG_subrange_type,false,[
  829. DW_AT_lower_bound,DW_FORM_udata,0,
  830. DW_AT_upper_bound,DW_FORM_udata,0
  831. ]);
  832. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def));
  833. finish_entry;
  834. end
  835. else
  836. begin
  837. finish_entry;
  838. { to simplify things, we don't write a multidimensional array here }
  839. append_entry(DW_TAG_subrange_type,false,[
  840. DW_AT_lower_bound,DW_FORM_sdata,def.lowrange,
  841. DW_AT_upper_bound,DW_FORM_sdata,def.highrange
  842. ]);
  843. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def));
  844. finish_entry;
  845. end;
  846. finish_children;
  847. end;
  848. procedure append_dwarftag_recorddef(def:trecorddef);
  849. begin
  850. if assigned(def.typesym) then
  851. append_entry(DW_TAG_structure_type,true,[
  852. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  853. DW_AT_byte_size,DW_FORM_udata,def.size
  854. ])
  855. else
  856. append_entry(DW_TAG_structure_type,true,[
  857. DW_AT_byte_size,DW_FORM_udata,def.size
  858. ]);
  859. finish_entry;
  860. def.symtable.foreach(@field_add_dwarftag,nil);
  861. finish_children;
  862. end;
  863. procedure append_dwarftag_objectdef(def:tobjectdef);
  864. procedure doappend;
  865. begin
  866. if assigned(def.objname) then
  867. append_entry(DW_TAG_structure_type,true,[
  868. DW_AT_name,DW_FORM_string,def.objname^+#0,
  869. DW_AT_byte_size,DW_FORM_udata,def.size
  870. ])
  871. else
  872. append_entry(DW_TAG_structure_type,true,[
  873. DW_AT_byte_size,DW_FORM_udata,def.size
  874. ]);
  875. finish_entry;
  876. if assigned(def.childof) then
  877. begin
  878. append_entry(DW_TAG_inheritance,false,[
  879. DW_AT_accessibility,DW_FORM_data1,DW_ACCESS_public,
  880. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
  881. ]);
  882. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  883. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
  884. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.childof));
  885. finish_entry;
  886. end;
  887. def.symtable.foreach(@field_add_dwarftag,nil);
  888. def.symtable.foreach(@method_add_dwarftag,nil);
  889. finish_children;
  890. end;
  891. var
  892. obj : tasmlabel;
  893. begin
  894. case def.objecttype of
  895. odt_cppclass,
  896. odt_object:
  897. doappend;
  898. odt_interfacecom,
  899. odt_interfacecorba,
  900. odt_dispinterface,
  901. odt_class:
  902. begin
  903. current_asmdata.getdatalabel(obj);
  904. { implicit pointer }
  905. append_entry(DW_TAG_pointer_type,false,[]);
  906. append_labelentry_ref(DW_AT_type,obj);
  907. finish_entry;
  908. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(obj,0));
  909. doappend;
  910. end;
  911. else
  912. internalerror(200602041);
  913. end;
  914. end;
  915. procedure append_dwarftag_pointerdef(def:tpointerdef);
  916. begin
  917. append_entry(DW_TAG_pointer_type,false,[]);
  918. if not(is_voidpointer(def)) then
  919. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.pointertype.def));
  920. finish_entry;
  921. end;
  922. procedure append_dwarftag_stringdef(def:tstringdef);
  923. var
  924. slen : aint;
  925. arr : tasmlabel;
  926. begin
  927. case def.string_typ of
  928. st_shortstring:
  929. begin
  930. { fix length of openshortstring }
  931. slen:=def.len;
  932. if slen=0 then
  933. slen:=255;
  934. { create a structure with two elements }
  935. current_asmdata.getdatalabel(arr);
  936. append_entry(DW_TAG_structure_type,true,[
  937. DW_AT_name,DW_FORM_string,'ShortString'#0,
  938. DW_AT_byte_size,DW_FORM_data1,2*sizeof(aint)
  939. ]);
  940. finish_entry;
  941. { length entry }
  942. append_entry(DW_TAG_member,false,[
  943. DW_AT_name,DW_FORM_string,'Length'#0,
  944. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
  945. ]);
  946. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  947. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
  948. append_labelentry_ref(DW_AT_type,def_dwarf_lab(u8inttype.def));
  949. finish_entry;
  950. { string data entry }
  951. append_entry(DW_TAG_member,false,[
  952. DW_AT_name,DW_FORM_string,'Data'#0,
  953. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(1)
  954. ]);
  955. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  956. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(1));
  957. append_labelentry_ref(DW_AT_type,arr);
  958. finish_entry;
  959. finish_children;
  960. { now the data array }
  961. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(arr,0));
  962. append_entry(DW_TAG_array_type,true,[
  963. DW_AT_byte_size,DW_FORM_udata,def.size,
  964. DW_AT_stride_size,DW_FORM_udata,1*8
  965. ]);
  966. append_labelentry_ref(DW_AT_type,def_dwarf_lab(cchartype.def));
  967. finish_entry;
  968. append_entry(DW_TAG_subrange_type,false,[
  969. DW_AT_lower_bound,DW_FORM_udata,0,
  970. DW_AT_upper_bound,DW_FORM_udata,slen
  971. ]);
  972. append_labelentry_ref(DW_AT_type,def_dwarf_lab(u8inttype.def));
  973. finish_entry;
  974. finish_children;
  975. end;
  976. st_longstring:
  977. begin
  978. {
  979. charst:=def_stab_number(cchartype.def);
  980. bytest:=def_stab_number(u8inttype.def);
  981. longst:=def_stab_number(u32inttype.def);
  982. result:=def_stabstr_evaluate(def,'s$1length:$2,0,32;dummy:$6,32,8;st:ar$2;1;$3;$4,40,$5;;',
  983. [tostr(def.len+5),longst,tostr(def.len),charst,tostr(def.len*8),bytest]);
  984. }
  985. end;
  986. st_ansistring:
  987. begin
  988. { looks like a pchar }
  989. append_entry(DW_TAG_pointer_type,false,[]);
  990. append_labelentry_ref(DW_AT_type,def_dwarf_lab(cchartype.def));
  991. finish_entry;
  992. end;
  993. st_widestring:
  994. begin
  995. { looks like a pwidechar }
  996. append_entry(DW_TAG_pointer_type,false,[]);
  997. append_labelentry_ref(DW_AT_type,def_dwarf_lab(cwidechartype.def));
  998. finish_entry;
  999. end;
  1000. end;
  1001. end;
  1002. procedure append_dwarftag_procvardef(def:tprocvardef);
  1003. procedure doappend;
  1004. var
  1005. i : longint;
  1006. begin
  1007. if assigned(def.typesym) then
  1008. append_entry(DW_TAG_subroutine_type,true,[
  1009. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1010. DW_AT_prototyped,DW_FORM_flag,true
  1011. ])
  1012. else
  1013. append_entry(DW_TAG_subroutine_type,true,[
  1014. DW_AT_prototyped,DW_FORM_flag,true
  1015. ]);
  1016. if not(is_void(tprocvardef(def).rettype.def)) then
  1017. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tprocvardef(def).rettype.def));
  1018. finish_entry;
  1019. { write parameters }
  1020. for i:=0 to def.paras.count-1 do
  1021. begin
  1022. append_entry(DW_TAG_formal_parameter,false,[
  1023. DW_AT_name,DW_FORM_string,tparavarsym(def.paras[i]).name+#0
  1024. ]);
  1025. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tparavarsym(def.paras[i]).vartype.def));
  1026. finish_entry;
  1027. end;
  1028. finish_children;
  1029. end;
  1030. var
  1031. proc : tasmlabel;
  1032. begin
  1033. if def.is_methodpointer then
  1034. begin
  1035. { create a structure with two elements }
  1036. current_asmdata.getdatalabel(proc);
  1037. append_entry(DW_TAG_structure_type,true,[
  1038. DW_AT_byte_size,DW_FORM_data1,2*sizeof(aint)
  1039. ]);
  1040. finish_entry;
  1041. { proc entry }
  1042. append_entry(DW_TAG_member,false,[
  1043. DW_AT_name,DW_FORM_string,'Proc'#0,
  1044. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
  1045. ]);
  1046. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  1047. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
  1048. append_labelentry_ref(DW_AT_type,proc);
  1049. finish_entry;
  1050. { self entry }
  1051. append_entry(DW_TAG_member,false,[
  1052. DW_AT_name,DW_FORM_string,'Self'#0,
  1053. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(aint))
  1054. ]);
  1055. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  1056. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(aint)));
  1057. append_labelentry_ref(DW_AT_type,def_dwarf_lab(class_tobject));
  1058. finish_entry;
  1059. finish_children;
  1060. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(proc,0));
  1061. doappend;
  1062. end
  1063. else
  1064. doappend;
  1065. end;
  1066. begin
  1067. list.concat(tai_symbol.create(def_dwarf_lab(def),0));
  1068. case def.deftype of
  1069. stringdef :
  1070. append_dwarftag_stringdef(tstringdef(def));
  1071. enumdef :
  1072. append_dwarftag_enumdef(tenumdef(def));
  1073. orddef :
  1074. append_dwarftag_orddef(torddef(def));
  1075. pointerdef :
  1076. append_dwarftag_pointerdef(tpointerdef(def));
  1077. floatdef :
  1078. append_dwarftag_floatdef(tfloatdef(def));
  1079. filedef :
  1080. begin
  1081. { gdb 6.4 doesn't support files so far so we use some fake recorddef
  1082. { file recs. are less than 1k so using data2 is enough }
  1083. if assigned(def.typesym) then
  1084. append_entry(DW_TAG_file_type,false,[
  1085. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1086. DW_AT_byte_size,DW_FORM_data2,def.size
  1087. ])
  1088. else
  1089. append_entry(DW_TAG_file_type,false,[
  1090. DW_AT_byte_size,DW_FORM_data2,def.size
  1091. ]);
  1092. if tfiledef(def).filetyp=ft_typed then
  1093. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tfiledef(def).typedfiletype.def));
  1094. }
  1095. if assigned(def.typesym) then
  1096. append_entry(DW_TAG_structure_type,false,[
  1097. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1098. DW_AT_byte_size,DW_FORM_udata,def.size
  1099. ])
  1100. else
  1101. append_entry(DW_TAG_structure_type,false,[
  1102. DW_AT_byte_size,DW_FORM_udata,def.size
  1103. ]);
  1104. finish_entry;
  1105. end;
  1106. recorddef :
  1107. append_dwarftag_recorddef(trecorddef(def));
  1108. variantdef :
  1109. { variants aren't known to dwarf but writting tvardata should be enough }
  1110. append_dwarftag_recorddef(trecorddef(vardatadef));
  1111. classrefdef :
  1112. append_dwarftag_pointerdef(tpointerdef(pvmttype.def));
  1113. setdef :
  1114. begin
  1115. { at least gdb up to 6.4 doesn't support sets in dwarf, there is a patch available to fix this:
  1116. http://sources.redhat.com/ml/gdb-patches/2005-05/msg00278.html (FK)
  1117. if assigned(def.typesym) then
  1118. append_entry(DW_TAG_set_type,false,[
  1119. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1120. DW_AT_byte_size,DW_FORM_data2,def.size
  1121. ])
  1122. else
  1123. append_entry(DW_TAG_set_type,false,[
  1124. DW_AT_byte_size,DW_FORM_data2,def.size
  1125. ]);
  1126. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tsetdef(def).elementtype.def));
  1127. finish_entry;
  1128. }
  1129. if assigned(def.typesym) then
  1130. append_entry(DW_TAG_base_type,false,[
  1131. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1132. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1133. DW_AT_byte_size,DW_FORM_data2,def.size
  1134. ])
  1135. else
  1136. append_entry(DW_TAG_base_type,false,[
  1137. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1138. DW_AT_byte_size,DW_FORM_data2,def.size
  1139. ]);
  1140. finish_entry;
  1141. end;
  1142. formaldef :
  1143. begin
  1144. { gdb 6.4 doesn't support DW_TAG_unspecified_type so we
  1145. replace it with a unsigned type with size 0 (FK)
  1146. }
  1147. append_entry(DW_TAG_base_type,false,[
  1148. DW_AT_name,DW_FORM_string,'FormalDef'#0,
  1149. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1150. DW_AT_byte_size,DW_FORM_data1,0
  1151. ]);
  1152. finish_entry;
  1153. end;
  1154. arraydef :
  1155. append_dwarftag_arraydef(tarraydef(def));
  1156. procvardef :
  1157. append_dwarftag_procvardef(tprocvardef(def));
  1158. objectdef :
  1159. append_dwarftag_objectdef(tobjectdef(def));
  1160. undefineddef :
  1161. begin
  1162. { gdb 6.4 doesn't support DW_TAG_unspecified_type so we
  1163. replace it with a unsigned type with size 0 (FK)
  1164. }
  1165. append_entry(DW_TAG_base_type,false,[
  1166. DW_AT_name,DW_FORM_string,'FormalDef'#0,
  1167. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1168. DW_AT_byte_size,DW_FORM_data1,0
  1169. ]);
  1170. finish_entry;
  1171. end;
  1172. else
  1173. internalerror(200601281);
  1174. end;
  1175. end;
  1176. procedure TDebugInfoDwarf.insertdef(list:TAsmList;def:tdef);
  1177. var
  1178. anc : tobjectdef;
  1179. oldtypesym : tsym;
  1180. i : longint;
  1181. begin
  1182. if (def.dbg_state in [dbg_state_writing,dbg_state_written]) then
  1183. exit;
  1184. { never write generic template defs }
  1185. if df_generic in def.defoptions then
  1186. begin
  1187. def.dbg_state:=dbg_state_written;
  1188. exit;
  1189. end;
  1190. { to avoid infinite loops }
  1191. def.dbg_state := dbg_state_writing;
  1192. { write dependencies first }
  1193. case def.deftype of
  1194. stringdef :
  1195. begin
  1196. if tstringdef(def).string_typ=st_widestring then
  1197. insertdef(list,cwidechartype.def)
  1198. else
  1199. begin
  1200. insertdef(list,cchartype.def);
  1201. insertdef(list,u8inttype.def);
  1202. end;
  1203. end;
  1204. floatdef :
  1205. insertdef(list,s32inttype.def);
  1206. filedef :
  1207. begin
  1208. insertdef(list,s32inttype.def);
  1209. {$ifdef cpu64bit}
  1210. insertdef(list,s64inttype.def);
  1211. {$endif cpu64bit}
  1212. insertdef(list,u8inttype.def);
  1213. insertdef(list,cchartype.def);
  1214. end;
  1215. classrefdef :
  1216. insertdef(list,pvmttype.def);
  1217. pointerdef :
  1218. insertdef(list,tpointerdef(def).pointertype.def);
  1219. setdef :
  1220. if assigned(tsetdef(def).elementtype.def) then
  1221. insertdef(list,tsetdef(def).elementtype.def);
  1222. procvardef:
  1223. begin
  1224. insertdef(list,tprocvardef(def).rettype.def);
  1225. if tprocvardef(def).is_methodpointer then
  1226. insertdef(list,class_tobject);
  1227. { parameters }
  1228. for i:=0 to tprocvardef(def).paras.count-1 do
  1229. insertdef(list,tparavarsym(tprocvardef(def).paras[i]).vartype.def);
  1230. end;
  1231. procdef :
  1232. insertdef(list,tprocdef(def).rettype.def);
  1233. enumdef :
  1234. if assigned(tenumdef(def).basedef) then
  1235. insertdef(list,tenumdef(def).basedef);
  1236. arraydef :
  1237. begin
  1238. insertdef(list,tarraydef(def).rangetype.def);
  1239. insertdef(list,tarraydef(def).elementtype.def);
  1240. end;
  1241. recorddef :
  1242. trecorddef(def).symtable.foreach(@field_write_defs,list);
  1243. variantdef :
  1244. trecorddef(vardatadef).symtable.foreach(@field_write_defs,list);
  1245. objectdef :
  1246. begin
  1247. insertdef(list,vmtarraytype.def);
  1248. { first the parents }
  1249. anc:=tobjectdef(def);
  1250. while assigned(anc.childof) do
  1251. begin
  1252. anc:=anc.childof;
  1253. insertdef(list,anc);
  1254. end;
  1255. tobjectdef(def).symtable.foreach(@field_write_defs,list);
  1256. tobjectdef(def).symtable.foreach(@method_write_defs,list);
  1257. end;
  1258. end;
  1259. append_dwarftag(list,def);
  1260. def.dbg_state:=dbg_state_written;
  1261. end;
  1262. procedure TDebugInfoDwarf.write_symtable_defs(list:TAsmList;st:tsymtable);
  1263. procedure dowritedwarf(list:TAsmList;st:tsymtable);
  1264. var
  1265. p : tdef;
  1266. begin
  1267. p:=tdef(st.defindex.first);
  1268. while assigned(p) do
  1269. begin
  1270. if (p.dbg_state=dbg_state_used) then
  1271. insertdef(list,p);
  1272. p:=tdef(p.indexnext);
  1273. end;
  1274. end;
  1275. var
  1276. old_writing_def_dwarf : boolean;
  1277. begin
  1278. case st.symtabletype of
  1279. staticsymtable :
  1280. list.concat(tai_comment.Create(strpnew('Defs - Begin Staticsymtable')));
  1281. globalsymtable :
  1282. list.concat(tai_comment.Create(strpnew('Defs - Begin unit '+st.name^+' has index '+tostr(st.moduleid))));
  1283. end;
  1284. old_writing_def_dwarf:=writing_def_dwarf;
  1285. writing_def_dwarf:=true;
  1286. dowritedwarf(list,st);
  1287. writing_def_dwarf:=old_writing_def_dwarf;
  1288. case st.symtabletype of
  1289. staticsymtable :
  1290. list.concat(tai_comment.Create(strpnew('Defs - End Staticsymtable')));
  1291. globalsymtable :
  1292. list.concat(tai_comment.Create(strpnew('Defs - End unit '+st.name^+' has index '+tostr(st.moduleid))));
  1293. end;
  1294. end;
  1295. procedure TDebugInfoDwarf.append_procdef(list:TAsmList;pd:tprocdef);
  1296. var
  1297. procendlabel : tasmlabel;
  1298. mangled_length : longint;
  1299. p : pchar;
  1300. hs : string;
  1301. begin
  1302. if assigned(pd.procstarttai) then
  1303. begin
  1304. append_entry(DW_TAG_subprogram,true,
  1305. [DW_AT_name,DW_FORM_string,pd.procsym.name+#0
  1306. { data continues below }
  1307. { problem: base reg isn't known here
  1308. DW_AT_frame_base,DW_FORM_block1,1
  1309. }
  1310. ]);
  1311. { append block data }
  1312. { current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(dwarf_reg(pd.))); }
  1313. if not(is_void(tprocdef(pd).rettype.def)) then
  1314. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tprocdef(pd).rettype.def));
  1315. { mark end of procedure }
  1316. current_asmdata.getlabel(procendlabel,alt_dbgtype);
  1317. current_asmdata.asmlists[al_procedures].insertbefore(tai_label.create(procendlabel),pd.procendtai);
  1318. append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(pd.mangledname));
  1319. append_labelentry(DW_AT_high_pc,procendlabel);
  1320. {
  1321. if assigned(pd.funcretsym) and
  1322. (tabstractnormalvarsym(pd.funcretsym).refs>0) then
  1323. begin
  1324. if tabstractnormalvarsym(pd.funcretsym).localloc.loc=LOC_REFERENCE then
  1325. begin
  1326. {$warning Need to add gdb support for ret in param register calling}
  1327. if paramanager.ret_in_param(pd.rettype.def,pd.proccalloption) then
  1328. hs:='X*'
  1329. else
  1330. hs:='X';
  1331. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  1332. '"'+pd.procsym.name+':'+hs+def_stab_number(pd.rettype.def)+'",'+
  1333. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  1334. if (m_result in aktmodeswitches) then
  1335. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  1336. '"RESULT:'+hs+def_stab_number(pd.rettype.def)+'",'+
  1337. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  1338. end;
  1339. end;
  1340. }
  1341. finish_entry;
  1342. {
  1343. { para types }
  1344. write_def_stabstr(templist,pd);
  1345. }
  1346. if assigned(pd.parast) then
  1347. write_symtable_syms(list,pd.parast);
  1348. { local type defs and vars should not be written
  1349. inside the main proc stab }
  1350. if assigned(pd.localst) and
  1351. (pd.localst.symtabletype=localsymtable) then
  1352. write_symtable_syms(list,pd.localst);
  1353. { last write the types from this procdef }
  1354. if assigned(pd.parast) then
  1355. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],pd.parast);
  1356. if assigned(pd.localst) and
  1357. (pd.localst.symtabletype=localsymtable) then
  1358. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],pd.localst);
  1359. finish_children;
  1360. end;
  1361. end;
  1362. procedure TDebugInfoDwarf.insertsym(list:TAsmList;sym:tsym);
  1363. procedure append_varsym(sym:tabstractnormalvarsym);
  1364. var
  1365. templist : TAsmList;
  1366. blocksize : longint;
  1367. tag : tdwarf_tag;
  1368. dreg : byte;
  1369. begin
  1370. { external symbols can't be resolved at link time, so we
  1371. can't generate stabs for them
  1372. not sure if this applies to dwarf as well (FK)
  1373. }
  1374. if vo_is_external in sym.varoptions then
  1375. exit;
  1376. { There is no space allocated for not referenced locals }
  1377. if (sym.owner.symtabletype=localsymtable) and (sym.refs=0) then
  1378. exit;
  1379. templist:=TAsmList.create;
  1380. case sym.localloc.loc of
  1381. LOC_REGISTER,
  1382. LOC_CREGISTER,
  1383. LOC_MMREGISTER,
  1384. LOC_CMMREGISTER,
  1385. LOC_FPUREGISTER,
  1386. LOC_CFPUREGISTER :
  1387. begin
  1388. templist.concat(tai_const.create_8bit(ord(DW_OP_regx)));
  1389. dreg:=dwarf_reg(sym.localloc.register);
  1390. templist.concat(tai_const.create_uleb128bit(dreg));
  1391. blocksize:=1+Lengthuleb128(dreg);
  1392. end;
  1393. else
  1394. begin
  1395. case sym.typ of
  1396. globalvarsym:
  1397. begin
  1398. if (vo_is_thread_var in sym.varoptions) then
  1399. begin
  1400. {$warning !!! FIXME: dwarf for thread vars !!!}
  1401. blocksize:=0;
  1402. end
  1403. else
  1404. begin
  1405. templist.concat(tai_const.create_8bit(3));
  1406. templist.concat(tai_const.createname(sym.mangledname,0));
  1407. blocksize:=1+sizeof(aword);
  1408. end;
  1409. end;
  1410. paravarsym,
  1411. localvarsym:
  1412. begin
  1413. dreg:=dwarf_reg(sym.localloc.reference.base);
  1414. templist.concat(tai_const.create_8bit(ord(DW_OP_breg0)+dreg));
  1415. templist.concat(tai_const.create_sleb128bit(sym.localloc.reference.offset));
  1416. blocksize:=1+Lengthsleb128(sym.localloc.reference.offset);
  1417. end
  1418. else
  1419. internalerror(200601288);
  1420. end;
  1421. end;
  1422. end;
  1423. if sym.typ=paravarsym then
  1424. tag:=DW_TAG_formal_parameter
  1425. else
  1426. tag:=DW_TAG_variable;
  1427. append_entry(tag,false,[
  1428. DW_AT_name,DW_FORM_string,sym.name+#0,
  1429. {
  1430. DW_AT_decl_file,DW_FORM_data1,0,
  1431. DW_AT_decl_line,DW_FORM_data1,
  1432. }
  1433. DW_AT_external,DW_FORM_flag,true,
  1434. { data continues below }
  1435. DW_AT_location,DW_FORM_block1,blocksize
  1436. ]);
  1437. { append block data }
  1438. current_asmdata.asmlists[al_dwarf_info].concatlist(templist);
  1439. append_labelentry_ref(DW_AT_type,def_dwarf_lab(sym.vartype.def));
  1440. templist.free;
  1441. finish_entry;
  1442. end;
  1443. procedure append_constsym(sym:tconstsym);
  1444. begin
  1445. append_entry(DW_TAG_constant,false,[
  1446. DW_AT_name,DW_FORM_string,sym.name+#0
  1447. ]);
  1448. { for string constants, consttype isn't set because they have no real type }
  1449. if not(sym.consttyp in [conststring,constresourcestring]) then
  1450. append_labelentry_ref(DW_AT_type,def_dwarf_lab(sym.consttype.def));
  1451. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_AT_const_value)));
  1452. case sym.consttyp of
  1453. conststring:
  1454. begin
  1455. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_string)));
  1456. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(strpas(pchar(sym.value.valueptr))));
  1457. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  1458. end;
  1459. constset,
  1460. constwstring,
  1461. constguid,
  1462. constresourcestring:
  1463. begin
  1464. { write dummy for now }
  1465. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_string)));
  1466. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(''));
  1467. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  1468. end;
  1469. constord:
  1470. begin
  1471. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_sdata)));
  1472. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sleb128bit(sym.value.valueord));
  1473. end;
  1474. constnil:
  1475. begin
  1476. {$ifdef cpu64bit}
  1477. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data8)));
  1478. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(0));
  1479. {$else cpu64bit}
  1480. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data4)));
  1481. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(0));
  1482. {$endif cpu64bit}
  1483. end;
  1484. constpointer:
  1485. begin
  1486. {$ifdef cpu64bit}
  1487. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data8)));
  1488. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(sym.value.valueordptr));
  1489. {$else cpu64bit}
  1490. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data4)));
  1491. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(sym.value.valueordptr));
  1492. {$endif cpu64bit}
  1493. end;
  1494. constreal:
  1495. begin
  1496. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_block1)));
  1497. case tfloatdef(sym.consttype.def).typ of
  1498. s32real:
  1499. begin
  1500. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(4));
  1501. current_asmdata.asmlists[al_dwarf_info].concat(tai_real_32bit.create(psingle(sym.value.valueptr)^));
  1502. end;
  1503. s64comp,
  1504. s64currency,
  1505. s64real:
  1506. begin
  1507. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(8));
  1508. current_asmdata.asmlists[al_dwarf_info].concat(tai_real_64bit.create(pdouble(sym.value.valueptr)^));
  1509. end;
  1510. s80real:
  1511. begin
  1512. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(10));
  1513. current_asmdata.asmlists[al_dwarf_info].concat(tai_real_80bit.create(pextended(sym.value.valueptr)^));
  1514. end;
  1515. else
  1516. internalerror(200601291);
  1517. end;
  1518. end;
  1519. else
  1520. internalerror(200601292);
  1521. end;
  1522. finish_entry;
  1523. end;
  1524. procedure append_procsym(sym:tprocsym);
  1525. var
  1526. i : longint;
  1527. begin
  1528. for i:=1 to sym.procdef_count do
  1529. append_procdef(list,sym.procdef[i]);
  1530. end;
  1531. procedure append_absolutesym(sym:tabsolutevarsym);
  1532. var
  1533. templist : TAsmList;
  1534. blocksize : longint;
  1535. symlist : psymlistitem;
  1536. begin
  1537. templist:=TAsmList.create;
  1538. case tabsolutevarsym(sym).abstyp of
  1539. toaddr :
  1540. begin
  1541. {$ifdef i386}
  1542. { in theory, we could write a DW_AT_segment entry here for sym.absseg,
  1543. however I doubt that gdb supports this (FK) }
  1544. {$endif i386}
  1545. templist.concat(tai_const.create_8bit(3));
  1546. templist.concat(tai_const.create_aint(sym.addroffset));
  1547. blocksize:=1+sizeof(aword);
  1548. end;
  1549. toasm :
  1550. begin
  1551. templist.concat(tai_const.create_8bit(3));
  1552. templist.concat(tai_const.createname(sym.mangledname,0));
  1553. blocksize:=1+sizeof(aword);
  1554. end;
  1555. tovar:
  1556. begin
  1557. symlist:=tabsolutevarsym(sym).ref.firstsym;
  1558. { can we insert the symbol? }
  1559. if assigned(symlist) and
  1560. (symlist^.sltype=sl_load) then
  1561. insertsym(list,symlist^.sym);
  1562. templist.free;
  1563. exit;
  1564. end;
  1565. end;
  1566. append_entry(DW_TAG_variable,false,[
  1567. DW_AT_name,DW_FORM_string,sym.name+#0,
  1568. {
  1569. DW_AT_decl_file,DW_FORM_data1,0,
  1570. DW_AT_decl_line,DW_FORM_data1,
  1571. }
  1572. DW_AT_external,DW_FORM_flag,true,
  1573. { data continues below }
  1574. DW_AT_location,DW_FORM_block1,blocksize
  1575. ]);
  1576. { append block data }
  1577. current_asmdata.asmlists[al_dwarf_info].concatlist(templist);
  1578. append_labelentry_ref(DW_AT_type,def_dwarf_lab(sym.vartype.def));
  1579. templist.free;
  1580. finish_entry;
  1581. end;
  1582. begin
  1583. case sym.typ of
  1584. globalvarsym :
  1585. append_varsym(tglobalvarsym(sym));
  1586. unitsym:
  1587. { for now, we ignore unit symbols }
  1588. ;
  1589. procsym :
  1590. append_procsym(tprocsym(sym));
  1591. labelsym :
  1592. { ignore label syms for now, the problem is that a label sym
  1593. can have more than one label associated e.g. in case of
  1594. an inline procedure expansion }
  1595. ;
  1596. localvarsym :
  1597. append_varsym(tlocalvarsym(sym));
  1598. paravarsym :
  1599. append_varsym(tparavarsym(sym));
  1600. typedconstsym :
  1601. begin
  1602. append_entry(DW_TAG_variable,false,[
  1603. DW_AT_name,DW_FORM_string,sym.name+#0,
  1604. {
  1605. DW_AT_decl_file,DW_FORM_data1,0,
  1606. DW_AT_decl_line,DW_FORM_data1,
  1607. }
  1608. DW_AT_external,DW_FORM_flag,true,
  1609. { data continues below }
  1610. DW_AT_location,DW_FORM_block1,1+sizeof(aword)
  1611. ]);
  1612. { append block data }
  1613. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(3));
  1614. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.createname(sym.mangledname,0));
  1615. append_labelentry_ref(DW_AT_type,def_dwarf_lab(ttypedconstsym(sym).typedconsttype.def));
  1616. finish_entry;
  1617. end;
  1618. constsym :
  1619. append_constsym(tconstsym(sym));
  1620. typesym :
  1621. begin
  1622. append_entry(DW_TAG_typedef,false,[
  1623. DW_AT_name,DW_FORM_string,sym.name+#0
  1624. ]);
  1625. append_labelentry_ref(DW_AT_type,def_dwarf_lab(ttypesym(sym).restype.def));
  1626. finish_entry;
  1627. end;
  1628. enumsym :
  1629. { ignore enum syms, they are written by the owner }
  1630. ;
  1631. rttisym :
  1632. { ignore rtti syms, they are only of internal use }
  1633. ;
  1634. syssym :
  1635. { ignore sys syms, they are only of internal use }
  1636. ;
  1637. absolutevarsym :
  1638. append_absolutesym(tabsolutevarsym(sym));
  1639. propertysym :
  1640. { ignored for now }
  1641. ;
  1642. else
  1643. begin
  1644. writeln(ord(sym.typ));
  1645. internalerror(200601242);
  1646. end;
  1647. end;
  1648. {
  1649. { For object types write also the symtable entries }
  1650. if (sym.typ=typesym) and (ttypesym(sym).restype.def.deftype=objectdef) then
  1651. write_symtable_syms(list,tobjectdef(ttypesym(sym).restype.def).symtable);
  1652. sym.isstabwritten:=true;
  1653. }
  1654. end;
  1655. procedure TDebugInfoDwarf.write_symtable_syms(list:TAsmList;st:tsymtable);
  1656. var
  1657. p : tsym;
  1658. begin
  1659. case st.symtabletype of
  1660. staticsymtable :
  1661. list.concat(tai_comment.Create(strpnew('Syms - Begin Staticsymtable')));
  1662. globalsymtable :
  1663. list.concat(tai_comment.Create(strpnew('Syms - Begin unit '+st.name^+' has index '+tostr(st.moduleid))));
  1664. end;
  1665. p:=tsym(st.symindex.first);
  1666. while assigned(p) do
  1667. begin
  1668. if (not p.isstabwritten) then
  1669. insertsym(list,p);
  1670. p:=tsym(p.indexnext);
  1671. end;
  1672. case st.symtabletype of
  1673. staticsymtable :
  1674. list.concat(tai_comment.Create(strpnew('Syms - End Staticsymtable')));
  1675. globalsymtable :
  1676. list.concat(tai_comment.Create(strpnew('Syms - End unit '+st.name^+' has index '+tostr(st.moduleid))));
  1677. end;
  1678. end;
  1679. procedure TDebugInfoDwarf.insertmoduleinfo;
  1680. var
  1681. templist : TAsmList;
  1682. begin
  1683. { insert .Ltext0 label }
  1684. templist:=TAsmList.create;
  1685. new_section(templist,sec_code,'',0);
  1686. templist.concat(tai_symbol.createname('.Ltext0',AT_DATA,0));
  1687. current_asmdata.asmlists[al_start].insertlist(templist);
  1688. templist.free;
  1689. { insert .Letext0 label }
  1690. templist:=TAsmList.create;
  1691. new_section(templist,sec_code,'',0);
  1692. templist.concat(tai_symbol.createname('.Letext0',AT_DATA,0));
  1693. current_asmdata.asmlists[al_end].insertlist(templist);
  1694. templist.free;
  1695. { insert .Ldebug_abbrev0 label }
  1696. templist:=TAsmList.create;
  1697. new_section(templist,sec_debug_abbrev,'',0);
  1698. templist.concat(tai_symbol.createname('.Ldebug_abbrev0',AT_DATA,0));
  1699. current_asmdata.asmlists[al_start].insertlist(templist);
  1700. templist.free;
  1701. { insert .Ldebug_line0 label }
  1702. templist:=TAsmList.create;
  1703. new_section(templist,sec_debug_line,'',0);
  1704. templist.concat(tai_symbol.createname('.Ldebug_line0',AT_DATA,0));
  1705. current_asmdata.asmlists[al_start].insertlist(templist);
  1706. templist.free;
  1707. end;
  1708. procedure TDebugInfoDwarf.inserttypeinfo;
  1709. var
  1710. storefilepos : tfileposinfo;
  1711. lenstartlabel : tasmlabel;
  1712. i : longint;
  1713. begin
  1714. storefilepos:=aktfilepos;
  1715. aktfilepos:=current_module.mainfilepos;
  1716. currabbrevnumber:=0;
  1717. writing_def_dwarf:=false;
  1718. nextdefnumber:=0;
  1719. defnumberlist:=TFPObjectList.create(false);
  1720. vardatadef:=search_system_type('TVARDATA').restype.def;
  1721. { not exported (FK)
  1722. filerecdef:=gettypedef('FILEREC');
  1723. textrecdef:=gettypedef('TEXTREC');
  1724. }
  1725. { write start labels }
  1726. current_asmdata.asmlists[al_dwarf_info].concat(tai_section.create(sec_debug_info,'',0));
  1727. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname('.Ldebug_info0',AT_DATA,0));
  1728. { start abbrev section }
  1729. new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0);
  1730. { debug info header }
  1731. current_asmdata.getlabel(lenstartlabel,alt_dbgfile);
  1732. { size }
  1733. { currently we create only 32 bit dwarf }
  1734. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(aitconst_32bit,
  1735. lenstartlabel,tasmsymbol.create('.Ledebug_info0',AB_COMMON,AT_DATA)));
  1736. current_asmdata.asmlists[al_dwarf_info].concat(tai_label.create(lenstartlabel));
  1737. { version }
  1738. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_16bit(2));
  1739. { abbrev table }
  1740. if isdwarf64 then
  1741. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_64bit,
  1742. current_asmdata.RefAsmSymbol('.Ldebug_abbrev0')))
  1743. else
  1744. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_32bit,
  1745. current_asmdata.RefAsmSymbol('.Ldebug_abbrev0')));
  1746. { address size }
  1747. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(aint)));
  1748. append_entry(DW_TAG_compile_unit,true,[
  1749. DW_AT_name,DW_FORM_string,FixFileName(current_module.sourcefiles.get_file(1).name^)+#0,
  1750. DW_AT_producer,DW_FORM_string,'Free Pascal '+full_version_string+' '+date_string+#0,
  1751. DW_AT_comp_dir,DW_FORM_string,BsToSlash(FixPath(current_module.sourcefiles.get_file(1).path^,false))+#0,
  1752. DW_AT_language,DW_FORM_data1,DW_LANG_Pascal83,
  1753. DW_AT_identifier_case,DW_FORM_data1,DW_ID_case_insensitive]);
  1754. { reference to line info section }
  1755. append_labelentry_data(DW_AT_stmt_list,current_asmdata.RefAsmSymbol('.Ldebug_line0'));
  1756. append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol('.Ltext0'));
  1757. append_labelentry(DW_AT_high_pc,current_asmdata.RefAsmSymbol('.Letext0'));
  1758. finish_entry;
  1759. { first write all global/local symbols. This will flag all required tdefs }
  1760. if assigned(current_module.globalsymtable) then
  1761. write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
  1762. if assigned(current_module.localsymtable) then
  1763. write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.localsymtable);
  1764. { reset unit type info flag }
  1765. reset_unit_type_info;
  1766. { write used types from the used units }
  1767. write_used_unit_type_info(current_asmdata.asmlists[al_dwarf_info],current_module);
  1768. { last write the types from this unit }
  1769. if assigned(current_module.globalsymtable) then
  1770. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
  1771. if assigned(current_module.localsymtable) then
  1772. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],current_module.localsymtable);
  1773. { close compilation unit entry }
  1774. finish_children;
  1775. { end of debug info table }
  1776. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  1777. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname('.Ledebug_info0',AT_DATA,0));
  1778. { reset all def labels }
  1779. for i:=0 to defnumberlist.count-1 do
  1780. begin
  1781. if assigned(defnumberlist[i]) then
  1782. begin
  1783. tdef(defnumberlist[i]).dwarf_lab:=nil;
  1784. tdef(defnumberlist[i]).dbg_state:=dbg_state_unused;
  1785. end;
  1786. end;
  1787. defnumberlist.free;
  1788. defnumberlist:=nil;
  1789. aktfilepos:=storefilepos;
  1790. end;
  1791. procedure TDebugInfoDwarf.referencesections(list:TAsmList);
  1792. begin
  1793. end;
  1794. procedure TDebugInfoDwarf.insertlineinfo(list:TAsmList);
  1795. var
  1796. currfileinfo,
  1797. lastfileinfo : tfileposinfo;
  1798. currfuncname : pstring;
  1799. currsectype : TAsmSectiontype;
  1800. hlabel : tasmlabel;
  1801. hp : tai;
  1802. infile : tinputfile;
  1803. current_file : tai_file;
  1804. begin
  1805. FillChar(lastfileinfo,sizeof(lastfileinfo),0);
  1806. currfuncname:=nil;
  1807. currsectype:=sec_code;
  1808. hp:=Tai(list.first);
  1809. while assigned(hp) do
  1810. begin
  1811. case hp.typ of
  1812. ait_section :
  1813. currsectype:=tai_section(hp).sectype;
  1814. ait_function_name :
  1815. currfuncname:=tai_function_name(hp).funcname;
  1816. ait_force_line :
  1817. lastfileinfo.line:=-1;
  1818. end;
  1819. if (currsectype=sec_code) and
  1820. (hp.typ=ait_instruction) then
  1821. begin
  1822. currfileinfo:=tailineinfo(hp).fileinfo;
  1823. { file changed ? (must be before line info) }
  1824. if (currfileinfo.fileindex<>0) and
  1825. (lastfileinfo.fileindex<>currfileinfo.fileindex) then
  1826. begin
  1827. infile:=current_module.sourcefiles.get_file(currfileinfo.fileindex);
  1828. if assigned(infile) then
  1829. begin
  1830. if (infile.path^<>'') then
  1831. begin
  1832. current_file:=tai_file.create(BsToSlash(FixPath(infile.path^,false)+FixFileName(infile.name^)));
  1833. list.insertbefore(current_file,hp)
  1834. end
  1835. else
  1836. begin
  1837. current_file:=tai_file.create(FixFileName(infile.name^));
  1838. list.insertbefore(current_file,hp);
  1839. end;
  1840. { force new line info }
  1841. lastfileinfo.line:=-1;
  1842. end;
  1843. end;
  1844. { line changed ? }
  1845. if (lastfileinfo.line<>currfileinfo.line) and (currfileinfo.line<>0) then
  1846. list.insertbefore(tai_loc.create(
  1847. current_file,currfileinfo.line,currfileinfo.column),hp);
  1848. lastfileinfo:=currfileinfo;
  1849. end;
  1850. hp:=tai(hp.next);
  1851. end;
  1852. end;
  1853. const
  1854. dbg_dwarf_info : tdbginfo =
  1855. (
  1856. id : dbg_dwarf;
  1857. idtxt : 'DWARF';
  1858. );
  1859. initialization
  1860. RegisterDebugInfo(dbg_dwarf_info,TDebugInfoDwarf);
  1861. end.