agra-uni-bremen / riscv-vp

RISC-V Virtual Prototype
MIT License
139 stars 49 forks source link

step and next does not function properly in debug mode #7

Closed U2654 closed 3 years ago

U2654 commented 3 years ago

Using the basic-debug example and connecting the gdb to the target, e.g. next just continues... Debug session example:

_start () at bootstrap.S:6
6   jal main
(gdb) c
Continuing.

Breakpoint 1, main () at main.c:14
14      int a = 5;
(gdb) next

Breakpoint 2, main () at main.c:19
19      a = f(x, y);
(gdb) 
nmeum commented 3 years ago

Works for me (assuming you have set a breakpoint in main):

$ gdb-multiarch sw/basic-debug/main
(gdb) target remote :5005
Remote debugging using :5005
_start () at bootstrap.S:6
6       jal main
(gdb) break main
Breakpoint 1 at 0x100ec: file main.c, line 14.
(gdb) cont
Continuing.

Breakpoint 1, main () at main.c:14
14              int a = 5;
(gdb) next
15              int b = 3;
(gdb) next
16              b--;

Please provide more information for reproducing this issue including the GDB version you are using and the full list of GDB commands you issued. The issue title also mentions that you encountered a problem with the step command though your issue description only mentions the next command. What kind of problem did you encounter with step?

U2654 commented 3 years ago

I just tried with a multilib version (gdb 10.1). risc-vp is freshly build. OS is Debian 10. The behaviour of next and step are the same. It continues.

./riscv64-unknown-elf-gdb --version
GNU gdb (GDB) 10.1
(gdb) target remote:5005
Remote debugging using :5005
start () at bootstrap.S:6
6   jal main
(gdb) b main
Breakpoint 1 at 0x100ec: file main.c, line 14.
(gdb) c
Continuing.

Breakpoint 1, main () at main.c:14
14      int a = 5;
(gdb) n

Program received signal SIGQUIT, Quit.
0x00010190 in _start ()
Cirromulus commented 3 years ago

Same problems with self-compiled RV-toolchain under Ubuntu, but it seems that it works with gdb-multiarch on some systems. Specifically, on mine it does not work with branch gdb-server-ipv4

(gdb) target remote :5005
Remote debugging using :5005
Truncated register 22 in remote 'g' packet
nmeum commented 3 years ago

Can reproduce this now (with the GDB from riscv-gnu-toolchain), will push a fix soonish.

nmeum commented 3 years ago

Thanks for reporting this, should be fixed now. If you encounter any further issues please let us know :)