This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Compiler: ofd2000: how to interpret "DW_AT_TYPE" field?

Tool/software: TI C/C++ Compiler

Hello everyone

I have a problem. I want to get structure members addresses from an "*.out" file. I guess, i have to use "ofd2000" for this to extract DWARF info and then parse it somehow. But I get stuck with the format.

For a simple program with two variable "iVar" (int) and "fVar" (float) i get something like this:

    00000098  23    DW_TAG_variable (.ebss)
    00000099           DW_AT_location       DW_OP_addr 0x00a806
    0000009f           DW_AT_name           iVar
    000000a4           DW_AT_external       true
    000000a5           DW_AT_type           .debug_info(20) + 0x294
    000000a9           DW_AT_TI_symbol_name _iVar
    000000af  23    DW_TAG_variable (.ebss)
    000000b0           DW_AT_location       DW_OP_addr 0x00a808
    000000b6           DW_AT_name           fVar
    000000bb           DW_AT_external       true
    000000bc           DW_AT_type           .debug_info(20) + 0x389
    000000c0           DW_AT_TI_symbol_name _fVar

So i thought that I should inspect fields with numbers "0x294" and "0x389" to get types. But there is no such info. Actually types description is in another place:

    00000177  14    DW_TAG_base_type
    00000178           DW_AT_name      float
    0000017e           DW_AT_byte_size 2
    0000017f           DW_AT_encoding  DW_ATE_float
    0000011a  14    DW_TAG_base_type
    0000011b           DW_AT_name      int
    0000011f           DW_AT_byte_size 1
    00000120           DW_AT_encoding  DW_ATE_signed

How are these numbers connected: "0x294 <-> 0x11a" and "0x389 <-> 0x177" ?

Thanks

  • If ofd2000 -g -x is used to generate XML format debug information, it looks easier to parse the information. E.g.:

    1. The definition of iVar is:

                      <die id="0xa:0xac">
                         <tag>DW_TAG_variable</tag>
                         <attribute>
                            <type>DW_AT_location</type>
                            <form>DW_FORM_block1</form>
                            <value>
                               <block>DW_OP_addr 0xa806</block>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_name</type>
                            <form>DW_FORM_string</form>
                            <value>
                               <string>iVar</string>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_external</type>
                            <form>DW_FORM_flag</form>
                            <value>
                               <flag>true</flag>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_type</type>
                            <form>DW_FORM_ref_addr</form>
                            <value>
                               <ref idref="0xa:0x12e"/>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_TI_symbol_name</type>
                            <form>DW_FORM_string</form>
                            <value>
                               <string>_iVar</string>
                            </value>
                         </attribute>
                      </die>

    Where the type reference for iVar is 0xa:0x12e, which is defined as:

                      <die id="0xa:0x12e">
                         <tag>DW_TAG_base_type</tag>
                         <attribute>
                            <type>DW_AT_name</type>
                            <form>DW_FORM_string</form>
                            <value>
                               <string>int</string>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_byte_size</type>
                            <form>DW_FORM_data1</form>
                            <value>
                               <const>0x1</const>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_encoding</type>
                            <form>DW_FORM_data1</form>
                            <value>
                               <const>0x5</const>
                            </value>
                         </attribute>
                      </die>

    2. The definition of fVar is:

                      <die id="0xa:0xc3">
                         <tag>DW_TAG_variable</tag>
                         <attribute>
                            <type>DW_AT_location</type>
                            <form>DW_FORM_block1</form>
                            <value>
                               <block>DW_OP_addr 0xa808</block>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_name</type>
                            <form>DW_FORM_string</form>
                            <value>
                               <string>fVar</string>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_external</type>
                            <form>DW_FORM_flag</form>
                            <value>
                               <flag>true</flag>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_type</type>
                            <form>DW_FORM_ref_addr</form>
                            <value>
                               <ref idref="0xa:0x181"/>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_TI_symbol_name</type>
                            <form>DW_FORM_string</form>
                            <value>
                               <string>_fVar</string>
                            </value>
                         </attribute>
                      </die>

    Where the type reference for fVar is 0xa:0x181, which is defined as:

                      <die id="0xa:0x181">
                         <tag>DW_TAG_base_type</tag>
                         <attribute>
                            <type>DW_AT_name</type>
                            <form>DW_FORM_string</form>
                            <value>
                               <string>float</string>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_byte_size</type>
                            <form>DW_FORM_data1</form>
                            <value>
                               <const>0x2</const>
                            </value>
                         </attribute>
                         <attribute>
                            <type>DW_AT_encoding</type>
                            <form>DW_FORM_data1</form>
                            <value>
                               <const>0x4</const>
                            </value>
                         </attribute>
                      </die>

  • Thank you, that helps.