public inbox for gdb-prs@sourceware.org
help / color / mirror / Atom feed
From: "mark at klomp dot org" <sourceware-bugzilla@sourceware.org>
To: gdb-prs@sourceware.org
Subject: [Bug gdb/30541] Add target valgrind
Date: Fri, 14 Jul 2023 15:15:51 +0000	[thread overview]
Message-ID: <bug-30541-4717-m4rdiz9xTG@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-30541-4717@http.sourceware.org/bugzilla/>

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

--- Comment #33 from Mark Wielaard <mark at klomp dot org> ---
(In reply to Pedro Alves from comment #32)
> > We prefer vgdb being launched from within gdb (target extended-remote | vgdb --multi) 
> > and get the environment/cwd inherited that way.
> 
> > But currently that means vgdb will communicate through stdin/out with gdb, so 
> > stdin/out aren't available for the inferior. This is being worked on by Sasha for 
> > https://sourceware.org/bugzilla/show_bug.cgi?id=28916 at 
> > https://git.sr.ht/~sasshka/binutils-gdb/log/split_fd but we aren't there yet 
> > (switching the file descriptors used for communication seems to work, but the whole 
> > terminal handling is a little complex).
> 
> Not sure if I fully understood that approach.

The basic idea is that gdb would dup the normal stdin/out/err and let the
gdbserver/vgdb inherit those file descriptors. Then gdb will sent a new
fdSwitch packet to notify that gdbserver/gdb should switch around its own
stdin/out/err with those file descriptors (and make any inferiors started use
those) and move the original stdin/out file descriptors so packets aren't sent
anymore over stdin/out.

> But, wouldn't it be simpler to teach GDB an alternative to "target
> extended-remote | CMD".
> 
> Like:
> 
>   target extended-remote -server-cmd "vgdb --multi :9999" :9999
> 
> "-server-cmd CMD" would spawn CMD, and GDB would wait/reap it like it does
> for "target extended-remote | CMD".
> 
> You could replace ":9999" with a unix domain socket, created by the "target
> valgrind" command, for example.
> 
> That would leave stdin/stdout/stderr to be used by gdbserver as normal.

Andrew also suggested something like that (replace | with some other magic
char) to get that effect. Maybe

> Terminal handling, for getting input into the inferior, yeah, that is a
> little complex. You have to put vgdb in the foreground whenever gdb wants to
> give the terminal to the inferior.

Maybe this part of the conversation should move to bug #28916
I think I am a little naive and was just hoping having a shared stdin between
gdb/gdbserver/inferior would be enough to get the inferior normal reading from
stdin. I didn't realize the terminal needed to know who is reading. But I
already noticed it totally messes up ^C handling... hohum.

Having stdout work would already be an improvement. gdbserver has a trick for
that which vgdb should probably just add too (redirect stdout to stderr for the
inferior).
https://bugs.kde.org/show_bug.cgi?id=471311

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

  parent reply	other threads:[~2023-07-14 15:15 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 13:14 [Bug gdb/30541] New: " mark at klomp dot org
2023-06-13 17:01 ` [Bug gdb/30541] " tromey at sourceware dot org
2023-06-13 17:03 ` tromey at sourceware dot org
2023-06-15 11:22 ` pedro at palves dot net
2023-06-15 12:54 ` tromey at sourceware dot org
2023-06-15 13:13 ` mark at klomp dot org
2023-06-15 13:31 ` pedro at palves dot net
2023-06-15 15:40 ` pjfloyd at wanadoo dot fr
2023-06-15 17:04 ` pedro at palves dot net
2023-06-20 17:54 ` tromey at sourceware dot org
2023-07-06 15:55 ` tromey at sourceware dot org
2023-07-06 16:44 ` mark at klomp dot org
2023-07-06 17:17 ` sam at gentoo dot org
2023-07-10 21:36 ` tromey at sourceware dot org
2023-07-11  8:18 ` pedro at palves dot net
2023-07-11  8:24 ` pedro at palves dot net
2023-07-11  8:26 ` pedro at palves dot net
2023-07-11 12:23 ` tromey at sourceware dot org
2023-07-11 17:27 ` pedro at palves dot net
2023-07-11 17:29 ` pedro at palves dot net
2023-07-11 18:46 ` tromey at sourceware dot org
2023-07-11 19:44 ` pedro at palves dot net
2023-07-11 19:50 ` pedro at palves dot net
2023-07-11 21:39 ` mark at klomp dot org
2023-07-12  9:05 ` pedro at palves dot net
2023-07-12 10:26 ` pedro at palves dot net
2023-07-12 10:29 ` pedro at palves dot net
2023-07-13 13:38 ` mark at klomp dot org
2023-07-13 13:59 ` mark at klomp dot org
2023-07-13 14:14 ` tromey at sourceware dot org
2023-07-13 14:26 ` mark at klomp dot org
2023-07-13 16:35 ` pedro at palves dot net
2023-07-13 16:38 ` pedro at palves dot net
2023-07-13 17:43 ` pedro at palves dot net
2023-07-14 15:15 ` mark at klomp dot org [this message]
2023-08-25 15:50 ` 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-30541-4717-m4rdiz9xTG@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).