]> git.eshelyaron.com Git - emacs.git/commitdiff
(gdb): Send -target-detach when buffer is killed (#3794).
authorDmitry Dzhus <dima@sphinx.net.ru>
Tue, 11 Aug 2009 23:26:04 +0000 (23:26 +0000)
committerDmitry Dzhus <dima@sphinx.net.ru>
Tue, 11 Aug 2009 23:26:04 +0000 (23:26 +0000)
(gdb-starting): Moved -data-list-register-names...
(gdb-stopped): ...here so it's sent when first thread stops.
(gdb-registers-handler-custom): Do nothing if register names are
unknown yet.

lisp/ChangeLog
lisp/progmodes/gdb-mi.el

index 87c0b4dc65e08da5358ebd574bdf8314ddf69203..874a413595780958d3e022f21ce4e5022cc31d13 100644 (file)
@@ -7,6 +7,11 @@
        (gdb-invalidate-disassembly): Do not refresh upon receiving
        'update signal. Instead, update all disassembly buffers only after
        threads list.
+       (gdb): Send -target-detach when buffer is killed (#3794).
+       (gdb-starting): Moved -data-list-register-names...
+       (gdb-stopped): ...here so it's sent when first thread stops.
+       (gdb-registers-handler-custom): Do nothing if register names are
+       unknown yet.
 
        * progmodes/gud.el (gud-stop-subjob): Rewritten without macros
        from `gdb-mi.el' to avoid extra tangling.
index 65b033e6b9fb0e543a1596aa6713135217d0ec83..91e9f685d9ecb24361dbf68dd7443fffc39c7ef3 100644 (file)
@@ -749,7 +749,16 @@ detailed description of this mode.
   (local-set-key "\C-i" 'gud-gdb-complete-command)
   (setq gdb-first-prompt t)
   (setq gud-running nil)
+
   (gdb-update)
+
+  (add-hook
+   'kill-buffer-hook
+   (function
+    (lambda ()
+      (gdb-input (list "-target-detach" 'ignore))))
+   nil t)
+
   (run-hooks 'gdb-mode-hook))
             
 (defun gdb-init-1 ()
@@ -776,6 +785,7 @@ detailed description of this mode.
         gdb-buf-publisher '()
         gdb-threads-list '()
         gdb-breakpoints-list '()
+        gdb-register-names '()
         gdb-non-stop gdb-non-stop-setting)
   ;;
   (setq gdb-buffer-type 'gdbmi)
@@ -1854,8 +1864,6 @@ Sets `gdb-thread-number' to new id."
 
 (defun gdb-starting (output-field)
   ;; CLI commands don't emit ^running at the moment so use gdb-running too.
-  (gdb-input
-   (list "-data-list-register-names" 'gdb-register-names-handler))
   (setq gdb-inferior-status "running")
   (gdb-force-mode-line-update
    (propertize gdb-inferior-status 'face font-lock-type-face))
@@ -1876,6 +1884,13 @@ current thread and update GDB buffers."
          (reason (gdb-get-field result 'reason))
          (thread-id (gdb-get-field result 'thread-id)))
 
+    ;; -data-list-register-names needs to be issued for any stopped
+    ;; thread
+    (when (not gdb-register-names)
+      (gdb-input
+       (list (concat "-data-list-register-names --thread " thread-id)
+             'gdb-register-names-handler)))
+
 ;;; Don't set gud-last-frame here as it's currently done in gdb-frame-handler
 ;;; because synchronous GDB doesn't give these fields with CLI.
 ;;;     (when file
@@ -3553,25 +3568,25 @@ member."
  'gdb-invalidate-registers)
 
 (defun gdb-registers-handler-custom ()
-  (let ((register-values (gdb-get-field (gdb-json-partial-output) 'register-values))
-        (table (make-gdb-table)))
-    (dolist (register register-values)
-      (let* ((register-number (gdb-get-field register 'number))
-             (value (gdb-get-field register 'value))
-             (register-name (nth (string-to-number register-number) 
-                                 gdb-register-names)))
-        (when register-name
-        (gdb-table-add-row
-         table
-         (list
-          (propertize register-name 'font-lock-face font-lock-variable-name-face)
-          (if (member register-number gdb-changed-registers)
-              (propertize value 'font-lock-face font-lock-warning-face)
-            value))
-         `(mouse-face highlight
-           help-echo "mouse-2: edit value"
-           gdb-register-name ,register-name)))))
-    (insert (gdb-table-string table " "))
+  (when gdb-register-names
+    (let ((register-values (gdb-get-field (gdb-json-partial-output) 'register-values))
+          (table (make-gdb-table)))
+      (dolist (register register-values)
+        (let* ((register-number (gdb-get-field register 'number))
+               (value (gdb-get-field register 'value))
+               (register-name (nth (string-to-number register-number) 
+                                   gdb-register-names)))
+          (gdb-table-add-row
+           table
+           (list
+            (propertize register-name 'font-lock-face font-lock-variable-name-face)
+            (if (member register-number gdb-changed-registers)
+                (propertize value 'font-lock-face font-lock-warning-face)
+              value))
+           `(mouse-face highlight
+                        help-echo "mouse-2: edit value"
+                        gdb-register-name ,register-name))))
+      (insert (gdb-table-string table " ")))
     (setq mode-name
           (gdb-current-context-mode-name "Registers"))))