how to read dwarf in linux

sudo apt install dwarfdump
dwarfdump a.out  &> log

Makefile

all:
        gcc demo.c -g -O0

demo.c

void main()
{
}

.debug_info

COMPILE_UNIT<header overall offset = 0x00000000>:
< 0><0x0000000c>  DW_TAG_compile_unit
                    DW_AT_producer              GNU C17 11.3.0 -mtune=generic -march=x86-64 -g -O0 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection
                    DW_AT_language              DW_LANG_C11
                    DW_AT_name                  demo.c
                    DW_AT_comp_dir              /home/prometheus/module-test/dwarf
                    DW_AT_low_pc                0x00001129
                    DW_AT_high_pc               <offset-from-lowpc> 11 <highpc: 0x00001134>
                    DW_AT_stmt_list             0x00000000

LOCAL_SYMBOLS:
< 1><0x0000002e>    DW_TAG_subprogram
                      DW_AT_external              yes(1)
                      DW_AT_name                  main
                      DW_AT_decl_file             0x00000001 /home/prometheus/module-test/dwarf/demo.c
                      DW_AT_decl_line             0x00000001
                      DW_AT_decl_column           0x00000006
                      DW_AT_low_pc                0x00001129
                      DW_AT_high_pc               <offset-from-lowpc> 11 <highpc: 0x00001134>
                      DW_AT_frame_base            len 0x0001: 0x9c:
                          DW_OP_call_frame_cfa
                      DW_AT_call_all_calls        yes(1)

.debug_line: line number info for a single cu
Source lines (from CU-DIE at .debug_info offset 0x0000000c):

            NS new statement, BB new basic block, ET end of text sequence
            PE prologue end, EB epilogue begin
            IS=val ISA number, DI=val discriminator value
<pc>        [lno,col] NS BB ET PE EB IS= DI= uri: "filepath"
0x00001129  [   2, 1] NS uri: "/home/prometheus/module-test/dwarf/demo.c"
0x00001131  [   5, 1] NS
0x00001134  [   5, 1] NS ET

.debug_str
name at offset 0x00000000, length  145 is 'GNU C17 11.3.0 -mtune=generic -march=x86-64 -g -O0 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection'
name at offset 0x00000092, length    4 is 'main'

.debug_aranges

COMPILE_UNIT<header overall offset = 0x00000000>:
< 0><0x0000000c>  DW_TAG_compile_unit
                    DW_AT_producer              GNU C17 11.3.0 -mtune=generic -march=x86-64 -g -O0 -fasynchronous-unwind-tables -fstack-protector-strong -fstack-clash-protection -fcf-protection
                    DW_AT_language              DW_LANG_C11
                    DW_AT_name                  demo.c
                    DW_AT_comp_dir              /home/prometheus/module-test/dwarf
                    DW_AT_low_pc                0x00001129
                    DW_AT_high_pc               <offset-from-lowpc> 11 <highpc: 0x00001134>
                    DW_AT_stmt_list             0x00000000


arange starts at 0x00001129, length of 0x0000000b, cu_die_offset = 0x0000000c
arange end

.debug_frame is not present


你可能感兴趣的:(linux,chrome,运维)