gdb - readelf 的 DWARF 转储中最左边的数字是什么意思?

标签 gdb dwarf readelf

例如:

 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
    <c>   DW_AT_producer    : (indirect string, offset: 0xe): GNU C1
1 5.4.0 20160609 -masm=intel -m32 -mtune=generic -march=i686 -g -fst
ack-protector-strong
    <10>   DW_AT_language    : 12       (ANSI C99)
    <11>   DW_AT_name        : (indirect string, offset: 0xbe): hell
o.c
    <15>   DW_AT_comp_dir    : (indirect string, offset: 0x97): /tmp
    <19>   DW_AT_low_pc      : 0x804840b
    <1d>   DW_AT_high_pc     : 0x2e
    <21>   DW_AT_stmt_list   : 0x0
 <1><25>: Abbrev Number: 2 (DW_TAG_base_type)
    <26>   DW_AT_byte_size   : 4
    <27>   DW_AT_encoding    : 7        (unsigned)
    <28>   DW_AT_name        : (indirect string, offset: 0x77): unsi
gned int
 <1><2c>: Abbrev Number: 2 (DW_TAG_base_type)
    <2d>   DW_AT_byte_size   : 1
    <2e>   DW_AT_encoding    : 8        (unsigned char)
    <2f>   DW_AT_name        : (indirect string, offset: 0x84): unsi
gned char
 <1><33>: Abbrev Number: 2 (DW_TAG_base_type)
    <34>   DW_AT_byte_size   : 2
    <35>   DW_AT_encoding    : 7        (unsigned)
    <36>   DW_AT_name        : (indirect string, offset: 0xa1): shor
t unsigned int

在每个 DIE 条目的开头,都有一个数字,例如 <0> , <1> ……这些数字是什么意思?似乎相同的数字表示相同的 DWARF 类型,我猜例如带有 <1> 的条目意味着他们都是 (DW_TAG_base_type) .

最佳答案

DWARF DIE 排列在树中。最左边的数字告诉您 DIE 的深度。在你的例子中:

 <0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<0>意味着这个 DIE 出现在最外层。这只会发生在编译或类型单元 DIE 中。

然后:
 <1><25>: Abbrev Number: 2 (DW_TAG_base_type)

此 DIE 是编译单元 DIE 的子项。

你可以得到更深的嵌套;例如,函数的局部变量可能嵌套很深,这取决于函数的块结构。命名空间中的项目也可能是嵌套的。

关于gdb - readelf 的 DWARF 转储中最左边的数字是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41610635/

相关文章:

objective-c - 运行代码返回垃圾;在调试器中输入会返回正确的结果

c - 检查整数和字符数组的内存时字节顺序不一致

c - 如何使矮人部分加载到 Sprite 文件中的内存中?

linux - 为什么/lib32/libc.so.6 中有两个 "fopen"符号?

android - ldd 在 android 上等效

gdb - 以编程方式访问 gdb 中观察点的旧值和新值

elf - 使用 binutils/readelf 确定符号地址

linux - 括号中的数字在 readelf 输出中意味着什么?

c++ - gdb 在检查断点处的条件时失败