-
Notifications
You must be signed in to change notification settings - Fork 607
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about debug mode on branch nanhu
#2317
Comments
把sysbus改成progbuf试试,sysbus读写有点问题 [TRANSLATION] |
另外,请用reset halt代替halt,这样可以让核心停在第一条指令执行之前 [TRANSLATION] |
附上我们使用的openocd.cfg adapter speed 10000
adapter driver remote_bitbang
remote_bitbang host localhost
remote_bitbang port 23334
set _CHIPNAME riscv
jtag newtap $_CHIPNAME cpu -irlen 5
set _TARGETNAME $_CHIPNAME.cpu
target create $_TARGETNAME riscv -chain-position $_TARGETNAME
riscv set_reset_timeout_sec 120
riscv set_command_timeout_sec 30
riscv set_mem_access progbuf
init
reset halt
echo "Halt at reset"
echo "sleep 10000ms"
sleep 10000
echo "Ready for Remote Connections" |
这会和我的openocd安装不正确有关吗 |
我安装openocd的命令如下: 请问在./configure那一步是不是需要加些其他的配置 |
我们最近有同事走了一遍流程,没遇到问题。openocd没有特殊的配置,用的是 你可以忽略读0x0这个地址的报错,继续往后调试,因为这可能是riscv-openocd或者riscv-gdb抽风,正常情况下不会有读这个地址的需求。 在openocd的启动命令里指定debug_level=3可以输出更详细的log,从log里你应该可以观察到gdb发出了扫描寄存器的请求,耐心等待扫描完pc和32个通用寄存器后,gdb就可以工作了。 [TRANSLATION] You can ignore the error reading at 0x0 and continue debugging, as this could be a riscv-openocd or riscv-gdb leak, which would not normally be required. Specifying debug_level=3 in the openocd launch command will output a more detailed log, from which you should observe that gdb asks to scan the registers, and after patiently waiting for the pc and 32 general-purpose registers to be scanned, gdb is ready to work. 读寄存器的过程
然后是openocd给gdb发送通用寄存器和PC值
随后gdb应该就可以操作了。 |
那请问用的是什么case呢,我用的是Xiangshan目录下ready-to-run的linux.bin,和tests目录下使用命令make ARCH=riscv64-xs编译的*.elf case。 |
方便的话可以看看你们 gdb 端的情况吗,我每次都是打完一个断点,然后运行命令 c 就卡死了。 [TRANSLATION] |
$ riscv64-unknown-elf-gdb ../nexus-am/apps/jtag_debug/build/jtag_debug-riscv64-xs-flash.elf
GNU gdb (GDB) 10.1
Copyright (C) 2020 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-pc-linux-gnu --target=riscv64-unknown-elf".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ../nexus-am/apps/jtag_debug/build/jtag_debug-riscv64-xs-flash.elf...
(gdb) set remotetimeout 100000
(gdb) target extended-remote localhost:3333
Remote debugging using localhost:3333
0x0000000010000000 in _start ()
(gdb) disassemble _start
Dump of assembler code for function _start:
=> 0x0000000010000000 <+0>: li s0,0
0x0000000010000004 <+4>: auipc sp,0x70008
0x0000000010000008 <+8>: addi sp,sp,-4 # 0x80008000
0x000000001000000c <+12>: lui a0,0x2
0x000000001000000e <+14>: csrs mstatus,a0
0x0000000010000012 <+18>: csrwi fcsr,0
0x0000000010000016 <+22>: jal ra,0x1000006c <_trm_init>
End of assembler dump.
(gdb) thb 7
Hardware assisted breakpoint 1 at 0x10000034: file nexus-am/apps/jtag_debug/jtag_debug.c, line 7.
(gdb) hb 6
Hardware assisted breakpoint 2 at 0x1000001a: file nexus-am/apps/jtag_debug/jtag_debug.c, line 6.
(gdb) hb 9
Hardware assisted breakpoint 3 at 0x10000042: file nexus-am/apps/jtag_debug/jtag_debug.c, line 9.
(gdb) c
Continuing.
Breakpoint 2, main () at nexus-am/apps/jtag_debug/jtag_debug.c:6
6 for (i = 0; i < 10000; i++) {
(gdb) disassemble main
Dump of assembler code for function main:
=> 0x000000001000001a <+0>: addi sp,sp,-32
0x000000001000001c <+2>: sd s1,8(sp)
0x000000001000001e <+4>: lui s1,0x2
0x0000000010000020 <+6>: sd s0,16(sp)
0x0000000010000022 <+8>: sd s2,0(sp)
0x0000000010000024 <+10>: sd ra,24(sp)
0x0000000010000026 <+12>: li s0,0
0x0000000010000028 <+14>: auipc s2,0x1
0x000000001000002c <+18>: addi s2,s2,272 # 0x10001138
0x0000000010000030 <+22>: addi s1,s1,1808 # 0x2710
0x0000000010000034 <+26>: mv a1,s0
0x0000000010000036 <+28>: mv a0,s2
0x0000000010000038 <+30>: addiw s0,s0,1
0x000000001000003a <+32>: jal ra,0x10001106 <printf_>
0x000000001000003e <+36>: bne s0,s1,0x10000034 <main+26>
0x0000000010000042 <+40>: ld ra,24(sp)
0x0000000010000044 <+42>: ld s0,16(sp)
0x0000000010000046 <+44>: ld s1,8(sp)
0x0000000010000048 <+46>: ld s2,0(sp)
0x000000001000004a <+48>: li a0,0
0x000000001000004c <+50>: addi sp,sp,32
0x000000001000004e <+52>: ret
End of assembler dump.
(gdb) si
0x000000001000001c 6 for (i = 0; i < 10000; i++) {
(gdb) si
0x000000001000001e 6 for (i = 0; i < 10000; i++) {
(gdb) disassemble main
Dump of assembler code for function main:
0x000000001000001a <+0>: addi sp,sp,-32
0x000000001000001c <+2>: sd s1,8(sp)
=> 0x000000001000001e <+4>: lui s1,0x2
0x0000000010000020 <+6>: sd s0,16(sp)
0x0000000010000022 <+8>: sd s2,0(sp)
0x0000000010000024 <+10>: sd ra,24(sp)
0x0000000010000026 <+12>: li s0,0
0x0000000010000028 <+14>: auipc s2,0x1
0x000000001000002c <+18>: addi s2,s2,272 # 0x10001138
0x0000000010000030 <+22>: addi s1,s1,1808 # 0x2710
0x0000000010000034 <+26>: mv a1,s0
0x0000000010000036 <+28>: mv a0,s2
0x0000000010000038 <+30>: addiw s0,s0,1
0x000000001000003a <+32>: jal ra,0x10001106 <printf_>
0x000000001000003e <+36>: bne s0,s1,0x10000034 <main+26>
0x0000000010000042 <+40>: ld ra,24(sp)
0x0000000010000044 <+42>: ld s0,16(sp)
0x0000000010000046 <+44>: ld s1,8(sp)
0x0000000010000048 <+46>: ld s2,0(sp)
0x000000001000004a <+48>: li a0,0
0x000000001000004c <+50>: addi sp,sp,32
0x000000001000004e <+52>: ret
End of assembler dump.
(gdb) info b
Num Type Disp Enb Address What
1 hw breakpoint del y 0x0000000010000034 in main
at nexus-am/apps/jtag_debug/jtag_debug.c:7
2 hw breakpoint keep y 0x000000001000001a in main
at nexus-am/apps/jtag_debug/jtag_debug.c:6
breakpoint already hit 1 time
3 hw breakpoint keep y 0x0000000010000042 in main
at nexus-am/apps/jtag_debug/jtag_debug.c:9
(gdb) c
Continuing.
Temporary breakpoint 1, main ()
at nexus-am/apps/jtag_debug/jtag_debug.c:7
7 printf("loop counter %d\n", i);
(gdb) info b
Num Type Disp Enb Address What
2 hw breakpoint keep y 0x000000001000001a in main
at nexus-am/apps/jtag_debug/jtag_debug.c:6
breakpoint already hit 1 time
3 hw breakpoint keep y 0x0000000010000042 in main
at nexus-am/apps/jtag_debug/jtag_debug.c:9
(gdb) thb *0x000000001000003a
Hardware assisted breakpoint 4 at 0x1000003a: file nexus-am/apps/jtag_debug/jtag_debug.c, line 7.
(gdb) info b
Num Type Disp Enb Address What
2 hw breakpoint keep y 0x000000001000001a in main
at nexus-am/apps/jtag_debug/jtag_debug.c:6
breakpoint already hit 1 time
3 hw breakpoint keep y 0x0000000010000042 in main
at nexus-am/apps/jtag_debug/jtag_debug.c:9
4 hw breakpoint del y 0x000000001000003a in main
at nexus-am/apps/jtag_debug/jtag_debug.c:7
(gdb) c
Continuing.
Temporary breakpoint 4, 0x000000001000003a in main ()
at nexus-am/apps/jtag_debug/jtag_debug.c:7
7 printf("loop counter %d\n", i);
(gdb) disassemble main
Dump of assembler code for function main:
0x000000001000001a <+0>: addi sp,sp,-32
0x000000001000001c <+2>: sd s1,8(sp)
0x000000001000001e <+4>: lui s1,0x2
0x0000000010000020 <+6>: sd s0,16(sp)
0x0000000010000022 <+8>: sd s2,0(sp)
0x0000000010000024 <+10>: sd ra,24(sp)
0x0000000010000026 <+12>: li s0,0
0x0000000010000028 <+14>: auipc s2,0x1
0x000000001000002c <+18>: addi s2,s2,272 # 0x10001138
0x0000000010000030 <+22>: addi s1,s1,1808 # 0x2710
0x0000000010000034 <+26>: mv a1,s0
0x0000000010000036 <+28>: mv a0,s2
0x0000000010000038 <+30>: addiw s0,s0,1
=> 0x000000001000003a <+32>: jal ra,0x10001106 <printf_>
0x000000001000003e <+36>: bne s0,s1,0x10000034 <main+26>
0x0000000010000042 <+40>: ld ra,24(sp)
0x0000000010000044 <+42>: ld s0,16(sp)
0x0000000010000046 <+44>: ld s1,8(sp)
0x0000000010000048 <+46>: ld s2,0(sp)
0x000000001000004a <+48>: li a0,0
0x000000001000004c <+50>: addi sp,sp,32
0x000000001000004e <+52>: ret
End of assembler dump.
(gdb) si
0x0000000010001108 in printf_ (format=format@entry=0x10001138 "loop counter %d\n")
at nexus-am/libs/klib/src/printf.c:865
865 va_start(va, format);
(gdb) c
Continuing.
^C
Program received signal SIGINT, Interrupt.
0x0000000010000cac in _vsnprintf (out=out@entry=0x10000a34 <_out_char>,
buffer=buffer@entry=0x80007f70 "cient me\230\177",
maxlen=maxlen@entry=18446744073709551615, format=<optimized out>,
format@entry=0x10001138 "loop counter %d\n", va=0x80007fa0, va@entry=0x80007f98)
at nexus-am/libs/klib/src/printf.c:736
736 idx = _ntoa_long(out, buffer, idx, maxlen, (unsigned int)(value > 0 ? value : 0 - value), value < 0, base, precision, width, flags);
(gdb) info b
Num Type Disp Enb Address What
2 hw breakpoint keep y 0x000000001000001a in main
at nexus-am/apps/jtag_debug/jtag_debug.c:6
breakpoint already hit 1 time
3 hw breakpoint keep y 0x0000000010000042 in main
at nexus-am/apps/jtag_debug/jtag_debug.c:9
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: nexus-am/apps/jtag_debug/build/jtag_debug-riscv64-xs-flash.elf
Breakpoint 2, main () at nexus-am/apps/jtag_debug/jtag_debug.c:6
6 for (i = 0; i < 10000; i++) {
(gdb) clear 6
Deleted breakpoint 2
(gdb) clear 9
Deleted breakpoint 3
(gdb) info b
No breakpoints or watchpoints.
(gdb) monitor reset halt
JTAG tap: riscv.cpu tap/device found: 0x00000001 (mfg: 0x000 (<invalid>), part: 0x0000, ver: 0x0)
keep_alive() was not invoked in the 1000 ms timelimit. GDB alive packet not sent! (1266 ms). Workaround: increase "set remotetimeout" in GDB
(gdb) info r pc
pc 0x1000001a 0x1000001a <main>
(gdb) si
0x0000000010000004 in _start ()
(gdb) info r pc
pc 0x10000004 0x10000004 <_start+4>
(gdb) q
A debugging session is active.
Inferior 1 [Remote target] will be detached.
Quit anyway? (y or n) y
Detaching from program: jtag_debug-riscv64-xs-flash.elf, Remote target
[Inferior 1 (Remote target) detached] |
我在nexus-am仓库自己构建的测试,用来测试硬件断点(因为软件断点是用break指令替换原指令实现的,和trigger无关) // nexus-am/apps/jtag_debug/jtag_debug.c
#include <klib.h>
int main()
{
int i;
for (i = 0; i < 10000; i++) {
printf("loop counter %d\n", i);
}
return 0;
} # nexus-am/apps/jtag_debug/Makefile
NAME = jtag_debug
SRCS = jtag_debug.c
include $(AM_HOME)/Makefile.app 然后 build/emu --flash jtag_debug -i anything --enable-jtag |
请用 [TRANSLATION] |
请问现在香山对于每个hart的run control状态位功能都实现了吗?(halt request,resume ack,halt-on-reset request,hart reset) [TRANSLATION] May I ask whether Xiangshan has implemented the function of run control status bit for each hart? (halt request, resume ack, Halt-on-reset request, hart reset) |
我看现在代码hart reset功能好像是false的,想确认一下。 |
请问如果想调试 debug 模式一般用什么方法呀? [TRANSLATION] |
你好,我调试是使用emu dump 波形命令,没有波形生成。命令如下: [TRANSLATION] build/emu --flash jtag_debug -i anything --no-diff --enable-jtag -b 0 -e 150000 --max-cycles=150000 --force-dump-result --dump-wave --wave-path .. /1.vcd |
你好,麻烦在编译的时候加上 比如 make emu -j64 EMU_THREADS=16 EMU_TRACE=1 |
我找负责的同事问问 |
好的,谢谢啦 |
nanhu
当前这些功能都是支持的 |
使用nanhu分支尝试调试模式,在GDB端对当前pc地址+4打断点,然后run程序,很久都没有跑到断点处,请问这是什么原因?
[TRANSLATION]
Use nanhu branch to try to debug mode, in the GDB side of the current pc address +4 break point, and then run program, did not run to the breakpoint for a long time, what is the reason?
emu端:
openocd端:
config.cfg内容:
gdb端:
The text was updated successfully, but these errors were encountered: