Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: "Jan Vraný" <Jan.Vrany@labware.com>
Cc: "gdb@sourceware.org" <gdb@sourceware.org>,
	 "tom@tromey.com" <tom@tromey.com>
Subject: Re: Question about struct type* ownership
Date: Wed, 08 Jan 2025 17:30:16 -0700	[thread overview]
Message-ID: <8734hsx207.fsf@tromey.com> (raw)
In-Reply-To: <078460761931d0f4a1574e18173e51464ee4ccb2.camel@labware.com> ("Jan =?utf-8?Q?Vran=C3=BD=22's?= message of "Wed, 8 Jan 2025 13:32:33 +0000")

Jan> Let's say I'd like to create new function type "int(struct s)", where
Jan> type "int" is arch-owned and "struct s" is objfile-owned. Am I correct
Jan> thinking that resulting function type should be objfile-owned? 

Yes, in particular by the same objfile that owns "struct s".

Jan> Generally speaking, if composing new type out of other types, if at
Jan> least one of the types is objfile-owned then the new type must by
Jan> also objfile-owned (by that very objfile), right? 

Yes.

Jan> Looking at lookup_function_type_with_arguments, it allocated new
Jan> function type is always "owned" by whoever "owns" the return type
Jan> (first param to lookup_function_type_with_arguments). So if I'm correct
Jan> about the above, I'd have to extend lookup_function_type_with_arguments
Jan> to pass down type allocator (like in create_array_type). Or is there
Jan> a better way?

It's new territory, so just whatever looks reasonably clean.  I think in
the past this wasn't an issue because essentially only symbol readers
made types.

Jan> Also, when experimenting with the example above, I realized that 
Jan> the arch-owner of "int" struct type* is a different struct gdbarch *
Jan> then gdbarch associated with objfile-owner of "struct s" type
Jan> (i mean, pointer values are different).
Jan> While I would think it is okay to compose new type from types owned by 
Jan> two distinct gdbarchs from lifecycle POV, it still puzzles me why
Jan> there are two different gdbarch instances (both are i386:x86-64)?

Offhand I don't know but there are a lot of ways a gdbarch can be
initialized.  Maybe they have different registers available.

Tom

  reply	other threads:[~2025-01-09  0:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-08 13:32 Jan Vraný via Gdb
2025-01-09  0:30 ` Tom Tromey [this message]
2025-01-09 11:02   ` Jan Vraný via Gdb

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=8734hsx207.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=Jan.Vrany@labware.com \
    --cc=gdb@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