Subject: bug#25488: 25.1; gdb package interpreter problem

From: Sergio Durigan Junior <[email-masked]>
Date: Mon, 16 Sep 2019 09:32:27 -0400

On Saturday, September 14 2019, Stefan Kangas wrote:

> Sergio Durigan Junior <[email-masked]> writes:
>
>> On Friday, January 20 2017, Glenn Morris wrote:
>>
>>>> 1. configure remote system by running "gdbserver --multi localhost:<port>"
>>>>
>>>> 2. on host system, run emacs, then "M-x gdb <ret> -i=mi"
>>>>
>>>> 3. at the gdb prompt:
>>>>
>>>>   file <path-to-exe>
>>>>   target extended-remote <remote-host-ip-addr>:<port>
>>>>   set remote exec-file <path-to-exe>
>>>>   start
>>>>
>>>> 4.on the remote side, note the message:
>>>>
>>>>   "Cannot exec <path-to-exe> : No such file or directory."
>>>>
>>>> specifically, note the space between "<path-to-exe>" and ":", which
>>>> should not be there. this is the extraneous space.
>>>
>>>
>>> Confirmed on rhel 7.
>>>
>>> This seems to be due to the " " in:
>>>
>>> (concat gdb-continuation string " ")
>>>
>>> in gdb-send, which was added in bug#14847. I've cc'd the author of that change.
>>
>> Heh, I helped the reporter diagnose this issue, and as it turns out I
>> was the culprit!
>>
>> Thanks for the report, I'll take a look at this later today.
>
> Hi Sergio,
>
> I see that the latest update here was in January 2017.  Did you ever get
> a chance to look into this issue?

Wow, what a strange concept of "later today"!  Sorry about that.

Yeah, I had the chance to look into it, and even though I don't remember
the details now, I have a patch here that seems to work for me.  I'm
attaching it to this message; can you check if it fixes the problem for
you, please?

It seems strange that the extra whitespace was added by mistake there.
I'm a bit afraid that there is a case which I haven't envisioned and
which requires that whitespace, but I couldn't come up with a testing
scenario that triggers the error.  I tested this by debugging a binary
with and without arguments (i.e., "/bin/true" and "/bin/true --help"),
and both worked fine.

Thanks,

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/

From cad0deb10f2dbdc7b3dd7d3c6f4347da9cb1f557 Mon Sep 17 00:00:00 2001
From: Sergio Durigan Junior <[email-masked]>
Date: Sun, 15 Sep 2019 14:50:17 -0400
Subject: [PATCH] [gdb-mi.el] Don't add trailing whitespace when passing
 argument to GDB

This fixes bug #25488.

* lisp/progmodes/gdb-mi.el (gdb-send): Don't append whitespace to
'gdb-continuation'.
---
 lisp/progmodes/gdb-mi.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/gdb-mi.el b/lisp/progmodes/gdb-mi.el
index 48c7dde9f51..cf54207337d 100644
--- a/lisp/progmodes/gdb-mi.el
+++ b/lisp/progmodes/gdb-mi.el
@@ -1827,7 +1827,7 @@ gdb-send
 		      " "))
       (setq gdb-first-done-or-error t)
       (let ((to-send (concat "-interpreter-exec console "
-                             (gdb-mi-quote (concat gdb-continuation string " "))
+                             (gdb-mi-quote (concat gdb-continuation string))
                              "\n")))
         (if gdb-enable-debug
             (push (cons 'mi-send to-send) gdb-debug-log))
-- 
2.20.1