the spike is supposed to be hanging there and waiting for gdb connection. But it runs through the whole program without stop, so that there is no way for gdb to connect with spike.
PS
Note that debugging the kernel things get pretty wonky as memory maps are set up etc. If you just want to debug a hello world program, I recommend adding:
volatile int i = 1;
while (1)
;
to the start of your program and running spike without -H. Then once youāve attached, set i to 0 to start execution.
After using -H, gdb can connect to spike. But the gdb commands can not be taken
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
0x00001000 in ?? ()
(gdb) l
1 #include <stdio.h>
2
3 volatile int flag = 1;
4
5 int main()
6 {
7 int i=0;
8
9 while(flag) ;
10
(gdb) b 5
Breakpoint 1 at 0x10174: file hello.c, line 5.
(gdb) r
The āremoteā target does not support ārunā. Try āhelp targetā or ācontinueā.
(gdb) step
Cannot find bounds of current function
(gdb)
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
0x00001000 in ?? ()
(gdb) l
1 #include <stdio.h>
2
3 volatile int flag = 1;
4
5 int main()
6 {
7 int i=0;
8
9 while(flag) ;
10
(gdb) b 5
Breakpoint 1 at 0x10174: file hello.c, line 5.
(gdb) r
The āremoteā target does not support ārunā. Try āhelp targetā or ācontinueā.
(gdb) step
Cannot find bounds of current function
(gdb) stepi
0x00001004 in ?? ()
(gdb) stepi
0x80000000 in ?? ()
(gdb) cont
Continuing.
Your breakpoint was set at 0x10174, but youāre continuing from 0x80000000, so probably you are never hitting your breakpoint. What if you try b main ?
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
0x00001000 in ?? ()
(gdb) b main
Breakpoint 1 at 0x10174: file hello.c, line 7.
(gdb) l
1 #include <stdio.h>
2
3 volatile int flag = 1;
4
5 int main()
6 {
7 int i=0;
8
9 while(flag) ;
10
(gdb) cont
Continuing.
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
0x00001000 in ?? ()
(gdb) b main
Breakpoint 1 at 0x121b0: file hello.c, line 7.
(gdb) l
1 #include <stdio.h>
2
3 volatile int flag = 1;
4
5 int main()
6 {
7 int i=0;
8
9 i=1;
10
(gdb) b 9
Breakpoint 2 at 0x121b4: file hello.c, line 9.
(gdb) c
Continuing.
Program received signal SIGINT, Interrupt.
0x000121c0 in main () at hello.c:11
11 while(flag) ;
In addition, the local variable cannot be visited also. Global variable can be printed.
(gdb) target remote localhost:9999
Remote debugging using localhost:9999
0x00001000 in ?? ()
(gdb) c
Continuing.
Program received signal SIGINT, Interrupt.
0x000121c0 in main () at hello.c:11
11 while(flag) ;
(gdb) p flag
$1 = 1
(gdb) p i
Cannot access memory at address 0x7ffffd8c
(gdb) l
6 {
7 int i=0;
8
9 i=1;
10
11 while(flag) ;
12
13 for(i=0; i<10; i++) ;
14 printf(āHello world! %d\nā, i);
15