1udo6arre / svd-tools

This repository groups a set of tools using svd features for debuging...
GNU General Public License v2.0
24 stars 6 forks source link

Output values are all "DataAbort" if GDB lacks the "monitor mdw" command #3

Closed sense-Jo closed 2 years ago

sense-Jo commented 2 years ago

Hi, thank you for this nice tool. It seem there is an additional requirement that GDB includes support for the monitor mdw command. The arm-none-eabi-gdb binary on my system, as well as the one from the Zephyr SDK, did not support this command, what caused svd-tools to print only DataAbort in the output file. This is caused by GDB outputting unrecognized command 'mdw', which causes the following exceptions:

Traceback (most recent call last):
   File "~/opt/svd-tools/gdb-svd.py", line 111, in get_registers_val
   File "~/opt/svd-tools/gdb-svd.py", line 132, in get_fields_val
 TypeError: unsupported operand type(s) for >>: 'ValueError' and 'int'
 <cmsis_svd.model.SVDRegister object at 0x7fc8c251cca0>
 invalid literal for int() with base 16: "unrecognized command 'mdw'\n"

(I added some additional exception handling to gdb-svd.py, thus the line number might differ slightly)

I couldn't find out which versions of GDB support the monitor mdw command. In the end, I resorted to the GDB provided by NixOS.

erwango commented 2 years ago

I faced the same issue and got it working by replacing monitor foo bar commands by more basics commands: read: cmd = "x /x {:#x}".format(addr) write: cmd = "set *(int *){:#x} = {:#x}".format(addr, val)

I had to use these in order to get the script working on pyocd (as I had trouble to use openocd on a TF-M use case). Since using these basics commands could solve multiple issues, I think these would be useful, for instance when it is known that mmu is not in play. @1udo6arre Are you open to add an option to use these basic commands instead of mmu safe ones ?

1udo6arre commented 2 years ago

Hi

yes the monitor mdw is a specific command for openocd (Memory Display Word, can be physical for processor with mmu) . I will take account your issue (good point), and i will propose a solution to be independent of debug probe.

sorry for the latency and thank erwan for your comment