2013-04-21 60 views
9

我注意到在GDB中,當發出像info variables這樣長輸出的命令時,輸出一次顯示一頁,按enter下降,q退出。使用less作爲gdb尋呼機

是否可以將默認尋呼機替換爲另一個尋呼機,如less,以便我可以上下導航,退出,搜索等?

回答

5

Is it possible to replace the default pager with another one

號:GDB不調用到外部程序來顯示輸出,它只是暫停輸出每screenfull(你可以把它不會被set height 0暫停)。

在addtion裏面emacs運行,你也可以使用screentmux(學習他們一般會幫你在很多其他情況),或者要求GDB到日誌輸出(set logging on),然後在gdb.txt任何$PAGER搜索你要。

+0

完美:我懷疑它是這樣的事情,但不知道我已經在使用'高度爲0。 tmux',所以這是最好的選擇!謝謝! – AkiRoss 2013-04-21 15:47:55

3

運行gdb裏面的emacs,你應該能夠使用emacs的分頁命令。

  1. 運行的emacs
  2. M-x gdb回報(M代表元 - 在Mac上Alt鍵或選擇)
  3. Emacs的消息欄現在將顯示消息: Run gdb (like this): gdb

更多信息可在此處獲得:http://tedlab.mit.edu/~dr/gdbintro.html

HTH

2

你可以把下面的用戶定義的命令在〜/ .gdbinit,然後

% cat ~/.gdbinit 
python import os 
define less1 
    python os.popen("less","w").write(gdb.execute("$arg0",to_string=True)) 
end 

define less2 
    python os.popen("less","w").write(gdb.execute("$arg0 $arg1",to_string=True)) 
end 
... 
% gdb 
(gdb) less2 info var 
... 
(gdb) less1 disass 
... 
+0

'回溯(最近最後一次通話): 文件 「」,1號線,在 NameError:名字 '操作系統' 沒有定義 錯誤而執行Python code.' – Barry 2015-11-22 08:04:47

+0

請您加入 「蟒蛇進口OS」。首先是gdbinit。 – wangych 2015-11-24 14:36:29