emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] master 2facb99 075/215: init.el: break and clear command use %X r


From: Rocky Bernstein
Subject: [elpa] master 2facb99 075/215: init.el: break and clear command use %X rather than %l
Date: Sat, 30 Jul 2016 14:48:55 +0000 (UTC)

branch: master
commit 2facb99aa81ae31b5d898030ca430d250f865a46
Author: rocky <address@hidden>
Commit: rocky <address@hidden>

    init.el: break and clear command use %X rather than %l
    Add some support functions for invoking via gdb -p. Fixes issue #58
---
 realgud/debugger/gdb/gdb.el  |   45 ++++++++++++++++++++++++++++++++++++++++++
 realgud/debugger/gdb/init.el |    4 ++--
 2 files changed, 47 insertions(+), 2 deletions(-)

diff --git a/realgud/debugger/gdb/gdb.el b/realgud/debugger/gdb/gdb.el
index c93c4db..e5d3432 100644
--- a/realgud/debugger/gdb/gdb.el
+++ b/realgud/debugger/gdb/gdb.el
@@ -21,8 +21,17 @@
 (require 'load-relative)
 (require-relative-list '("../../common/helper" "../../common/utils")
                       "realgud-")
+
+(require-relative-list '("../../common/buffer/command"
+                        "../../common/buffer/source")
+                      "realgud-buffer-")
+
 (require-relative-list '("core" "track-mode") "realgud:gdb-")
 
+(declare-function realgud-cmdbuf? 'realgud-buffer-command)
+(declare-function realgud:cmdbuf-associate 'realgud-buffer-source)
+(declare-function realgud-parse-command-arg 'realgud-core)
+
 ;; This is needed, or at least the docstring part of it is needed to
 ;; get the customization menu to work in Emacs 24.
 (defgroup realgud:gdb nil
@@ -53,6 +62,42 @@ This should be an executable on your path, or an absolute 
file name."
 ;; The end.
 ;;
 
+(defun realgud:gdb-pid-command-buffer (pid)
+  "Return the command buffer used when gdb -p PID is invoked"
+  (format "*gdb %d shell*" pid)
+  )
+
+(defun realgud:gdb-find-command-buffer (pid)
+  "Find the among current buffers a buffer that is a realgud command buffer
+running gdb on process number PID"
+  (let ((find-cmd-buf (realgud:gdb-pid-command-buffer pid)))
+    (dolist (buf (buffer-list))
+      (if (and (equal find-cmd-buf (buffer-name buf))
+               (realgud-cmdbuf? buf)
+               (get-buffer-process buf))
+       (return buf)))))
+
+(defun realgud:gdb-pid (pid)
+  "Start debugging gdb process with pid PID."
+  (interactive "nEnter the pid that gdb should attach to: ")
+  (realgud:gdb (format "%s -p %d" realgud:gdb-command-name pid))
+  ;; FIXME: should add code to test if attach worked.
+  )
+
+(defun realgud:gdb-pid-associate (pid)
+  "Start debugging gdb process with pid PID and associate the
+current buffer to that realgud command buffer."
+  (interactive "nEnter the pid that gdb should attach to and associate the 
current buffer to: ")
+  (let* ((command-buf)
+        (source-buf (current-buffer))
+        )
+    (realgud:gdb-pid pid)
+    (setq command-buf (realgud:gdb-find-command-buffer pid))
+    (if command-buf
+       (with-current-buffer source-buf
+         (realgud:cmdbuf-associate (buffer-name command-buf)))
+      )))
+
 ;;;###autoload
 (defun realgud:gdb (&optional opt-cmd-line no-reset)
   "Invoke the gdb debugger and start the Emacs user interface.
diff --git a/realgud/debugger/gdb/init.el b/realgud/debugger/gdb/init.el
index 547e794..a7ea767 100644
--- a/realgud/debugger/gdb/init.el
+++ b/realgud/debugger/gdb/init.el
@@ -114,8 +114,8 @@ realgud-loc-pat struct")
   "Hash key is command name like 'continue' and the value is
   the gdb command to use, like 'continue'")
 
-(setf (gethash "break"    realgud:gdb-command-hash) "break %l")
-(setf (gethash "clear"    realgud:gdb-command-hash) "clear %l")
+(setf (gethash "break"    realgud:gdb-command-hash) "break %X:%l")
+(setf (gethash "clear"    realgud:gdb-command-hash) "clear %X:%l")
 (setf (gethash "continue" realgud:gdb-command-hash) "continue")
 (setf (gethash "eval"     realgud:gdb-command-hash) "print %s")
 (setf (gethash "quit"     realgud:gdb-command-hash) "quit")



reply via email to

[Prev in Thread] Current Thread [Next in Thread]