MIT6.S081除錯技巧
阿新 • • 發佈:2022-01-16
Lab除錯總結
debug開啟
在一個視窗執行make qemu-gdb
。
在另一視窗執行gdb-multiarch kernel/kernel
,如果要匯入其他debubg的可執行檔案,如除錯find程式,執行file user/_find
,之後遠端連結gdb,target remote localhost:26000
,然後正常除錯。
一些有用的除錯技巧:
分屏
Change the layout of windows. Usage: layout prev | next | LAYOUT-NAME List of layout subcommands: layout asm -- Apply the "asm" layout. layout next -- Apply the next TUI layout. layout prev -- Apply the previous TUI layout. layout regs -- Apply the TUI register layout. layout split -- Apply the "split" layout. layout src -- Apply the "src" layout.
分屏後窗口聚焦
focus reg -- 聚焦在reg視窗
focus asm -- 聚焦在asm視窗
顯示技巧
set print address on -- 檢視地址
set print array on -- 陣列顯示
set print pretty on -- 結構體內容顯示
info顯示資訊
info breakpoints(info b) -- Status of specified breakpoints (all user-settable breakpoints if no argument). info registers(info r) -- List of integer registers and their contents, for selected stack frame.
delete
delete breakpoints -- Delete all or some breakpoints or auto-display expressions.
GDB的內建手冊
apropos -- Search for commands matching a REGEXP.