public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Simon Marchi <simark@simark.ca>
To: Andrew Burgess <aburgess@redhat.com>, gdb-patches@sourceware.org
Subject: Re: [PATCH] gdb: fix target_ops reference count for some cases
Date: Thu, 22 Sep 2022 10:52:49 -0400	[thread overview]
Message-ID: <a6e4152c-631e-b00d-3b92-b5180062395c@simark.ca> (raw)
In-Reply-To: <87edw3ebgm.fsf@redhat.com>



> I agree with you 100%.  Unfortunately, the following targets all seem to
> depend on current_inferior being set (in their ::close method):
> 
>   bsd_kvm_target
>   core_target
>   darwin_nat_target
>   record_btrace_target
>   ctf_target
>   tfile_target
>   windows_nat_target (though this is only for debug output)
> 
> I suspect that this means these targets only really work when GDB has a
> single inferior maybe?  In most cases GDB seems to be clearing out some
> per-inferior state relating to the target... I need to investigate more,
> but I guess I wanted to raise this in case you (or anyone) had thoughts.

Ah, ok.  Yeah I see some targets calling exit_inferior_silent on the
current inferior, among other things.  I guess I misunderstand what
target_ops::close is meant to do, I thought this would have been done
earlier.  Different targets seem to use the close method for different
things.

So, in any case, my proposition falls into "no doable right now".

>>> At the moment the inferior's program_space is deleted in
>>> delete_inferior before we call inferior::~inferior, so, I think, to
>>> place the pop_all_targets call into inferior::~inferior would require
>>> additional adjustment to GDB.  As delete_inferior already exists, and
>>> includes various house keeping tasks, it doesn't seem unreasonable to
>>> place the pop_all_targets call there.
>>
>> I don't object to fixing it like this.  I'm just wondering, did you
>> consider changing target_stack::m_stack to make it hold string
>> references, something like std::vector<target_ops_ref>?  I haven't tried
>> so maybe this doesn't make sense / is too difficult.  But if it does, I
>> guess the problem would take care of itself.  When deleting an inferior
>> that still has some targets pushed, they would be automatically decref'd
>> and closed if needed.
> 
> I did think about this.  I think in the end the fix I proposed here
> was just less churn.

Agreed.

> As I mention above, right now it seems we do need th correct inferior
> selected, so we might need something like this, I'll see how my new
> patches work out.

I think your approach is ok, it fixes a real bug, so big refactorings
should not get in the way of that.

I'll take a look at the code now.

Simon

  reply	other threads:[~2022-09-22 14:52 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 13:12 Andrew Burgess
2022-09-21 15:30 ` Simon Marchi
2022-09-22 14:21   ` Andrew Burgess
2022-09-22 14:52     ` Simon Marchi [this message]
2022-09-22 15:00 ` Simon Marchi
2022-09-22 17:24   ` Andrew Burgess
2022-09-26 14:16     ` Simon Marchi
2022-10-01 20:58       ` Andrew Burgess
2022-10-02 17:04 ` [PATCHv2 0/7] " Andrew Burgess
2022-10-02 17:04   ` [PATCHv2 1/7] gdb/remote: remove some manual reference count handling Andrew Burgess
2022-10-02 17:04   ` [PATCHv2 2/7] gdb: remove decref_target Andrew Burgess
2022-10-02 17:04   ` [PATCHv2 3/7] gdb: have target_stack automate reference count handling Andrew Burgess
2022-10-02 17:04   ` [PATCHv2 4/7] gdb: remove the pop_all_targets (and friends) global functions Andrew Burgess
2022-10-05 20:49     ` Lancelot SIX
2022-10-06 11:14       ` Andrew Burgess
2022-10-02 17:04   ` [PATCHv2 5/7] gdb: ensure all targets are popped before an inferior is destructed Andrew Burgess
2022-10-02 17:04   ` [PATCHv2 6/7] gdb/maint: add core file name to 'maint info program-spaces' output Andrew Burgess
2022-10-02 17:21     ` Eli Zaretskii
2022-10-02 17:04   ` [PATCHv2 7/7] gdb: some process_stratum_target should not be shared Andrew Burgess
2022-10-02 17:21     ` Eli Zaretskii
2022-10-05 21:15     ` Lancelot SIX
2022-10-06 11:44       ` Andrew Burgess
2022-11-18 16:42   ` [PATCHv3 0/7] gdb: fix target_ops reference count for some cases Andrew Burgess
2022-11-18 16:42     ` [PATCHv3 1/7] gdb/remote: remove some manual reference count handling Andrew Burgess
2022-11-18 16:42     ` [PATCHv3 2/7] gdb: remove decref_target Andrew Burgess
2022-11-18 17:22       ` Tom Tromey
2022-11-18 16:42     ` [PATCHv3 3/7] gdb: have target_stack automate reference count handling Andrew Burgess
2022-11-18 17:25       ` Tom Tromey
2022-11-18 16:42     ` [PATCHv3 4/7] gdb: remove the pop_all_targets (and friends) global functions Andrew Burgess
2022-11-18 17:29       ` Tom Tromey
2022-11-18 16:42     ` [PATCHv3 5/7] gdb: ensure all targets are popped before an inferior is destructed Andrew Burgess
2022-11-18 16:42     ` [PATCHv3 6/7] gdb/maint: add core file name to 'maint info program-spaces' output Andrew Burgess
2022-11-18 17:03       ` Eli Zaretskii
2022-11-18 16:42     ` [PATCHv3 7/7] gdb: some process_stratum_target should not be shared Andrew Burgess
2022-11-18 17:02       ` Eli Zaretskii
2022-11-18 18:04       ` Tom Tromey
2022-12-14 13:57         ` Andrew Burgess

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=a6e4152c-631e-b00d-3b92-b5180062395c@simark.ca \
    --to=simark@simark.ca \
    --cc=aburgess@redhat.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).