public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Tom Tromey <tom@tromey.com>
To: Simon Marchi via Gdb-patches <gdb-patches@sourceware.org>
Cc: Tom Tromey <tom@tromey.com>,  Simon Marchi <simon.marchi@polymtl.ca>
Subject: Re: [PATCH 1/3] gdb: add inferior_target_stack_changed observer, use it to clear auxv cache
Date: Fri, 02 Dec 2022 13:59:16 -0700	[thread overview]
Message-ID: <87cz91ldy3.fsf@tromey.com> (raw)
In-Reply-To: <7f956f4e-1418-2e15-c2f1-418d0f2e84d4@polymtl.ca> (Simon Marchi via Gdb-patches's message of "Fri, 2 Dec 2022 14:36:51 -0500")

>> It seems like overall it would be better to have the auxv cache just be
>> some member of 'inferior'.  Then these indirections and observers
>> wouldn't be needed -- the inferior could just manage it directly.

Simon> I kind of like observers, it gives the impression that things are
Simon> decoupled... but yeah in practice it just adds unnecessary layers of
Simon> indirection.

I like them depending on the situation.  For me it's sort of like
attaching a registry entry.

If there are "optional" modules that need to attach data to a core data
structure (e.g., something arch-specific attaching to an objfile) then a
registry entry makes sense.  But for things that are inherit attributes
of an object, a registry entry would be sort of absurd.

I see observers the same way.  If two modules "should be" decoupled,
like if one is a core bit of gdb and another is some thing that might be
not compiled in, or only useful in some situations, then an observer is
a good way to convey state changes.

For auxv, IIUC, it's intended to always cache this data, which is
somewhat intrinsic to the inferior and the module must track some
aspects of the inferior's lifetime.  To me this says, just make some
auxv cache object as a field of inferior and let the inferior tell it
directly.

That said I wouldn't expect a change here since it's already written.
Just wouldn't object; and I guess it's worthwhile to try to articulate
the principle for new code.

thanks,
Tom

      reply	other threads:[~2022-12-02 20:59 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-29  2:50 Simon Marchi
2022-11-29  2:50 ` [PATCH 2/3] gdb: break up core_target initialization Simon Marchi
2022-11-29 19:27   ` John Baldwin
2022-11-29 21:53     ` Simon Marchi
2022-11-30 17:29       ` John Baldwin
2022-11-30 16:05   ` Tom Tromey
2022-12-02 19:38     ` Simon Marchi
2022-11-29  2:50 ` [PATCH 3/3] gdb: remove target_ops parameter from gdbarch_core_read_description Simon Marchi
2022-11-29 19:16   ` John Baldwin
2022-11-29 21:45     ` Simon Marchi
2022-12-02 20:51   ` [PATCH v1.1 " Simon Marchi
2022-11-30 15:44 ` [PATCH 1/3] gdb: add inferior_target_stack_changed observer, use it to clear auxv cache Tom Tromey
2022-12-02 19:36   ` Simon Marchi
2022-12-02 20:59     ` Tom Tromey [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=87cz91ldy3.fsf@tromey.com \
    --to=tom@tromey.com \
    --cc=gdb-patches@sourceware.org \
    --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).