]> code.delx.au - gnu-emacs/commitdiff
Show returned value after gdb-mi "finish" command
authorEli Zaretskii <eliz@gnu.org>
Fri, 10 Jun 2016 08:57:17 +0000 (11:57 +0300)
committerEli Zaretskii <eliz@gnu.org>
Fri, 10 Jun 2016 08:57:17 +0000 (11:57 +0300)
* lisp/progmodes/gdb-mi.el (gdb-stopped): Display the expected
"Value returned" message in response to "finish", when not
produced by GDB/MI.  (Bug#23720)

lisp/progmodes/gdb-mi.el

index 5ad101df7bf2d36dcf96727e0c0dcff3bcaf1c9a..b2c06145187e04e659b40cf02eae8858a8446d60 100644 (file)
@@ -2488,7 +2488,9 @@ current thread and update GDB buffers."
   ;; Reason is available with target-async only
   (let* ((result (gdb-json-string output-field))
          (reason (bindat-get-field result 'reason))
-         (thread-id (bindat-get-field result 'thread-id)))
+         (thread-id (bindat-get-field result 'thread-id))
+         (retval (bindat-get-field result 'return-value))
+         (varnum (bindat-get-field result 'gdb-result-var)))
 
     ;; -data-list-register-names needs to be issued for any stopped
     ;; thread
@@ -2514,6 +2516,15 @@ current thread and update GDB buffers."
     (if (string-equal reason "exited-normally")
        (setq gdb-active-process nil))
 
+    (when (and retval varnum
+               ;; When the user typed CLI commands, GDB/MI helpfully
+               ;; includes the "Value returned" response in the "~"
+               ;; record; here we avoid displaying it twice.
+               (not (string-match "^Value returned is " gdb-filter-output)))
+      (setq gdb-filter-output
+            (concat gdb-filter-output
+                    (format "Value returned is %s = %s\n" varnum retval))))
+
     ;; Select new current thread.
 
     ;; Don't switch if we have no reasons selected