1 / 11

What is DWARF

What is DWARF. Introduction to the DWARF Format 2012.05.03. Reference. Introduction to the DWARF Debugging Format, Michael J. Eager, Eager Consulting DWARF Debugging Information Format, Version 4, DWARF Debugging Information Format Committee ; http://www.dwarfstd.org

chinara
Download Presentation

What is DWARF

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. What is DWARF Introduction to the DWARF Format 2012.05.03

  2. Reference • Introduction to the DWARF Debugging Format, Michael J. Eager, Eager Consulting • DWARF Debugging Information Format, Version 4, DWARF Debugging Information Format Committee; http://www.dwarfstd.org • Gnu gold linker, GNU Binutils • Gnu BFD, GNU Binutils

  3. Introduction • DWARF is a format for debugging. • DWARF data are several sections in the object file • The purpose is to figure out the mapping between object code and source code. • DWARF is a tree structure with nodes called Debugging Information Entry (DIE). • The tree describes the whole source program • readelf --dump-debug to dump the debug data

  4. Debug Sections

  5. DIE • DIEs are used to represent types, variables, or functions. • DIE contains a Tag and a set of Attributes • TAG • Specify what this DIE describes • DW_TAG_XXX : DW_TAG_base_type, DW_TAG_variable,... • Attribute • A detail description such as name, size, address,… • DW_AT_XXX: DW_AT_name, DW_AT_byte_size,…

  6. Base Types and Variables • Describes 32-bit and 16-bit int base type • DW_TAG_base_type • DW_AT_name = int • DW_AT_byte_size= 4 • DW_AT_encoding= signed • DW_TAG_base_type • DW_AT_name = int • DW_AT_byte_size= 2 • DW_AT_encoding= signed • Describes int *px • <1>: DW_TAG_variable • DW_AT_name = px • DW_AT_type = <2> • <2>: DW_TAG_pointer_type • DW_AT_byte_size = 4 • DW_AT_type = <3> • <3>: DW_TAG_base_type • DW_AT_name = word • DW_AT_byte_size = 4 • DW_AT_encoding = signed

  7. Describe Executable Code • Compilation Unit DIE • Each separately compiled source file is a compilation unit • Each compilation unit has a DIE to describe its name, directory, address, … • The parent of all other DIEs for this compilation unit • Functions • Subprograms DIE • Describes name, low/high pc • Return value : DW_AT_TYPE • Input parameter DIE • Owned by subprogram • Described parameter name, type, …

  8. Executable Code, an Example • Compilation Unit DIE intfoo(inti) { return i++; } .debug_abbrev 1 DW_TAG_compile_unit [has children] DW_AT_producerDW_FORM_strp DW_AT_language DW_FORM_data1 DW_AT_nameDW_FORM_strp DW_AT_comp_dirDW_FORM_strp DW_AT_low_pcDW_FORM_addr DW_AT_high_pcDW_FORM_addr DW_AT_stmt_list DW_FORM_data4 Describe the data types .debug_info <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit) < c> DW_AT_producer : (indirect string, offset: 0x0): GNU C 4.4.1 <10> DW_AT_language : 1 (ANSI C) <11> DW_AT_name : (indirect string, offset: 0xc): test.c <15> DW_AT_comp_dir : (indirect string, offset: 0x13): /proj/mtk02422/test/test2 <19> DW_AT_low_pc : 0x0 <1d> DW_AT_high_pc : 0x30 <21> DW_AT_stmt_list : 0x0 Describe the value

  9. Executable Code, an Example • Subprograms DIE .debug_info <1><25>: Abbrev Number: 2 (DW_TAG_subprogram) <26> DW_AT_external : 1 <27> DW_AT_name : foo <2b> DW_AT_decl_file : 1 <2c> DW_AT_decl_line : 1 <2d> DW_AT_prototyped : 1 <2e> DW_AT_type : <0x4f> <32> DW_AT_low_pc : 0x0 <36> DW_AT_high_pc : 0x30 <3a> DW_AT_frame_base : 0x0 (location list) <3e> DW_AT_sibling : <0x4f> … <1><4f>: Abbrev Number: 4 (DW_TAG_base_type) <50> DW_AT_byte_size : 4 <51> DW_AT_encoding : 5 (signed) <52> DW_AT_name : int

  10. Other DWARF Data • Line Number Table • .debug_line • Mapping between the source lines and the memory address • Line number program • The byte-coded instruction stream • State machine • Expand the line number program and recreate the line number table • Macro Information • .debug_macinfo • Call Frame Information • .debug_frame • Virtually unwind and find out the desired data in the call stack • CIE (Common Information Entry) • FDE (Frame Description Entry)

  11. What linkers should do? • Related options • --strip-debug • Strip the debugging information • --strip-debug-non-line • Emit only debug line number information (gold only) • --strip-debug-gdb • Strip debug symbols that are unused by gdb (at least version 6.7) (gold only) • Section merge, applying relocation (Normal passes) • Post processing • Compress the sections • Reduce the debug output data • .debug_abbrev • .debug_info • DWARF reader • For error message

More Related