From: Patrick Palka <patrick@parcs.ath.cx>
To: Doug Evans <xdje42@gmail.com>
Cc: "gdb-patches@sourceware.org" <gdb-patches@sourceware.org>
Subject: Re: [PATCH 1/2] Use gdbarch obstack to allocate types in alloc_type_arch
Date: Sat, 29 Aug 2015 22:31:00 -0000 [thread overview]
Message-ID: <CA+C-WL9XcSQG-gqDAhyKHQCXXD2P5w8Za6WWU_i-=bo1Pc-Z0w@mail.gmail.com> (raw)
In-Reply-To: <CA+C-WL8EPj70AJWWsZx+GgRsDL9GN2gO2no=5k_y2QmrR503sQ@mail.gmail.com>
On Sat, Aug 29, 2015 at 6:29 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> On Sat, Aug 29, 2015 at 5:35 PM, Doug Evans <xdje42@gmail.com> wrote:
>> On Sat, Aug 29, 2015 at 2:26 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
>>>...
>>> Some background for this change: The TYPE_OBJFILE_OWNED macro tells us
>>> who owns a given type, and according to the macro's documentation a
>>> type is always owned either by an objfile or by a gdbarch. Given this
>>> binary encoding of ownership it doesn't seem to make much sense for
>>> _any_ type to be allocated by malloc. All types should be allocated
>>> on an objfile obstack or on a gdbarch obstack.
>>
>> I can imagine types being allocated by malloc and tracked via whatever
>> object "owns" them. All that matters is that when the owner is freed
>> all its owned objects are freed too. Whether those objects are
>> malloc'd or in an obstack is just an implementation detail.
>>
>> I know that that's not how arch-owned types worked prior to your patch.
>> I'm just saying they *could* have worked that way.
>> Moving them to an obstack obviates the need for keeping a copy of
>> the pointer so it can later be freed.
>
> That makes sense.
>
>>
>>> To support allocating a type by malloc, I think the type ownership
>>> scheme should have three possible cases: that a type is owned by an
>>> objfile, or that it's owned by a gdbarch, or that it's owned by the
>>> caller. This new last case could correspond to a type that's
>>> allocated by malloc instead of on an obstack.
>>>
>>> Does this make sense, or maybe I am misunderstanding what "owning" means here?
>>
>> I think you've got it right.
>>
>> There's still, technically, an open issue of "What happens if an arch
>> is freed and there's still a value in the history that uses that type?
>> Would we then have to preserve that type again? (bleah)"
>
> Ah, yeah..
>
>>
>> I don't have too strong an opinion on what's right here.
>> If someone wants to allow for arches being freed and thus
>> "preserved" types have to be "owned" by something else, ok,
>> but I don't see it as an urgent need. We *could* just say that
>> arches are never freed for now.
>
> Makes sense.
>
> I reverted this patch, with a revised one incoming.
Er, sorry, I reverted and revised the 2nd patch, not this one.
prev parent reply other threads:[~2015-08-29 22:31 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-30 2:28 Patrick Palka
2015-06-30 2:28 ` [PATCH 2/2] Use gdbarch obstack to allocate the TYPE_NAME string in arch_type Patrick Palka
2015-06-30 9:36 ` Pedro Alves
2015-06-30 20:05 ` Patrick Palka
2015-08-29 12:59 ` Patrick Palka
2015-08-29 18:20 ` Doug Evans
2015-08-29 21:29 ` Patrick Palka
2015-08-29 22:33 ` Patrick Palka
2015-09-02 5:12 ` Doug Evans
2015-08-29 18:06 ` [PATCH 1/2] Use gdbarch obstack to allocate types in alloc_type_arch Doug Evans
2015-08-29 21:26 ` Patrick Palka
2015-08-29 21:35 ` Doug Evans
2015-08-29 22:30 ` Patrick Palka
2015-08-29 22:31 ` Patrick Palka [this message]
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='CA+C-WL9XcSQG-gqDAhyKHQCXXD2P5w8Za6WWU_i-=bo1Pc-Z0w@mail.gmail.com' \
--to=patrick@parcs.ath.cx \
--cc=gdb-patches@sourceware.org \
--cc=xdje42@gmail.com \
/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).