From: Pedro Alves <palves@redhat.com>
To: Don Breazeal <donb@codesourcery.com>,
"gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH v3 1/4] Extended-remote follow exec
Date: Fri, 11 Sep 2015 08:34:00 -0000 [thread overview]
Message-ID: <55F2922C.9060306@redhat.com> (raw)
In-Reply-To: <55F20AA7.8050301@codesourcery.com>
Hi Don,
Other than the nits below, it LGTM. Fix those and you're
good to go. Please push.
On 09/10/2015 11:56 PM, Don Breazeal wrote:
> On 9/10/2015 5:43 AM, Pedro Alves wrote:
>> On 09/10/2015 12:05 AM, Don Breazeal wrote:
>>> Hi Pedro,
>>>
>>> This is an updated version of the patch previously submitted here:
>>> https://sourceware.org/ml/gdb-patches/2015-07/msg00924.html. Changes
>>> from the previous version include:
>>>
>>> * In gdbserver, when an exec event occurs, gdbserver deletes all
>>> of the data (inferior, lwps, threads) associated with the execing
>>> process and replaces it with a new set of data.
>>>
>>> * In GDB, the remote exec-file is now stored per-inferior in the
>>> inferior's program space as a REGISTRY field.
>>>
>>> * In GDB, a new target hook, target_follow_exec, is used to enable
>>> storing the remote exec-file as per-inferior data.
>>>
>>> * In GDB, follow_exec now calls add_inferior_with_spaces for mode
>>> "new" in place of add_inferior and the calls to set up the program
>>> and address spaces.
>>>
>>> Some of the things that were part of the previous patchset were
>>> eliminated as a result of these changes, including:
>>>
>>> * Deleting "vanished" lwps in gdbserver/linux-low.c:send_sigstop.
>>>
>>> * Fiddling with the regcache and r_debug in
>>> gdbserver/linux-low.c:handle_extended_wait.
>>>
>>> * Fiddling with the inferior's architecture in
>>> remote.c:remote_parse_stop_reply.
>>>
>>> A couple of your questions about the previous version of the patch still
>>> apply, in spite of the rework. Regarding the handling of the exec event
>>> in linux-low.c:handle_extended_wait:
>>>
>>>>> + /* Mark the exec status as pending. */
>>>>> + event_lwp->stopped = 1;
>>>>> + event_lwp->status_pending_p = 1;
>>>>> + event_lwp->status_pending = wstat;
>>>>> + event_thr->last_resume_kind = resume_stop;
>>>>
>>>> Shouldn't this be resume_continue?
>>>
>>> My thinking here is that as far as gdbserver is concerned, we *do* want
>>> to use resume_stop, so that we stop and report the event to GDB. It will
>>> be up to GDB whether to continue from this point. Does that make sense?
>>
>> Not really -- putting exec events out of the picture, consider:
>>
>> If you simply continue a thread (vCont;c) and it hits a breakpoint, it'll
>> have last_resume_kind==resume_continue, and we still report the event
>> to gdb, and it's still up to GDB whether to continue past the breakpoint.
>>
>> So if you set last_resume_kind to resume_continue, and drop this hunk:
>>
>>> @@ -3373,7 +3463,8 @@ linux_wait_1 (ptid_t ptid,
>>> ourstatus->value.sig = GDB_SIGNAL_0;
>>> }
>>> else if (current_thread->last_resume_kind == resume_stop
>>> - && WSTOPSIG (w) != SIGSTOP)
>>> + && WSTOPSIG (w) != SIGSTOP
>>> + && ourstatus->kind != TARGET_WAITKIND_EXECD)
>>> {
>>> /* A thread that has been requested to stop by GDB with vCont;t,
>>> but, it stopped for other reasons. */
>>> @@ -5801,6 +5892,14 @@ linux_supports_vfork_events (void)
>>> return linux_supports_tracefork ();
>>> }
>>
>> ... what doesn't work?
>
> That works just fine. I've made that change.
>
> Clearly I didn't understand the purpose of resume_stop. Is that only
> used when GDB requests a stop, and/or when an inferior is just starting
> up or being attached? As opposed to when the inferior is stopped by an
> event?
Yeah, lots of different state flags, and several layers of state machines
involved. gdb's, core gdbserver's, and linux-low's. The flags we have
today have come into being through code evolution, rather than design...
Probably, we could probably merge/simplify them, but it'd require lots of
careful analysis.
Anyway, from a high level, thread->last_resume_kind indicates the last
resume state from _gdb_'s perspective. So resume_stop is used:
- when GDB requests an explicit stop with vCont;t. The thread gets
set to resume_stop even if it is still running.
- when a thread that was last continued/stepped (resume_continue/resume_step)
hits an event and _after_ gdbserver reports the stop to gdb, _then_ it's
last resume kind is set to resume_stop.
> --- a/gdb/remote.c
> +++ b/gdb/remote.c
> @@ -75,6 +75,14 @@
> static char *target_buf;
> static long target_buf_size;
>
> +/* Per-program-space data key. */
> +static const struct program_space_data *remote_pspace_data;
> +
> +/* The variable registered as the control variable used by the
> + remote exec-file commands. Used by the set/show machinery
> + as the location of the remote exec-file value. */
> +static char *remote_exec_file_var;
I think we should mention the per-program-space aspect. Something like:
/* The variable registered as the control variable used by the
remote exec-file commands. While the remote exec-file setting is
per-program-space, the set/show machinery uses this as location
of the remote exec-file value. */
> +/* Fetch the remote exec-file from the current program space. */
> +
> +static const char *
> +get_remote_exec_file (void)
> +{
> + char *remote_exec_file;
> +
> + remote_exec_file = program_space_data (current_program_space,
> + remote_pspace_data);
> + if (remote_exec_file == NULL)
> + return "";
> +
> + return remote_exec_file;
> +}
> +
> +/* Set the remote exec file for the current program space. */
/* Set the remote exec file for PSPACE. */
> +
> +static void
> +set_remote_exec_file_1 (struct program_space *pspace,
> + char *remote_exec_file)
I think we can now rename this for clarity. E.g.,
set_program_space_remote_exec_file / set_pspace_remote_exec_file.
> +{
> + char *old_file = program_space_data (pspace, remote_pspace_data);
> +
> + xfree (old_file);
> + set_program_space_data (pspace, remote_pspace_data,
> + xstrdup (remote_exec_file));
> +}
Thanks,
Pedro Alves
next prev parent reply other threads:[~2015-09-11 8:34 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-15 21:49 [PATCH 0/5] " Don Breazeal
2015-07-15 21:50 ` [PATCH 1/5] Extended-remote exec events Don Breazeal
2015-07-16 14:01 ` Yao Qi
2015-07-16 15:52 ` Don Breazeal
2015-07-16 16:35 ` Yao Qi
2015-07-16 17:06 ` Don Breazeal
2015-07-17 11:55 ` Yao Qi
2015-07-15 21:50 ` [PATCH 3/5] Extended-remote support for exec event tests Don Breazeal
2015-07-15 21:50 ` [PATCH 2/5] Extended-remote exec catchpoints Don Breazeal
2015-08-13 15:00 ` Pedro Alves
2015-07-15 21:51 ` [PATCH 4/5] Eliminate spurious warnings from remote exec Don Breazeal
2015-07-15 21:51 ` [PATCH 5/5] Extended-remote exec event docs Don Breazeal
2015-07-16 2:39 ` Eli Zaretskii
2015-07-30 23:19 ` [PATCH v2 0/5] Extended-remote exec events Don Breazeal
2015-07-30 23:19 ` [PATCH v2 2/5] Extended-remote exec catchpoints Don Breazeal
2015-07-30 23:19 ` [PATCH v2 1/5] Extended-remote follow exec Don Breazeal
2015-08-13 14:50 ` Pedro Alves
2015-07-30 23:20 ` [PATCH v2 3/5] Extended-remote support for exec event tests Don Breazeal
2015-08-13 15:22 ` Pedro Alves
2015-07-30 23:20 ` [PATCH v2 5/5] Extended-remote exec event docs Don Breazeal
2015-07-31 6:36 ` Eli Zaretskii
2015-07-31 17:06 ` Don Breazeal
2015-08-13 15:43 ` Pedro Alves
2015-07-30 23:20 ` [PATCH v2 4/5] Eliminate spurious warnings from remote exec Don Breazeal
2015-08-13 15:38 ` Pedro Alves
2015-09-09 23:05 ` [PATCH v3 0/4] Extended-remote exec events Don Breazeal
2015-09-09 23:06 ` [PATCH v3 3/4] Extended-remote support for exec event tests Don Breazeal
2015-09-10 13:26 ` Pedro Alves
2015-09-09 23:06 ` [PATCH v3 4/4] Extended-remote exec event docs Don Breazeal
2015-09-10 15:23 ` Eli Zaretskii
2015-09-09 23:06 ` [PATCH v3 2/4] Extended-remote exec catchpoints Don Breazeal
2015-09-09 23:06 ` [PATCH v3 1/4] Extended-remote follow exec Don Breazeal
[not found] ` <55F17AFA.5080102@redhat.com>
2015-09-10 22:56 ` Don Breazeal
2015-09-10 23:00 ` Don Breazeal
2015-09-11 8:34 ` Pedro Alves [this message]
2015-09-11 18:38 ` [pushed][PATCH " Don Breazeal
2015-09-11 18:38 ` [pushed][PATCH v3 2/4] Extended-remote exec catchpoints Don Breazeal
2015-09-11 18:38 ` [pushed][PATCH v3 3/4] Extended-remote exec test Don Breazeal
2015-09-15 15:45 ` Pedro Alves
2015-09-15 15:53 ` Don Breazeal
2015-09-15 15:58 ` Pedro Alves
2015-09-15 16:00 ` Breazeal, Don
2015-09-15 16:28 ` Pedro Alves
2015-09-11 18:39 ` [pushed][PATCH v3 4/4] Extended-remote exec event docs Don Breazeal
2015-09-15 8:56 ` [pushed][PATCH v3 1/4] Extended-remote follow exec Yao Qi
2015-09-15 16:12 ` Don Breazeal
2015-09-15 16:31 ` Yao Qi
2015-09-30 16:20 ` Pedro Alves
2015-09-30 16:22 ` Breazeal, Don
2016-12-08 11:54 ` Thomas Schwinge
2017-02-17 16:45 ` Pedro Alves
2019-02-14 16:42 ` Thomas Schwinge
2019-02-14 17:26 ` Tom Tromey
2019-02-14 23:11 ` 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=55F2922C.9060306@redhat.com \
--to=palves@redhat.com \
--cc=donb@codesourcery.com \
--cc=gdb-patches@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