How to use riscv gdb

1,420 views
Skip to first unread message

b little

unread,
Jul 11, 2018, 2:19:04 PM7/11/18
to RISC-V SW Dev
Hi, I'm currently developing a framework supporting risc v, but I have been struggling trying to use the gdb from the riscv port.
https://github.com/riscv/riscv-binutils-gdb

I failed trying to use it to debug code natively by running gdb in qemu using fedora image and also failed trying to use the coredump file on gdb for analysis.
Although the debugging with spike works, that doesn't help with finding the bug in my code.

I'm trying to use openocd, gdb and spike, but my program spans a large memory image so I'm not sure that will work.

I was wondering if you could share your experience on using the gdb if you have succeeded using it.

That would be very helpful.

Thank you.

Jim Wilson

unread,
Jul 11, 2018, 2:36:21 PM7/11/18
to b little, RISC-V SW Dev
On Wed, Jul 11, 2018 at 11:19 AM, b little <ror...@gmail.com> wrote:
> Hi, I'm currently developing a framework supporting risc v, but I have been
> struggling trying to use the gdb from the riscv port.
> https://github.com/riscv/riscv-binutils-gdb

I doubt that the native linux support in that gdb will work. The core
architecture support for gdb has been upstreamed to FSF gdb, but there
is no RISC-V native linux support in that gdb tree.

I have a gdb port in progress based off of the FSF gdb tree. It
requires both gdb and linux kernel patches, and will probably be a
while before it is fully functional, as I need to write some more gdb
and linux kernel patches to get it fully working, and it will take
time to get the patches upstreamed and merged into linux distros, etc.
See
https://github.com/jim-wilson/riscv-linux-native-gdb
The README.md file mentions the linux kernel patches you need to make
it work at present; this list will be changing as the port progresses.
Only some basic commands are working: break, run, stepi, etc. Only
integer registers are supported. Some shared library features are
working. There is no core file support, but then I've never seen a
RISC-V corefile be generated by any kernel I've tried. I've only
tested this on Fedora with a patched kernel, both running on qemu and
on the HiFive Unleashed. I'm in the process of trying to add support
for FP registers now, that will require another linux kernel patch.

Jim

b little

unread,
Jul 11, 2018, 2:46:11 PM7/11/18
to RISC-V SW Dev, ror...@gmail.com
Thank you. 
I just have basic requirements for debugging. 
The functions you have just mentioned should be sufficient.
I'll try it out to see if it works or not.

By the way, I found the core file I was looking for in /var/lib/systmed/coredump/.
It was dumped because of segmentation fault.
When I was using the corefile on the natively built gdb on Fedora, gdb said unrecognized core file format.
So, there's probably no support for that now. 

在 2018年7月11日星期三 UTC+1下午7:36:21,Jim Wilson写道:

Jim Wilson

unread,
Jul 11, 2018, 3:35:35 PM7/11/18
to b little, RISC-V SW Dev
On Wed, Jul 11, 2018 at 11:46 AM, b little <ror...@gmail.com> wrote:
> By the way, I found the core file I was looking for in
> /var/lib/systmed/coredump/.

Thanks. This is some systemd wierdness I hadn't ran into before.
You can use coredumpctl to access the core dumps. But now that I have
a corefile I've got another item to add to my gdb TODO list.

Jim
Reply all
Reply to author
Forward
0 new messages