Consider the following sample of dwarf code -
<0><b>: Abbrev Number: 1 (DW_TAG_compile_unit)
<c> DW_AT_producer : (indirect string, offset: 0xd): GNU C++ 4.3.0 20080428 (Red Hat 4.3.0-8)
<10> DW_AT_language : 4 (C++)
<11> DW_AT_name : (indirect string, offset: 0x75): test.cpp
<15> DW_AT_comp_dir : (indirect string, offset: 0x4d): /home/dwarf
<19> DW_AT_low_pc : 0x0
<21> DW_AT_high_pc : 0xb
<29> DW_AT_stmt_list : 0x0
<1><2d>: Abbrev Number: 2 (DW_TAG_class_type)
<2e> DW_AT_name : C
<30> DW_AT_byte_size : 8
<31> DW_AT_decl_file : 1
<32> DW_AT_decl_line : 1
<33> DW_AT_sibling : <0x86>
<2><37>: Abbrev Number: 3 (DW_TAG_member)
<38> DW_AT_name : x
<3a> DW_AT_decl_file : 1
<3b> DW_AT_decl_line : 7
<3c> DW_AT_type : <0x86>
<40> DW_AT_data_member_location: 2 byte block: 23 0 (DW_OP_plus_uconst: 0)
<43> DW_AT_accessibility: 3 (private)
<2><44>: Abbrev Number: 3 (DW_TAG_member)
<45> DW_AT_name : y
<47> DW_AT_decl_file : 1
<48> DW_AT_decl_line : 8
<49> DW_AT_type : <0x86>
<4d> DW_AT_data_member_location: 2 byte block: 23 4 (DW_OP_plus_uconst: 4)
<50> DW_AT_accessibility: 3 (private)
I have been working on a program that parses through dwarf files, and I am unsure of one part of it. If you notice, each tag has an extra number to the left of it (in this sample there is <0>, <1> and <2>). Im not really sure what it is. I think it is some sort of stack level or something, since <0> is given to the program as a whole, <1> is given to a top level class, and <2> is given to its member variables. However, I have not been able to find anything on it in the documentation. For reference, here is the original program -
class C {
public:
C();
C(int x, int y);
int getX();
private:
int x;
int y;
};
class SubC : public C {
int z;
};
int f() {return 0;}
C c;
SubC subC;
int i;
double d;