Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks

Andrew Cagney
2004-02-15T16:04:29Z

> Date: Sat, 07 Feb 2004 18:48:47 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> > Here's my proposal for the per-architecture DWARF CFI register state
> > initialization hooks needed for S/390, and others. This is a RFC,
> > since I'm not entirely confident whether my approach is acceptable. I
> > chose to implement this using per-architecture data instead of adding
> > a function to the architecture vector. I think it is cleaner since it
> > keeps things localized and modular, and the architecture vector is big
> > enough as it stands.
>
> Yes. Technical nit though - I think it is still better to have a local
> data struct and store the value in there.
>
> I'm not sure what your idea is here. Is it that you want me to use a
> data structure that would be allocated by the dwarf2-frame.c module
> such that I'd only need a single per-arch data key for the entire
> dwarf2-frame.c module?

Yes, just this:

> static struct gdbarch_data *frame_base_data;
>
> struct frame_base_table
> {
> frame_base_sniffer_ftype **sniffer;
....
> };
>
> static struct frame_base_table *
> frame_base_table (struct gdbarch *gdbarch)
> {
> struct frame_base_table *table = gdbarch_data (gdbarch, frame_base_data);
> ...
> return table;
> }

i.e, put the function inside a struct, instead of storing the function
directly in that per-arch data pointer.

It's more consistent with:
http://sources.redhat.com/gdb/current/onlinedocs/gdbint_13.html#SEC114
but hmm, that's out of date, sigh. Instead of free, memory is obtained
using gdbarch_obstack_zalloc.

> Or do you want the architecture to allocate
> and initialize the structure? The latter would mean more work for the
> architecture; if you want to override a single member of the structure
> you'd have to fill in all the details. I don't really like that.
>
> From: Daniel Jacobowitz <drow@mvista.com>
> Date: Sat, 7 Feb 2004 18:03:30 -0500
>
> Hmm, I do. You're adding a per-architecture data item which is a
> function pointer, and what amounts to the rest of what gdbarch.sh would
> generate (wrapper functions, default initialization. I'd rather you
> just used gdbarch.sh.
>
>
> What about Daniels objections that I'm hand-coding much what
> gdbarch.sh already does? I'm feeling that the modularity is worth it,
> but how do you feel about that?

No. Yes. Using gdbarch, and loosing that modularity, is far too high a
price to pay.

Andrew