From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Jean-Philippe Gravel Newsgroups: gmane.emacs.bugs Subject: bug#13845: 24.3.50; gud commands stop responding when using gdb-mi Date: Thu, 28 Feb 2013 21:02:56 -0500 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1362103454 32060 80.91.229.3 (1 Mar 2013 02:04:14 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 1 Mar 2013 02:04:14 +0000 (UTC) To: 13845@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Mar 01 03:04:37 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1UBFKt-0003sH-Uo for geb-bug-gnu-emacs@m.gmane.org; Fri, 01 Mar 2013 03:04:36 +0100 Original-Received: from localhost ([::1]:55082 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBFKY-00088Q-U5 for geb-bug-gnu-emacs@m.gmane.org; Thu, 28 Feb 2013 21:04:14 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45122) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBFKS-00087E-6f for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:04:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBFKO-0000UH-4L for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:04:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:51588) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBFKN-0000UD-QJ for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:04:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1UBFMI-0000Ln-J1 for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:06:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Jean-Philippe Gravel Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 01 Mar 2013 02:06:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13845 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13621035131289 (code B ref -1); Fri, 01 Mar 2013 02:06:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 1 Mar 2013 02:05:13 +0000 Original-Received: from localhost ([127.0.0.1]:57052 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UBFLU-0000Kj-46 for submit@debbugs.gnu.org; Thu, 28 Feb 2013 21:05:12 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:33351) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1UBFLQ-0000KY-Ow for submit@debbugs.gnu.org; Thu, 28 Feb 2013 21:05:10 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBFJS-0000AO-CY for submit@debbugs.gnu.org; Thu, 28 Feb 2013 21:03:09 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:36311) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBFJS-0000AJ-94 for submit@debbugs.gnu.org; Thu, 28 Feb 2013 21:03:06 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:44678) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBFJP-000812-8F for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:03:06 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UBFJL-000082-Ni for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:03:03 -0500 Original-Received: from mail-bk0-f42.google.com ([209.85.214.42]:44055) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UBFJL-00007j-DE for bug-gnu-emacs@gnu.org; Thu, 28 Feb 2013 21:02:59 -0500 Original-Received: by mail-bk0-f42.google.com with SMTP id jk7so1125466bkc.29 for ; Thu, 28 Feb 2013 18:02:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:date:message-id:subject:from:to :content-type; bh=uW6pnXidOq/9BO6XxKmUO/RK5iiVU+9GECD0jgLoBVw=; b=yWwq7Q8Y41VJhzMoheZX4mZYgUQnpUWq/wLMo6oPfJiGOLsngeuLkn1vs4PqXNSg+d YaH8l/uB5n5fKsiqJnUWoFYdGCH+FXKSjLFZqS4G8/KzFOaLjO7gFK1+2IjyVHH41Fvu GmD17+sHCQyW7VFTX23OZsZqQAfMucYe0qFG+Jq+8/2eg2YpDMXEdAevEbwMiAgd4Ch9 OzIklc3uUBIJFcvTSh5Zzt3LEdPpginFLiGxKrZxa/5ETP3oSTZnae9QwaO8Y5doZajg XZulgy5JmfPpjAPYuKMIagYzYHRlLCuuMFyVlMvM1UxkQgiw3GL7cFbfeZ0Y5XzsUP25 qlKw== X-Received: by 10.204.147.82 with SMTP id k18mr3197807bkv.38.1362103376624; Thu, 28 Feb 2013 18:02:56 -0800 (PST) Original-Received: by 10.204.195.71 with HTTP; Thu, 28 Feb 2013 18:02:56 -0800 (PST) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:71966 Archived-At: When debugging a program using gdb-mi, the gud commands (gud-break for instance) stop responding. I get the problem all the time on the trunk version of Emacs (revision 111899). I have gdb version 7.5.1 installed. The following steps should reproduce the problem: Start Emacs: cd trunk/src ./emacs -Q Start a another Emacs in gdb-mi. Use the CLI interface to start the program: M-x gdb Run gdb (like this): gdb -i=mi emacs (gdb) run Back in the first emacs, break GDB: C-c C-c Open one of the Emacs source file (emacs.c) C-x C-f Find file: ../trunk/src/emacs.c In the function main, position the cursor on a line of code and try to set a break point using the gud command: M-x gud-break The break point is successfully created. Return to the *gud-emacs* buffer and resume the debugged Emacs, then break again: (gdb) continue C-c C-c Go back in the emacs.c file and try to set a breakpoint again in the main function. From this point on, the gud-break will refuse to work. The internal state of gdb-mi is in fact in a stall. Several other features of gdb-mi are also disabled. For instance, if you start gdb-many-windows: M-x gdb-many-windows and click on the Threads tab, the buffer will be empty even though the debugged program isn't running. I investigated the problem and found it's root in the gdb-mi.el file. When typing "run" in the debugger, GDB responds with a "^running" message. gdb-mi handles this by calling the gdb-starting function. In this function, you will find the following: (defun gdb-starting (_output-field) [...] ;; GDB doesn't seem to respond to -thread-info before first stop or ;; thread exit (even in non-stop mode), so this is useless. ;; Behavior may change in the future. (gdb-emit-signal gdb-buf-publisher 'update-threads)) Indeed, GDB doesn't respond to the -thread-info command. Nevertheless, gdb-mi records the -thread-info request in the variable gdb-pending-trigger and will refuse to send any other -thread-info command until GDB responds the command gdb-mi is waiting for. Back to our stalled gdb-mi, if we probe the gdb-pending-trigger variable, we get: C-h v Describe variable: gdb-pending-trigger gdb-pending-triggers is a variable defined in `gdb-mi.el'. Its value is ((# . gdb-invalidate-threads)) We can get back on our feet by clearing that variable: M-: Eval: (setq gdb-pending-triggers nil) and then run a CLI command in GDB: (gdb) where Only resetting the variable is not enough on it's own, but running a CLI command right after seems to wake-up gdb-mi out of it's coma. After this, you can run gud commands again and gdb-many-windows is back to life. Commenting out the (gdb-emit-signal gdb-buf-publisher 'update-threads) statement in both gdb-starting and gdb-running helps quite a bit, but this fix is not enough. I sometimes encounter cases where gdb-mi fails to receive replies for a bunch of other commands to update all other gdb window (breakpoints, call-stack, etc.) Unfortunately, this condition is harder to encounter and I cannot provide repro-steps at this point. I do not know if this should be considered an emacs or a GDB bug (should GDB always reply to commands, even when the program is running?) What I can say for sure is that there is definitively room for improvement on the emacs side: the pending message handling should be more robust and gdb-mi should not hang if GDB skips a reply. In GNU Emacs 24.3.50.1 (i686-pc-linux-gnu, GTK+ Version 3.4.2) of 2013-02-28 on ubuntu Bzr revision: 111899 juri@jurta.org-20130228215111-mwv0v6velfkb8vbw Windowing system distributor `The X.Org Foundation', version 11.0.11103000 System Description: Ubuntu 12.04.1 LTS Important settings: value of $LANG: en_US.UTF-8 locale-coding-system: utf-8-unix default enable-multibyte-characters: t Major mode: C/l Minor modes in effect: gdb-many-windows: t tooltip-mode: t mouse-wheel-mode: t tool-bar-mode: t menu-bar-mode: t file-name-shadow-mode: t global-font-lock-mode: t font-lock-mode: t blink-cursor-mode: t auto-composition-mode: t auto-encryption-mode: t auto-compression-mode: t line-number-mode: t transient-mark-mode: t abbrev-mode: t Recent input: M-x g d b e m a c s r u n C-c C-c C-x C-f e m a c s . c C-s m a i n SPC ( C-s C-x SPC C-x b c o n t i n u e C-c C-c C-x b C-x SPC C-x b M-x g d b - m a n y - w i n d o w C-h v g d b - p e n d i n g q M-: ( s e t q SPC g d b - p e n d i n t r SPC n i l ) w h e r e C-x SPC M-x r e p o r t - e m a c s - b u g Recent messages: For information about GNU Emacs and the GNU system, type C-h C-a. Switched to thread 1 Loading cc-langs...done Mark saved where search started Command: break emacs.c:654 Gdb-Many-Windows mode enabled Type "q" to restore previous buffer. nil Command: break emacs.c:656 Load-path shadows: None found. Features: (shadow sort gnus-util mail-extr emacsbug message cl-macs gv format-spec rfc822 mml mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util mail-prsvr mail-utils pp help-mode help-fns cus-start cus-load misearch multi-isearch vc-bzr cc-langs cl nadvice cl-lib cc-mode cc-fonts easymenu cc-guess cc-menus cc-cmds cc-styles cc-align cc-engine cc-vars cc-defs gdb-mi bindat json gud easy-mmode comint ansi-color ring time-date tooltip ediff-hook vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image regexp-opt fringe tabulated-list newcomment lisp-mode register page menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock syntax facemenu font-core frame cham georgian utf-8-lang misc-lang vietnamese tibetan thai tai-viet lao korean japanese hebrew greek romanian slovak czech european ethiopic indian cyrillic chinese case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs button faces cus-face macroexp files text-properties overlay sha1 md5 base64 format env code-pages mule custom widget hashtable-print-readable backquote make-network-process inotify dynamic-setting system-font-setting font-render-setting move-toolbar gtk x-toolkit x multi-tty emacs)