2011-06-06 81 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) 

干杯。