unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Minor gdb-ui patches to make it a bit more robust
@ 2008-02-18 21:08 Stefan Monnier
  2008-02-18 22:12 ` Nick Roberts
  0 siblings, 1 reply; 8+ messages in thread
From: Stefan Monnier @ 2008-02-18 21:08 UTC (permalink / raw)
  To: emacs-devel


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.


        Stefan


--- 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 @@
 	(progn
 	  (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)))
       output)))
 
 (defun gdb-concat-output (so-far new)




^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-02-20 22:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-18 21:08 Minor gdb-ui patches to make it a bit more robust Stefan Monnier
2008-02-18 22:12 ` Nick Roberts
2008-02-19  2:42   ` Stefan Monnier
2008-02-19  9:42     ` Andreas Schwab
2008-02-19 10:11     ` Nick Roberts
2008-02-19 15:57       ` Stefan Monnier
2008-02-19 23:48         ` Nick Roberts
2008-02-20 22:00           ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).