RISC-V: Is it reasonable to extend current target_description for KGDB?

Vincent Chen
2019-10-15T07:43:21Z

Hi,
I am a Linux developer and trying to add the KGDB support to the
RISC-V Linux. During the porting, I encountered a GDB issue with the
'g' packet. I hope the GDB experts can give me some advice.
The KGDB is a debugger provided by the kernel for users to debug
kernel space through GDB. To parse the GDB packets, the KGDB has a
simple gdb stub. However, this gdb stub does not support the
"qSupported" packet. In this case, GDB does not know the register
configuration on the remote target. From the gdb remote debugging
messages, I guess GDB will assume that the remote target only supports
x0~x31 plus pc registers. This will cause GDB not to query the remote
target about the content of the specified register by sending a "p"
packet If the specified register does not belong to the register list
of the "g" packet. In other words, GDB only can get the information of
x0~x31 plus pc registers from KGDB.
One way to solve this problem may be to add 'qSupported' packet
support to the KGDB's gdb stub. However, I think this may be a bit
inappropriate because the KGDB in RISC-V only reports 36 registers,
namely 32 GPRs, $PC, $sstatus, $sbadaddr and $scause. Therefore, from
the viewpoint of KGDB, if the register list of the 'p' packet can
include these 36 registers, the complex implementation for the
register query flow will be unnecessary. In fact, I found that other
architectures (such as ARM, ARM64, and PowerPC) make the register list
of the 'p' packet include all reported registers. However, I am not
familiar with GDB, and I don't know if the current GDB implementation
has some limitations or points to note about achieving this feature.
Therefore, I would be grateful if anyone could give me any advice or
would like to implement it.

Thanks

Best regards
Vincent Chen