Re: why gdb try to read address 0x0 when I set $pc，how to suppress this behavior?

庄秋彬
2023-07-19T12:44:57Z

Some debug info on another board that allows read address 0, shows that gdb did read address 0 when set pc:

(gdb) set debug remote 1
(gdb) p $pc
$2 = (void (*)()) 0xffffffff80003e4a
(gdb) set $pc=0xffffffff80003e4a
[remote] Sending packet: $m0,2#fb
[remote] Packet received: 7310
[remote] Sending packet: $m2,2#fd
[remote] Packet received: 4030
[remote] Sending packet: $g#67
[remote] Packet received: 000000000000000014ed5c80ffffffffd03d2081ffffffff78a13181ffffffff40c22081ffffffff40d71e7ed8ffffff00000000000000006036e080ffffffffe03d2081ffffffff00000000000000000000000000000000f872f180ffffffff000000000000000040c22081ffffffff010000000000000000a050fdd8ffffff0000000000000000454d495400000000f8c13181ffffffffd0c33181ffffffff000000000000000018c03181ffffffff08008080ffffffff7f000000000000003850034000000000987605400000000000000000000000000000000000000000fe030000000000000000000000000000ebdecce0000000000000000000000000 [16 bytes omitted]
[remote] Sending packet: $m0,2#fb
[remote] Packet received: 7310
[remote] Sending packet: $m2,2#fd
[remote] Packet received: 4030
> From: "庄秋彬"<mark.zhuang@spacemit.com>
> Date: Wed, Jul 19, 2023, 15:59
> Subject: why gdb try to read address 0x0 when I set $pc，how to suppress this behavior?
> To: "gdb@sourceware.org"<gdb@sourceware.org>
> Hi,
>
> I use gdb with openocd to debug a riscv board, and found that when set $pc=xxx(a non-zero value) in gdb, gdb would first read the address 0x0, which caused an error on this riscv device.
> Is there any documentation or suggestions for reading the source code to solve this problem?
> Thanks