-
Notifications
You must be signed in to change notification settings - Fork 233
Compiling the gdbserver for native riscv execution #96
Comments
These are defined in gdb/riscv-linux-nat.c and gdb/gdbserver/riscv-linux-low.c and should be getting picked up from one of those (depending on if you're building GDB or gdbserver). I don't think anyone has tried this in a while, so it's probably just some build system drift. Does something like this
work? |
Thank you very much Palmer. I couldn't apply the patch directly, so I did it by hand and run it again. Sadly I got the same error:
But now I see the riscv-linux-nat included into the linking.
while the riscv-linux-nat has it implemented with following arguments:
|
I realised that I don't need gdb to run natively, the only gdbserver would be enough. So I went to the gdb/gdbserver directory. Run the ./configure --prefix=$RISCV --host=riscv64-unknown-linux-gnu --target=riscv64-unknown-linux-gnu And then make was failing on a missing include which linux-riscv-low includes:
|
Looks like you just want host to build gdbserver: https://sourceware.org/gdb/wiki/BuildingCrossGDBandGDBserver#For_GDBserver |
Thank you very much for your answer. I deleted the whole directory (this reverted the patch as well), started fresh, made separate directories for the builds as the instructions advised, used host only for the gdbserver. But still same error:
|
I don't want to over-complicate things too much and I don't understand the topic good enough, but would the be possible or better to cross compile the GCC so that could run native and maybe under the Linux compile the gdb natively? Or I'm making the things worse? |
You could try, but it probably won't fix the problem. IIRC there's support in riscv-gnu-toolchain for this sort of cross compile, we do it to generate the Windows binaries. |
Is there maybe something else I could do? As you probably noticed my toolchain knowledge is limited. Personally, I don't mind any type of process if it will produce a working native binary. |
So about a year ago we (Fedora) were able to get gdb built and running as a RISC-V executable. It turned out to not be especially useful because neither "target native" nor "target core" worked; "target remote" did, but if you want to debug remotely you don't need to be on the target. That was a year ago, it's possible the native and core targets have been implemented since then. Meanwhile I've learned a couple things about interpreting core dumps in hex editors… |
GDB yes, but what about gdb-server? You mean that I don't need the gdbserver running on the target to remotely debug an application? |
To my current knowledge, gdb-server doesn't work at all no matter where you run it. I could easily have missed this being fixed. My knowledge is, again, a year old. |
Thank you very much for your insights. |
It's a little bit strange that if we have riscv-linux works, neither native gdb nor gdb-server works. |
This has nothing to do with the debug spec. The debug spec is ONLY for debugging systems. You can debug user mode programs currently using qemu-user's gdb stub. Just not under riscv-linux. |
Personally I would prefer the gdb-server over the gdb-stub. Probably the gdb-server it's not high enough priority at the moment? |
FWIW the correct patch to fix this is:
|
Patch committed via pull request #126 fixing building native gdb. I didn't check native gdbserver, it didn't configure for me. |
gdbserver only configures for native builds. I hacked around this to try a canadian cross build, but it fails because of a missing arch/abi.h header file which I see was already mentioned. I think this linux-riscv-low.c was copied from linux-tile-low.c and is useless as is. Note for instance the reference to tilegx near the bottom of the linux-tile-low.c file, which makes sense, and the reference to riscvgx near the bottom of the linux-riscv-low.c file which makes no sense. This is just a simple string replacement which was never tested. Someone will have to do a gdbserver port from scratch before we will be able to build it, though you can probably use the existing linux-riscv-low.c file as a template to start with. We will still need the gdbserver/Makefile.in patch Palmer suggested, to add linux-riscv-low.c to SFILES. |
Anybody know if there's been any update/change in the status of gdbserver for RISC-V? |
@jim-wilson Was there a specific use case you needed to do the Canadian cross build? |
The only use case is responding to bug reports. I saw a bug report that native gdb and gdbserver would not build. I did a canadian cross build to reproduce the native gdb problem and fix it. But gdbserver does not configure in a canadian cross build, so I hacked the configure scripts to work around this, and then discovered that we don't actually have a gdbserver port, just some useless code pretending to be a gdbserver port, so I stopped looking at gdbserver. Someone needs to do a port from scratch. Embecosm has been working on improving the gdb port, with the eventual goal of upstreaming it, but I haven't seen any progress reports from them, so I don't know what is happening there. I don't know if they have looked at gdbserver. I haven't tried running native gdb. I haven't needed it as yet. I've only done some debugging with printf. But now that we have hardware, I may have a need for gdb soon, and may have to take a look at this. |
Thanks Jim |
When I was starting the Go runtime bringup I was using gdb with the qemu-riscv64 gdb stub. However, that doesn't work well at all with multithreaded programs, so once the runtime was working well enough to start threads I switched back to prints. I was never able to get gdb to work with a native or core target. Additionally, it seems likely that riscv linux ptrace() and core dump functionality has seen close to zero testing, so fixes there may be needed in addition to gdb work. |
Thanks sorear - so it sounds like proper/adequate RISC-V linux app debug support may be a long way off at the moment if people are forced to use printf "debugging" right now. Pity... :-( |
Thanks @jim-wilson and @sorear for clarifications. It's a problem, but at least it's good to know it's real problem. In the beginning, when I was opening this ticket I was not even sure if the fault is on my side because I just don't understand it and my skills are lacking, while somebody else is happily debugging with his gdbserver. After the presentation with the RISC-V and the Quake is clear the Linux is getting closer. And I would say the gdbserver is an important part for the toolchain to be supporting Linux targets properly. |
gdbserver is quite useful when a kernel port begins to work, but in the meantime, I used to debug userspace applications via 'normal' gdb (gdb used to debug any bare applications) with a small 'hack' : 1/ Launch your kernel (via qemu with -s option) Finally, you should break into the main function of your app and you can debug it as you would do with a userspace gdb.
Alex |
RISC-V Linux native support is now present in upstream FSF gdb, and will appear in riscv-binutils-gdb when the upstream FSF gdb port replaces our local port. gdbserver support is still missing. |
That is great news :) |
Maciej (macro) of WDC has posted patches for riscv linux gdbserver support to the FSF gdb-patches mailing list. It is looking good so far and should be accepted upstream within a few days. That would put it in the next FSF gdb release, which is probably a few months away. |
Thanks for heads up, will have to give it a try. |
Hi
This is probably more a question than an issue. I'm not even sure if this is possible, but at the moment I'm trying to compile the binutils so I will get gdb-server which could be run natively on the riscv linux. My goal is to be able to debug remotely user space application inside the riscv linux.
I use the riscv-next branch and configure it with these commands:
./configure --prefix=$RISCV --host=riscv64-unknown-linux-gnu --target=riscv64-unknown-linux-gnu
And it the end it outputs these errors:
I attached the whole log file
gdbserver-build.txt
Compiling the kernel, busybox and making my own rootfs works well, I only get stuck at step. Could somebody point me to the right direction or if this is even feasible or not?
The text was updated successfully, but these errors were encountered: