如何使用GDB调试带SMP(对称多处理器)的QEMU?
How to use GDB to debug QEMU with SMP (symmetric multiple processors)?
我正在攻读操作系统研究生 class,我们正在使用 QEMU 模拟我们的内核,并使用 gdb 对其进行调试。调试一直很简单……直到现在。我如何将 gdb 连接到 QEMU 中 运行 的其他 CPU?
我们的 makefile 允许我们在一个终端中使用 "make qemu-nox" 或 "make qemu-nox-gdb" 启动 qemu,如果我们使用后者,则仅使用 "gdb" 与 gdb 连接在另一个终端(在同一目录中)。因此,我不太确定如何再次连接到同一个 QEMU,而是连接到不同的处理器(我现在 运行 总共有 4 个)。
每个 qemu CPU 在 gdb 中作为一个单独的线程可见。要检查另一个 CPU 的状态,请使用 thread
命令切换 CPUs。
(gdb) info thread
Id Target Id Frame
* 1 Thread 1 (CPU#0 [running]) 0x80105163 in stosl (addr=0x89c3e000, data=16843009, cnt=1024) at x86.h:44
2 Thread 2 (CPU#1 [halted ]) halt () at x86.h:127
3 Thread 3 (CPU#2 [halted ]) halt () at x86.h:127
4 Thread 4 (CPU#3 [halted ]) halt () at x86.h:127
(gdb) where
#0 0x80105163 in stosl (addr=0x89c3e000, data=16843009, cnt=1024) at x86.h:44
#1 0x801051bf in memset (dst=0x89c3e000, c=1, n=4096) at string.c:8
#2 0x80102b5a in kfree (v=0x89c3e000 "[=10=]1[=10=]1[=10=]1[=10=]1") at kalloc.c:63
#3 0x80102af4 in freerange (vstart=0x80400000, vend=0x8e000000) at kalloc.c:47
#4 0x80102ac1 in kinit2 (vstart=0x80400000, vend=0x8e000000) at kalloc.c:38
#5 0x8010386a in main () at main.c:37
(gdb) thread 3
[Switching to thread 3 (Thread 3)]
#0 halt () at x86.h:127
127 }
(gdb) where
#0 halt () at x86.h:127
#1 0x80104aeb in scheduler () at proc.c:288
#2 0x801038f6 in mpmain () at main.c:59
#3 0x801038b0 in mpenter () at main.c:50
#4 0x0000705a in ?? ()
我正在攻读操作系统研究生 class,我们正在使用 QEMU 模拟我们的内核,并使用 gdb 对其进行调试。调试一直很简单……直到现在。我如何将 gdb 连接到 QEMU 中 运行 的其他 CPU?
我们的 makefile 允许我们在一个终端中使用 "make qemu-nox" 或 "make qemu-nox-gdb" 启动 qemu,如果我们使用后者,则仅使用 "gdb" 与 gdb 连接在另一个终端(在同一目录中)。因此,我不太确定如何再次连接到同一个 QEMU,而是连接到不同的处理器(我现在 运行 总共有 4 个)。
每个 qemu CPU 在 gdb 中作为一个单独的线程可见。要检查另一个 CPU 的状态,请使用 thread
命令切换 CPUs。
(gdb) info thread
Id Target Id Frame
* 1 Thread 1 (CPU#0 [running]) 0x80105163 in stosl (addr=0x89c3e000, data=16843009, cnt=1024) at x86.h:44
2 Thread 2 (CPU#1 [halted ]) halt () at x86.h:127
3 Thread 3 (CPU#2 [halted ]) halt () at x86.h:127
4 Thread 4 (CPU#3 [halted ]) halt () at x86.h:127
(gdb) where
#0 0x80105163 in stosl (addr=0x89c3e000, data=16843009, cnt=1024) at x86.h:44
#1 0x801051bf in memset (dst=0x89c3e000, c=1, n=4096) at string.c:8
#2 0x80102b5a in kfree (v=0x89c3e000 "[=10=]1[=10=]1[=10=]1[=10=]1") at kalloc.c:63
#3 0x80102af4 in freerange (vstart=0x80400000, vend=0x8e000000) at kalloc.c:47
#4 0x80102ac1 in kinit2 (vstart=0x80400000, vend=0x8e000000) at kalloc.c:38
#5 0x8010386a in main () at main.c:37
(gdb) thread 3
[Switching to thread 3 (Thread 3)]
#0 halt () at x86.h:127
127 }
(gdb) where
#0 halt () at x86.h:127
#1 0x80104aeb in scheduler () at proc.c:288
#2 0x801038f6 in mpmain () at main.c:59
#3 0x801038b0 in mpenter () at main.c:50
#4 0x0000705a in ?? ()