From: Andrew Burgess <andrew.burgess@embecosm.com>
To: Simon Marchi <simon.marchi@polymtl.ca>
Cc: gdb-patches@sourceware.org, Simon Marchi <simon.marchi@efficios.com>
Subject: Re: [PATCH 1/5] gdb: make target_close check that the target isn't pushed in all inferiors
Date: Thu, 6 May 2021 17:14:41 +0100 [thread overview]
Message-ID: <20210506161441.GE6612@embecosm.com> (raw)
In-Reply-To: <20210506142806.30363-1-simon.marchi@polymtl.ca>
* Simon Marchi via Gdb-patches <gdb-patches@sourceware.org> [2021-05-06 10:28:02 -0400]:
> From: Simon Marchi <simon.marchi@efficios.com>
>
> The target_close function currently checks that the target to be closed
> isn't pushed in the current inferior:
>
> gdb_assert (!current_inferior ()->target_is_pushed (targ));
>
> When a target is closed, it's normally because its refcount has dropped
> to 0, because it's not used in any inferior anymore. I think it would
> make sense to change that assert to not only check in the current
> inferior, but to check in all inferiors. It would be quite bad (and a
> bug) to close a target while it's still pushed in one of the non-current
> inferiors.
>
> gdb/ChangeLog:
>
> * target.c (target_close): Check in all inferiors that the
> target is not pushed.
LGTM.
Thanks,
Andrew
>
> Change-Id: I6e37fc3f3476a0593da1e476604642b2de90f1d5
> ---
> gdb/target.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/gdb/target.c b/gdb/target.c
> index 1f0741471d82..00f0acde7586 100644
> --- a/gdb/target.c
> +++ b/gdb/target.c
> @@ -3734,7 +3734,8 @@ debug_target::info () const
> void
> target_close (struct target_ops *targ)
> {
> - gdb_assert (!current_inferior ()->target_is_pushed (targ));
> + for (inferior *inf : all_inferiors ())
> + gdb_assert (!inf->target_is_pushed (targ));
>
> fileio_handles_invalidate_target (targ);
>
> --
> 2.30.1
>
next prev parent reply other threads:[~2021-05-06 16:14 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-05-06 14:28 Simon Marchi
2021-05-06 14:28 ` [PATCH 2/5] gdb: remove reference to current inferior in target_stack::unpush Simon Marchi
2021-05-06 16:15 ` Andrew Burgess
2021-05-07 15:53 ` Simon Marchi
2021-05-06 14:28 ` [PATCH 3/5] gdb: call target_follow_exec when "set follow-exec-mode" is "same" Simon Marchi
2021-05-06 14:28 ` [PATCH 4/5] gdb: on exec, delegate pushing / unpushing target and adding thread to target_ops::follow_exec Simon Marchi
2021-05-06 14:28 ` [PATCH 5/5] gdb: maybe unpush target from old inferior in inf_child_target::follow_exec Simon Marchi
2021-05-13 19:30 ` Simon Marchi
2021-05-06 16:01 ` [PATCH 1/5] gdb: make target_close check that the target isn't pushed in all inferiors Aktemur, Tankut Baris
2021-05-06 16:35 ` Simon Marchi
2021-05-07 7:44 ` Aktemur, Tankut Baris
2021-05-07 15:52 ` Simon Marchi
2021-05-06 16:14 ` Andrew Burgess [this message]
2021-05-07 14:36 ` Tom Tromey
2021-05-07 15:42 ` Simon Marchi
2021-05-07 16:47 ` 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=20210506161441.GE6612@embecosm.com \
--to=andrew.burgess@embecosm.com \
--cc=gdb-patches@sourceware.org \
--cc=simon.marchi@efficios.com \
--cc=simon.marchi@polymtl.ca \
/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).