Emacs - GDB trace right to interrupt without stepping through all files

Emacs - GDB trace right to interrupt without stepping through all files

我正在从事 Pintos OS 项目。我收到此消息:

Page fault at 0xbfffefe0: not present error writing page in user context.

Pintos OS 项目的问题在于它不会简单地告诉导致异常的行和方法。

我知道如何使用 breakpoints/watchpoints 等,但是有什么方法可以直接进入它而无需逐行通过整个流程和所有 OS 文件,以便我可以跳入导致异常并在那里放置断点的行?我查看了 GDB 命令,但没有找到任何东西。

当我调试这个项目时,我必须逐步执行整个程序,直到我发现 error/exception,这非常耗时。可能有更快的方法来做到这一点。

谢谢。 整个轨迹:

nestilll@vdebian:~/Class/pintos/proj-3-bhling-nestilll-nsren/src/vm/build$ pintos -v -k -T 60 --qemu --gdb  --filesys-size=2 -p tests/vm/pt-grow-pusha -a pt-grow-pusha --swap-size=4 -- -q  -f run pt-grow-pusha
Use of literal control characters in variable names is deprecated at /home/nestilll/Class/pintos/src/utils/pintos line 909.
Prototype mismatch: sub main::SIGVTALRM () vs none at /home/nestilll/Class/pintos/src/utils/pintos line 933.
Constant subroutine SIGVTALRM redefined at /home/nestilll/Class/pintos/src/utils/pintos line 925.
warning: disabling timeout with --gdb
Copying tests/vm/pt-grow-pusha to scratch partition...
qemu -hda /tmp/N2JbACdqyV.dsk -m 4 -net none -nographic -s -S
PiLo hda1
Loading............
Kernel command line: -q -f extract run pt-grow-pusha
Pintos booting with 4,088 kB RAM...
382 pages available in kernel pool.
382 pages available in user pool.
Calibrating timer...  419,020,800 loops/s.
hda: 13,104 sectors (6 MB), model "QM00001", serial "QEMU HARDDISK"
hda1: 205 sectors (102 kB), Pintos OS kernel (20)
hda2: 4,096 sectors (2 MB), Pintos file system (21)
hda3: 98 sectors (49 kB), Pintos scratch (22)
hda4: 8,192 sectors (4 MB), Pintos swap (23)
filesys: using hda2
scratch: using hda3
swap: using hda4
Formatting file system...done.
Boot complete.
Extracting ustar archive from scratch device into file system...
Putting 'pt-grow-pusha' into the file system...
Erasing ustar archive...
Executing 'pt-grow-pusha':
(pt-grow-pusha) begin
Page fault at 0xbfffefe0: not present error writing page in user context.
pt-grow-pusha: dying due to interrupt 0x0e (#PF Page-Fault Exception).
Interrupt 0x0e (#PF Page-Fault Exception) at eip=0x804809c
 cr2=bfffefe0 error=00000006
 eax=bfffff8c ebx=00000000 ecx=0000000e edx=00000027
 esi=00000000 edi=00000000 esp=bffff000 ebp=bfffffa8
 cs=001b ds=0023 es=0023 ss=0023
pt-grow-pusha: exit(-1)
Execution of 'pt-grow-pusha' complete.
Timer: 71 ticks
Thread: 0 idle ticks, 63 kernel ticks, 8 user ticks
hda2 (filesys): 62 reads, 200 writes
hda3 (scratch): 97 reads, 2 writes
hda4 (swap): 0 reads, 0 writes
Console: 1359 characters output
Keyboard: 0 keys pressed
Exception: 1 page faults
Powering off...

When I debug this project I have to step through the whole program until I find what caused error/exception which is very time consuming. There is probably a faster way to do this.

通常你会做的是在错误之前设置一个断点。然后你的程序将运行全速运行,无需你的干预,直到达到那个点。

这里有几条皱纹。

首先,有时很难知道断点放在哪里。在这种情况下,我想我会寻找打印消息的代码,然后从那里向后工作。有时您必须在失败点停止,检查堆栈,再向上设置一个新断点,然后重新运行 程序。

然后是设置断点的机制。一种简单的方法是按函数名称中断,例如 break my_function。另一种是使用文件名和行号,如 break my_file.c:73.

最后,有时在看到失败之前可以多次命中断点。您可以使用忽略计数(参见 help ignore)或条件断点(如 break my_function if variable = 27)来限制停止次数。

使用 GDB 调试器 运行 并在所需位置停止:

gdb 文件名<--启动调试会话 br main <--在main()函数的第一行设置断点 r <--运行 直到到达断点 br filename.c:linenumber <--在所需的代码行设置另一个断点 c <--继续直到遇到第二个断点

调试器将在文件中的所需位置停止,如果它确实到达那里,