[Top][All Lists]

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

Minor gdb-ui patches to make it a bit more robust

From: Stefan Monnier
Subject: Minor gdb-ui patches to make it a bit more robust
Date: Mon, 18 Feb 2008 16:08:29 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

Here are 2 patches which help me deal with gdb-ui.

The first 2 hunks reset gdb-output-sink as it should after starting
a new process.  I think this is a plain bug fix, but I'll let
Nick decide.

The second hunk make it fallback on the old gud-gdb code in case the
prompt appears before we get to receive the expected annotations.
I've been using M-x gdb RET with "gdb --fullname emacs" for ever and it
took me a while to understand why it suddenly stopped working properly:
the behavior is pretty nasty: you get all the expected GDB output but
your input isn't sent to the gdb process (because gdb-ui thinks that
GDB is still initializing) and completion just hangs (because it sends
a command which isn't passed on to the process and then waits for the
process to reply).

Maybe my hack isn't such a great idea, but it seems to work OK for my
test and it brings back Emacs-21's M-x gdb behavior of automatically
choosing gdb-ui or plain gud-gdb.

Maybe Nick can suggest a more reliable way to detect when the
annotations are missing.


--- orig/lisp/progmodes/gdb-ui.el
+++ mod/lisp/progmodes/gdb-ui.el
@@ -150,7 +150,7 @@
 (defvar gdb-prompting nil
   "True when gdb is idle with no pending input.")
-(defvar gdb-output-sink 'user
+(defvar gdb-output-sink nil
   "The disposition of the output of the current gdb command.
 Possible values are these symbols:
@@ -317,6 +317,7 @@
   (local-set-key "\C-i" 'gud-gdb-complete-command)
   (setq comint-prompt-regexp "^(.*gdb[+]?) *")
   (setq paragraph-start comint-prompt-regexp)
+  (setq gdb-output-sink 'user)
   (setq gdb-first-prompt t)
   (setq gud-running nil)
   (setq gdb-ready nil)
@@ -1673,6 +1674,16 @@
          (setq output (gdb-concat-output output gud-marker-acc))
          (setq gud-marker-acc "")))
+      (unless gdb-ready           ;Should we check gdb-first-prompt instead?
+        (when (string-match "\n(gdb) \\'" output)
+          ;; We just received a GDB prompt but haven't seen any of the
+          ;; annotations we expect to come along with it.  Apparently GDB
+          ;; was not run with "annotate=3".  Let's try to fallback on the
+          ;; old mode.
+          (message "Falling back to old GDB support")
+          (set (make-local-variable 'gud-minor-mode) 'gdb)
+          (kill-local-variable 'comint-input-sender)
+          (setq gud-marker-filter 'gud-gdb-marker-filter)))
 (defun gdb-concat-output (so-far new)

reply via email to

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