2016-11-12 43 views
0

我正在開發Pintos OS項目。我收到此消息:Emacs -GDB跟蹤權限中斷而不通過所有文件

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

Pintos OS項目的問題是它不會簡單地告訴導致異常的行和方法。

我知道如何使用斷點/觀察點等,但有沒有任何方法可以直接進入它,而無需逐行瀏覽整個流程和所有操作系統文件,這樣我就可以跳入導致異常並將斷點那裏?我查看了GDB命令,但沒有找到任何東西。

當我調試這個項目時,我必須遍歷整個程序,直到找到非常耗時的錯誤/異常。可能有更快的方法來做到這一點。

感謝。 整個跟蹤:

[email protected]:~/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... 

回答

1

有GDB調試器中運行,並在所需位置停止:

gdb的文件名< --start調試會話在main()函數的第一行 BR主要< --set斷點 [R < - -run直到斷點達到 BR FILENAME.C:行號< --set另一個斷點處的代碼所需的行 ç< --continue直到第二斷點encuntered

調試器將停止在文件中的所需位置,如果它真的到達那裏,

+0

問題是我不知道所需的位置在哪裏,直到我從開始到結束步驟,直到出現相同的異常/錯誤。在其他項目中,例如,在簡單的Java中,我可以讀取堆棧跟蹤來執行此操作。無論如何要做Pintos操作系統? –

+0

'gdb'有一個顯示堆棧跟蹤的命令。您可以使用'bt'或'backtrace'來顯示堆棧回溯。 – user3629249

+0

是的,我也使用過,並不總是有幫助。但謝謝你的建議。 –

0

當我調試這個項目我必須逐步完成整個程序 ,直到我發現是什麼原因造成的錯誤/異常,這是非常耗時。 可能有更快的方法來做到這一點。

通常情況下,您要做的就是在錯誤發生之前設置一個斷點。然後,您的程序將全速運行,無需您的干預,直到達到該點。

這裏有幾處皺紋。

首先,有時很難知道在哪裏放置斷點。在這種情況下,我想我會尋找打印消息的代碼,然後從那裏開始工作。有時你必須停在故障點,檢查堆棧,進一步設置新的斷點,然後重新運行程序。

然後是設置斷點的機制。一個簡單的方法是按功能名稱打破,如break my_function。另一種方法是使用文件名和行號,如break my_file.c:73

最後,在發現故障之前,有時可能會多次觸發斷點。您可以使用忽略計數(請參閱help ignore)或條件斷點(如break my_function if variable = 27)來限制停止次數。