2011-06-06 80 views
8

我已經通過在Emacs 23.3 GUD使用PDB開始,我怎麼能勾發送到從緩衝區中的調試器命令消息?我寫了以下的建議,供用gdb使用,以堅持COMINT的戒指,卻找不到一個同等功能的掛鉤PDB。我使用python-mode.el作爲我的主要模式。我如何通過gud發送到pdb的鉤子命令?

謝謝。

(defadvice gdb-send-item (before gdb-save-history first nil activate) 
    "write input ring on quit" 
    (if (equal (type-of item) 'string) ; avoid problems with 'unprintable' structures sent to this function.. 
    (if (string-match "^q\\(u\\|ui\\|uit\\)?$" item) 
     (progn (comint-write-input-ring) 
      (message "history file '%s' written" comint-input-ring-file-name))))) 
+0

一張字條:「GDB-發送項目」從emacs的去除(23.3)和現在(24.3)之間的地方,那麼,而是簡單地在答案的建議合併上面的字符串匹配下面有我的emacs GUD/GDB並再次同步外部gdb歷史記錄 – elbeardmorez 2013-05-03 07:09:40

回答

1

我想我大概會在只有多一點挖的時候已經回答了我自己的問題,但第一個gdb的解決方案,而把它從我的舊學前。我回過神來,所以..

C-H B C-S主要

後有點滾動,我們可以找出的「通信情報,送輸入」作爲必然鍵「進入」功能。看着這個功能的源代碼,comint.el:1765是「運行鉤與-ARGS」 ..this一個電話就是我們認識到,沒有什麼地方特別是「PDB」做我們想要的。

GUD是一個通用的包裝來調用外部調試過程並返回結果..hence控制是不存在的elisp的。它是用gdb相同,但有圍繞這使得告知該功能覺得「乾淨」外部調用一個不錯的(預先存在的)包裝。

所以黑客..只是上面的 '通信情報,發送輸入' 謊言 'COMINT-添加到輸入歷史' ..容易死人。

;;save command history 
(defadvice comint-add-to-input-history (before pdb-save-history activate compile) 
    "write input ring on exit" 
    (message "%s" cmd) 
    (if (string-match "^e\\(x\\|xi\\|xit\\)?$" cmd) 
    (progn (comint-write-input-ring) 
    (message "history file '%s' written" comint-input-ring-file-name))) 
) 

僅供參考,我有這些是開始爲調試會話

;#debugger history 
(defun debug-history-ring (file) 
    (comint-read-input-ring t) 
    (setq comint-input-ring-file-name file) 
    (setq comint-input-ring-size 1000) 
    (setq comint-input-ignoredups t)) 
(let ((hooks '((gdb-mode-hook . (lambda() (debug-history-ring "~/.gdbhist"))) 
     (pdb-mode-hook . (lambda() (debug-history-ring "~/.pythonhist")))))) 
    (dolist (hook hooks) (print (cdr hook)) (add-hook (car hook) (cdr hook)))) 

..和輸入環寫入歷史文件,如果調試緩衝區被殺害

(add-hook 'kill-buffer-hook 'comint-write-input-ring) 

乾杯。