dbgdwarf.pas 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067
  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. u64bit :
  674. begin
  675. append_entry(DW_TAG_base_type,false,[
  676. DW_AT_name,DW_FORM_string,'QWord'#0,
  677. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  678. DW_AT_byte_size,DW_FORM_data1,8
  679. ]);
  680. finish_entry;
  681. end;
  682. scurrency :
  683. begin
  684. { we should use DW_ATE_signed_fixed, however it isn't supported yet by GDB (FK) }
  685. append_entry(DW_TAG_base_type,false,[
  686. DW_AT_name,DW_FORM_string,'Currency'#0,
  687. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  688. DW_AT_byte_size,DW_FORM_data1,8
  689. ]);
  690. finish_entry;
  691. end;
  692. s64bit :
  693. begin
  694. append_entry(DW_TAG_base_type,false,[
  695. DW_AT_name,DW_FORM_string,'Int64'#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. else
  702. internalerror(200601287);
  703. end;
  704. end;
  705. procedure append_dwarftag_floatdef(def:tfloatdef);
  706. begin
  707. case def.typ of
  708. s32real,
  709. s64real,
  710. s80real:
  711. if assigned(def.typesym) then
  712. append_entry(DW_TAG_base_type,false,[
  713. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  714. DW_AT_encoding,DW_FORM_data1,DW_ATE_float,
  715. DW_AT_byte_size,DW_FORM_data1,def.size
  716. ])
  717. else
  718. append_entry(DW_TAG_base_type,false,[
  719. DW_AT_encoding,DW_FORM_data1,DW_ATE_float,
  720. DW_AT_byte_size,DW_FORM_data1,def.size
  721. ]);
  722. s64currency:
  723. { we should use DW_ATE_signed_fixed, however it isn't supported yet by GDB (FK) }
  724. if assigned(def.typesym) then
  725. append_entry(DW_TAG_base_type,false,[
  726. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  727. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  728. DW_AT_byte_size,DW_FORM_data1,8
  729. ])
  730. else
  731. append_entry(DW_TAG_base_type,false,[
  732. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  733. DW_AT_byte_size,DW_FORM_data1,8
  734. ]);
  735. s64comp:
  736. if assigned(def.typesym) then
  737. append_entry(DW_TAG_base_type,false,[
  738. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  739. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  740. DW_AT_byte_size,DW_FORM_data1,8
  741. ])
  742. else
  743. append_entry(DW_TAG_base_type,false,[
  744. DW_AT_encoding,DW_FORM_data1,DW_ATE_signed,
  745. DW_AT_byte_size,DW_FORM_data1,8
  746. ]);
  747. else
  748. internalerror(200601289);
  749. end;
  750. finish_entry;
  751. end;
  752. procedure append_dwarftag_enumdef(def:tenumdef);
  753. var
  754. hp : tenumsym;
  755. begin
  756. if assigned(def.typesym) then
  757. append_entry(DW_TAG_enumeration_type,true,[
  758. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  759. DW_AT_byte_size,DW_FORM_data1,def.size
  760. ])
  761. else
  762. append_entry(DW_TAG_enumeration_type,true,[
  763. DW_AT_byte_size,DW_FORM_data1,def.size
  764. ]);
  765. if assigned(def.basedef) then
  766. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.basedef));
  767. finish_entry;
  768. { write enum symbols }
  769. hp:=tenumsym(def.firstenum);
  770. while assigned(hp) do
  771. begin
  772. append_entry(DW_TAG_enumerator,false,[
  773. DW_AT_name,DW_FORM_string,hp.name+#0,
  774. DW_AT_const_value,DW_FORM_data4,hp.value
  775. ]);
  776. finish_entry;
  777. hp:=tenumsym(hp).nextenum;
  778. end;
  779. finish_children;
  780. end;
  781. procedure append_dwarftag_arraydef(def:tarraydef);
  782. var
  783. size : aint;
  784. begin
  785. if is_special_array(def) then
  786. size:=def.elesize
  787. else
  788. size:=def.size;
  789. if assigned(def.typesym) then
  790. append_entry(DW_TAG_array_type,true,[
  791. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  792. DW_AT_byte_size,DW_FORM_udata,size,
  793. DW_AT_stride_size,DW_FORM_udata,def.elesize*8
  794. ])
  795. else
  796. append_entry(DW_TAG_array_type,true,[
  797. DW_AT_byte_size,DW_FORM_udata,size,
  798. DW_AT_stride_size,DW_FORM_udata,def.elesize*8
  799. ]);
  800. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.elementtype.def));
  801. if is_dynamic_array(def) then
  802. begin
  803. { !!! FIXME !!! }
  804. { gdb's dwarf implementation sucks, so we can't use DW_OP_push_object here (FK)
  805. { insert location attribute manually }
  806. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(DW_AT_data_location));
  807. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(DW_FORM_block1));
  808. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(1));
  809. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(DW_OP_push_object));
  810. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(DW_OP_deref));
  811. }
  812. finish_entry;
  813. { to simplify things, we don't write a multidimensional array here }
  814. append_entry(DW_TAG_subrange_type,false,[
  815. DW_AT_lower_bound,DW_FORM_udata,0,
  816. DW_AT_upper_bound,DW_FORM_udata,0
  817. ]);
  818. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def));
  819. finish_entry;
  820. end
  821. else
  822. begin
  823. finish_entry;
  824. { to simplify things, we don't write a multidimensional array here }
  825. append_entry(DW_TAG_subrange_type,false,[
  826. DW_AT_lower_bound,DW_FORM_sdata,def.lowrange,
  827. DW_AT_upper_bound,DW_FORM_sdata,def.highrange
  828. ]);
  829. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.rangetype.def));
  830. finish_entry;
  831. end;
  832. finish_children;
  833. end;
  834. procedure append_dwarftag_recorddef(def:trecorddef);
  835. begin
  836. if assigned(def.typesym) then
  837. append_entry(DW_TAG_structure_type,true,[
  838. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  839. DW_AT_byte_size,DW_FORM_udata,def.size
  840. ])
  841. else
  842. append_entry(DW_TAG_structure_type,true,[
  843. DW_AT_byte_size,DW_FORM_udata,def.size
  844. ]);
  845. finish_entry;
  846. def.symtable.foreach(@field_add_dwarftag,nil);
  847. finish_children;
  848. end;
  849. procedure append_dwarftag_objectdef(def:tobjectdef);
  850. procedure doappend;
  851. begin
  852. if assigned(def.objname) then
  853. append_entry(DW_TAG_structure_type,true,[
  854. DW_AT_name,DW_FORM_string,def.objname^+#0,
  855. DW_AT_byte_size,DW_FORM_udata,def.size
  856. ])
  857. else
  858. append_entry(DW_TAG_structure_type,true,[
  859. DW_AT_byte_size,DW_FORM_udata,def.size
  860. ]);
  861. finish_entry;
  862. if assigned(def.childof) then
  863. begin
  864. append_entry(DW_TAG_inheritance,false,[
  865. DW_AT_accessibility,DW_FORM_data1,DW_ACCESS_public,
  866. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
  867. ]);
  868. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  869. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
  870. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.childof));
  871. finish_entry;
  872. end;
  873. def.symtable.foreach(@field_add_dwarftag,nil);
  874. def.symtable.foreach(@method_add_dwarftag,nil);
  875. finish_children;
  876. end;
  877. var
  878. obj : tasmlabel;
  879. begin
  880. case def.objecttype of
  881. odt_cppclass,
  882. odt_object:
  883. doappend;
  884. odt_interfacecom,
  885. odt_interfacecorba,
  886. odt_dispinterface,
  887. odt_class:
  888. begin
  889. current_asmdata.getdatalabel(obj);
  890. { implicit pointer }
  891. append_entry(DW_TAG_pointer_type,false,[]);
  892. append_labelentry_ref(DW_AT_type,obj);
  893. finish_entry;
  894. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(obj,0));
  895. doappend;
  896. end;
  897. else
  898. internalerror(200602041);
  899. end;
  900. end;
  901. procedure append_dwarftag_pointerdef(def:tpointerdef);
  902. begin
  903. append_entry(DW_TAG_pointer_type,false,[]);
  904. if not(is_voidpointer(def)) then
  905. append_labelentry_ref(DW_AT_type,def_dwarf_lab(def.pointertype.def));
  906. finish_entry;
  907. end;
  908. procedure append_dwarftag_stringdef(def:tstringdef);
  909. var
  910. slen : aint;
  911. arr : tasmlabel;
  912. begin
  913. case def.string_typ of
  914. st_shortstring:
  915. begin
  916. { fix length of openshortstring }
  917. slen:=def.len;
  918. if slen=0 then
  919. slen:=255;
  920. { create a structure with two elements }
  921. current_asmdata.getdatalabel(arr);
  922. append_entry(DW_TAG_structure_type,true,[
  923. DW_AT_name,DW_FORM_string,'ShortString'#0,
  924. DW_AT_byte_size,DW_FORM_data1,2*sizeof(aint)
  925. ]);
  926. finish_entry;
  927. { length entry }
  928. append_entry(DW_TAG_member,false,[
  929. DW_AT_name,DW_FORM_string,'Length'#0,
  930. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
  931. ]);
  932. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  933. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
  934. append_labelentry_ref(DW_AT_type,def_dwarf_lab(u8inttype.def));
  935. finish_entry;
  936. { string data entry }
  937. append_entry(DW_TAG_member,false,[
  938. DW_AT_name,DW_FORM_string,'Data'#0,
  939. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(1)
  940. ]);
  941. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  942. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(1));
  943. append_labelentry_ref(DW_AT_type,arr);
  944. finish_entry;
  945. finish_children;
  946. { now the data array }
  947. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(arr,0));
  948. append_entry(DW_TAG_array_type,true,[
  949. DW_AT_byte_size,DW_FORM_udata,def.size,
  950. DW_AT_stride_size,DW_FORM_udata,1*8
  951. ]);
  952. append_labelentry_ref(DW_AT_type,def_dwarf_lab(cchartype.def));
  953. finish_entry;
  954. append_entry(DW_TAG_subrange_type,false,[
  955. DW_AT_lower_bound,DW_FORM_udata,0,
  956. DW_AT_upper_bound,DW_FORM_udata,slen
  957. ]);
  958. append_labelentry_ref(DW_AT_type,def_dwarf_lab(u8inttype.def));
  959. finish_entry;
  960. finish_children;
  961. end;
  962. st_longstring:
  963. begin
  964. {
  965. charst:=def_stab_number(cchartype.def);
  966. bytest:=def_stab_number(u8inttype.def);
  967. longst:=def_stab_number(u32inttype.def);
  968. result:=def_stabstr_evaluate(def,'s$1length:$2,0,32;dummy:$6,32,8;st:ar$2;1;$3;$4,40,$5;;',
  969. [tostr(def.len+5),longst,tostr(def.len),charst,tostr(def.len*8),bytest]);
  970. }
  971. end;
  972. st_ansistring:
  973. begin
  974. { looks like a pchar }
  975. append_entry(DW_TAG_pointer_type,false,[]);
  976. append_labelentry_ref(DW_AT_type,def_dwarf_lab(cchartype.def));
  977. finish_entry;
  978. end;
  979. st_widestring:
  980. begin
  981. { looks like a pwidechar }
  982. append_entry(DW_TAG_pointer_type,false,[]);
  983. append_labelentry_ref(DW_AT_type,def_dwarf_lab(cwidechartype.def));
  984. finish_entry;
  985. end;
  986. end;
  987. end;
  988. procedure append_dwarftag_procvardef(def:tprocvardef);
  989. procedure doappend;
  990. var
  991. i : longint;
  992. begin
  993. if assigned(def.typesym) then
  994. append_entry(DW_TAG_subroutine_type,true,[
  995. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  996. DW_AT_prototyped,DW_FORM_flag,true
  997. ])
  998. else
  999. append_entry(DW_TAG_subroutine_type,true,[
  1000. DW_AT_prototyped,DW_FORM_flag,true
  1001. ]);
  1002. if not(is_void(tprocvardef(def).rettype.def)) then
  1003. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tprocvardef(def).rettype.def));
  1004. finish_entry;
  1005. { write parameters }
  1006. for i:=0 to def.paras.count-1 do
  1007. begin
  1008. append_entry(DW_TAG_formal_parameter,false,[
  1009. DW_AT_name,DW_FORM_string,tparavarsym(def.paras[i]).name+#0
  1010. ]);
  1011. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tparavarsym(def.paras[i]).vartype.def));
  1012. finish_entry;
  1013. end;
  1014. finish_children;
  1015. end;
  1016. var
  1017. proc : tasmlabel;
  1018. begin
  1019. if def.is_methodpointer then
  1020. begin
  1021. { create a structure with two elements }
  1022. current_asmdata.getdatalabel(proc);
  1023. append_entry(DW_TAG_structure_type,true,[
  1024. DW_AT_byte_size,DW_FORM_data1,2*sizeof(aint)
  1025. ]);
  1026. finish_entry;
  1027. { proc entry }
  1028. append_entry(DW_TAG_member,false,[
  1029. DW_AT_name,DW_FORM_string,'Proc'#0,
  1030. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(0)
  1031. ]);
  1032. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  1033. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(0));
  1034. append_labelentry_ref(DW_AT_type,proc);
  1035. finish_entry;
  1036. { self entry }
  1037. append_entry(DW_TAG_member,false,[
  1038. DW_AT_name,DW_FORM_string,'Self'#0,
  1039. DW_AT_data_member_location,DW_FORM_block1,1+lengthuleb128(sizeof(aint))
  1040. ]);
  1041. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(ord(DW_OP_plus_uconst)));
  1042. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_uleb128bit(sizeof(aint)));
  1043. append_labelentry_ref(DW_AT_type,def_dwarf_lab(class_tobject));
  1044. finish_entry;
  1045. finish_children;
  1046. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.create(proc,0));
  1047. doappend;
  1048. end
  1049. else
  1050. doappend;
  1051. end;
  1052. begin
  1053. list.concat(tai_symbol.create(def_dwarf_lab(def),0));
  1054. case def.deftype of
  1055. stringdef :
  1056. append_dwarftag_stringdef(tstringdef(def));
  1057. enumdef :
  1058. append_dwarftag_enumdef(tenumdef(def));
  1059. orddef :
  1060. append_dwarftag_orddef(torddef(def));
  1061. pointerdef :
  1062. append_dwarftag_pointerdef(tpointerdef(def));
  1063. floatdef :
  1064. append_dwarftag_floatdef(tfloatdef(def));
  1065. filedef :
  1066. begin
  1067. { gdb 6.4 doesn't support files so far so we use some fake recorddef
  1068. { file recs. are less than 1k so using data2 is enough }
  1069. if assigned(def.typesym) then
  1070. append_entry(DW_TAG_file_type,false,[
  1071. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1072. DW_AT_byte_size,DW_FORM_data2,def.size
  1073. ])
  1074. else
  1075. append_entry(DW_TAG_file_type,false,[
  1076. DW_AT_byte_size,DW_FORM_data2,def.size
  1077. ]);
  1078. if tfiledef(def).filetyp=ft_typed then
  1079. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tfiledef(def).typedfiletype.def));
  1080. }
  1081. if assigned(def.typesym) then
  1082. append_entry(DW_TAG_structure_type,false,[
  1083. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1084. DW_AT_byte_size,DW_FORM_udata,def.size
  1085. ])
  1086. else
  1087. append_entry(DW_TAG_structure_type,false,[
  1088. DW_AT_byte_size,DW_FORM_udata,def.size
  1089. ]);
  1090. finish_entry;
  1091. end;
  1092. recorddef :
  1093. append_dwarftag_recorddef(trecorddef(def));
  1094. variantdef :
  1095. { variants aren't known to dwarf but writting tvardata should be enough }
  1096. append_dwarftag_recorddef(trecorddef(vardatadef));
  1097. classrefdef :
  1098. append_dwarftag_pointerdef(tpointerdef(pvmttype.def));
  1099. setdef :
  1100. begin
  1101. { at least gdb up to 6.4 doesn't support sets in dwarf, there is a patch available to fix this:
  1102. http://sources.redhat.com/ml/gdb-patches/2005-05/msg00278.html (FK)
  1103. if assigned(def.typesym) then
  1104. append_entry(DW_TAG_set_type,false,[
  1105. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1106. DW_AT_byte_size,DW_FORM_data2,def.size
  1107. ])
  1108. else
  1109. append_entry(DW_TAG_set_type,false,[
  1110. DW_AT_byte_size,DW_FORM_data2,def.size
  1111. ]);
  1112. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tsetdef(def).elementtype.def));
  1113. finish_entry;
  1114. }
  1115. if assigned(def.typesym) then
  1116. append_entry(DW_TAG_base_type,false,[
  1117. DW_AT_name,DW_FORM_string,def.typesym.name+#0,
  1118. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1119. DW_AT_byte_size,DW_FORM_data2,def.size
  1120. ])
  1121. else
  1122. append_entry(DW_TAG_base_type,false,[
  1123. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1124. DW_AT_byte_size,DW_FORM_data2,def.size
  1125. ]);
  1126. finish_entry;
  1127. end;
  1128. formaldef :
  1129. begin
  1130. { gdb 6.4 doesn't support DW_TAG_unspecified_type so we
  1131. replace it with a unsigned type with size 0 (FK)
  1132. }
  1133. append_entry(DW_TAG_base_type,false,[
  1134. DW_AT_name,DW_FORM_string,'FormalDef'#0,
  1135. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1136. DW_AT_byte_size,DW_FORM_data1,0
  1137. ]);
  1138. finish_entry;
  1139. end;
  1140. arraydef :
  1141. append_dwarftag_arraydef(tarraydef(def));
  1142. procvardef :
  1143. append_dwarftag_procvardef(tprocvardef(def));
  1144. objectdef :
  1145. append_dwarftag_objectdef(tobjectdef(def));
  1146. undefineddef :
  1147. begin
  1148. { gdb 6.4 doesn't support DW_TAG_unspecified_type so we
  1149. replace it with a unsigned type with size 0 (FK)
  1150. }
  1151. append_entry(DW_TAG_base_type,false,[
  1152. DW_AT_name,DW_FORM_string,'FormalDef'#0,
  1153. DW_AT_encoding,DW_FORM_data1,DW_ATE_unsigned,
  1154. DW_AT_byte_size,DW_FORM_data1,0
  1155. ]);
  1156. finish_entry;
  1157. end;
  1158. else
  1159. internalerror(200601281);
  1160. end;
  1161. end;
  1162. procedure TDebugInfoDwarf.insertdef(list:TAsmList;def:tdef);
  1163. var
  1164. anc : tobjectdef;
  1165. oldtypesym : tsym;
  1166. i : longint;
  1167. begin
  1168. if (def.dbg_state in [dbg_state_writing,dbg_state_written]) then
  1169. exit;
  1170. { never write generic template defs }
  1171. if df_generic in def.defoptions then
  1172. begin
  1173. def.dbg_state:=dbg_state_written;
  1174. exit;
  1175. end;
  1176. { to avoid infinite loops }
  1177. def.dbg_state := dbg_state_writing;
  1178. { write dependencies first }
  1179. case def.deftype of
  1180. stringdef :
  1181. begin
  1182. if tstringdef(def).string_typ=st_widestring then
  1183. insertdef(list,cwidechartype.def)
  1184. else
  1185. begin
  1186. insertdef(list,cchartype.def);
  1187. insertdef(list,u8inttype.def);
  1188. end;
  1189. end;
  1190. floatdef :
  1191. insertdef(list,s32inttype.def);
  1192. filedef :
  1193. begin
  1194. insertdef(list,s32inttype.def);
  1195. {$ifdef cpu64bit}
  1196. insertdef(list,s64inttype.def);
  1197. {$endif cpu64bit}
  1198. insertdef(list,u8inttype.def);
  1199. insertdef(list,cchartype.def);
  1200. end;
  1201. classrefdef :
  1202. insertdef(list,pvmttype.def);
  1203. pointerdef :
  1204. insertdef(list,tpointerdef(def).pointertype.def);
  1205. setdef :
  1206. if assigned(tsetdef(def).elementtype.def) then
  1207. insertdef(list,tsetdef(def).elementtype.def);
  1208. procvardef:
  1209. begin
  1210. insertdef(list,tprocvardef(def).rettype.def);
  1211. if tprocvardef(def).is_methodpointer then
  1212. insertdef(list,class_tobject);
  1213. { parameters }
  1214. for i:=0 to tprocvardef(def).paras.count-1 do
  1215. insertdef(list,tparavarsym(tprocvardef(def).paras[i]).vartype.def);
  1216. end;
  1217. procdef :
  1218. insertdef(list,tprocdef(def).rettype.def);
  1219. enumdef :
  1220. if assigned(tenumdef(def).basedef) then
  1221. insertdef(list,tenumdef(def).basedef);
  1222. arraydef :
  1223. begin
  1224. insertdef(list,tarraydef(def).rangetype.def);
  1225. insertdef(list,tarraydef(def).elementtype.def);
  1226. end;
  1227. recorddef :
  1228. trecorddef(def).symtable.foreach(@field_write_defs,list);
  1229. variantdef :
  1230. trecorddef(vardatadef).symtable.foreach(@field_write_defs,list);
  1231. objectdef :
  1232. begin
  1233. insertdef(list,vmtarraytype.def);
  1234. { first the parents }
  1235. anc:=tobjectdef(def);
  1236. while assigned(anc.childof) do
  1237. begin
  1238. anc:=anc.childof;
  1239. insertdef(list,anc);
  1240. end;
  1241. tobjectdef(def).symtable.foreach(@field_write_defs,list);
  1242. tobjectdef(def).symtable.foreach(@method_write_defs,list);
  1243. end;
  1244. end;
  1245. append_dwarftag(list,def);
  1246. def.dbg_state:=dbg_state_written;
  1247. end;
  1248. procedure TDebugInfoDwarf.write_symtable_defs(list:TAsmList;st:tsymtable);
  1249. procedure dowritedwarf(list:TAsmList;st:tsymtable);
  1250. var
  1251. p : tdef;
  1252. begin
  1253. p:=tdef(st.defindex.first);
  1254. while assigned(p) do
  1255. begin
  1256. if (p.dbg_state=dbg_state_used) then
  1257. insertdef(list,p);
  1258. p:=tdef(p.indexnext);
  1259. end;
  1260. end;
  1261. var
  1262. old_writing_def_dwarf : boolean;
  1263. begin
  1264. case st.symtabletype of
  1265. staticsymtable :
  1266. list.concat(tai_comment.Create(strpnew('Defs - Begin Staticsymtable')));
  1267. globalsymtable :
  1268. list.concat(tai_comment.Create(strpnew('Defs - Begin unit '+st.name^+' has index '+tostr(st.moduleid))));
  1269. end;
  1270. old_writing_def_dwarf:=writing_def_dwarf;
  1271. writing_def_dwarf:=true;
  1272. dowritedwarf(list,st);
  1273. writing_def_dwarf:=old_writing_def_dwarf;
  1274. case st.symtabletype of
  1275. staticsymtable :
  1276. list.concat(tai_comment.Create(strpnew('Defs - End Staticsymtable')));
  1277. globalsymtable :
  1278. list.concat(tai_comment.Create(strpnew('Defs - End unit '+st.name^+' has index '+tostr(st.moduleid))));
  1279. end;
  1280. end;
  1281. procedure TDebugInfoDwarf.append_procdef(list:TAsmList;pd:tprocdef);
  1282. var
  1283. procendlabel : tasmlabel;
  1284. mangled_length : longint;
  1285. p : pchar;
  1286. hs : string;
  1287. begin
  1288. if assigned(pd.procstarttai) then
  1289. begin
  1290. append_entry(DW_TAG_subprogram,true,
  1291. [DW_AT_name,DW_FORM_string,pd.procsym.name+#0
  1292. { data continues below }
  1293. { problem: base reg isn't known here
  1294. DW_AT_frame_base,DW_FORM_block1,1
  1295. }
  1296. ]);
  1297. { append block data }
  1298. { current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(dwarf_reg(pd.))); }
  1299. if not(is_void(tprocdef(pd).rettype.def)) then
  1300. append_labelentry_ref(DW_AT_type,def_dwarf_lab(tprocdef(pd).rettype.def));
  1301. { mark end of procedure }
  1302. current_asmdata.getlabel(procendlabel,alt_dbgtype);
  1303. current_asmdata.asmlists[al_procedures].insertbefore(tai_label.create(procendlabel),pd.procendtai);
  1304. append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol(pd.mangledname));
  1305. append_labelentry(DW_AT_high_pc,procendlabel);
  1306. {
  1307. if assigned(pd.funcretsym) and
  1308. (tabstractnormalvarsym(pd.funcretsym).refs>0) then
  1309. begin
  1310. if tabstractnormalvarsym(pd.funcretsym).localloc.loc=LOC_REFERENCE then
  1311. begin
  1312. {$warning Need to add gdb support for ret in param register calling}
  1313. if paramanager.ret_in_param(pd.rettype.def,pd.proccalloption) then
  1314. hs:='X*'
  1315. else
  1316. hs:='X';
  1317. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  1318. '"'+pd.procsym.name+':'+hs+def_stab_number(pd.rettype.def)+'",'+
  1319. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  1320. if (m_result in aktmodeswitches) then
  1321. templist.concat(Tai_stab.create(stab_stabs,strpnew(
  1322. '"RESULT:'+hs+def_stab_number(pd.rettype.def)+'",'+
  1323. tostr(N_tsym)+',0,0,'+tostr(tabstractnormalvarsym(pd.funcretsym).localloc.reference.offset))));
  1324. end;
  1325. end;
  1326. }
  1327. finish_entry;
  1328. {
  1329. { para types }
  1330. write_def_stabstr(templist,pd);
  1331. }
  1332. if assigned(pd.parast) then
  1333. write_symtable_syms(list,pd.parast);
  1334. { local type defs and vars should not be written
  1335. inside the main proc stab }
  1336. if assigned(pd.localst) and
  1337. (pd.localst.symtabletype=localsymtable) then
  1338. write_symtable_syms(list,pd.localst);
  1339. { last write the types from this procdef }
  1340. if assigned(pd.parast) then
  1341. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],pd.parast);
  1342. if assigned(pd.localst) and
  1343. (pd.localst.symtabletype=localsymtable) then
  1344. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],pd.localst);
  1345. finish_children;
  1346. end;
  1347. end;
  1348. procedure TDebugInfoDwarf.insertsym(list:TAsmList;sym:tsym);
  1349. procedure append_varsym(sym:tabstractnormalvarsym);
  1350. var
  1351. templist : TAsmList;
  1352. blocksize : longint;
  1353. tag : tdwarf_tag;
  1354. dreg : byte;
  1355. begin
  1356. { external symbols can't be resolved at link time, so we
  1357. can't generate stabs for them
  1358. not sure if this applies to dwarf as well (FK)
  1359. }
  1360. if vo_is_external in sym.varoptions then
  1361. exit;
  1362. { There is no space allocated for not referenced locals }
  1363. if (sym.owner.symtabletype=localsymtable) and (sym.refs=0) then
  1364. exit;
  1365. templist:=TAsmList.create;
  1366. case sym.localloc.loc of
  1367. LOC_REGISTER,
  1368. LOC_CREGISTER,
  1369. LOC_MMREGISTER,
  1370. LOC_CMMREGISTER,
  1371. LOC_FPUREGISTER,
  1372. LOC_CFPUREGISTER :
  1373. begin
  1374. templist.concat(tai_const.create_8bit(ord(DW_OP_regx)));
  1375. dreg:=dwarf_reg(sym.localloc.register);
  1376. templist.concat(tai_const.create_uleb128bit(dreg));
  1377. blocksize:=1+Lengthuleb128(dreg);
  1378. end;
  1379. else
  1380. begin
  1381. case sym.typ of
  1382. globalvarsym:
  1383. begin
  1384. if (vo_is_thread_var in sym.varoptions) then
  1385. begin
  1386. {$warning !!! FIXME: dwarf for thread vars !!!}
  1387. blocksize:=0;
  1388. end
  1389. else
  1390. begin
  1391. templist.concat(tai_const.create_8bit(3));
  1392. templist.concat(tai_const.createname(sym.mangledname,0));
  1393. blocksize:=1+sizeof(aword);
  1394. end;
  1395. end;
  1396. paravarsym,
  1397. localvarsym:
  1398. begin
  1399. dreg:=dwarf_reg(sym.localloc.reference.base);
  1400. templist.concat(tai_const.create_8bit(ord(DW_OP_breg0)+dreg));
  1401. templist.concat(tai_const.create_sleb128bit(sym.localloc.reference.offset));
  1402. blocksize:=1+Lengthsleb128(sym.localloc.reference.offset);
  1403. end
  1404. else
  1405. internalerror(200601288);
  1406. end;
  1407. end;
  1408. end;
  1409. if sym.typ=paravarsym then
  1410. tag:=DW_TAG_formal_parameter
  1411. else
  1412. tag:=DW_TAG_variable;
  1413. append_entry(tag,false,[
  1414. DW_AT_name,DW_FORM_string,sym.name+#0,
  1415. {
  1416. DW_AT_decl_file,DW_FORM_data1,0,
  1417. DW_AT_decl_line,DW_FORM_data1,
  1418. }
  1419. DW_AT_external,DW_FORM_flag,true,
  1420. { data continues below }
  1421. DW_AT_location,DW_FORM_block1,blocksize
  1422. ]);
  1423. { append block data }
  1424. current_asmdata.asmlists[al_dwarf_info].concatlist(templist);
  1425. append_labelentry_ref(DW_AT_type,def_dwarf_lab(sym.vartype.def));
  1426. templist.free;
  1427. finish_entry;
  1428. end;
  1429. procedure append_constsym(sym:tconstsym);
  1430. begin
  1431. append_entry(DW_TAG_constant,false,[
  1432. DW_AT_name,DW_FORM_string,sym.name+#0
  1433. ]);
  1434. { for string constants, consttype isn't set because they have no real type }
  1435. if not(sym.consttyp in [conststring,constresourcestring]) then
  1436. append_labelentry_ref(DW_AT_type,def_dwarf_lab(sym.consttype.def));
  1437. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_AT_const_value)));
  1438. case sym.consttyp of
  1439. conststring:
  1440. begin
  1441. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_string)));
  1442. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(strpas(pchar(sym.value.valueptr))));
  1443. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  1444. end;
  1445. constset,
  1446. constwstring,
  1447. constguid,
  1448. constresourcestring:
  1449. begin
  1450. { write dummy for now }
  1451. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_string)));
  1452. current_asmdata.asmlists[al_dwarf_info].concat(tai_string.create(''));
  1453. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  1454. end;
  1455. constord:
  1456. begin
  1457. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_sdata)));
  1458. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_sleb128bit(sym.value.valueord));
  1459. end;
  1460. constnil:
  1461. begin
  1462. {$ifdef cpu64bit}
  1463. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data8)));
  1464. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(0));
  1465. {$else cpu64bit}
  1466. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data4)));
  1467. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(0));
  1468. {$endif cpu64bit}
  1469. end;
  1470. constpointer:
  1471. begin
  1472. {$ifdef cpu64bit}
  1473. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data8)));
  1474. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_64bit(sym.value.valueordptr));
  1475. {$else cpu64bit}
  1476. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_data4)));
  1477. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_32bit(sym.value.valueordptr));
  1478. {$endif cpu64bit}
  1479. end;
  1480. constreal:
  1481. begin
  1482. current_asmdata.asmlists[al_dwarf_abbrev].concat(tai_const.create_uleb128bit(ord(DW_FORM_block1)));
  1483. case tfloatdef(sym.consttype.def).typ of
  1484. s32real:
  1485. begin
  1486. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(4));
  1487. current_asmdata.asmlists[al_dwarf_info].concat(tai_real_32bit.create(psingle(sym.value.valueptr)^));
  1488. end;
  1489. s64comp,
  1490. s64currency,
  1491. s64real:
  1492. begin
  1493. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(8));
  1494. current_asmdata.asmlists[al_dwarf_info].concat(tai_real_64bit.create(pdouble(sym.value.valueptr)^));
  1495. end;
  1496. s80real:
  1497. begin
  1498. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(10));
  1499. current_asmdata.asmlists[al_dwarf_info].concat(tai_real_80bit.create(pextended(sym.value.valueptr)^));
  1500. end;
  1501. else
  1502. internalerror(200601291);
  1503. end;
  1504. end;
  1505. else
  1506. internalerror(200601292);
  1507. end;
  1508. finish_entry;
  1509. end;
  1510. procedure append_procsym(sym:tprocsym);
  1511. var
  1512. i : longint;
  1513. begin
  1514. for i:=1 to sym.procdef_count do
  1515. append_procdef(list,sym.procdef[i]);
  1516. end;
  1517. procedure append_absolutesym(sym:tabsolutevarsym);
  1518. var
  1519. templist : TAsmList;
  1520. blocksize : longint;
  1521. symlist : psymlistitem;
  1522. begin
  1523. templist:=TAsmList.create;
  1524. case tabsolutevarsym(sym).abstyp of
  1525. toaddr :
  1526. begin
  1527. {$ifdef i386}
  1528. { in theory, we could write a DW_AT_segment entry here for sym.absseg,
  1529. however I doubt that gdb supports this (FK) }
  1530. {$endif i386}
  1531. templist.concat(tai_const.create_8bit(3));
  1532. templist.concat(tai_const.create_aint(sym.addroffset));
  1533. blocksize:=1+sizeof(aword);
  1534. end;
  1535. toasm :
  1536. begin
  1537. templist.concat(tai_const.create_8bit(3));
  1538. templist.concat(tai_const.createname(sym.mangledname,0));
  1539. blocksize:=1+sizeof(aword);
  1540. end;
  1541. tovar:
  1542. begin
  1543. symlist:=tabsolutevarsym(sym).ref.firstsym;
  1544. { can we insert the symbol? }
  1545. if assigned(symlist) and
  1546. (symlist^.sltype=sl_load) then
  1547. insertsym(list,symlist^.sym);
  1548. templist.free;
  1549. exit;
  1550. end;
  1551. end;
  1552. append_entry(DW_TAG_variable,false,[
  1553. DW_AT_name,DW_FORM_string,sym.name+#0,
  1554. {
  1555. DW_AT_decl_file,DW_FORM_data1,0,
  1556. DW_AT_decl_line,DW_FORM_data1,
  1557. }
  1558. DW_AT_external,DW_FORM_flag,true,
  1559. { data continues below }
  1560. DW_AT_location,DW_FORM_block1,blocksize
  1561. ]);
  1562. { append block data }
  1563. current_asmdata.asmlists[al_dwarf_info].concatlist(templist);
  1564. append_labelentry_ref(DW_AT_type,def_dwarf_lab(sym.vartype.def));
  1565. templist.free;
  1566. finish_entry;
  1567. end;
  1568. begin
  1569. case sym.typ of
  1570. globalvarsym :
  1571. append_varsym(tglobalvarsym(sym));
  1572. unitsym:
  1573. { for now, we ignore unit symbols }
  1574. ;
  1575. procsym :
  1576. append_procsym(tprocsym(sym));
  1577. labelsym :
  1578. { ignore label syms for now, the problem is that a label sym
  1579. can have more than one label associated e.g. in case of
  1580. an inline procedure expansion }
  1581. ;
  1582. localvarsym :
  1583. append_varsym(tlocalvarsym(sym));
  1584. paravarsym :
  1585. append_varsym(tparavarsym(sym));
  1586. typedconstsym :
  1587. begin
  1588. append_entry(DW_TAG_variable,false,[
  1589. DW_AT_name,DW_FORM_string,sym.name+#0,
  1590. {
  1591. DW_AT_decl_file,DW_FORM_data1,0,
  1592. DW_AT_decl_line,DW_FORM_data1,
  1593. }
  1594. DW_AT_external,DW_FORM_flag,true,
  1595. { data continues below }
  1596. DW_AT_location,DW_FORM_block1,1+sizeof(aword)
  1597. ]);
  1598. { append block data }
  1599. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(3));
  1600. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.createname(sym.mangledname,0));
  1601. append_labelentry_ref(DW_AT_type,def_dwarf_lab(ttypedconstsym(sym).typedconsttype.def));
  1602. finish_entry;
  1603. end;
  1604. constsym :
  1605. append_constsym(tconstsym(sym));
  1606. typesym :
  1607. begin
  1608. append_entry(DW_TAG_typedef,false,[
  1609. DW_AT_name,DW_FORM_string,sym.name+#0
  1610. ]);
  1611. append_labelentry_ref(DW_AT_type,def_dwarf_lab(ttypesym(sym).restype.def));
  1612. finish_entry;
  1613. end;
  1614. enumsym :
  1615. { ignore enum syms, they are written by the owner }
  1616. ;
  1617. rttisym :
  1618. { ignore rtti syms, they are only of internal use }
  1619. ;
  1620. syssym :
  1621. { ignore sys syms, they are only of internal use }
  1622. ;
  1623. absolutevarsym :
  1624. append_absolutesym(tabsolutevarsym(sym));
  1625. propertysym :
  1626. { ignored for now }
  1627. ;
  1628. else
  1629. begin
  1630. writeln(ord(sym.typ));
  1631. internalerror(200601242);
  1632. end;
  1633. end;
  1634. {
  1635. { For object types write also the symtable entries }
  1636. if (sym.typ=typesym) and (ttypesym(sym).restype.def.deftype=objectdef) then
  1637. write_symtable_syms(list,tobjectdef(ttypesym(sym).restype.def).symtable);
  1638. sym.isstabwritten:=true;
  1639. }
  1640. end;
  1641. procedure TDebugInfoDwarf.write_symtable_syms(list:TAsmList;st:tsymtable);
  1642. var
  1643. p : tsym;
  1644. begin
  1645. case st.symtabletype of
  1646. staticsymtable :
  1647. list.concat(tai_comment.Create(strpnew('Syms - Begin Staticsymtable')));
  1648. globalsymtable :
  1649. list.concat(tai_comment.Create(strpnew('Syms - Begin unit '+st.name^+' has index '+tostr(st.moduleid))));
  1650. end;
  1651. p:=tsym(st.symindex.first);
  1652. while assigned(p) do
  1653. begin
  1654. if (not p.isstabwritten) then
  1655. insertsym(list,p);
  1656. p:=tsym(p.indexnext);
  1657. end;
  1658. case st.symtabletype of
  1659. staticsymtable :
  1660. list.concat(tai_comment.Create(strpnew('Syms - End Staticsymtable')));
  1661. globalsymtable :
  1662. list.concat(tai_comment.Create(strpnew('Syms - End unit '+st.name^+' has index '+tostr(st.moduleid))));
  1663. end;
  1664. end;
  1665. procedure TDebugInfoDwarf.insertmoduleinfo;
  1666. var
  1667. templist : TAsmList;
  1668. begin
  1669. { insert .Ltext0 label }
  1670. templist:=TAsmList.create;
  1671. new_section(templist,sec_code,'',0);
  1672. templist.concat(tai_symbol.createname('.Ltext0',AT_DATA,0));
  1673. current_asmdata.asmlists[al_start].insertlist(templist);
  1674. templist.free;
  1675. { insert .Letext0 label }
  1676. templist:=TAsmList.create;
  1677. new_section(templist,sec_code,'',0);
  1678. templist.concat(tai_symbol.createname('.Letext0',AT_DATA,0));
  1679. current_asmdata.asmlists[al_end].insertlist(templist);
  1680. templist.free;
  1681. { insert .Ldebug_abbrev0 label }
  1682. templist:=TAsmList.create;
  1683. new_section(templist,sec_debug_abbrev,'',0);
  1684. templist.concat(tai_symbol.createname('.Ldebug_abbrev0',AT_DATA,0));
  1685. current_asmdata.asmlists[al_start].insertlist(templist);
  1686. templist.free;
  1687. { insert .Ldebug_line0 label }
  1688. templist:=TAsmList.create;
  1689. new_section(templist,sec_debug_line,'',0);
  1690. templist.concat(tai_symbol.createname('.Ldebug_line0',AT_DATA,0));
  1691. current_asmdata.asmlists[al_start].insertlist(templist);
  1692. templist.free;
  1693. end;
  1694. procedure TDebugInfoDwarf.inserttypeinfo;
  1695. var
  1696. storefilepos : tfileposinfo;
  1697. lenstartlabel : tasmlabel;
  1698. i : longint;
  1699. begin
  1700. storefilepos:=aktfilepos;
  1701. aktfilepos:=current_module.mainfilepos;
  1702. currabbrevnumber:=0;
  1703. writing_def_dwarf:=false;
  1704. nextdefnumber:=0;
  1705. defnumberlist:=TFPObjectList.create(false);
  1706. vardatadef:=search_system_type('TVARDATA').restype.def;
  1707. { not exported (FK)
  1708. filerecdef:=gettypedef('FILEREC');
  1709. textrecdef:=gettypedef('TEXTREC');
  1710. }
  1711. { write start labels }
  1712. current_asmdata.asmlists[al_dwarf_info].concat(tai_section.create(sec_debug_info,'',0));
  1713. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname('.Ldebug_info0',AT_DATA,0));
  1714. { start abbrev section }
  1715. new_section(current_asmdata.asmlists[al_dwarf_abbrev],sec_debug_abbrev,'',0);
  1716. { debug info header }
  1717. current_asmdata.getlabel(lenstartlabel,alt_dbgfile);
  1718. { size }
  1719. { currently we create only 32 bit dwarf }
  1720. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_rel_sym(aitconst_32bit,
  1721. lenstartlabel,tasmsymbol.create('.Ledebug_info0',AB_COMMON,AT_DATA)));
  1722. current_asmdata.asmlists[al_dwarf_info].concat(tai_label.create(lenstartlabel));
  1723. { version }
  1724. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_16bit(2));
  1725. { abbrev table }
  1726. if isdwarf64 then
  1727. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_64bit,
  1728. current_asmdata.RefAsmSymbol('.Ldebug_abbrev0')))
  1729. else
  1730. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_type_sym(aitconst_32bit,
  1731. current_asmdata.RefAsmSymbol('.Ldebug_abbrev0')));
  1732. { address size }
  1733. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(sizeof(aint)));
  1734. append_entry(DW_TAG_compile_unit,true,[
  1735. DW_AT_name,DW_FORM_string,FixFileName(current_module.sourcefiles.get_file(1).name^)+#0,
  1736. DW_AT_producer,DW_FORM_string,'Free Pascal '+full_version_string+' '+date_string+#0,
  1737. DW_AT_comp_dir,DW_FORM_string,BsToSlash(FixPath(current_module.sourcefiles.get_file(1).path^,false))+#0,
  1738. DW_AT_language,DW_FORM_data1,DW_LANG_Pascal83,
  1739. DW_AT_identifier_case,DW_FORM_data1,DW_ID_case_insensitive]);
  1740. { reference to line info section }
  1741. append_labelentry_data(DW_AT_stmt_list,current_asmdata.RefAsmSymbol('.Ldebug_line0'));
  1742. append_labelentry(DW_AT_low_pc,current_asmdata.RefAsmSymbol('.Ltext0'));
  1743. append_labelentry(DW_AT_high_pc,current_asmdata.RefAsmSymbol('.Letext0'));
  1744. finish_entry;
  1745. { first write all global/local symbols. This will flag all required tdefs }
  1746. if assigned(current_module.globalsymtable) then
  1747. write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
  1748. if assigned(current_module.localsymtable) then
  1749. write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.localsymtable);
  1750. { reset unit type info flag }
  1751. reset_unit_type_info;
  1752. { write used types from the used units }
  1753. write_used_unit_type_info(current_asmdata.asmlists[al_dwarf_info],current_module);
  1754. { last write the types from this unit }
  1755. if assigned(current_module.globalsymtable) then
  1756. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
  1757. if assigned(current_module.localsymtable) then
  1758. write_symtable_defs(current_asmdata.asmlists[al_dwarf_info],current_module.localsymtable);
  1759. { close compilation unit entry }
  1760. finish_children;
  1761. { end of debug info table }
  1762. current_asmdata.asmlists[al_dwarf_info].concat(tai_const.create_8bit(0));
  1763. current_asmdata.asmlists[al_dwarf_info].concat(tai_symbol.createname('.Ledebug_info0',AT_DATA,0));
  1764. { reset all def labels }
  1765. for i:=0 to defnumberlist.count-1 do
  1766. begin
  1767. if assigned(defnumberlist[i]) then
  1768. begin
  1769. tdef(defnumberlist[i]).dwarf_lab:=nil;
  1770. tdef(defnumberlist[i]).dbg_state:=dbg_state_unused;
  1771. end;
  1772. end;
  1773. defnumberlist.free;
  1774. defnumberlist:=nil;
  1775. aktfilepos:=storefilepos;
  1776. end;
  1777. procedure TDebugInfoDwarf.referencesections(list:TAsmList);
  1778. begin
  1779. end;
  1780. procedure TDebugInfoDwarf.insertlineinfo(list:TAsmList);
  1781. var
  1782. currfileinfo,
  1783. lastfileinfo : tfileposinfo;
  1784. currfuncname : pstring;
  1785. currsectype : TAsmSectiontype;
  1786. hlabel : tasmlabel;
  1787. hp : tai;
  1788. infile : tinputfile;
  1789. current_file : tai_file;
  1790. begin
  1791. FillChar(lastfileinfo,sizeof(lastfileinfo),0);
  1792. currfuncname:=nil;
  1793. currsectype:=sec_code;
  1794. hp:=Tai(list.first);
  1795. while assigned(hp) do
  1796. begin
  1797. case hp.typ of
  1798. ait_section :
  1799. currsectype:=tai_section(hp).sectype;
  1800. ait_function_name :
  1801. currfuncname:=tai_function_name(hp).funcname;
  1802. ait_force_line :
  1803. lastfileinfo.line:=-1;
  1804. end;
  1805. if (currsectype=sec_code) and
  1806. (hp.typ=ait_instruction) then
  1807. begin
  1808. currfileinfo:=tailineinfo(hp).fileinfo;
  1809. { file changed ? (must be before line info) }
  1810. if (currfileinfo.fileindex<>0) and
  1811. (lastfileinfo.fileindex<>currfileinfo.fileindex) then
  1812. begin
  1813. infile:=current_module.sourcefiles.get_file(currfileinfo.fileindex);
  1814. if assigned(infile) then
  1815. begin
  1816. if (infile.path^<>'') then
  1817. begin
  1818. current_file:=tai_file.create(BsToSlash(FixPath(infile.path^,false)+FixFileName(infile.name^)));
  1819. list.insertbefore(current_file,hp)
  1820. end
  1821. else
  1822. begin
  1823. current_file:=tai_file.create(FixFileName(infile.name^));
  1824. list.insertbefore(current_file,hp);
  1825. end;
  1826. { force new line info }
  1827. lastfileinfo.line:=-1;
  1828. end;
  1829. end;
  1830. { line changed ? }
  1831. if (lastfileinfo.line<>currfileinfo.line) and (currfileinfo.line<>0) then
  1832. list.insertbefore(tai_loc.create(
  1833. current_file,currfileinfo.line,currfileinfo.column),hp);
  1834. lastfileinfo:=currfileinfo;
  1835. end;
  1836. hp:=tai(hp.next);
  1837. end;
  1838. end;
  1839. const
  1840. dbg_dwarf_info : tdbginfo =
  1841. (
  1842. id : dbg_dwarf;
  1843. idtxt : 'DWARF';
  1844. );
  1845. initialization
  1846. RegisterDebugInfo(dbg_dwarf_info,TDebugInfoDwarf);
  1847. end.