public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/27989] gdb.base/args.exp fails with native-extended-gdbserver board
Date: Fri, 06 Oct 2023 12:08:32 +0000	[thread overview]
Message-ID: <bug-27989-4717-xVpbisclOx@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-27989-4717@http.sourceware.org/bugzilla/>

https://sourceware.org/bugzilla/show_bug.cgi?id=27989

--- Comment #4 from cvs-commit at gcc dot gnu.org <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Andrew Burgess <aburgess@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=f1f0a06d5b34231edd75fbd71a3be79097437f62

commit f1f0a06d5b34231edd75fbd71a3be79097437f62
Author: Andrew Burgess <aburgess@redhat.com>
Date:   Tue Sep 26 17:32:24 2023 +0100

    gdbserver: fix handling of single quote arguments

    I noticed that passing arguments containing single quotes to gdbserver
    didn't work correctly:

      gdb -ex 'set sysroot' --args /tmp/show-args
      Reading symbols from /tmp/show-args...
      (gdb) target extended-remote | gdbserver --once --multi - /tmp/show-args
      Remote debugging using | gdbserver --once --multi - /tmp/show-args
      stdin/stdout redirected
      Process /tmp/show-args created; pid = 176054
      Remote debugging using stdio
      Reading symbols from /lib64/ld-linux-x86-64.so.2...
      (No debugging symbols found in /lib64/ld-linux-x86-64.so.2)
      0x00007ffff7fd3110 in _start () from /lib64/ld-linux-x86-64.so.2
      (gdb) set args \'
      (gdb) r
      The program being debugged has been started already.
      Start it from the beginning? (y or n) y
      Starting program: /tmp/show-args \'
      stdin/stdout redirected
      Process /tmp/show-args created; pid = 176088
      2 args are:
        /tmp/show-args
        \'
      Done.
      [Inferior 1 (process 176088) exited normally]
      (gdb) target native
      Done.  Use the "run" command to start a process.
      (gdb) run
      Starting program: /tmp/show-args \'
      2 args are:
        /tmp/show-args
        '
      Done.
      [Inferior 1 (process 176095) exited normally]
      (gdb) q

    The 'shows-args' program used here just prints the arguments passed to
    the inferior.

    Notice that when starting the inferior using the extended-remote
    target the second argument is "\'", while when running using native
    target the argument is "'".  The second of these is correct, the \'
    used with the "set args" command is just to show GDB that the single
    quote is not opening an argument string.

    It turns out that the extra backslash is injected on the gdbserver
    side when gdbserver processes the arguments that GDB passes it, the
    code that does this was added as part of this much larger commit:

      commit 2090129c36c7e582943b7d300968d19b46160d84
      Date:   Thu Dec 22 21:11:11 2016 -0500

          Share fork_inferior et al with gdbserver

    In this commit I propose removing the specific code that adds what I
    believe is a stray backslash.  I've extended an existing test to cover
    this case, and I now see identical behaviour when using an
    extended-remote target as with the native target.

    This partially fixes PR gdb/27989, though there are still some issues
    with newline handling which I'll address in a later commit.

    During review I was pointed to this older series:

     
https://inbox.sourceware.org/gdb-patches/20211022071933.3478427-1-m.weghorn@posteo.de/

    which also includes this fix as part of a larger set of changes.  I'm
    giving a Co-Authored-By credit to the author of that original series.
    I believe this smaller fix brings some benefits on its own, though the
    original series does offer additional improvements.  Once this is
    merged I'll take a look at rebasing and resubmitting the original series.

    Bug: https://sourceware.org/bugzilla/show_bug.cgi?id=27989

    Co-Authored-By: Michael Weghorn <m.weghorn@posteo.de>
    Approved-By: Tom Tromey <tom@tromey.com>

-- 
You are receiving this mail because:
You are on the CC list for the bug.

  parent reply	other threads:[~2023-10-06 12:08 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-16 18:45 [Bug gdb/27989] New: " simark at simark dot ca
2021-06-16 19:11 ` [Bug gdb/27989] " simark at simark dot ca
2021-06-17 13:42 ` cvs-commit at gcc dot gnu.org
2021-10-21 13:52 ` m.weghorn at posteo dot de
2023-10-06 12:08 ` cvs-commit at gcc dot gnu.org [this message]
2023-10-06 12:08 ` cvs-commit at gcc dot gnu.org
2023-10-09 14:40 ` aburgess at redhat dot com

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-27989-4717-xVpbisclOx@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=gdb-prs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).