Skip to content

Instantly share code, notes, and snippets.

@ngladitz
Created April 22, 2016 15:03
Show Gist options
  • Save ngladitz/748fdfb34a6e4221dadf6b95df109873 to your computer and use it in GitHub Desktop.
Save ngladitz/748fdfb34a6e4221dadf6b95df109873 to your computer and use it in GitHub Desktop.
debug symbols
% ninja -v
[1/3] /usr/bin/c++ -O2 -g -DNDEBUG -MMD -MT CMakeFiles/foo.dir/foo.cpp.o -MF CMakeFiles/foo.dir/foo.cpp.o.d -o CMakeFiles/foo.dir/foo.cpp.o -c ../foo.cpp
[2/3] : && /usr/bin/c++ -O2 -g -DNDEBUG CMakeFiles/foo.dir/foo.cpp.o -o foo && :
[3/3] cd /home/ngladitz/src/test/debug/build && /usr/bin/objdump --debugging /home/ngladitz/src/test/debug/build/foo
/home/ngladitz/src/test/debug/build/foo: file format elf64-x86-64
Contents of the .eh_frame section:
00000000 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 (rsp) ofs 8
DW_CFA_offset: r16 (rip) at cfa-8
DW_CFA_undefined: r16 (rip)
00000018 0000000000000014 0000001c FDE cie=00000000 pc=00000000004003f0..000000000040041a
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
00000030 0000000000000014 00000000 CIE
Version: 1
Augmentation: "zR"
Code alignment factor: 1
Data alignment factor: -8
Return address column: 16
Augmentation data: 1b
DW_CFA_def_cfa: r7 (rsp) ofs 8
DW_CFA_offset: r16 (rip) at cfa-8
DW_CFA_nop
DW_CFA_nop
00000048 0000000000000024 0000001c FDE cie=00000030 pc=00000000004003b0..00000000004003d0
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 6 to 00000000004003b6
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 10 to 00000000004003c0
DW_CFA_def_cfa_expression (DW_OP_breg7 (rsp): 8; DW_OP_breg16 (rip): 0; DW_OP_lit15; DW_OP_and; DW_OP_lit11; DW_OP_ge; DW_OP_lit3; DW_OP_shl; DW_OP_plus)
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
00000070 0000000000000014 00000044 FDE cie=00000030 pc=00000000004003e0..00000000004003e3
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
00000088 0000000000000044 0000005c FDE cie=00000030 pc=00000000004004f0..0000000000400555
DW_CFA_advance_loc: 2 to 00000000004004f2
DW_CFA_def_cfa_offset: 16
DW_CFA_offset: r15 (r15) at cfa-16
DW_CFA_advance_loc: 2 to 00000000004004f4
DW_CFA_def_cfa_offset: 24
DW_CFA_offset: r14 (r14) at cfa-24
DW_CFA_advance_loc: 5 to 00000000004004f9
DW_CFA_def_cfa_offset: 32
DW_CFA_offset: r13 (r13) at cfa-32
DW_CFA_advance_loc: 2 to 00000000004004fb
DW_CFA_def_cfa_offset: 40
DW_CFA_offset: r12 (r12) at cfa-40
DW_CFA_advance_loc: 8 to 0000000000400503
DW_CFA_def_cfa_offset: 48
DW_CFA_offset: r6 (rbp) at cfa-48
DW_CFA_advance_loc: 8 to 000000000040050b
DW_CFA_def_cfa_offset: 56
DW_CFA_offset: r3 (rbx) at cfa-56
DW_CFA_advance_loc: 13 to 0000000000400518
DW_CFA_def_cfa_offset: 64
DW_CFA_advance_loc: 50 to 000000000040054a
DW_CFA_def_cfa_offset: 56
DW_CFA_advance_loc: 1 to 000000000040054b
DW_CFA_def_cfa_offset: 48
DW_CFA_advance_loc: 1 to 000000000040054c
DW_CFA_def_cfa_offset: 40
DW_CFA_advance_loc: 2 to 000000000040054e
DW_CFA_def_cfa_offset: 32
DW_CFA_advance_loc: 2 to 0000000000400550
DW_CFA_def_cfa_offset: 24
DW_CFA_advance_loc: 2 to 0000000000400552
DW_CFA_def_cfa_offset: 16
DW_CFA_advance_loc: 2 to 0000000000400554
DW_CFA_def_cfa_offset: 8
DW_CFA_nop
000000d0 0000000000000014 000000a4 FDE cie=00000030 pc=0000000000400560..0000000000400562
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
DW_CFA_nop
000000e8 ZERO terminator
Contents of the .debug_aranges section:
Length: 44
Version: 2
Offset into .debug_info: 0x0
Pointer Size: 8
Segment Size: 0
Address Length
00000000004003e0 0000000000000003
0000000000000000 0000000000000000
Contents of the .debug_info section:
Compilation Unit @ offset 0x0:
Length: 0x4a (32-bit)
Version: 4
Abbrev Offset: 0x0
Pointer Size: 8
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0x0): GNU C++ 5.3.1 20160413 -mtune=generic -march=x86-64 -g -O2 -fstack-protector-strong
<10> DW_AT_language : 4 (C++)
<11> DW_AT_name : (indirect string, offset: 0x54): ../foo.cpp
<15> DW_AT_comp_dir : (indirect string, offset: 0x5f): /home/ngladitz/src/test/debug/build
<19> DW_AT_ranges : 0x0
<1d> DW_AT_low_pc : 0x0
<25> DW_AT_stmt_list : 0x0
<1><29>: Abbrev Number: 2 (DW_TAG_subprogram)
<2a> DW_AT_external : 1
<2a> DW_AT_name : (indirect string, offset: 0x83): main
<2e> DW_AT_decl_file : 1
<2f> DW_AT_decl_line : 1
<30> DW_AT_type : <0x46>
<34> DW_AT_low_pc : 0x4003e0
<3c> DW_AT_high_pc : 0x3
<44> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<46> DW_AT_GNU_all_call_sites: 1
<1><46>: Abbrev Number: 3 (DW_TAG_base_type)
<47> DW_AT_byte_size : 4
<48> DW_AT_encoding : 5 (signed)
<49> DW_AT_name : int
<1><4d>: Abbrev Number: 0
Contents of the .debug_abbrev section:
Number TAG (0x0)
1 DW_TAG_compile_unit [has children]
DW_AT_producer DW_FORM_strp
DW_AT_language DW_FORM_data1
DW_AT_name DW_FORM_strp
DW_AT_comp_dir DW_FORM_strp
DW_AT_ranges DW_FORM_sec_offset
DW_AT_low_pc DW_FORM_addr
DW_AT_stmt_list DW_FORM_sec_offset
DW_AT value: 0 DW_FORM value: 0
2 DW_TAG_subprogram [no children]
DW_AT_external DW_FORM_flag_present
DW_AT_name DW_FORM_strp
DW_AT_decl_file DW_FORM_data1
DW_AT_decl_line DW_FORM_data1
DW_AT_type DW_FORM_ref4
DW_AT_low_pc DW_FORM_addr
DW_AT_high_pc DW_FORM_data8
DW_AT_frame_base DW_FORM_exprloc
DW_AT_GNU_all_call_sites DW_FORM_flag_present
DW_AT value: 0 DW_FORM value: 0
3 DW_TAG_base_type [no children]
DW_AT_byte_size DW_FORM_data1
DW_AT_encoding DW_FORM_data1
DW_AT_name DW_FORM_string
DW_AT value: 0 DW_FORM value: 0
Raw dump of debug contents of section .debug_line:
Offset: 0x0
Length: 57
DWARF Version: 2
Prologue Length: 33
Minimum Instruction Length: 1
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
Opcodes:
Opcode 1 has 0 args
Opcode 2 has 1 args
Opcode 3 has 1 args
Opcode 4 has 1 args
Opcode 5 has 1 args
Opcode 6 has 0 args
Opcode 7 has 0 args
Opcode 8 has 0 args
Opcode 9 has 1 args
Opcode 10 has 0 args
Opcode 11 has 0 args
Opcode 12 has 1 args
The Directory Table (offset 0x1b):
1 ..
The File Name Table (offset 0x1f):
Entry Dir Time Size Name
1 1 0 0 foo.cpp
Line Number Statements:
[0x0000002b] Extended opcode 2: set Address to 0x4003e0
[0x00000036] Copy
[0x00000037] Copy
[0x00000038] Advance PC by 3 to 0x4003e3
[0x0000003a] Extended opcode 1: End of Sequence
Contents of the .debug_str section:
0x00000000 474e5520 432b2b20 352e332e 31203230 GNU C++ 5.3.1 20
0x00000010 31363034 3133202d 6d74756e 653d6765 160413 -mtune=ge
0x00000020 6e657269 63202d6d 61726368 3d783836 neric -march=x86
0x00000030 2d363420 2d67202d 4f32202d 66737461 -64 -g -O2 -fsta
0x00000040 636b2d70 726f7465 63746f72 2d737472 ck-protector-str
0x00000050 6f6e6700 2e2e2f66 6f6f2e63 7070002f ong.../foo.cpp./
0x00000060 686f6d65 2f6e676c 61646974 7a2f7372 home/ngladitz/sr
0x00000070 632f7465 73742f64 65627567 2f627569 c/test/debug/bui
0x00000080 6c64006d 61696e00 ld.main.
Contents of the .debug_ranges section:
Offset Begin End
00000000 00000000004003e0 00000000004003e3
00000000 <End of list>
cmake_minimum_required(VERSION 3.4)
file(WRITE foo.cpp "int main() {}")
add_executable(foo foo.cpp)
add_custom_target(foo-dump ALL COMMAND ${CMAKE_OBJDUMP} --debugging $<TARGET_FILE:foo>)
% cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -GNinja ..
-- The C compiler identification is GNU 5.3.1
-- The CXX compiler identification is GNU 5.3.1
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ngladitz/src/test/debug/build
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment