public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Andrew Burgess <aburgess@redhat.com>
To: Tom Tromey <tom@tromey.com>,
	Alexandra Petlanova Hajkova <ahajkova@redhat.com>
Cc: Tom Tromey <tom@tromey.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH 0/6] Add vDefaultInferiorFd feature
Date: Fri, 08 Dec 2023 13:06:20 +0000	[thread overview]
Message-ID: <87zfykg7xv.fsf@redhat.com> (raw)
In-Reply-To: <87zfyok5bk.fsf@tromey.com>

Tom Tromey <tom@tromey.com> writes:

>>>>>> "Alexandra" == Alexandra Petlanova Hajkova <ahajkova@redhat.com> writes:
>
>>  Another approach might be to have a different way to specify the
>>  connection fd to the remote, like a command-line option naming the fd to
>>  use for RSP traffic.
>
> Alexandra> Are you imagining something like "target remote | gdbserver --once RSP_FD ...." ?
> Alexandra> And GDB would replace RSP_FD with the actual file descriptor to use?
>
> Yeah.

There is one problem I see with this approach, maybe a bit of an edge
case, but, what if the application wanted to use the text RSP_FD
elsewhere in it's command line.  For example, a user does:

  (gdb) target remote | gdbserver --once RSP_FD /tmp/myprog

And everything is great, GDB replaces RSP_FD with the descriptor to use
for RSP traffic, and that's fine.

Or a user does:

  (gdb) target remote | gdbserver --once /tmp/myprog

And GDB doesn't spot RSP_FD, so doesn't redirect the RSP traffic, and
just continues to use stdin/stdout as it does right now.

But what about the poor user who needs to do this:

  (gdb) target remote | gdbserver --once /tmp/myprog RSP_FD

that is the 'RSP_FD' is an actual argument string to pass to 'myprog'!
Unlikely maybe, but not impossible.  Anything that requires GDB to
understand the command that appears after the `|` suffers from the
possibility that GDB might get it wrong.

>
> Alexandra> avoids adding a new packet and the whole FD switching business. But adding the new 
> Alexandra> packet approach makes it easier for the users. It's possible to run GDB to then run
> Alexandra>  Valgrind from inside by using simply
>
> Alexandra> target extended-remote | vgdb --multi
>
> Alexandra> I hope this command will be replaced with an even simpler " target valgrind" at
> Alexandra> some point.
>
> Part of the idea would be to hide the new file descriptor handling
> behind the "target valgrind" facade.  That is, the implementation of
> "target valgrind" would handle setting up the command line arguments to
> vgdb.

Even writing a Python wrapper doesn't really solve the above problem, it
just shifts it from GDB into the Python code.

And (I think) ideally we wouldn't rely on users having to write a Python
wrapper in order to use this feature with their own tools, so it would
be nice if this feature was usable from pure GDB.

Maybe it's just enough to add an on/off control setting, and have GDB
announce when it's performed the command line replacements.  Then
(hopefully) users will know that if they don't want this feature they
could turn this off...

Just my thoughts.

Thanks,
Andrew


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

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-17 11:18 Alexandra Hájková
2023-11-17 11:18 ` [PATCH 1/6] gdb.server/non-existing-program.exp: Use gdbserver_start Alexandra Hájková
2023-11-17 11:18 ` [PATCH 2/6] gdb/ser-pipe.c: Duplicate the file descriptors Alexandra Hájková
2023-12-12 19:42   ` Tom Tromey
2023-11-17 11:18 ` [PATCH 3/6] Add new vDefaultInferiorFd packet Alexandra Hájková
2023-11-17 12:09   ` Eli Zaretskii
2023-12-12 20:03   ` Tom Tromey
2023-11-17 11:18 ` [PATCH 4/6] gdbserver/linux-low.cc: Connect the inferior to the terminal Alexandra Hájková
2023-12-12 20:10   ` Tom Tromey
2023-11-17 11:18 ` [PATCH 5/6] remote.c: Add terminal handling functions Alexandra Hájková
2023-12-12 20:11   ` Tom Tromey
2023-11-17 11:18 ` [PATCH 6/6] Add defaultinf.exp test to the testsuite Alexandra Hájková
2023-11-27 10:01 ` [PATCH 0/6] Add vDefaultInferiorFd feature Alexandra Petlanova Hajkova
2023-12-01 20:22 ` Tom Tromey
2023-12-04 11:08   ` Andrew Burgess
2023-12-04 12:11   ` Alexandra Petlanova Hajkova
2023-12-05 16:00     ` Tom Tromey
2023-12-08 13:06       ` Andrew Burgess [this message]
2023-12-12 20:14   ` Tom Tromey

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=87zfykg7xv.fsf@redhat.com \
    --to=aburgess@redhat.com \
    --cc=ahajkova@redhat.com \
    --cc=gdb-patches@sourceware.org \
    --cc=tom@tromey.com \
    /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).