Weird gdb behaviour
Created by: jrrk
When the gdb/openocd debugger stops at a breakpoint, register A0 is always zero. If the programmer debugs any expression involving A0 at that point, the debugger may perform an illegal access. Since A0 is the first function parameter, this is a highly likely scenario if it contains a pointer. A workaround of adding a dummy first parameter in the source code to each function that might be stopped in the debugger fixes the problem. Single stepping involving instructions that read A0 gives the expected (non zero) answer. This is suggestive to me that reporting temporary registers used in the debugger service ROM is incorrect, or perhaps an API incompatibility in openocd.
Open On-Chip Debugger 0.10.0+dev-00778-g425c0a7 (2019-01-15-17:51) GNU gdb (GDB) 8.0.50.20170724-git ariane development branch (based on master branch)