freedom-u-sdk icon indicating copy to clipboard operation
freedom-u-sdk copied to clipboard

gdb can not work on breakpoints.

Open thomascp opened this issue 6 years ago • 3 comments

Hi All,

  1. Use qemu to simulate riscv, and it works OK. qemu-system-riscv64 -nographic -machine virt -kernel bbl -drive file=rootfs.bin,format=raw,id=hd0 -device virtio-blk-device,drive=hd0 -netdev user,id=net0 -device virtio-net-device,netdev=net0 -S -gdb tcp::12345
  2. Use gdb to connect to it riscv64-unknown-linux-gnu-gdb target remote 127.0.0.1:12345 symbol-file vmlinux
  3. But, when I add breakpoints, it can not beak at it and also print "Register 3921 is not available". (gdb) b start_kernel Register 3921 is not available

BR, Peng

thomascp avatar May 11 '18 08:05 thomascp

Yes, gdb is a problem. Some people have reported success by disabling compressed breakpoints. See for instance https://github.com/riscv/riscv-gnu-toolchain/issues/217

Some gdb support has been upstreamed to the FSF gdb tree at http://sourceware.org/gdb If you are trying the riscv-gnu-toolchain gdb, you might want to try the FSF gdb instead. The riscv-gnu-toolchain gdb is not being actively maintained. This will eventually be fixed, but not clear when. The FSF gdb is being actively maintained.

3921 incidentally is the 1.9 misa. 3921 - 65 = 3856 = 0xf10. Gdb tries to read misa to determine if there is floating point support. It tries to read the 1.10 misa first, and if that fails, then it tries to read the 1.9 misa.

jim-wilson avatar May 11 '18 17:05 jim-wilson

Hi Jim,

Thanks!

Then, I went to http://sourceware.org/gdb, downloaded the latest version gdb-8.1. I made gdb with these commands: ./configure --target=riscv64-unknown-linux-gnu --prefix=/disk/riscv/gdb-8.1/build make && make install

But, the binary runs uncorrecttly with these outputs: ./build/bin/riscv64-unknown-linux-gnu-gdb arch-utils.c:694: internal-error: initialize_current_architecture: Selection of initial architecture failed A problem internal to GDB has been detected, further debugging may prove unreliable. Quit this debugging session? (y or n) Segmentation fault (core dumped)

And also, checking information for gdb build is OK. checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... riscv64-unknown-linux-gnu

Did I make mistakes? Please help to point it out. Thanks!

BR, Peng

thomascp avatar May 12 '18 16:05 thomascp

gdb-8.1 was released on January. The RISC-V support was added in March. So you have to use the mainline development tree to get the RISC-V support.

I'm not a gdb expert, but I do find the behavior here a little odd. I would have expected a configure error for gdb, or maybe a build error, but not a run-time error.

jim-wilson avatar May 16 '18 19:05 jim-wilson