DWARF reading not complete types <p>How can I read a non complete types in DWARF dumps?</p> <p>For example we have a derived class:</p> <pre><code>class Base { public: int Base_var1; int Base_var2; .... } class OtherClass : public Base { int OtherClass_var1; int OtherClass_var2; .... } OtherClass otherClass(); </code></pre> <p>We compile this with GCC compiler and want to find all members of <code>otherClass</code> object. We get the next DWARF dump:</p> <pre><code>&lt;1&gt;&lt;20a&gt;: Abbrev Number: 15 (DW_TAG_variable) &lt;20b&gt; DW_AT_name : otherClass &lt;211&gt; DW_AT_type : &lt;0x131&gt; &lt;1&gt;&lt;131&gt;: Abbrev Number: 117 (DW_TAG_class_type) &lt;132&gt; DW_AT_name : OtherClass &lt;133&gt; DW_AT_declaration : 1 &lt;134&gt; DW_AT_sibling : &lt;0x150&gt; &lt;2&gt;&lt;135&gt;: Abbrev Number: 45 (DW_TAG_member) &lt;136&gt; DW_AT_name : OtherClass_var1 &lt;137&gt; DW_AT_type : &lt;0x12&gt; &lt;138&gt; DW_AT_data_member_location: 2 byte block: 23 8 (DW_OP_plus_uconst: 8) ...... </code></pre> <p>We have a variable <code>otherClass</code>, which have a type of <code>0x131</code>. This type have <code>DW_AT_declaration</code> flag, which means that this is non complete type. Type at <code>0x131</code> have all members of it's main class (<code>OtherClass_var1</code> and <code>OtherClass_var2</code>), but don't have any information about derived members.</p> <p>If continue reading DWARF dump, then in some place we get this:</p> <pre><code>&lt;1&gt;&lt;500&gt;: Abbrev Number: 150 (DW_TAG_class_type) &lt;501&gt; DW_AT_specification: &lt;0x131&gt; &lt;502&gt; DW_AT_byte_size : 2696 &lt;503&gt; DW_AT_containing_type: &lt;0x560&gt; &lt;504&gt; DW_AT_sibling : &lt;0x36078&gt; &lt;2&gt;&lt;135&gt;: Abbrev Number: 45 (DW_TAG_member) &lt;136&gt; DW_AT_name : Base_var1 &lt;137&gt; DW_AT_type : &lt;0x12&gt; &lt;138&gt; DW_AT_data_member_location: 2 byte block: 23 8 ..... </code></pre> <p>There is a definition for our base class and this definition have <code>DW_AT_specification</code> tag, which shows where to find a other part of this class (main part).</p> <p>How can we correctly read this <code>otherClass</code> object? At this moment I have to store array of all types and when I get a <code>DW_AT_declaration</code> tag, I should go through array and find a type with specification to this type.</p> <p>And how can I get a absolute address of derived members? We have a absolute address of variable <code>otherClass</code>. Then member <code>OtherClass_var1</code> would have the same address as <code>otherClass</code>. Member <code>OtherClass_var2</code> would have address of <code>OtherClass_var1</code> plus a byte size of <code>OtherClass_var1</code>. But how can we calculate the address of derived members <code>Base_var1</code> and <code>Base_var2</code>?</p>