From debbugs-submit-bounces@debbugs.gnu.org Thu Jul 11 23:51:44 2013 Received: (at submit) by debbugs.gnu.org; 12 Jul 2013 03:51:44 +0000 Received: from localhost ([127.0.0.1]:49198 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UxUOW-0001HW-08 for submit@debbugs.gnu.org; Thu, 11 Jul 2013 23:51:44 -0400 Received: from eggs.gnu.org ([208.118.235.92]:52055) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UxUOT-0001HF-TV for submit@debbugs.gnu.org; Thu, 11 Jul 2013 23:51:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxUOK-0005fl-PY for submit@debbugs.gnu.org; Thu, 11 Jul 2013 23:51:36 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=BAYES_05,UNPARSEABLE_RELAY autolearn=disabled version=3.3.2 Received: from lists.gnu.org ([2001:4830:134:3::11]:47921) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUOK-0005fh-MZ for submit@debbugs.gnu.org; Thu, 11 Jul 2013 23:51:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53752) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUOH-0002Ac-Er for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:51:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxUOE-0005fA-QR for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:51:29 -0400 Received: from mx1.riseup.net ([198.252.153.129]:45873) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUOE-0005f6-FR for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:51:26 -0400 Received: from fulvetta.riseup.net (fulvetta-pn.riseup.net [10.0.1.75]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Gandi Standard SSL CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id B31C24AC56 for ; Thu, 11 Jul 2013 20:51:24 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sergiodj@fulvetta.riseup.net) with ESMTPSA id 6B4B7731 From: Sergio Durigan Junior To: bug-gnu-emacs@gnu.org Subject: 24.1; gdb-mi.el does not handle backslashes as quotes Date: Fri, 12 Jul 2013 00:51:20 -0300 Message-ID: <87r4f4qvuv.fsf@riseup.net> MIME-Version: 1.0 Content-Type: text/plain X-Virus-Scanned: clamav-milter 0.97.8 at mx1 X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2001:4830:134:3::11 X-Spam-Score: -4.3 (----) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -4.3 (----) If you start gdb-mi.el (on Emacs 24.1), and try to use backslashes to quote/break long lines, it is not handled correctly. For example, suppose your program being debugged inside GDB takes 3 arguments. You could run it with: (gdb) file myprogram Reading symbols from myprogram...done. (gdb) run \ first_arg \ second_arg \ third_arg GDB should correctly run the binary using the 3 args. However, inside Emacs, you receive an error: Undefined command: "third_arg". Try "help". This is because gdb-mi.el is not handling the backslashes correctly. The error is specifically on the function `gdb_send', and the patch inlined in this message fixes this. The patch can also be seen on: And there is also a GDB bug related to this issue: Thanks. lisp/ChangeLog: 2013-07-12 Sergio Durigan Junior * progmodes/gdb-mi.el (gdb-strip-string-backslash): New function. (gdb-send): Correctly handle continuation strings with backslashes, and properly set the last command typed. diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 2c4d6a0..87c5f98 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1759,6 +1759,9 @@ static char *magick[] = { As long as GDB is in the recursive reading loop, it does not expect commands to be prefixed by \"-interpreter-exec console\".") +(defun gdb-strip-string-backslash (string) + (replace-regexp-in-string "\\\\$" "" string)) + (defun gdb-send (proc string) "A comint send filter for gdb." (with-current-buffer gud-comint-buffer @@ -1766,8 +1769,13 @@ commands to be prefixed by \"-interpreter-exec console\".") (remove-text-properties (point-min) (point-max) '(face)))) ;; mimic key to repeat previous command in GDB (if (not (string= "" string)) - (setq gdb-last-command string) - (if gdb-last-command (setq string gdb-last-command))) + (if gdb-continuation + (setq gdb-last-command (concat gdb-continuation + (gdb-strip-string-backslash string) + " ")) + (setq gdb-last-command (gdb-strip-string-backslash string))) + (if gdb-last-command (setq string gdb-last-command)) + (setq gdb-continuation nil)) (if (or (string-match "^-" string) (> gdb-control-level 0)) ;; Either MI command or we are feeding GDB's recursive reading loop. @@ -1779,10 +1787,13 @@ commands to be prefixed by \"-interpreter-exec console\".") (setq gdb-control-level (1- gdb-control-level)))) ;; CLI command (if (string-match "\\\\$" string) - (setq gdb-continuation (concat gdb-continuation string "\n")) + (setq gdb-continuation + (concat gdb-continuation (gdb-strip-string-backslash + string) + " ")) (setq gdb-first-done-or-error t) (let ((to-send (concat "-interpreter-exec console " - (gdb-mi-quote string) + (gdb-mi-quote (concat gdb-continuation string " ")) "\n"))) (if gdb-enable-debug (push (cons 'mi-send to-send) gdb-debug-log)) From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 12 04:51:02 2013 Received: (at 14847) by debbugs.gnu.org; 12 Jul 2013 08:51:02 +0000 Received: from localhost ([127.0.0.1]:49592 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UxZ49-0005MS-Pp for submit@debbugs.gnu.org; Fri, 12 Jul 2013 04:51:02 -0400 Received: from mtaout22.012.net.il ([80.179.55.172]:38028) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1UxZ47-0005Ls-Ct for 14847@debbugs.gnu.org; Fri, 12 Jul 2013 04:51:00 -0400 Received: from conversion-daemon.a-mtaout22.012.net.il by a-mtaout22.012.net.il (HyperSendmail v2007.08) id <0MPT00600F3AFE00@a-mtaout22.012.net.il> for 14847@debbugs.gnu.org; Fri, 12 Jul 2013 11:50:39 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout22.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MPT006L4F8E7T60@a-mtaout22.012.net.il>; Fri, 12 Jul 2013 11:50:39 +0300 (IDT) Date: Fri, 12 Jul 2013 11:50:33 +0300 From: Eli Zaretskii Subject: Re: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes In-reply-to: <87r4f4qvuv.fsf@riseup.net> X-012-Sender: halo1@inter.net.il To: Sergio Durigan Junior Message-id: <83hag05fhi.fsf@gnu.org> References: <87r4f4qvuv.fsf@riseup.net> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 14847 Cc: 14847@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Sergio Durigan Junior > Date: Fri, 12 Jul 2013 00:51:20 -0300 > > If you start gdb-mi.el (on Emacs 24.1), and try to use backslashes to > quote/break long lines, it is not handled correctly. For example, > suppose your program being debugged inside GDB takes 3 arguments. You > could run it with: > > (gdb) file myprogram > Reading symbols from myprogram...done. > (gdb) run \ > first_arg \ > second_arg \ > third_arg > > GDB should correctly run the binary using the 3 args. However, inside > Emacs, you receive an error: > > Undefined command: "third_arg". Try "help". > > This is because gdb-mi.el is not handling the backslashes correctly. > The error is specifically on the function `gdb_send', and the patch > inlined in this message fixes this. The patch can also be seen on: > > > > And there is also a GDB bug related to this issue: > > Your patch doesn't seem to work for me. I tried on GNU/Linux and on MS-Windows, and in both cases I get the same error. Here's the recipe I tried (after applying your latest patch and rebuilding Emacs): emacs -Q M-x gdb RET gdb -i=mi ./src/emacs RET (gdb) break main (gdb) run \ -Q When I type RET after "-Q", I get an error: Undefined MI command: Q What am I doing wrong? Thanks. From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 12 11:51:33 2013 Received: (at 14847) by debbugs.gnu.org; 12 Jul 2013 15:51:33 +0000 Received: from localhost ([127.0.0.1]:50680 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uxfd6-0005MG-8g for submit@debbugs.gnu.org; Fri, 12 Jul 2013 11:51:32 -0400 Received: from mx1.riseup.net ([198.252.153.129]:43565) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uxfd4-0005M7-C3 for 14847@debbugs.gnu.org; Fri, 12 Jul 2013 11:51:31 -0400 Received: from fulvetta.riseup.net (fulvetta-pn.riseup.net [10.0.1.75]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "*.riseup.net", Issuer "Gandi Standard SSL CA" (not verified)) by mx1.riseup.net (Postfix) with ESMTPS id C02BD4A958; Fri, 12 Jul 2013 08:51:28 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sergiodj@fulvetta.riseup.net) with ESMTPSA id 5AB451C2 From: Sergio Durigan Junior To: Eli Zaretskii Subject: Re: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes References: <87r4f4qvuv.fsf@riseup.net> <83hag05fhi.fsf@gnu.org> X-URL: http://sergiodj.net/blog Date: Fri, 12 Jul 2013 12:51:24 -0300 In-Reply-To: <83hag05fhi.fsf@gnu.org> (Eli Zaretskii's message of "Fri, 12 Jul 2013 11:50:33 +0300") Message-ID: <87k3kvzshv.fsf@riseup.net> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Virus-Scanned: clamav-milter 0.97.8 at mx1 X-Virus-Status: Clean X-Spam-Score: -0.3 (/) X-Debbugs-Envelope-To: 14847 Cc: 14847@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -0.3 (/) On Friday, July 12 2013, Eli Zaretskii wrote: > Your patch doesn't seem to work for me. I tried on GNU/Linux and on > MS-Windows, and in both cases I get the same error. Here's the recipe > I tried (after applying your latest patch and rebuilding Emacs): > > emacs -Q > M-x gdb RET > gdb -i=mi ./src/emacs RET > (gdb) break main > (gdb) run \ > -Q > > When I type RET after "-Q", I get an error: > > Undefined MI command: Q > > What am I doing wrong? Hi Eli, Thanks for testing! You're doing nothing wrong, the patch is the culprit. `gdb-send' checks for commands starting with "-", but this check should be disabled when a command is being continued. Could you please try the following version? Thanks, -- Sergio diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el index 2c4d6a0..10472ec 100644 --- a/lisp/progmodes/gdb-mi.el +++ b/lisp/progmodes/gdb-mi.el @@ -1759,6 +1759,9 @@ static char *magick[] = { As long as GDB is in the recursive reading loop, it does not expect commands to be prefixed by \"-interpreter-exec console\".") +(defun gdb-strip-string-backslash (string) + (replace-regexp-in-string "\\\\$" "" string)) + (defun gdb-send (proc string) "A comint send filter for gdb." (with-current-buffer gud-comint-buffer @@ -1766,10 +1769,15 @@ commands to be prefixed by \"-interpreter-exec console\".") (remove-text-properties (point-min) (point-max) '(face)))) ;; mimic key to repeat previous command in GDB (if (not (string= "" string)) - (setq gdb-last-command string) - (if gdb-last-command (setq string gdb-last-command))) - (if (or (string-match "^-" string) - (> gdb-control-level 0)) + (if gdb-continuation + (setq gdb-last-command (concat gdb-continuation + (gdb-strip-string-backslash string) + " ")) + (setq gdb-last-command (gdb-strip-string-backslash string))) + (if gdb-last-command (setq string gdb-last-command)) + (setq gdb-continuation nil)) + (if (and (not gdb-continuation) (or (string-match "^-" string) + (> gdb-control-level 0))) ;; Either MI command or we are feeding GDB's recursive reading loop. (progn (setq gdb-first-done-or-error t) @@ -1779,10 +1787,13 @@ commands to be prefixed by \"-interpreter-exec console\".") (setq gdb-control-level (1- gdb-control-level)))) ;; CLI command (if (string-match "\\\\$" string) - (setq gdb-continuation (concat gdb-continuation string "\n")) + (setq gdb-continuation + (concat gdb-continuation (gdb-strip-string-backslash + string) + " ")) (setq gdb-first-done-or-error t) (let ((to-send (concat "-interpreter-exec console " - (gdb-mi-quote string) + (gdb-mi-quote (concat gdb-continuation string " ")) "\n"))) (if gdb-enable-debug (push (cons 'mi-send to-send) gdb-debug-log)) From debbugs-submit-bounces@debbugs.gnu.org Fri Jul 12 14:20:53 2013 Received: (at 14847-done) by debbugs.gnu.org; 12 Jul 2013 18:20:53 +0000 Received: from localhost ([127.0.0.1]:51092 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uxhxd-0001wI-6E for submit@debbugs.gnu.org; Fri, 12 Jul 2013 14:20:53 -0400 Received: from mtaout23.012.net.il ([80.179.55.175]:42702) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1Uxhxa-0001vw-Oo for 14847-done@debbugs.gnu.org; Fri, 12 Jul 2013 14:20:51 -0400 Received: from conversion-daemon.a-mtaout23.012.net.il by a-mtaout23.012.net.il (HyperSendmail v2007.08) id <0MPU0060058L1W00@a-mtaout23.012.net.il> for 14847-done@debbugs.gnu.org; Fri, 12 Jul 2013 21:20:27 +0300 (IDT) Received: from HOME-C4E4A596F7 ([87.69.4.28]) by a-mtaout23.012.net.il (HyperSendmail v2007.08) with ESMTPA id <0MPU006NK5M21340@a-mtaout23.012.net.il>; Fri, 12 Jul 2013 21:20:27 +0300 (IDT) Date: Fri, 12 Jul 2013 21:20:22 +0300 From: Eli Zaretskii Subject: Re: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes In-reply-to: <87k3kvzshv.fsf@riseup.net> X-012-Sender: halo1@inter.net.il To: Sergio Durigan Junior Message-id: <834nbz63o9.fsf@gnu.org> References: <87r4f4qvuv.fsf@riseup.net> <83hag05fhi.fsf@gnu.org> <87k3kvzshv.fsf@riseup.net> X-Spam-Score: 1.0 (+) X-Debbugs-Envelope-To: 14847-done Cc: 14847-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list Reply-To: Eli Zaretskii List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 1.0 (+) > From: Sergio Durigan Junior > Cc: 14847@debbugs.gnu.org > Date: Fri, 12 Jul 2013 12:51:24 -0300 > > Thanks for testing! You're doing nothing wrong, the patch is the > culprit. `gdb-send' checks for commands starting with "-", but this > check should be disabled when a command is being continued. > > Could you please try the following version? Thanks, this works, so I committed this version, and I'm closing the bug. From unknown Sun Jun 15 09:00:36 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Sat, 10 Aug 2013 11:24:02 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator