This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Unset attach_flag when running a new process
- From: Doug Evans <xdje42 at gmail dot com>
- To: Patrick Palka <patrick at parcs dot ath dot cx>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 16 Sep 2015 09:32:52 -0700
- Subject: Re: [PATCH] Unset attach_flag when running a new process
- Authentication-results: sourceware.org; auth=none
- References: <CA+C-WL-pXAYhLBcVE2Cj7Qtjhxm_XbHnJOHjwB=4FmHhvnoQ7Q at mail dot gmail dot com> <1439816493-17559-1-git-send-email-patrick at parcs dot ath dot cx>
Patrick Palka <patrick@parcs.ath.cx> writes:
> We currently set attach_flag when attaching to a process, so we should
> make sure to unset it when forking a new process. Otherwise attach_flag
> would remain set after forking, if the previous process associated with
> the inferior was attached to.
>
> gdb/ChangeLog:
>
> * target.c (target_pre_inferior): Unset attach_flag.
>
> gdb/testsuite/ChangeLog:
>
> * gdb.base/run-after-attach.exp: New test file.
> * gdb.base/run-after-attach.c: New test file.
> ---
> gdb/target.c | 4 ++
> gdb/testsuite/gdb.base/run-after-attach.c | 25 +++++++++++
> gdb/testsuite/gdb.base/run-after-attach.exp | 65 +++++++++++++++++++++++++++++
> 3 files changed, 94 insertions(+)
> create mode 100644 gdb/testsuite/gdb.base/run-after-attach.c
> create mode 100644 gdb/testsuite/gdb.base/run-after-attach.exp
>
> diff --git a/gdb/target.c b/gdb/target.c
> index e41a338..96e7df7 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -2138,6 +2138,10 @@ target_pre_inferior (int from_tty)
> target_clear_description ();
> }
>
> + /* attach_flag may be set if the previous process associated with
> + the inferior was attached to. */
> + current_inferior ()->attach_flag = 0;
> +
> agent_capability_invalidate ();
> }
Hi.
A couple of comments for discussion's sake.
There's a lot of state in struct inferior.
Is there anything else that needs to be reset?
And how can we set things up so that future readers
don't walk away with the same question?
A function to reset struct inferior in preparation for a
"new" inferior is something I'd expect to find in the API that
inferior.[ch] should be providing to gdb.
Thoughts?