This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Unset attach_flag when running a new process


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?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]