From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Sergio Durigan Junior Newsgroups: gmane.emacs.bugs Subject: bug#14847: 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> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1373601131 1857 80.91.229.3 (12 Jul 2013 03:52:11 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 12 Jul 2013 03:52:11 +0000 (UTC) To: 14847@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 12 05:52:13 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 1UxUOw-00066n-VG for geb-bug-gnu-emacs@m.gmane.org; Fri, 12 Jul 2013 05:52:11 +0200 Original-Received: from localhost ([::1]:48599 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUOw-0002C6-L0 for geb-bug-gnu-emacs@m.gmane.org; Thu, 11 Jul 2013 23:52:10 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:53908) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUOr-0002Bu-DV for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:52:08 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UxUOo-0005pn-Sf for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:52:05 -0400 Original-Received: from debbugs.gnu.org ([140.186.70.43]:54882) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UxUOo-0005pi-Ol for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:52:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1UxUOo-0001IF-40 for bug-gnu-emacs@gnu.org; Thu, 11 Jul 2013 23:52:02 -0400 X-Loop: help-debbugs@gnu.org 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: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.13736011044935 (code B ref -1); Fri, 12 Jul 2013 03:52:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Jul 2013 03:51:44 +0000 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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 Original-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) Original-Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sergiodj@fulvetta.riseup.net) with ESMTPSA id 6B4B7731 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-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.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:76257 Archived-At: 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))