From: Tom Tromey <tom@tromey.com>
To: Pedro Alves <palves@redhat.com>
Cc: gdb-patches@sourceware.org
Subject: Re: [PATCH 17/23] Multi-target support
Date: Wed, 11 Sep 2019 17:11:00 -0000 [thread overview]
Message-ID: <87zhja4v2z.fsf@tromey.com> (raw)
In-Reply-To: <20190906232807.6191-18-palves@redhat.com> (Pedro Alves's message of "Sat, 7 Sep 2019 00:28:01 +0100")
>>>>> "Pedro" == Pedro Alves <palves@redhat.com> writes:
Pedro> This commit adds multi-target support to GDB. What this means is that
Pedro> with this commit, GDB can now be connected to different targets at the
Pedro> same time. E.g., you can debug a live native process and a core dump
Pedro> at the same time, connect to multiple gdbservers, etc.
Awesome!
I read through the patch, but I can't really claim to understand how all
the parts interrelate. However your overview made sense to me, and I
don't have any conceptual concerns; just the usual sort of thing that
there are lurking bugs. I guess my main fear is that this will
introduce regressions... but on the other hand, I think it's important
direction for gdb, so I'd rather err on the side of moving forward with
it.
Pedro> To fix this,
Pedro> this commit renames gdbserver's target_ops to process_stratum_target.
Pedro> I think this makes sense. There's no concept of target stack in
Pedro> gdbserver, and gdbserver's target_ops really implements a
Pedro> process_stratum-like target.
Makes sense. Sometimes I dream about re-merging the target stacks,
further shrinking the size of the gdbserver fork.
Pedro> - you can only resume more that one target at the same time if all
Pedro> targets support asynchronous debugging, and support non-stop mode.
Pedro> It should be possible to support mixed all-stop + non-stop
Pedro> backends, but that is left for another time. This means that
Pedro> currently in order to do multi-target with gdbserver you need to
Pedro> issue "maint set target-non-stop on". I would like to make that
Pedro> mode be the default, but we're not there yet. Note that I'm
Pedro> talking about how the target backend works, only. User-visible
Pedro> all-stop mode works just fine.
Pedro> - as explained above, connecting to different remote servers at the
Pedro> same time is likely to produce bad results if they don't support the
Pedro> exact set of RSP features.
Are these limitations something that can be noticed when making the
remote connection, or do they require the user to be careful? What
happens if the user forgets or just doesn't know?
Pedro> - thread_info *tp = find_thread_ptid (task_info->ptid);
Pedro> + thread_info *tp = find_thread_ptid (inf->process_target (), task_info->ptid);
There are a few spots in the patch that could use the overload that
accepts an inferior, but instead call the process_target method
directly.
Pedro> +/* Calls target_commit_resume on all targets. */
Pedro> +
Pedro> +static void
Pedro> +commit_resume_all_targets ()
Pedro> +{
Pedro> + scoped_restore_current_thread restore_thread;
Pedro> +
Pedro> + for (inferior *inf : all_non_exited_inferiors ())
Pedro> + if (inf->has_execution ())
Pedro> + {
Pedro> + switch_to_inferior_no_thread (inf);
Pedro> + target_commit_resume ();
Pedro> + }
IIUC this can cause multiple calls to a given target's commit_resume
method. That seems fine (assuming you audited these implementations)
but I suppose it would be good to document this somewhere.
Alternatively I guess gdb would need some kind of iterator that ensures
it only visits each target once.
Pedro> - event_ptid = wait_one (&ws);
Pedro> + wait_one_event event = wait_one ();
Pedro> + target_waitstatus &ws = event.ws;
Pedro> + ptid_t &event_ptid = event.ptid;
I was wondering if these need to be references. It seemed like maybe
they could be const references but I couldn't immediately tell.
Pedro> - For all-stop targets, we only step INFERIOR_PTID and continue others. */
Pedro> + For all-stop targets, we only step INFERIOR_PTID and continue others. */
This looks like extra indentation was added.
Pedro> struct regcache *
Pedro> get_thread_regcache_for_ptid (ptid_t ptid)
Pedro> {
Pedro> - return get_thread_regcache (ptid);
Pedro> + /* This function doesn't take a process_stratum_target parameter
Pedro> + because it's a common/ routine implemented by both gdb and
Pedro> + gdbserver. It always refers to a ptid of the current target. */
It's "gdbsupport/" now.
Pedro> /* The status of the stub support for the various vCont actions. */
Pedro> vCont_action_support supports_vCont;
Pedro> + /* Whether vCont support was probed already. */
Pedro> + bool supports_vCont_probed;
If it's the case that this is only a temporary measure, then I think
this comment should mention that.
Pedro> @@ -6601,6 +6622,8 @@ remote_target::commit_resume ()
Pedro> }
Pedro> vcont_builder.flush ();
Pedro> +
Pedro> + target_async (1);
Pedro> }
I didn't understand this. Like, is it always ok to do this?
Pedro> /* Callback for iterate_over_inferiors. Gets rid of the given
Pedro> inferior. */
Pedro> -static int
Pedro> -dispose_inferior (struct inferior *inf, void *args)
Pedro> +static void
Pedro> +dispose_inferior (inferior *inf)
Pedro> {
Pedro> /* Not all killed inferiors can, or will ever be, removed from the
Pedro> inferior list. Killed inferiors clearly don't need to be killed
Pedro> again, so, we're done. */
Pedro> if (inf->pid == 0)
Pedro> - return 0;
Pedro> + return;
I think the comments here (both the intro comment and the one in the
function) need to be updated, since it seems that just a single inferior
is handled here now, and this is no longer a callback for
iterate_over_inferiors.
I didn't understand this change. Why did it used to iterate but now
does not?
Pedro> target_pass_ctrlc (void)
Pedro> {
Pedro> - current_top_target ()->pass_ctrlc ();
Pedro> + /* Pass the Ctrl-C to the first inferior that has a thread
Pedro> + running. */
Pedro> + for (inferior *inf : all_inferiors ())
Pedro> + {
[...]
Pedro> + return;
I didn't understand this. It seemed to me that a C-c should maybe be
sent to all running inferiors?
I don't actually know this area. Maybe that's obvious now :)
Pedro> /* See target.h. */
Pedro> @@ -3987,10 +4047,8 @@ set_write_memory_permission (const char *args, int from_tty,
Pedro> }
Pedro> void
Pedro> -initialize_targets (void)
Pedro> +_initialize_target (void)
You might as well remove the 'void' when touching the line.
Pedro> - explicit all_matching_threads_iterator (ptid_t filter_ptid);
Pedro> + explicit all_matching_threads_iterator (process_stratum_target *filter_target,
Pedro> + ptid_t filter_ptid);
I guess this could drop the "explicit".
Pedro> - explicit all_matching_threads_range (ptid_t filter_ptid)
Pedro> - : m_filter_ptid (filter_ptid)
Pedro> + explicit all_matching_threads_range (process_stratum_target *filter_target,
Pedro> + ptid_t filter_ptid)
Here too.
Pedro> - explicit all_non_exited_threads_range (ptid_t filter_ptid)
Pedro> - : m_filter_ptid (filter_ptid)
Pedro> + explicit all_non_exited_threads_range (process_stratum_target *filter_target,
Pedro> + ptid_t filter_ptid)
Pedro> + : m_filter_target (filter_target), m_filter_ptid (filter_ptid)
And here.
Tom
next prev parent reply other threads:[~2019-09-11 17:11 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-06 23:28 [PATCH 00/23] " Pedro Alves
2019-09-06 23:28 ` [PATCH 18/23] Add multi-target tests Pedro Alves
2019-10-09 16:01 ` Aktemur, Tankut Baris
2019-10-17 0:55 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 08/23] Introduce switch_to_inferior_no_thread Pedro Alves
2019-09-09 18:42 ` Tom Tromey
2019-10-17 1:07 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 11/23] tfile_target::close: trace_fd can't be -1 Pedro Alves
2019-09-06 23:28 ` [PATCH 17/23] Multi-target support Pedro Alves
2019-09-11 17:11 ` Tom Tromey [this message]
2019-10-17 1:54 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 06/23] Don't check target is running in remote_target::mourn_inferior Pedro Alves
2019-09-06 23:28 ` [PATCH 20/23] Revert 'Remove unused struct serial::name field' Pedro Alves
2019-09-06 23:47 ` Christian Biesinger via gdb-patches
2019-09-08 19:30 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 19/23] gdbarch-selftests.c: No longer error out if debugging something Pedro Alves
2019-09-06 23:28 ` [PATCH 16/23] Fix reconnecting to a gdbserver already debugging multiple processes, II Pedro Alves
2019-09-06 23:28 ` [PATCH 03/23] Make "show remote exec-file" inferior-aware Pedro Alves
2019-09-06 23:28 ` [PATCH 09/23] switch inferior/thread before calling target methods Pedro Alves
2019-09-06 23:28 ` [PATCH 15/23] Fix reconnecting to a gdbserver already debugging multiple processes, I Pedro Alves
2019-09-06 23:28 ` [PATCH 10/23] Some get_last_target_status tweaks Pedro Alves
2019-09-09 18:53 ` Tom Tromey
2019-10-17 1:14 ` Pedro Alves
2019-09-06 23:28 ` [PATCH 01/23] Preserve selected thread in all-stop w/ background execution Pedro Alves
2019-10-09 9:36 ` Aktemur, Tankut Baris
2019-10-16 23:54 ` [PATCH v1.1 " Pedro Alves
2019-10-17 10:21 ` Aktemur, Tankut Baris
2019-09-06 23:28 ` [PATCH 02/23] Don't rely on inferior_ptid in record_full_wait Pedro Alves
2020-07-31 3:17 ` Tom Tromey
2020-08-01 16:14 ` Simon Marchi
2020-08-01 19:32 ` John Baldwin
2020-08-01 20:47 ` Tom Tromey
2020-08-01 20:46 ` Tom Tromey
2020-08-01 22:56 ` Simon Marchi
2020-08-02 17:52 ` Tom Tromey
2020-08-03 0:08 ` Simon Marchi
2019-09-06 23:28 ` [PATCH 13/23] Delete exit_inferior_silent(int pid) Pedro Alves
2019-09-06 23:33 ` [PATCH 23/23] Multi-target: NEWS and user manual Pedro Alves
2019-09-07 6:33 ` Eli Zaretskii
2019-10-17 2:08 ` Pedro Alves
2019-10-17 7:55 ` Eli Zaretskii
2019-10-17 2:42 ` Pedro Alves
2019-10-17 8:14 ` Eli Zaretskii
2019-10-17 15:31 ` Pedro Alves
2019-09-06 23:34 ` [PATCH 04/23] exceptions.c:print_flush: Remove obsolete check Pedro Alves
2019-09-09 18:07 ` Tom Tromey
2019-09-06 23:35 ` [PATCH 05/23] Make target_ops::has_execution take an 'inferior *' instead of a ptid_t Pedro Alves
2019-09-09 18:12 ` Tom Tromey
2019-09-06 23:36 ` [PATCH 07/23] Delete unnecessary code from kill_command Pedro Alves
2019-10-01 10:19 ` Aktemur, Tankut Baris
2019-10-01 13:28 ` Aktemur, Tankut Baris
2019-09-06 23:36 ` [PATCH 12/23] Use all_non_exited_inferiors in infrun.c Pedro Alves
2019-09-06 23:36 ` [PATCH 14/23] Tweak handling of remote errors in response to resumption packet Pedro Alves
2019-10-09 13:35 ` Aktemur, Tankut Baris
2019-10-17 0:54 ` [PATCH 14.5/23] Avoid another inferior_ptid reference in gdb/remote.c (Re: [PATCH 14/23] Tweak handling of remote errors in response to resumption packet) Pedro Alves
2019-09-06 23:37 ` [PATCH 21/23] Add "info connections" command, "info inferiors" connection number/string Pedro Alves
2019-09-09 20:18 ` Tom Tromey
2019-10-17 2:21 ` Pedro Alves
2019-10-17 14:23 ` Tom Tromey
2019-09-06 23:37 ` [PATCH 22/23] Require always-non-stop for multi-target resumptions Pedro Alves
2019-09-07 11:19 ` [PATCH 00/23] Multi-target support Philippe Waroquiers
2019-09-08 20:06 ` Pedro Alves
2019-09-08 20:50 ` Philippe Waroquiers
2019-10-16 19:08 ` Pedro Alves
2019-10-16 19:14 ` [PATCH] Avoid inferior_ptid reference in gdb/remote.c (Re: [PATCH 00/23] Multi-target support) Pedro Alves
2019-09-09 19:09 ` [PATCH 00/23] Multi-target support Tom Tromey
2019-09-09 20:22 ` 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=87zhja4v2z.fsf@tromey.com \
--to=tom@tromey.com \
--cc=gdb-patches@sourceware.org \
--cc=palves@redhat.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