Skip to main content
Visitor II
March 4, 2020
Solved

Parsing DWARF and static variables declared in functions?

  • March 4, 2020
  • 2 replies
  • 2174 views

Do you plan to add support for parsing static variables declared in functions?

You already need to parse DWARF, maybe add location resolution for this type of variables also.

You do it in STM32CubeIDE:

0690X00000DYdI9QAL.png

We do it externally using pyelftools.

Yes, there is a lot of assumptions in our script (compression, dwarf format,...), but it works in our use case.

Kind regards,

Ziga

Code:0690X00000DYd4vQAD.png

Dwarf parsing useing pyelftools (modified example of https://github.com/eliben/pyelftools/blob/master/examples/dwarf_die_tree.py) to output also all DIE properties

0690X00000DYd6wQAD.png

"current_" is on location:

DW_AT_location = [3, 44, 1, 0, 32]

DW_OP_addr = 0x03, next bytes are in little endian

0x2000012C

    This topic has been closed for replies.
    Best answer by stephane.legargeant

    Hello

    STM32CubeMonitor uses GDB to parse the elf files. This type of variables are listed in a section "Non-debugging symbols:" which has a different formatting and is skipped by the tool.

    As a workaround, you can add the variable manually in the list of variables monitored, or use a global variable for debug purpose.

    Best regards

    Stephane

    2 replies

    ST Employee
    March 4, 2020

    Hello

    STM32CubeMonitor uses GDB to parse the elf files. This type of variables are listed in a section "Non-debugging symbols:" which has a different formatting and is skipped by the tool.

    As a workaround, you can add the variable manually in the list of variables monitored, or use a global variable for debug purpose.

    Best regards

    Stephane

    Visitor II
    March 5, 2020

    Hi,

    thank you for clarifying.

    Multiple functions can have same variable name. So name is not unique identifier.

    Makes sense.