【发布时间】:2016-06-13 11:53:27
【问题描述】:
我正在尝试解析 DWARF 调试信息,以确定堆栈跟踪地址中的函数。如果它适用于我的 C 函数(使用 gcc 编译),它不适用于我的 C++ 函数(使用 g++ 编译)
我的 C 函数在 .debug_info 表中都有一个 DW_AT_low_pc 和一个 DW_AT_low_high 属性,它们告诉我这个函数是什么内存范围,例如
<1><17433>: Abbrev Number: 33 (DW_TAG_subprogram)
<17434> DW_AT_external : 1
<17434> DW_AT_name : (indirect string, offset: 0x4704): TLSCursor_init
<17438> DW_AT_decl_file : 1
<17439> DW_AT_decl_line : 46
<1743a> DW_AT_linkage_name: (indirect string, offset: 0x4536): _Z14TLSCursor_initP9TLSCursorP13TCPConnection
<1743e> DW_AT_low_pc : 0x1178ce
<17442> DW_AT_high_pc : 0x1b
<17446> DW_AT_frame_base : 1 byte block: 9c (DW_OP_call_frame_cfa)
<17448> DW_AT_GNU_all_call_sites: 1
<17448> DW_AT_sibling : <0x17469>`
Most of my C++ methods, however most do NOT have such attributes:
`<2><144de>: Abbrev Number: 7 (DW_TAG_subprogram)
<144df> DW_AT_external : 1
<144df> DW_AT_name : (indirect string, offset: 0x3505): ~TLSNumber
<144e3> DW_AT_decl_file : 3
<144e4> DW_AT_decl_line : 23
<144e5> DW_AT_linkage_name: (indirect string, offset: 0x3510): _ZN9TLSNumberD4Ev
<144e9> DW_AT_accessibility: 1 (public)
<144ea> DW_AT_declaration : 1
<144ea> DW_AT_object_pointer: <0x144f2>
<144ee> DW_AT_sibling : <0x144fd>
这有什么原因吗?在这种情况下如何确定函数的地址范围?
【问题讨论】: