0

I compile an ELF file including debug info and then read the debug-info back and parse it to get a list of all variables (global variables and class variables) in the RAM. This already works with the older version of the compiler, but with the newer version the debug-info looks different, although both outputs are DWARF v4 format. So the existing parser does not work anymore.

As an example before in compiler version 7.3.1 the output for a global variable was only one DW_TAG_variable which includes directly the address (DW_AT_location):

 <1><26ec2>: Abbrev Number: 90 (DW_TAG_variable)
    <26ec3>   DW_AT_name        : (indirect string, offset: 0x165b): SystemCoreClock
    <26ec7>   DW_AT_decl_file   : 120
    <26ec8>   DW_AT_decl_line   : 135
    <26ec9>   DW_AT_type        : <0x4d>
    <26ecd>   DW_AT_location    : 5 byte block: 3 68 0 0 20     (DW_OP_addr: 20000068)

Now in version 10.3.1 this is split to 3 different DW_TAG_variable which are linked backwards. The first one containing the name and the last one containing the address:

 <1><b3540>: Abbrev Number: 13 (DW_TAG_variable)
    <b3541>   DW_AT_name        : (indirect string, offset: 0x2f0a0): SystemCoreClock
    <b3545>   DW_AT_decl_file   : 4
    <b3546>   DW_AT_decl_line   : 58
    <b3547>   DW_AT_decl_column : 17
    <b3548>   DW_AT_type        : <0xb3379>
    <b354c>   DW_AT_external    : 1
    <b354c>   DW_AT_declaration : 1


 <1><b37d5>: Abbrev Number: 14 (DW_TAG_variable)
    <b37d6>   DW_AT_specification: <0xb3540>
    <b37da>   DW_AT_decl_file   : 6
    <b37db>   DW_AT_decl_line   : 135
    <b37dc>   DW_AT_decl_column : 12


 <1><14cfe>: Abbrev Number: 30 (DW_TAG_variable)
    <14cff>   DW_AT_abstract_origin: <0xb37d5>
    <14d03>   DW_AT_location    : 5 byte block: 3 0 0 0 20  (DW_OP_addr: 20000000)

The compiler used is arm-none-eabi-gcc.

Is there any way to get the debug-info with the new compiler version back to way it was?

I already tried some different compiler options like "-gdwarf-version" but without success so far.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
Martin
  • 11
  • 1

1 Answers1

0

Is there any way to get the debug-info with the new compiler version back to way it was?

No. The new way is more accurate, and the compiler just isn't going to degrade the info it outputs for the benefit of your parser.

Employed Russian
  • 199,314
  • 34
  • 295
  • 362
  • Thank you for your answer! Unfortunately I was already expecting this.. Do you know if there is a parser available that parses all global variables AND also class variables so that I have name, address in RAM and type: GlobalVariableName Address DataType ObjectName.ClassVariableName Address DataType – Martin Apr 06 '23 at 07:14
  • @Martin The "standard" DWARF parser is libwarf https://www.prevanders.net/dwarf.html. There is also (newer) https://github.com/aclements/libelfin. I have no experience with either. – Employed Russian Apr 06 '23 at 16:41