From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Minor gdb-ui patches to make it a bit more robust Date: Mon, 18 Feb 2008 16:08:29 -0500 Message-ID: NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1203368933 6121 80.91.229.12 (18 Feb 2008 21:08:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 18 Feb 2008 21:08:53 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Feb 18 22:09:16 2008 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1JRDEb-0007e9-DS for ged-emacs-devel@m.gmane.org; Mon, 18 Feb 2008 22:09:09 +0100 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRDE6-0000IP-5Q for ged-emacs-devel@m.gmane.org; Mon, 18 Feb 2008 16:08:38 -0500 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JRDE3-0000I2-BS for emacs-devel@gnu.org; Mon, 18 Feb 2008 16:08:35 -0500 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JRDE1-0000Hm-Qa for emacs-devel@gnu.org; Mon, 18 Feb 2008 16:08:35 -0500 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JRDE1-0000Hj-O5 for emacs-devel@gnu.org; Mon, 18 Feb 2008 16:08:33 -0500 Original-Received: from ironport2-out.pppoe.ca ([206.248.154.182]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JRDE1-0000gz-9K for emacs-devel@gnu.org; Mon, 18 Feb 2008 16:08:33 -0500 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ao8CAMeCuUfO+KMJdGdsb2JhbACQVgEwnG2BAg X-IronPort-AV: E=Sophos;i="4.25,373,1199682000"; d="scan'208";a="14676922" Original-Received: from smtp.pppoe.ca ([65.39.196.238]) by ironport2-out.pppoe.ca with ESMTP; 18 Feb 2008 16:08:30 -0500 Original-Received: from pastel.home ([206.248.163.9]) by smtp.pppoe.ca (Internet Mail Server v1.0) with ESMTP id YXA78530; Mon, 18 Feb 2008 16:08:30 -0500 Original-Received: by pastel.home (Postfix, from userid 20848) id 5A6BE8153; Mon, 18 Feb 2008 16:08:29 -0500 (EST) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:89523 Archived-At: 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)