調(diào)試代碼的時(shí)候,只能看到下一行,每次使用list非常煩,不知道當(dāng)前代碼的context
http:///guide/bggdb/#compiling
簡(jiǎn)單來(lái)說(shuō)就是在以往的gdb開(kāi)始的時(shí)候添加一個(gè)-tui選項(xiàng).有的版本已經(jīng)有g(shù)dbtui這個(gè)程序了
在linux自帶的終端里是正常顯示的,但是在securecrt里面,可能由于編碼的問(wèn)題,邊緣會(huì)有些亂碼,不過(guò)不影響使用(如果你的程序有錯(cuò)誤輸出,會(huì)擾亂整個(gè)界面,所以在調(diào)試的時(shí)候,建議添加2>/dev/null,這樣的話基本可用)
啟動(dòng)gdb之后,上面是src窗口,下面是cmd窗口,默認(rèn)focus在src窗口的,這樣的話上下鍵以及pagedown,pageup都是在移動(dòng)顯示代碼,并不顯示上下的調(diào)試命令.這個(gè)時(shí)候要切換focus,具體可簡(jiǎn)單參見(jiàn)
(gdb) info win 查看當(dāng)前focus
SRC (36 lines) <has focus>
CMD (18 lines)
(gdb) fs next 切換focus
Focus set to CMD window.
(gdb) info win
SRC (36 lines)
CMD (18 lines) <has focus>
(gdb) fs SRC 切換指定focus
Focus set to SRC window.
(gdb)
(Window names are case in-sensitive.)
To start in neato and highly-recommended GUI mode, start the debugger with gdb -tui. (For many of the examples, below, I show the output of gdb's dumb terminal mode, but in real life I use TUI mode exclusively.)
And here is a screenshot of what you'll see, approximately:

In TUI mode, the layout command controls which windows you see. Additionally, the tui reg allows control of the register window, and will open it if it's not already open.
The commands are:| layout src | Standard layout—source on top, command window on the bottom |
| layout asm | Just like the "src" layout, except it's an assembly window on top |
| layout split | Three windows: source on top, assembly in the middle, and command at the bottom |
| layout reg | Opens the register window on top of either source or assembly, whichever was opened last |
| tui reg general | Show the general registers |
| tui reg float | Show the floating point registers |
| tui reg system | Show the "system" registers |
| tui reg next | Show the next page of registers—this is important because there might be pages of registers that aren't in the "general", "float", or "system" sets |