From unknown Sun Jun 15 09:02:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes Resent-From: Sergio Durigan Junior Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jul 2013 03:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 14847 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: 14847@debbugs.gnu.org X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.13736011044935 (code B ref -1); Fri, 12 Jul 2013 03:52:02 +0000 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 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-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 unknown Sun Jun 15 09:02:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes Resent-From: Eli Zaretskii Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jul 2013 08:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14847 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Sergio Durigan Junior Cc: 14847@debbugs.gnu.org Reply-To: Eli Zaretskii Received: via spool by 14847-submit@debbugs.gnu.org id=B14847.137361906220621 (code B ref 14847); Fri, 12 Jul 2013 08:52:02 +0000 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 In-reply-to: <87r4f4qvuv.fsf@riseup.net> X-012-Sender: halo1@inter.net.il Message-id: <83hag05fhi.fsf@gnu.org> References: <87r4f4qvuv.fsf@riseup.net> X-Spam-Score: 1.0 (+) 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: 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 unknown Sun Jun 15 09:02:08 2025 X-Loop: help-debbugs@gnu.org Subject: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes Resent-From: Sergio Durigan Junior Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 12 Jul 2013 15:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 14847 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: To: Eli Zaretskii Cc: 14847@debbugs.gnu.org Received: via spool by 14847-submit@debbugs.gnu.org id=B14847.137364429320605 (code B ref 14847); Fri, 12 Jul 2013 15:52:01 +0000 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 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-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 unknown Sun Jun 15 09:02:08 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.503 (Entity 5.503) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Sergio Durigan Junior Subject: bug#14847: closed (Re: bug#14847: 24.1; gdb-mi.el does not handle backslashes as quotes) Message-ID: References: <834nbz63o9.fsf@gnu.org> <87r4f4qvuv.fsf@riseup.net> X-Gnu-PR-Message: they-closed 14847 X-Gnu-PR-Package: emacs Reply-To: 14847@debbugs.gnu.org Date: Fri, 12 Jul 2013 18:21:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1373653262-7488-1" This is a multi-part message in MIME format... ------------=_1373653262-7488-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #14847: 24.1; gdb-mi.el does not handle backslashes as quotes which was filed against the emacs package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 14847@debbugs.gnu.org. --=20 14847: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D14847 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1373653262-7488-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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. ------------=_1373653262-7488-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit 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)) ------------=_1373653262-7488-1--