* [patch/rfc] Separate gdbarch_data_register_pre_init
@ 2004-03-08 19:28 Andrew Cagney
2004-03-08 22:41 ` Mark Kettenis
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-08 19:28 UTC (permalink / raw)
To: gdb-patches, Mark Kettenis; +Cc: Eli Zaretskii
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
Hello,
This patch is ment to address the problem identifed in this thread:
http://sources.redhat.com/ml/gdb-patches/2004-02/msg00517.html
It changes the gdbarch_data framework so that the data is differentiated
as being:
pre_init:
Created while the architecture object is still being initialized
(strictly speaking it can also be called after the architecture has been
initialized, however the pre_init code can't tell the difference).
post_init:
Called after the architecture has been initialized.
The dwarf2-frame code is then modified to use the first mechanism. I've
left the other clients alone (but did deprecate set_gdbarch_data as that
should now be redundant).
Also note the name changes (better suggestions?).
thoughts? this is tabled for at least a week,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 26079 bytes --]
2004-03-07 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (gdbarch_data_pre_init_fytpe)
(gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe)
(gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype
and register_gdbarch_data.
(deprecated_set_gdbarch_data): Rename set_gdbarch_data.
(struct gdbarch_data): Replace "init" by "pre_init" and
"post_init".
* gdbarch.h, gdbarch.c: Re-generate.
* dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter
with"obstack", use OBSTACK_ZALLOC.
(dwarf2_frame_ops): Delete.
(dwarf2_frame_set_init_reg): Use gdbarch_data.
(dwarf2_frame_init_reg): Use gdbarch_data.
(_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init.
* solib-svr4.c (set_solib_svr4_fetch_link_map_offsets)
(_initialize_svr4_solib): Update.
* user-regs.c (_initialize_user_regs): Update.
* reggroups.c (_initialize_reggroup): Update.
* regcache.c (_initialize_regcache): Update.
* mips-linux-tdep.c (_initialize_mips_linux_tdep): Update.
* libunwind-frame.c (_initialize_libunwind_frame): Update.
* gnu-v3-abi.c (init_gnuv3_ops): Update.
* frame-unwind.c (_initialize_frame_unwind): Update.
* frame-base.c (_initialize_frame_base): Update.
* user-regs.c (user_reg_add): Update.
* reggroups.c (reggroup_add): Update.
* mips-linux-tdep.c (set_mips_linux_register_addr): Update.
* libunwind-frame.c (libunwind_frame_set_descr): Update.
* frame-unwind.c (frame_unwind_append_sniffer): Update.
* frame-base.c (frame_base_table): Update.
* remote.c (_initialize_remote): Update.
* gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
Index: doc/ChangeLog
2004-03-07 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Coding): Update section on gdbarch_data,
describe pre_init and post_init.
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.190
diff -u -r1.190 gdbint.texinfo
--- doc/gdbint.texinfo 26 Feb 2004 20:52:08 -0000 1.190
+++ doc/gdbint.texinfo 8 Mar 2004 19:12:09 -0000
@@ -4872,133 +4872,101 @@
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
-The multi-arch framework includes a mechanism for adding module specific
-per-architecture data-pointers to the @code{struct gdbarch} architecture
-object.
-
-A module registers one or more per-architecture data-pointers using the
-function @code{register_gdbarch_data}:
-
-@deftypefun struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *@var{init})
-
-The @var{init} function is used to obtain an initial value for a
-per-architecture data-pointer. The function is called, after the
-architecture has been created, when the data-pointer is still
-uninitialized (@code{NULL}) and its value has been requested via a call
-to @code{gdbarch_data}. A data-pointer can also be initialize
-explicitly using @code{set_gdbarch_data}.
-
-Any memory required by the @var{init} function should be allocated
-using @code{GDBARCH_OBSTACK_ZALLOC}. That memory is automatically
-released when the corresponding architecture is deleted.
-
-The function @code{register_gdbarch_data} returns a @code{struct
-gdbarch_data} that is used to identify the data-pointer that was added
-to the module.
-
+The multi-arch framework includes a mechanism for adding module
+specific per-architecture data-pointers to the @code{struct gdbarch}
+architecture object.
+
+A module registers one or more per-architecture data-pointers using:
+
+@deftypefun struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *@var{pre_init})
+@var{pre_init} is used to, on-demand, allocate an initial value for a
+per-architecture data-pointer using the architecture's obstack (passed
+in as a parameter). Since @var{pre_init} can be called during
+architecture creation, it is not parameterized with the architecture.
+and must not call modules that use per-architecture data.
@end deftypefun
-A typical module has an @code{init} function of the form:
-
-@smallexample
-struct nozel @{ int total; @};
-static struct gdbarch_data *nozel_handle;
-static void *
-nozel_init (struct gdbarch *gdbarch)
-@{
- struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
- @dots{}
- return data;
-@}
-@end smallexample
-
-Since uninitialized (@code{NULL}) data-pointers are initialized
-on-demand, an @code{init} function is free to call other modules that
-use data-pointers. Those modules data-pointers will be initialized as
-needed. Care should be taken to ensure that the @code{init} call graph
-does not contain cycles.
-
-The data-pointer is registered with the call:
+@deftypefun struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *@var{post_init})
+@var{post_init} is used to obtain an initial value for a
+per-architecture data-pointer @emph{after}. Since @var{post_init} is
+always called after architecture creation, it both receives the fully
+initialized architecture and is free to call modules that use
+per-architecture data (care should be taken to avoid cycles in the
+call graph).
+@end deftypefun
-@smallexample
-void
-_initialize_nozel (void)
-@{
- nozel_handle = register_gdbarch_data (nozel_init);
-@dots{}
-@end smallexample
+These functions return a @code{struct gdbarch_data} that is used to
+identify the per-architecture data-pointer added for that module.
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
-@var{data_handle} (returned by @code{register_gdbarch_data}, this
-function returns the current value of the per-architecture data-pointer.
+@var{data_handle} (returned by @code{gdbarch_data_register_pre_init}
+or @code{gdbarch_data_register_post_init}), this function returns the
+current value of the per-architecture data-pointer. If the data
+pointer is @code{NULL}, it is first initialize by calling the
+corresponding @var{pre_init} or @var{post_init} method.
@end deftypefun
-The non-@code{NULL} data-pointer returned by @code{gdbarch_data} should
-be saved in a local variable and then used directly:
+The examples below assuming the following definitions:
@smallexample
-int
-nozel_total (struct gdbarch *gdbarch)
-@{
- int total;
- struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
- @dots{}
- return total;
-@}
+struct nozel @{ int total; @};
+static struct gdbarch_data *nozel_handle;
@end smallexample
-It is also possible to directly initialize the data-pointer using:
+A module can extend the architecture vector, adding additional
+per-architecture attributes, using the @var{pre_init} method. These
+attribute being set by the architecture's @var{gdbarch_init} method
+during architecture creation.
-@deftypefun void set_gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{handle}, void *@var{pointer})
-Set the still @code{NULL} data-pointer corresponding to @var{handle}
-to the non-@code{NULL} @var{pointer} value.
-@end deftypefun
-
-This function is used by modules that require a mechanism for explicitly
-setting the per-architecture data-pointer during architecture creation:
+In the below, the attribute nozel is added. An architecture can
+specify its nozel @code{set_gdbarch_nozel}.
@smallexample
-/* Always return a non-NULL nozel. */
-static struct nozel *
-gdbarch_nozel (struct gdbarch *gdbarch)
+static void *
+nozel_pre_init (struct obstack *obstack)
@{
- struct nozel *nozel = gdbarch_data (gdbarch, nozel_handle);
- if (nozel == NULL)
- @{
- nozel = nozel_init (gdbarch);
- set_gdbarch_data (gdbarch, nozel_handle, nozel);
- @}
- return nozel;
+ struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
+ return data;
@}
@end smallexample
@smallexample
-/* Called during architecture creation. */
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
- struct nozel *data = gdbarch_nozel (gdbarch);
- @dots{}
- data->total = total;
+ struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
+ data->total = nozel;
@}
@end smallexample
+A module can on-demand create architecture dependant data structures
+using @code{post_init}.
+
+In the below, the nozel's total is computed on-demand by
+@code{nozel_post_init} using information obtained from the
+architecture.
+
@smallexample
-void
-_initialize_nozel (void)
+static void *
+nozel_post_init (struct gdbarch *gdbarch)
@{
- nozel_handle = register_gdbarch_data (nozel_init);
- @dots{}
+ struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
+ nozel->total = gdbarch@dots{} (gdbarch);
+ return data;
+@}
@end smallexample
-@noindent
-Note that an @code{init} function still needs to be registered. It is
-used to initialize the data-pointer when the architecture creation phase
-fail to set an initial value.
-
+@smallexample
+extern int
+nozel_total (struct gdbarch *gdbarch)
+@{
+ struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
+ return data->total;
+@}
+@end smallexample
@section Wrapping Output Lines
@cindex line wrap in output
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.31
diff -u -r1.31 dwarf2-frame.c
--- dwarf2-frame.c 16 Feb 2004 20:32:01 -0000 1.31
+++ dwarf2-frame.c 8 Mar 2004 19:12:02 -0000
@@ -509,29 +509,15 @@
/* Return a default for the architecture-specific operations. */
static void *
-dwarf2_frame_init (struct gdbarch *gdbarch)
+dwarf2_frame_init (struct obstack *obstack)
{
struct dwarf2_frame_ops *ops;
- ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
+ ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
ops->init_reg = dwarf2_frame_default_init_reg;
return ops;
}
-static struct dwarf2_frame_ops *
-dwarf2_frame_ops (struct gdbarch *gdbarch)
-{
- struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- if (ops == NULL)
- {
- /* ULGH, called during architecture initialization. Patch
- things up. */
- ops = dwarf2_frame_init (gdbarch);
- set_gdbarch_data (gdbarch, dwarf2_frame_data, ops);
- }
- return ops;
-}
-
/* Set the architecture-specific register state initialization
function for GDBARCH to INIT_REG. */
@@ -540,9 +526,8 @@
void (*init_reg) (struct gdbarch *, int,
struct dwarf2_frame_state_reg *))
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg = init_reg;
}
@@ -552,9 +537,8 @@
dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg)
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg (gdbarch, regnum, reg);
}
\f
@@ -1608,6 +1592,6 @@
void
_initialize_dwarf2_frame (void)
{
- dwarf2_frame_data = register_gdbarch_data (dwarf2_frame_init);
+ dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
dwarf2_frame_objfile_data = register_objfile_data ();
}
Index: frame-base.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-base.c,v
retrieving revision 1.8
diff -u -r1.8 frame-base.c
--- frame-base.c 4 Aug 2003 22:24:44 -0000 1.8
+++ frame-base.c 8 Mar 2004 19:12:02 -0000
@@ -92,7 +92,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_base_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_base_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_base_data, table);
}
return table;
}
@@ -146,5 +146,5 @@
void
_initialize_frame_base (void)
{
- frame_base_data = register_gdbarch_data (frame_base_init);
+ frame_base_data = gdbarch_data_register_post_init (frame_base_init);
}
Index: frame-unwind.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-unwind.c,v
retrieving revision 1.8
diff -u -r1.8 frame-unwind.c
--- frame-unwind.c 22 Feb 2004 17:08:42 -0000 1.8
+++ frame-unwind.c 8 Mar 2004 19:12:02 -0000
@@ -63,7 +63,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_unwind_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_unwind_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_unwind_data, table);
}
append_predicate (table, sniffer);
}
@@ -95,5 +95,5 @@
void
_initialize_frame_unwind (void)
{
- frame_unwind_data = register_gdbarch_data (frame_unwind_init);
+ frame_unwind_data = gdbarch_data_register_post_init (frame_unwind_init);
}
Index: gdb_obstack.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_obstack.h,v
retrieving revision 1.2
diff -u -r1.2 gdb_obstack.h
--- gdb_obstack.h 9 Feb 2004 23:50:55 -0000 1.2
+++ gdb_obstack.h 8 Mar 2004 19:12:02 -0000
@@ -24,6 +24,12 @@
#include "obstack.h"
+/* Utility macros - wrap obstack alloc into something more robust. */
+
+#define OBSTACK_ZALLOC(OBSTACK,TYPE) (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE)))
+
+#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), 0, (NUMBER) * sizeof (TYPE)))
+
/* Unless explicitly specified, GDB obstacks always use xmalloc() and
xfree(). */
/* Note: ezannoni 2004-02-09: One could also specify the allocation
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.301
diff -u -r1.301 gdbarch.sh
--- gdbarch.sh 16 Feb 2004 21:49:21 -0000 1.301
+++ gdbarch.sh 8 Mar 2004 19:12:03 -0000
@@ -890,6 +890,7 @@
struct regset;
struct disassemble_info;
struct target_ops;
+struct obstack;
extern struct gdbarch *current_gdbarch;
@@ -1201,10 +1202,6 @@
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
- The per-architecture data-pointer is either initialized explicitly
- (set_gdbarch_data()) or implicitly (by INIT() via a call to
- gdbarch_data()).
-
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
@@ -1218,11 +1215,13 @@
struct gdbarch_data;
-typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
-extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init);
-extern void set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer);
+typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
+extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
+typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
+extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
+extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer);
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
@@ -1238,7 +1237,7 @@
Memory regions are swapped / initialized in the order that they are
registered. NULL DATA and/or INIT values can be specified.
- New code should use register_gdbarch_data(). */
+ New code should use gdbarch_data_register_*(). */
typedef void (gdbarch_swap_ftype) (void);
extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init);
@@ -1811,7 +1810,8 @@
{
unsigned index;
int init_p;
- gdbarch_data_init_ftype *init;
+ gdbarch_data_pre_init_ftype *pre_init;
+ gdbarch_data_post_init_ftype *post_init;
};
struct gdbarch_data_registration
@@ -1831,8 +1831,9 @@
0, NULL,
};
-struct gdbarch_data *
-register_gdbarch_data (gdbarch_data_init_ftype *init)
+static struct gdbarch_data *
+gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
+ gdbarch_data_post_init_ftype *post_init)
{
struct gdbarch_data_registration **curr;
/* Append the new registraration. */
@@ -1843,11 +1844,23 @@
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct gdbarch_data);
(*curr)->data->index = gdbarch_data_registry.nr++;
- (*curr)->data->init = init;
+ (*curr)->data->pre_init = pre_init;
+ (*curr)->data->post_init = post_init;
(*curr)->data->init_p = 1;
return (*curr)->data;
}
+struct gdbarch_data *
+gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
+{
+ return gdbarch_data_register (pre_init, NULL);
+}
+
+struct gdbarch_data *
+gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
+{
+ return gdbarch_data_register (NULL, post_init);
+}
/* Create/delete the gdbarch data vector. */
@@ -1863,12 +1876,13 @@
data-pointer. */
void
-set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer)
+deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer)
{
gdb_assert (data->index < gdbarch->nr_data);
gdb_assert (gdbarch->data[data->index] == NULL);
+ gdb_assert (data->pre_init == NULL);
gdbarch->data[data->index] = pointer;
}
@@ -1879,18 +1893,33 @@
gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
{
gdb_assert (data->index < gdbarch->nr_data);
- /* The data-pointer isn't initialized, call init() to get a value but
- only if the architecture initializaiton has completed. Otherwise
- punt - hope that the caller knows what they are doing. */
- if (gdbarch->data[data->index] == NULL
- && gdbarch->initialized_p)
+ if (gdbarch->data[data->index] == NULL)
{
- /* Be careful to detect an initialization cycle. */
- gdb_assert (data->init_p);
- data->init_p = 0;
- gdb_assert (data->init != NULL);
- gdbarch->data[data->index] = data->init (gdbarch);
- data->init_p = 1;
+ /* The data-pointer isn't initialized, call init() to get a
+ value. */
+ if (data->pre_init != NULL)
+ /* Mid architecture creation: pass just the obstack, and not
+ the entire architecture, as that way it isn't possible for
+ pre-init code to refer to undefined architecture
+ fields. */
+ gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
+ else if (gdbarch->initialized_p
+ && data->post_init != NULL)
+ /* Post architecture creation: pass the entire architecture
+ (as all fields are valid), but be careful to also detect
+ recursive references. */
+ {
+ gdb_assert (data->init_p);
+ data->init_p = 0;
+ gdbarch->data[data->index] = data->post_init (gdbarch);
+ data->init_p = 1;
+ }
+ else
+ /* The architecture initialization hasn't completed - punt -
+ hope that the caller knows what they are doing. Once
+ deprecated_set_gdbarch_data has been initialized, this can be
+ changed to an internal error. */
+ return NULL;
gdb_assert (gdbarch->data[data->index] != NULL);
}
return gdbarch->data[data->index];
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.20
diff -u -r1.20 gnu-v3-abi.c
--- gnu-v3-abi.c 5 Dec 2003 04:25:09 -0000 1.20
+++ gnu-v3-abi.c 8 Mar 2004 19:12:03 -0000
@@ -422,7 +422,7 @@
static void
init_gnuv3_ops (void)
{
- vtable_type_gdbarch_data = register_gdbarch_data (build_gdb_vtable_type);
+ vtable_type_gdbarch_data = gdbarch_data_register_post_init (build_gdb_vtable_type);
gnu_v3_abi_ops.shortname = "gnu-v3";
gnu_v3_abi_ops.longname = "GNU G++ Version 3 ABI";
Index: libunwind-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/libunwind-frame.c,v
retrieving revision 1.2
diff -u -r1.2 libunwind-frame.c
--- libunwind-frame.c 13 Dec 2003 03:51:56 -0000 1.2
+++ libunwind-frame.c 8 Mar 2004 19:12:03 -0000
@@ -111,7 +111,7 @@
{
/* First time here. Must initialize data area. */
arch_descr = libunwind_descr_init (gdbarch);
- set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
+ deprecated_set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
}
/* Copy new descriptor info into arch descriptor. */
@@ -381,7 +381,7 @@
void
_initialize_libunwind_frame (void)
{
- libunwind_descr_handle = register_gdbarch_data (libunwind_descr_init);
+ libunwind_descr_handle = gdbarch_data_register_post_init (libunwind_descr_init);
libunwind_initialized = libunwind_load ();
}
Index: mips-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v
retrieving revision 1.19
diff -u -r1.19 mips-linux-tdep.c
--- mips-linux-tdep.c 14 Feb 2004 04:41:33 -0000 1.19
+++ mips-linux-tdep.c 8 Mar 2004 19:12:03 -0000
@@ -668,7 +668,7 @@
set_mips_linux_register_addr (struct gdbarch *gdbarch,
CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR))
{
- set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
+ deprecated_set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
}
static void *
@@ -844,7 +844,7 @@
const struct bfd_arch_info *arch_info;
register_addr_data =
- register_gdbarch_data (init_register_addr_data);
+ gdbarch_data_register_post_init (init_register_addr_data);
for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
arch_info != NULL;
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.109
diff -u -r1.109 regcache.c
--- regcache.c 29 Feb 2004 17:01:38 -0000 1.109
+++ regcache.c 8 Mar 2004 19:12:03 -0000
@@ -1705,7 +1705,7 @@
void
_initialize_regcache (void)
{
- regcache_descr_handle = register_gdbarch_data (init_regcache_descr);
+ regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_registers);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_register_valid);
Index: reggroups.c
===================================================================
RCS file: /cvs/src/src/gdb/reggroups.c,v
retrieving revision 1.8
diff -u -r1.8 reggroups.c
--- reggroups.c 22 Aug 2003 09:49:01 -0000 1.8
+++ reggroups.c 8 Mar 2004 19:12:03 -0000
@@ -109,7 +109,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
groups = reggroups_init (gdbarch);
- set_gdbarch_data (gdbarch, reggroups_data, groups);
+ deprecated_set_gdbarch_data (gdbarch, reggroups_data, groups);
}
add_group (groups, group,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct reggroup_el));
@@ -268,7 +268,7 @@
void
_initialize_reggroup (void)
{
- reggroups_data = register_gdbarch_data (reggroups_init);
+ reggroups_data = gdbarch_data_register_post_init (reggroups_init);
/* The pre-defined list of groups. */
add_group (&default_groups, general_reggroup, XMALLOC (struct reggroup_el));
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.130
diff -u -r1.130 remote.c
--- remote.c 25 Feb 2004 20:41:00 -0000 1.130
+++ remote.c 8 Mar 2004 19:12:06 -0000
@@ -5456,7 +5456,7 @@
struct cmd_list_element *tmpcmd;
/* architecture specific data */
- remote_gdbarch_data_handle = register_gdbarch_data (init_remote_state);
+ remote_gdbarch_data_handle = gdbarch_data_register_post_init (init_remote_state);
/* Old tacky stuff. NOTE: This comes after the remote protocol so
that the remote protocol has been initialized. */
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.41
diff -u -r1.41 solib-svr4.c
--- solib-svr4.c 21 Feb 2004 18:34:45 -0000 1.41
+++ solib-svr4.c 8 Mar 2004 19:12:06 -0000
@@ -1490,7 +1490,7 @@
set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
struct link_map_offsets *(*flmo) (void))
{
- set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
+ deprecated_set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
}
/* Initialize the architecture-specific link_map_offsets fetcher.
@@ -1588,7 +1588,7 @@
_initialize_svr4_solib (void)
{
fetch_link_map_offsets_gdbarch_data =
- register_gdbarch_data (init_fetch_link_map_offsets);
+ gdbarch_data_register_post_init (init_fetch_link_map_offsets);
svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;
Index: user-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/user-regs.c,v
retrieving revision 1.3
diff -u -r1.3 user-regs.c
--- user-regs.c 4 Aug 2003 22:24:44 -0000 1.3
+++ user-regs.c 8 Mar 2004 19:12:07 -0000
@@ -104,7 +104,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
regs = user_regs_init (gdbarch);
- set_gdbarch_data (gdbarch, user_regs_data, regs);
+ deprecated_set_gdbarch_data (gdbarch, user_regs_data, regs);
}
append_user_reg (regs, name, read,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
@@ -201,5 +201,5 @@
void
_initialize_user_regs (void)
{
- user_regs_data = register_gdbarch_data (user_regs_init);
+ user_regs_data = gdbarch_data_register_post_init (user_regs_init);
}
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-08 19:28 [patch/rfc] Separate gdbarch_data_register_pre_init Andrew Cagney
@ 2004-03-08 22:41 ` Mark Kettenis
2004-03-19 0:09 ` Mark Kettenis
2004-03-19 0:09 ` Andrew Cagney
2004-03-15 20:44 ` Andrew Cagney
` (2 subsequent siblings)
3 siblings, 2 replies; 19+ messages in thread
From: Mark Kettenis @ 2004-03-08 22:41 UTC (permalink / raw)
To: cagney; +Cc: gdb-patches, eliz
Date: Mon, 08 Mar 2004 14:28:00 -0500
From: Andrew Cagney <cagney@gnu.org>
The dwarf2-frame code is then modified to use the first mechanism. I've
left the other clients alone (but did deprecate set_gdbarch_data as that
should now be redundant).
I'm not so sure that set_gdbarch_data is now redundant. I can imagine
that one would like to set a per-architecture data thingy to a
different value after its initial initialization. So I'd rather you
wouldn't deprecate the interface.
Also note the name changes (better suggestions?).
The names look fine to me.
Mark
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-19 0:09 ` Andrew Cagney
@ 2004-03-08 23:51 ` Andrew Cagney
0 siblings, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-08 23:51 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches, eliz
> Date: Mon, 08 Mar 2004 14:28:00 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> The dwarf2-frame code is then modified to use the first mechanism. I've
> left the other clients alone (but did deprecate set_gdbarch_data as that
> should now be redundant).
>
> I'm not so sure that set_gdbarch_data is now redundant. I can imagine
> that one would like to set a per-architecture data thingy to a
> different value after its initial initialization.
Hmm, only one assignment has ever been possible:
> set_gdbarch_data (struct gdbarch *gdbarch,
> struct gdbarch_data *data,
> void *pointer)
> {
> gdb_assert (data->index < gdbarch->nr_data);
> gdb_assert (gdbarch->data[data->index] == NULL);
> gdbarch->data[data->index] = pointer;
> }
and being able to do otherwize wasn't the intent. Instead of trying to
modify the data thingie, code should modify the contents pointed to by
the thingie. For instance, in dwarf2-frame:
struct dwarf2_frame_ops
{
/* Pre-initialize the register state REG for register REGNUM. */
void (*init_reg) (struct gdbarch *, int, struct
dwarf2_frame_state_reg *);
};
the code can perform multiple assignments to "init_reg".
> So I'd rather you
> wouldn't deprecate the interface.
>
> Also note the name changes (better suggestions?).
>
> The names look fine to me.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-19 0:09 ` Andrew Cagney
@ 2004-03-15 17:21 ` Andrew Cagney
2004-03-15 19:55 ` Eli Zaretskii
1 sibling, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-15 17:21 UTC (permalink / raw)
To: Andrew Cagney, Eli Zaretskii; +Cc: gdb-patches, Mark Kettenis
[-- Attachment #1: Type: text/plain, Size: 58 bytes --]
Eli,
How does the doco part of this change look?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 8499 bytes --]
2004-03-07 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Coding): Update section on gdbarch_data,
describe pre_init and post_init.
Index: gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.190
diff -c -r1.190 gdbint.texinfo
*** gdbint.texinfo 26 Feb 2004 20:52:08 -0000 1.190
--- gdbint.texinfo 15 Mar 2004 17:19:56 -0000
***************
*** 4872,5004 ****
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module specific
! per-architecture data-pointers to the @code{struct gdbarch} architecture
! object.
!
! A module registers one or more per-architecture data-pointers using the
! function @code{register_gdbarch_data}:
!
! @deftypefun struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *@var{init})
!
! The @var{init} function is used to obtain an initial value for a
! per-architecture data-pointer. The function is called, after the
! architecture has been created, when the data-pointer is still
! uninitialized (@code{NULL}) and its value has been requested via a call
! to @code{gdbarch_data}. A data-pointer can also be initialize
! explicitly using @code{set_gdbarch_data}.
!
! Any memory required by the @var{init} function should be allocated
! using @code{GDBARCH_OBSTACK_ZALLOC}. That memory is automatically
! released when the corresponding architecture is deleted.
!
! The function @code{register_gdbarch_data} returns a @code{struct
! gdbarch_data} that is used to identify the data-pointer that was added
! to the module.
!
@end deftypefun
! A typical module has an @code{init} function of the form:
!
! @smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
! static void *
! nozel_init (struct gdbarch *gdbarch)
! @{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! @dots{}
! return data;
! @}
! @end smallexample
!
! Since uninitialized (@code{NULL}) data-pointers are initialized
! on-demand, an @code{init} function is free to call other modules that
! use data-pointers. Those modules data-pointers will be initialized as
! needed. Care should be taken to ensure that the @code{init} call graph
! does not contain cycles.
!
! The data-pointer is registered with the call:
! @smallexample
! void
! _initialize_nozel (void)
! @{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
! @end smallexample
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{register_gdbarch_data}, this
! function returns the current value of the per-architecture data-pointer.
@end deftypefun
! The non-@code{NULL} data-pointer returned by @code{gdbarch_data} should
! be saved in a local variable and then used directly:
@smallexample
! int
! nozel_total (struct gdbarch *gdbarch)
! @{
! int total;
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! @dots{}
! return total;
! @}
@end smallexample
! It is also possible to directly initialize the data-pointer using:
! @deftypefun void set_gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{handle}, void *@var{pointer})
! Set the still @code{NULL} data-pointer corresponding to @var{handle}
! to the non-@code{NULL} @var{pointer} value.
! @end deftypefun
!
! This function is used by modules that require a mechanism for explicitly
! setting the per-architecture data-pointer during architecture creation:
@smallexample
! /* Always return a non-NULL nozel. */
! static struct nozel *
! gdbarch_nozel (struct gdbarch *gdbarch)
@{
! struct nozel *nozel = gdbarch_data (gdbarch, nozel_handle);
! if (nozel == NULL)
! @{
! nozel = nozel_init (gdbarch);
! set_gdbarch_data (gdbarch, nozel_handle, nozel);
! @}
! return nozel;
@}
@end smallexample
@smallexample
- /* Called during architecture creation. */
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_nozel (gdbarch);
! @dots{}
! data->total = total;
@}
@end smallexample
@smallexample
! void
! _initialize_nozel (void)
@{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
@end smallexample
! @noindent
! Note that an @code{init} function still needs to be registered. It is
! used to initialize the data-pointer when the architecture creation phase
! fail to set an initial value.
!
@section Wrapping Output Lines
@cindex line wrap in output
--- 4872,4972 ----
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module
! specific per-architecture data-pointers to the @code{struct gdbarch}
! architecture object.
!
! A module registers one or more per-architecture data-pointers using:
!
! @deftypefun struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *@var{pre_init})
! @var{pre_init} is used to, on-demand, allocate an initial value for a
! per-architecture data-pointer using the architecture's obstack (passed
! in as a parameter). Since @var{pre_init} can be called during
! architecture creation, it is not parameterized with the architecture.
! and must not call modules that use per-architecture data.
@end deftypefun
! @deftypefun struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *@var{post_init})
! @var{post_init} is used to obtain an initial value for a
! per-architecture data-pointer @emph{after}. Since @var{post_init} is
! always called after architecture creation, it both receives the fully
! initialized architecture and is free to call modules that use
! per-architecture data (care should be taken to avoid cycles in the
! call graph).
! @end deftypefun
! These functions return a @code{struct gdbarch_data} that is used to
! identify the per-architecture data-pointer added for that module.
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{gdbarch_data_register_pre_init}
! or @code{gdbarch_data_register_post_init}), this function returns the
! current value of the per-architecture data-pointer. If the data
! pointer is @code{NULL}, it is first initialize by calling the
! corresponding @var{pre_init} or @var{post_init} method.
@end deftypefun
! The examples below assuming the following definitions:
@smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
@end smallexample
! A module can extend the architecture vector, adding additional
! per-architecture attributes, using the @var{pre_init} method. These
! attribute being set by the architecture's @var{gdbarch_init} method
! during architecture creation.
! In the below, the attribute nozel is added. An architecture can
! specify its nozel @code{set_gdbarch_nozel}.
@smallexample
! static void *
! nozel_pre_init (struct obstack *obstack)
@{
! struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
! return data;
@}
@end smallexample
@smallexample
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! data->total = nozel;
@}
@end smallexample
+ A module can on-demand create architecture dependant data structures
+ using @code{post_init}.
+
+ In the below, the nozel's total is computed on-demand by
+ @code{nozel_post_init} using information obtained from the
+ architecture.
+
@smallexample
! static void *
! nozel_post_init (struct gdbarch *gdbarch)
@{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! nozel->total = gdbarch@dots{} (gdbarch);
! return data;
! @}
@end smallexample
! @smallexample
! extern int
! nozel_total (struct gdbarch *gdbarch)
! @{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! return data->total;
! @}
! @end smallexample
@section Wrapping Output Lines
@cindex line wrap in output
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-19 0:09 ` Andrew Cagney
2004-03-15 17:21 ` Andrew Cagney
@ 2004-03-15 19:55 ` Eli Zaretskii
2004-03-15 21:13 ` Andrew Cagney
2004-03-19 0:09 ` Eli Zaretskii
1 sibling, 2 replies; 19+ messages in thread
From: Eli Zaretskii @ 2004-03-15 19:55 UTC (permalink / raw)
To: Andrew Cagney; +Cc: cagney, gdb-patches, kettenis
> Date: Mon, 15 Mar 2004 12:21:07 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> How does the doco part of this change look?
Looks okay to me, except for the following small gotchas:
> ! @var{post_init} is used to obtain an initial value for a
> ! per-architecture data-pointer @emph{after}. Since @var{post_init} is
> ! always called after architecture creation, it both receives the fully
> ! initialized architecture and is free to call modules that use
> ! per-architecture data (care should be taken to avoid cycles in the
> ! call graph).
> ! @end deftypefun
This sounds like important notes, but they are worded too vaguely,
IMHO. A question that popped up in my mind when I read that was: what
cycles should I avoid in the call graph, and how?
Perhaps an example would help drive these points home.
> ! current value of the per-architecture data-pointer. If the data
> ! pointer is @code{NULL}, it is first initialize by calling the
^^^^^^^^^^^^^^^^^^^^^^
A typo: it should be "initialized".
> ! The examples below assuming the following definitions:
^^^^^^^^
"The examples ... assume ..."
> ! A module can extend the architecture vector, adding additional
> ! per-architecture attributes, using the @var{pre_init} method. These
> ! attribute being set by the architecture's @var{gdbarch_init} method
> ! during architecture creation.
"These attributes are set by the architecture's @var{gdbarch_init}
method ...".
Btw, what ``attributes'' are those? The text doesn't explain that.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-08 19:28 [patch/rfc] Separate gdbarch_data_register_pre_init Andrew Cagney
2004-03-08 22:41 ` Mark Kettenis
@ 2004-03-15 20:44 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
3 siblings, 1 reply; 19+ messages in thread
From: Andrew Cagney @ 2004-03-15 20:44 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Kettenis, Eli Zaretskii
I've checked this part in, still working on the doco tweaks.
> 2004-03-07 Andrew Cagney <cagney@redhat.com>
>
> * gdbarch.sh (gdbarch_data_pre_init_fytpe)
> (gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe)
> (gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype
> and register_gdbarch_data.
> (deprecated_set_gdbarch_data): Rename set_gdbarch_data.
> (struct gdbarch_data): Replace "init" by "pre_init" and
> "post_init".
> * gdbarch.h, gdbarch.c: Re-generate.
> * dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter
> with"obstack", use OBSTACK_ZALLOC.
> (dwarf2_frame_ops): Delete.
> (dwarf2_frame_set_init_reg): Use gdbarch_data.
> (dwarf2_frame_init_reg): Use gdbarch_data.
> (_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init.
> * solib-svr4.c (set_solib_svr4_fetch_link_map_offsets)
> (_initialize_svr4_solib): Update.
> * user-regs.c (_initialize_user_regs): Update.
> * reggroups.c (_initialize_reggroup): Update.
> * regcache.c (_initialize_regcache): Update.
> * mips-linux-tdep.c (_initialize_mips_linux_tdep): Update.
> * libunwind-frame.c (_initialize_libunwind_frame): Update.
> * gnu-v3-abi.c (init_gnuv3_ops): Update.
> * frame-unwind.c (_initialize_frame_unwind): Update.
> * frame-base.c (_initialize_frame_base): Update.
> * user-regs.c (user_reg_add): Update.
> * reggroups.c (reggroup_add): Update.
> * mips-linux-tdep.c (set_mips_linux_register_addr): Update.
> * libunwind-frame.c (libunwind_frame_set_descr): Update.
> * frame-unwind.c (frame_unwind_append_sniffer): Update.
> * frame-base.c (frame_base_table): Update.
> * remote.c (_initialize_remote): Update.
> * gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-15 19:55 ` Eli Zaretskii
@ 2004-03-15 21:13 ` Andrew Cagney
2004-03-17 11:30 ` Eli Zaretskii
` (2 more replies)
2004-03-19 0:09 ` Eli Zaretskii
1 sibling, 3 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-15 21:13 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, kettenis
[-- Attachment #1: Type: text/plain, Size: 1773 bytes --]
>>> Date: Mon, 15 Mar 2004 12:21:07 -0500
>>> From: Andrew Cagney <cagney@gnu.org>
>>>
>>> How does the doco part of this change look?
>
>
> Looks okay to me, except for the following small gotchas:
>
>
>>> ! @var{post_init} is used to obtain an initial value for a
>>> ! per-architecture data-pointer @emph{after}. Since @var{post_init} is
>>> ! always called after architecture creation, it both receives the fully
>>> ! initialized architecture and is free to call modules that use
>>> ! per-architecture data (care should be taken to avoid cycles in the
>>> ! call graph).
>>> ! @end deftypefun
>
>
> This sounds like important notes, but they are worded too vaguely,
> IMHO. A question that popped up in my mind when I read that was: what
> cycles should I avoid in the call graph, and how?
>
> Perhaps an example would help drive these points home.
I've tried to make the problem more explict.
>>> ! current value of the per-architecture data-pointer. If the data
>>> ! pointer is @code{NULL}, it is first initialize by calling the
>
> ^^^^^^^^^^^^^^^^^^^^^^
> A typo: it should be "initialized".
yes.
>>> ! The examples below assuming the following definitions:
>
> ^^^^^^^^
> "The examples ... assume ..."
yes
>>> ! A module can extend the architecture vector, adding additional
>>> ! per-architecture attributes, using the @var{pre_init} method. These
>>> ! attribute being set by the architecture's @var{gdbarch_init} method
>>> ! during architecture creation.
>
>
> "These attributes are set by the architecture's @var{gdbarch_init}
> method ...".
>
> Btw, what ``attributes'' are those? The text doesn't explain that.
I've re-worded it so that it doesn't use "attribute".
ok?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 24511 bytes --]
2004-03-15 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (gdbarch_data_pre_init_fytpe)
(gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe)
(gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype
and register_gdbarch_data.
(deprecated_set_gdbarch_data): Rename set_gdbarch_data.
(struct gdbarch_data): Replace "init" by "pre_init" and
"post_init".
* gdbarch.h, gdbarch.c: Re-generate.
* dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter
with"obstack", use OBSTACK_ZALLOC.
(dwarf2_frame_ops): Delete.
(dwarf2_frame_set_init_reg): Use gdbarch_data.
(dwarf2_frame_init_reg): Use gdbarch_data.
(_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init.
* solib-svr4.c (set_solib_svr4_fetch_link_map_offsets)
(_initialize_svr4_solib): Update.
* user-regs.c (_initialize_user_regs): Update.
* reggroups.c (_initialize_reggroup): Update.
* regcache.c (_initialize_regcache): Update.
* mips-linux-tdep.c (_initialize_mips_linux_tdep): Update.
* libunwind-frame.c (_initialize_libunwind_frame): Update.
* gnu-v3-abi.c (init_gnuv3_ops): Update.
* frame-unwind.c (_initialize_frame_unwind): Update.
* frame-base.c (_initialize_frame_base): Update.
* user-regs.c (user_reg_add): Update.
* reggroups.c (reggroup_add): Update.
* mips-linux-tdep.c (set_mips_linux_register_addr): Update.
* libunwind-frame.c (libunwind_frame_set_descr): Update.
* frame-unwind.c (frame_unwind_append_sniffer): Update.
* frame-base.c (frame_base_table): Update.
* remote.c (_initialize_remote): Update.
* gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.31
diff -u -r1.31 dwarf2-frame.c
--- dwarf2-frame.c 16 Feb 2004 20:32:01 -0000 1.31
+++ dwarf2-frame.c 15 Mar 2004 20:36:39 -0000
@@ -509,29 +509,15 @@
/* Return a default for the architecture-specific operations. */
static void *
-dwarf2_frame_init (struct gdbarch *gdbarch)
+dwarf2_frame_init (struct obstack *obstack)
{
struct dwarf2_frame_ops *ops;
- ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
+ ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
ops->init_reg = dwarf2_frame_default_init_reg;
return ops;
}
-static struct dwarf2_frame_ops *
-dwarf2_frame_ops (struct gdbarch *gdbarch)
-{
- struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- if (ops == NULL)
- {
- /* ULGH, called during architecture initialization. Patch
- things up. */
- ops = dwarf2_frame_init (gdbarch);
- set_gdbarch_data (gdbarch, dwarf2_frame_data, ops);
- }
- return ops;
-}
-
/* Set the architecture-specific register state initialization
function for GDBARCH to INIT_REG. */
@@ -540,9 +526,8 @@
void (*init_reg) (struct gdbarch *, int,
struct dwarf2_frame_state_reg *))
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg = init_reg;
}
@@ -552,9 +537,8 @@
dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg)
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg (gdbarch, regnum, reg);
}
\f
@@ -1608,6 +1592,6 @@
void
_initialize_dwarf2_frame (void)
{
- dwarf2_frame_data = register_gdbarch_data (dwarf2_frame_init);
+ dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
dwarf2_frame_objfile_data = register_objfile_data ();
}
Index: frame-base.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-base.c,v
retrieving revision 1.8
diff -u -r1.8 frame-base.c
--- frame-base.c 4 Aug 2003 22:24:44 -0000 1.8
+++ frame-base.c 15 Mar 2004 20:36:39 -0000
@@ -92,7 +92,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_base_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_base_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_base_data, table);
}
return table;
}
@@ -146,5 +146,5 @@
void
_initialize_frame_base (void)
{
- frame_base_data = register_gdbarch_data (frame_base_init);
+ frame_base_data = gdbarch_data_register_post_init (frame_base_init);
}
Index: frame-unwind.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-unwind.c,v
retrieving revision 1.8
diff -u -r1.8 frame-unwind.c
--- frame-unwind.c 22 Feb 2004 17:08:42 -0000 1.8
+++ frame-unwind.c 15 Mar 2004 20:36:39 -0000
@@ -63,7 +63,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_unwind_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_unwind_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_unwind_data, table);
}
append_predicate (table, sniffer);
}
@@ -95,5 +95,5 @@
void
_initialize_frame_unwind (void)
{
- frame_unwind_data = register_gdbarch_data (frame_unwind_init);
+ frame_unwind_data = gdbarch_data_register_post_init (frame_unwind_init);
}
Index: gdb_obstack.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_obstack.h,v
retrieving revision 1.2
diff -u -r1.2 gdb_obstack.h
--- gdb_obstack.h 9 Feb 2004 23:50:55 -0000 1.2
+++ gdb_obstack.h 15 Mar 2004 20:36:39 -0000
@@ -24,6 +24,12 @@
#include "obstack.h"
+/* Utility macros - wrap obstack alloc into something more robust. */
+
+#define OBSTACK_ZALLOC(OBSTACK,TYPE) (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE)))
+
+#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), 0, (NUMBER) * sizeof (TYPE)))
+
/* Unless explicitly specified, GDB obstacks always use xmalloc() and
xfree(). */
/* Note: ezannoni 2004-02-09: One could also specify the allocation
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.275
diff -u -r1.275 gdbarch.c
--- gdbarch.c 16 Feb 2004 21:49:21 -0000 1.275
+++ gdbarch.c 15 Mar 2004 20:36:40 -0000
@@ -5382,7 +5382,8 @@
{
unsigned index;
int init_p;
- gdbarch_data_init_ftype *init;
+ gdbarch_data_pre_init_ftype *pre_init;
+ gdbarch_data_post_init_ftype *post_init;
};
struct gdbarch_data_registration
@@ -5402,8 +5403,9 @@
0, NULL,
};
-struct gdbarch_data *
-register_gdbarch_data (gdbarch_data_init_ftype *init)
+static struct gdbarch_data *
+gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
+ gdbarch_data_post_init_ftype *post_init)
{
struct gdbarch_data_registration **curr;
/* Append the new registraration. */
@@ -5414,11 +5416,23 @@
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct gdbarch_data);
(*curr)->data->index = gdbarch_data_registry.nr++;
- (*curr)->data->init = init;
+ (*curr)->data->pre_init = pre_init;
+ (*curr)->data->post_init = post_init;
(*curr)->data->init_p = 1;
return (*curr)->data;
}
+struct gdbarch_data *
+gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
+{
+ return gdbarch_data_register (pre_init, NULL);
+}
+
+struct gdbarch_data *
+gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
+{
+ return gdbarch_data_register (NULL, post_init);
+}
/* Create/delete the gdbarch data vector. */
@@ -5434,12 +5448,13 @@
data-pointer. */
void
-set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer)
+deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer)
{
gdb_assert (data->index < gdbarch->nr_data);
gdb_assert (gdbarch->data[data->index] == NULL);
+ gdb_assert (data->pre_init == NULL);
gdbarch->data[data->index] = pointer;
}
@@ -5450,18 +5465,33 @@
gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
{
gdb_assert (data->index < gdbarch->nr_data);
- /* The data-pointer isn't initialized, call init() to get a value but
- only if the architecture initializaiton has completed. Otherwise
- punt - hope that the caller knows what they are doing. */
- if (gdbarch->data[data->index] == NULL
- && gdbarch->initialized_p)
+ if (gdbarch->data[data->index] == NULL)
{
- /* Be careful to detect an initialization cycle. */
- gdb_assert (data->init_p);
- data->init_p = 0;
- gdb_assert (data->init != NULL);
- gdbarch->data[data->index] = data->init (gdbarch);
- data->init_p = 1;
+ /* The data-pointer isn't initialized, call init() to get a
+ value. */
+ if (data->pre_init != NULL)
+ /* Mid architecture creation: pass just the obstack, and not
+ the entire architecture, as that way it isn't possible for
+ pre-init code to refer to undefined architecture
+ fields. */
+ gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
+ else if (gdbarch->initialized_p
+ && data->post_init != NULL)
+ /* Post architecture creation: pass the entire architecture
+ (as all fields are valid), but be careful to also detect
+ recursive references. */
+ {
+ gdb_assert (data->init_p);
+ data->init_p = 0;
+ gdbarch->data[data->index] = data->post_init (gdbarch);
+ data->init_p = 1;
+ }
+ else
+ /* The architecture initialization hasn't completed - punt -
+ hope that the caller knows what they are doing. Once
+ deprecated_set_gdbarch_data has been initialized, this can be
+ changed to an internal error. */
+ return NULL;
gdb_assert (gdbarch->data[data->index] != NULL);
}
return gdbarch->data[data->index];
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.238
diff -u -r1.238 gdbarch.h
--- gdbarch.h 16 Feb 2004 21:49:21 -0000 1.238
+++ gdbarch.h 15 Mar 2004 20:36:41 -0000
@@ -48,6 +48,7 @@
struct regset;
struct disassemble_info;
struct target_ops;
+struct obstack;
extern struct gdbarch *current_gdbarch;
@@ -2517,10 +2518,6 @@
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
- The per-architecture data-pointer is either initialized explicitly
- (set_gdbarch_data()) or implicitly (by INIT() via a call to
- gdbarch_data()).
-
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
@@ -2534,11 +2531,13 @@
struct gdbarch_data;
-typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
-extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init);
-extern void set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer);
+typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
+extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
+typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
+extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
+extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer);
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
@@ -2554,7 +2553,7 @@
Memory regions are swapped / initialized in the order that they are
registered. NULL DATA and/or INIT values can be specified.
- New code should use register_gdbarch_data(). */
+ New code should use gdbarch_data_register_*(). */
typedef void (gdbarch_swap_ftype) (void);
extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.301
diff -u -r1.301 gdbarch.sh
--- gdbarch.sh 16 Feb 2004 21:49:21 -0000 1.301
+++ gdbarch.sh 15 Mar 2004 20:36:41 -0000
@@ -890,6 +890,7 @@
struct regset;
struct disassemble_info;
struct target_ops;
+struct obstack;
extern struct gdbarch *current_gdbarch;
@@ -1201,10 +1202,6 @@
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
- The per-architecture data-pointer is either initialized explicitly
- (set_gdbarch_data()) or implicitly (by INIT() via a call to
- gdbarch_data()).
-
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
@@ -1218,11 +1215,13 @@
struct gdbarch_data;
-typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
-extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init);
-extern void set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer);
+typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
+extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
+typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
+extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
+extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer);
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
@@ -1238,7 +1237,7 @@
Memory regions are swapped / initialized in the order that they are
registered. NULL DATA and/or INIT values can be specified.
- New code should use register_gdbarch_data(). */
+ New code should use gdbarch_data_register_*(). */
typedef void (gdbarch_swap_ftype) (void);
extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init);
@@ -1811,7 +1810,8 @@
{
unsigned index;
int init_p;
- gdbarch_data_init_ftype *init;
+ gdbarch_data_pre_init_ftype *pre_init;
+ gdbarch_data_post_init_ftype *post_init;
};
struct gdbarch_data_registration
@@ -1831,8 +1831,9 @@
0, NULL,
};
-struct gdbarch_data *
-register_gdbarch_data (gdbarch_data_init_ftype *init)
+static struct gdbarch_data *
+gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
+ gdbarch_data_post_init_ftype *post_init)
{
struct gdbarch_data_registration **curr;
/* Append the new registraration. */
@@ -1843,11 +1844,23 @@
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct gdbarch_data);
(*curr)->data->index = gdbarch_data_registry.nr++;
- (*curr)->data->init = init;
+ (*curr)->data->pre_init = pre_init;
+ (*curr)->data->post_init = post_init;
(*curr)->data->init_p = 1;
return (*curr)->data;
}
+struct gdbarch_data *
+gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
+{
+ return gdbarch_data_register (pre_init, NULL);
+}
+
+struct gdbarch_data *
+gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
+{
+ return gdbarch_data_register (NULL, post_init);
+}
/* Create/delete the gdbarch data vector. */
@@ -1863,12 +1876,13 @@
data-pointer. */
void
-set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer)
+deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer)
{
gdb_assert (data->index < gdbarch->nr_data);
gdb_assert (gdbarch->data[data->index] == NULL);
+ gdb_assert (data->pre_init == NULL);
gdbarch->data[data->index] = pointer;
}
@@ -1879,18 +1893,33 @@
gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
{
gdb_assert (data->index < gdbarch->nr_data);
- /* The data-pointer isn't initialized, call init() to get a value but
- only if the architecture initializaiton has completed. Otherwise
- punt - hope that the caller knows what they are doing. */
- if (gdbarch->data[data->index] == NULL
- && gdbarch->initialized_p)
+ if (gdbarch->data[data->index] == NULL)
{
- /* Be careful to detect an initialization cycle. */
- gdb_assert (data->init_p);
- data->init_p = 0;
- gdb_assert (data->init != NULL);
- gdbarch->data[data->index] = data->init (gdbarch);
- data->init_p = 1;
+ /* The data-pointer isn't initialized, call init() to get a
+ value. */
+ if (data->pre_init != NULL)
+ /* Mid architecture creation: pass just the obstack, and not
+ the entire architecture, as that way it isn't possible for
+ pre-init code to refer to undefined architecture
+ fields. */
+ gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
+ else if (gdbarch->initialized_p
+ && data->post_init != NULL)
+ /* Post architecture creation: pass the entire architecture
+ (as all fields are valid), but be careful to also detect
+ recursive references. */
+ {
+ gdb_assert (data->init_p);
+ data->init_p = 0;
+ gdbarch->data[data->index] = data->post_init (gdbarch);
+ data->init_p = 1;
+ }
+ else
+ /* The architecture initialization hasn't completed - punt -
+ hope that the caller knows what they are doing. Once
+ deprecated_set_gdbarch_data has been initialized, this can be
+ changed to an internal error. */
+ return NULL;
gdb_assert (gdbarch->data[data->index] != NULL);
}
return gdbarch->data[data->index];
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.20
diff -u -r1.20 gnu-v3-abi.c
--- gnu-v3-abi.c 5 Dec 2003 04:25:09 -0000 1.20
+++ gnu-v3-abi.c 15 Mar 2004 20:36:42 -0000
@@ -422,7 +422,7 @@
static void
init_gnuv3_ops (void)
{
- vtable_type_gdbarch_data = register_gdbarch_data (build_gdb_vtable_type);
+ vtable_type_gdbarch_data = gdbarch_data_register_post_init (build_gdb_vtable_type);
gnu_v3_abi_ops.shortname = "gnu-v3";
gnu_v3_abi_ops.longname = "GNU G++ Version 3 ABI";
Index: libunwind-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/libunwind-frame.c,v
retrieving revision 1.2
diff -u -r1.2 libunwind-frame.c
--- libunwind-frame.c 13 Dec 2003 03:51:56 -0000 1.2
+++ libunwind-frame.c 15 Mar 2004 20:36:42 -0000
@@ -111,7 +111,7 @@
{
/* First time here. Must initialize data area. */
arch_descr = libunwind_descr_init (gdbarch);
- set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
+ deprecated_set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
}
/* Copy new descriptor info into arch descriptor. */
@@ -381,7 +381,7 @@
void
_initialize_libunwind_frame (void)
{
- libunwind_descr_handle = register_gdbarch_data (libunwind_descr_init);
+ libunwind_descr_handle = gdbarch_data_register_post_init (libunwind_descr_init);
libunwind_initialized = libunwind_load ();
}
Index: mips-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v
retrieving revision 1.19
diff -u -r1.19 mips-linux-tdep.c
--- mips-linux-tdep.c 14 Feb 2004 04:41:33 -0000 1.19
+++ mips-linux-tdep.c 15 Mar 2004 20:36:42 -0000
@@ -668,7 +668,7 @@
set_mips_linux_register_addr (struct gdbarch *gdbarch,
CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR))
{
- set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
+ deprecated_set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
}
static void *
@@ -844,7 +844,7 @@
const struct bfd_arch_info *arch_info;
register_addr_data =
- register_gdbarch_data (init_register_addr_data);
+ gdbarch_data_register_post_init (init_register_addr_data);
for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
arch_info != NULL;
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.109
diff -u -r1.109 regcache.c
--- regcache.c 29 Feb 2004 17:01:38 -0000 1.109
+++ regcache.c 15 Mar 2004 20:36:42 -0000
@@ -1705,7 +1705,7 @@
void
_initialize_regcache (void)
{
- regcache_descr_handle = register_gdbarch_data (init_regcache_descr);
+ regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_registers);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_register_valid);
Index: reggroups.c
===================================================================
RCS file: /cvs/src/src/gdb/reggroups.c,v
retrieving revision 1.8
diff -u -r1.8 reggroups.c
--- reggroups.c 22 Aug 2003 09:49:01 -0000 1.8
+++ reggroups.c 15 Mar 2004 20:36:42 -0000
@@ -109,7 +109,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
groups = reggroups_init (gdbarch);
- set_gdbarch_data (gdbarch, reggroups_data, groups);
+ deprecated_set_gdbarch_data (gdbarch, reggroups_data, groups);
}
add_group (groups, group,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct reggroup_el));
@@ -268,7 +268,7 @@
void
_initialize_reggroup (void)
{
- reggroups_data = register_gdbarch_data (reggroups_init);
+ reggroups_data = gdbarch_data_register_post_init (reggroups_init);
/* The pre-defined list of groups. */
add_group (&default_groups, general_reggroup, XMALLOC (struct reggroup_el));
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.130
diff -u -r1.130 remote.c
--- remote.c 25 Feb 2004 20:41:00 -0000 1.130
+++ remote.c 15 Mar 2004 20:36:44 -0000
@@ -5456,7 +5456,7 @@
struct cmd_list_element *tmpcmd;
/* architecture specific data */
- remote_gdbarch_data_handle = register_gdbarch_data (init_remote_state);
+ remote_gdbarch_data_handle = gdbarch_data_register_post_init (init_remote_state);
/* Old tacky stuff. NOTE: This comes after the remote protocol so
that the remote protocol has been initialized. */
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.42
diff -u -r1.42 solib-svr4.c
--- solib-svr4.c 11 Mar 2004 17:04:40 -0000 1.42
+++ solib-svr4.c 15 Mar 2004 20:36:44 -0000
@@ -1486,7 +1486,7 @@
set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
struct link_map_offsets *(*flmo) (void))
{
- set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
+ deprecated_set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
}
/* Initialize the architecture-specific link_map_offsets fetcher.
@@ -1584,7 +1584,7 @@
_initialize_svr4_solib (void)
{
fetch_link_map_offsets_gdbarch_data =
- register_gdbarch_data (init_fetch_link_map_offsets);
+ gdbarch_data_register_post_init (init_fetch_link_map_offsets);
svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;
Index: user-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/user-regs.c,v
retrieving revision 1.4
diff -u -r1.4 user-regs.c
--- user-regs.c 9 Mar 2004 20:03:37 -0000 1.4
+++ user-regs.c 15 Mar 2004 20:36:44 -0000
@@ -110,7 +110,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
regs = user_regs_init (gdbarch);
- set_gdbarch_data (gdbarch, user_regs_data, regs);
+ deprecated_set_gdbarch_data (gdbarch, user_regs_data, regs);
}
append_user_reg (regs, name, read,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
@@ -207,5 +207,5 @@
void
_initialize_user_regs (void)
{
- user_regs_data = register_gdbarch_data (user_regs_init);
+ user_regs_data = gdbarch_data_register_post_init (user_regs_init);
}
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-19 0:09 ` Andrew Cagney
@ 2004-03-15 21:18 ` Andrew Cagney
0 siblings, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-15 21:18 UTC (permalink / raw)
To: Andrew Cagney, Eli Zaretskii; +Cc: gdb-patches, kettenis
[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]
[hopefully with the correct patch]
>>> Date: Mon, 15 Mar 2004 12:21:07 -0500
>>> From: Andrew Cagney <cagney@gnu.org>
>>>
>>> How does the doco part of this change look?
>
>
>
> Looks okay to me, except for the following small gotchas:
>
>
>>> ! @var{post_init} is used to obtain an initial value for a
>>> ! per-architecture data-pointer @emph{after}. Since @var{post_init} is
>>> ! always called after architecture creation, it both receives the fully
>>> ! initialized architecture and is free to call modules that use
>>> ! per-architecture data (care should be taken to avoid cycles in the
>>> ! call graph).
>>> ! @end deftypefun
>
>
>
> This sounds like important notes, but they are worded too vaguely,
> IMHO. A question that popped up in my mind when I read that was: what
> cycles should I avoid in the call graph, and how?
>
> Perhaps an example would help drive these points home.
I've tried to make the problem more explict.
>>> ! current value of the per-architecture data-pointer. If the data
>>> ! pointer is @code{NULL}, it is first initialize by calling the
>
>
> ^^^^^^^^^^^^^^^^^^^^^^
> A typo: it should be "initialized".
yes.
>>> ! The examples below assuming the following definitions:
>
>
> ^^^^^^^^
> "The examples ... assume ..."
yes
>>> ! A module can extend the architecture vector, adding additional
>>> ! per-architecture attributes, using the @var{pre_init} method. These
>>> ! attribute being set by the architecture's @var{gdbarch_init} method
>>> ! during architecture creation.
>
>
>
> "These attributes are set by the architecture's @var{gdbarch_init}
> method ...".
>
> Btw, what ``attributes'' are those? The text doesn't explain that.
I've re-worded it so that it doesn't use "attribute".
ok?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 8645 bytes --]
2004-03-15 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Coding): Update section on gdbarch_data,
describe pre_init and post_init.
Index: gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.190
diff -c -r1.190 gdbint.texinfo
*** gdbint.texinfo 26 Feb 2004 20:52:08 -0000 1.190
--- gdbint.texinfo 15 Mar 2004 21:11:49 -0000
***************
*** 4872,5004 ****
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module specific
! per-architecture data-pointers to the @code{struct gdbarch} architecture
! object.
!
! A module registers one or more per-architecture data-pointers using the
! function @code{register_gdbarch_data}:
!
! @deftypefun struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *@var{init})
!
! The @var{init} function is used to obtain an initial value for a
! per-architecture data-pointer. The function is called, after the
! architecture has been created, when the data-pointer is still
! uninitialized (@code{NULL}) and its value has been requested via a call
! to @code{gdbarch_data}. A data-pointer can also be initialize
! explicitly using @code{set_gdbarch_data}.
!
! Any memory required by the @var{init} function should be allocated
! using @code{GDBARCH_OBSTACK_ZALLOC}. That memory is automatically
! released when the corresponding architecture is deleted.
!
! The function @code{register_gdbarch_data} returns a @code{struct
! gdbarch_data} that is used to identify the data-pointer that was added
! to the module.
!
@end deftypefun
! A typical module has an @code{init} function of the form:
!
! @smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
! static void *
! nozel_init (struct gdbarch *gdbarch)
! @{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! @dots{}
! return data;
! @}
! @end smallexample
!
! Since uninitialized (@code{NULL}) data-pointers are initialized
! on-demand, an @code{init} function is free to call other modules that
! use data-pointers. Those modules data-pointers will be initialized as
! needed. Care should be taken to ensure that the @code{init} call graph
! does not contain cycles.
!
! The data-pointer is registered with the call:
! @smallexample
! void
! _initialize_nozel (void)
! @{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
! @end smallexample
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{register_gdbarch_data}, this
! function returns the current value of the per-architecture data-pointer.
@end deftypefun
! The non-@code{NULL} data-pointer returned by @code{gdbarch_data} should
! be saved in a local variable and then used directly:
@smallexample
! int
! nozel_total (struct gdbarch *gdbarch)
! @{
! int total;
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! @dots{}
! return total;
! @}
@end smallexample
! It is also possible to directly initialize the data-pointer using:
!
! @deftypefun void set_gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{handle}, void *@var{pointer})
! Set the still @code{NULL} data-pointer corresponding to @var{handle}
! to the non-@code{NULL} @var{pointer} value.
! @end deftypefun
!
! This function is used by modules that require a mechanism for explicitly
! setting the per-architecture data-pointer during architecture creation:
@smallexample
! /* Always return a non-NULL nozel. */
! static struct nozel *
! gdbarch_nozel (struct gdbarch *gdbarch)
@{
! struct nozel *nozel = gdbarch_data (gdbarch, nozel_handle);
! if (nozel == NULL)
! @{
! nozel = nozel_init (gdbarch);
! set_gdbarch_data (gdbarch, nozel_handle, nozel);
! @}
! return nozel;
@}
@end smallexample
@smallexample
- /* Called during architecture creation. */
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_nozel (gdbarch);
! @dots{}
! data->total = total;
@}
@end smallexample
@smallexample
! void
! _initialize_nozel (void)
@{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
@end smallexample
! @noindent
! Note that an @code{init} function still needs to be registered. It is
! used to initialize the data-pointer when the architecture creation phase
! fail to set an initial value.
!
@section Wrapping Output Lines
@cindex line wrap in output
--- 4872,4974 ----
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module
! specific per-architecture data-pointers to the @code{struct gdbarch}
! architecture object.
!
! A module registers one or more per-architecture data-pointers using:
!
! @deftypefun struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *@var{pre_init})
! @var{pre_init} is used to, on-demand, allocate an initial value for a
! per-architecture data-pointer using the architecture's obstack (passed
! in as a parameter). Since @var{pre_init} can be called during
! architecture creation, it is not parameterized with the architecture.
! and must not call modules that use per-architecture data.
@end deftypefun
! @deftypefun struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *@var{post_init})
! @var{post_init} is used to obtain an initial value for a
! per-architecture data-pointer @emph{after}. Since @var{post_init} is
! always called after architecture creation, it both receives the fully
! initialized architecture and is free to call modules that use
! per-architecture data (care needs to be taken to ensure that those
! other modules do not try to call back to this module as that will
! create in cycles in the initialization call graph).
! @end deftypefun
! These functions return a @code{struct gdbarch_data} that is used to
! identify the per-architecture data-pointer added for that module.
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{gdbarch_data_register_pre_init}
! or @code{gdbarch_data_register_post_init}), this function returns the
! current value of the per-architecture data-pointer. If the data
! pointer is @code{NULL}, it is first initialized by calling the
! corresponding @var{pre_init} or @var{post_init} method.
@end deftypefun
! The examples below assume the following definitions:
@smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
@end smallexample
! A module can extend the architecture vector, adding additional
! per-architecture data, using the @var{pre_init} method. The module's
! per-architecture data is then initialized during architecture
! creation.
!
! In the below, the module's per-architecture @emph{nozel} is added. An
! architecture can specify its nozel by calling @code{set_gdbarch_nozel}
! from @code{gdbarch_init}.
@smallexample
! static void *
! nozel_pre_init (struct obstack *obstack)
@{
! struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
! return data;
@}
@end smallexample
@smallexample
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! data->total = nozel;
@}
@end smallexample
+ A module can on-demand create architecture dependant data structures
+ using @code{post_init}.
+
+ In the below, the nozel's total is computed on-demand by
+ @code{nozel_post_init} using information obtained from the
+ architecture.
+
@smallexample
! static void *
! nozel_post_init (struct gdbarch *gdbarch)
@{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! nozel->total = gdbarch@dots{} (gdbarch);
! return data;
! @}
@end smallexample
! @smallexample
! extern int
! nozel_total (struct gdbarch *gdbarch)
! @{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! return data->total;
! @}
! @end smallexample
@section Wrapping Output Lines
@cindex line wrap in output
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-15 21:13 ` Andrew Cagney
@ 2004-03-17 11:30 ` Eli Zaretskii
2004-03-19 0:09 ` Eli Zaretskii
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2 siblings, 2 replies; 19+ messages in thread
From: Eli Zaretskii @ 2004-03-17 11:30 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches, kettenis
> Date: Mon, 15 Mar 2004 16:13:25 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> ok?
Yes, thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-15 21:13 ` Andrew Cagney
2004-03-17 11:30 ` Eli Zaretskii
@ 2004-03-19 0:09 ` Andrew Cagney
2004-03-15 21:18 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2 siblings, 1 reply; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: Andrew Cagney, Eli Zaretskii; +Cc: gdb-patches, kettenis
[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]
[hopefully with the correct patch]
>>> Date: Mon, 15 Mar 2004 12:21:07 -0500
>>> From: Andrew Cagney <cagney@gnu.org>
>>>
>>> How does the doco part of this change look?
>
>
>
> Looks okay to me, except for the following small gotchas:
>
>
>>> ! @var{post_init} is used to obtain an initial value for a
>>> ! per-architecture data-pointer @emph{after}. Since @var{post_init} is
>>> ! always called after architecture creation, it both receives the fully
>>> ! initialized architecture and is free to call modules that use
>>> ! per-architecture data (care should be taken to avoid cycles in the
>>> ! call graph).
>>> ! @end deftypefun
>
>
>
> This sounds like important notes, but they are worded too vaguely,
> IMHO. A question that popped up in my mind when I read that was: what
> cycles should I avoid in the call graph, and how?
>
> Perhaps an example would help drive these points home.
I've tried to make the problem more explict.
>>> ! current value of the per-architecture data-pointer. If the data
>>> ! pointer is @code{NULL}, it is first initialize by calling the
>
>
> ^^^^^^^^^^^^^^^^^^^^^^
> A typo: it should be "initialized".
yes.
>>> ! The examples below assuming the following definitions:
>
>
> ^^^^^^^^
> "The examples ... assume ..."
yes
>>> ! A module can extend the architecture vector, adding additional
>>> ! per-architecture attributes, using the @var{pre_init} method. These
>>> ! attribute being set by the architecture's @var{gdbarch_init} method
>>> ! during architecture creation.
>
>
>
> "These attributes are set by the architecture's @var{gdbarch_init}
> method ...".
>
> Btw, what ``attributes'' are those? The text doesn't explain that.
I've re-worded it so that it doesn't use "attribute".
ok?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 8645 bytes --]
2004-03-15 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Coding): Update section on gdbarch_data,
describe pre_init and post_init.
Index: gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.190
diff -c -r1.190 gdbint.texinfo
*** gdbint.texinfo 26 Feb 2004 20:52:08 -0000 1.190
--- gdbint.texinfo 15 Mar 2004 21:11:49 -0000
***************
*** 4872,5004 ****
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module specific
! per-architecture data-pointers to the @code{struct gdbarch} architecture
! object.
!
! A module registers one or more per-architecture data-pointers using the
! function @code{register_gdbarch_data}:
!
! @deftypefun struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *@var{init})
!
! The @var{init} function is used to obtain an initial value for a
! per-architecture data-pointer. The function is called, after the
! architecture has been created, when the data-pointer is still
! uninitialized (@code{NULL}) and its value has been requested via a call
! to @code{gdbarch_data}. A data-pointer can also be initialize
! explicitly using @code{set_gdbarch_data}.
!
! Any memory required by the @var{init} function should be allocated
! using @code{GDBARCH_OBSTACK_ZALLOC}. That memory is automatically
! released when the corresponding architecture is deleted.
!
! The function @code{register_gdbarch_data} returns a @code{struct
! gdbarch_data} that is used to identify the data-pointer that was added
! to the module.
!
@end deftypefun
! A typical module has an @code{init} function of the form:
!
! @smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
! static void *
! nozel_init (struct gdbarch *gdbarch)
! @{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! @dots{}
! return data;
! @}
! @end smallexample
!
! Since uninitialized (@code{NULL}) data-pointers are initialized
! on-demand, an @code{init} function is free to call other modules that
! use data-pointers. Those modules data-pointers will be initialized as
! needed. Care should be taken to ensure that the @code{init} call graph
! does not contain cycles.
!
! The data-pointer is registered with the call:
! @smallexample
! void
! _initialize_nozel (void)
! @{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
! @end smallexample
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{register_gdbarch_data}, this
! function returns the current value of the per-architecture data-pointer.
@end deftypefun
! The non-@code{NULL} data-pointer returned by @code{gdbarch_data} should
! be saved in a local variable and then used directly:
@smallexample
! int
! nozel_total (struct gdbarch *gdbarch)
! @{
! int total;
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! @dots{}
! return total;
! @}
@end smallexample
! It is also possible to directly initialize the data-pointer using:
!
! @deftypefun void set_gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{handle}, void *@var{pointer})
! Set the still @code{NULL} data-pointer corresponding to @var{handle}
! to the non-@code{NULL} @var{pointer} value.
! @end deftypefun
!
! This function is used by modules that require a mechanism for explicitly
! setting the per-architecture data-pointer during architecture creation:
@smallexample
! /* Always return a non-NULL nozel. */
! static struct nozel *
! gdbarch_nozel (struct gdbarch *gdbarch)
@{
! struct nozel *nozel = gdbarch_data (gdbarch, nozel_handle);
! if (nozel == NULL)
! @{
! nozel = nozel_init (gdbarch);
! set_gdbarch_data (gdbarch, nozel_handle, nozel);
! @}
! return nozel;
@}
@end smallexample
@smallexample
- /* Called during architecture creation. */
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_nozel (gdbarch);
! @dots{}
! data->total = total;
@}
@end smallexample
@smallexample
! void
! _initialize_nozel (void)
@{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
@end smallexample
! @noindent
! Note that an @code{init} function still needs to be registered. It is
! used to initialize the data-pointer when the architecture creation phase
! fail to set an initial value.
!
@section Wrapping Output Lines
@cindex line wrap in output
--- 4872,4974 ----
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module
! specific per-architecture data-pointers to the @code{struct gdbarch}
! architecture object.
!
! A module registers one or more per-architecture data-pointers using:
!
! @deftypefun struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *@var{pre_init})
! @var{pre_init} is used to, on-demand, allocate an initial value for a
! per-architecture data-pointer using the architecture's obstack (passed
! in as a parameter). Since @var{pre_init} can be called during
! architecture creation, it is not parameterized with the architecture.
! and must not call modules that use per-architecture data.
@end deftypefun
! @deftypefun struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *@var{post_init})
! @var{post_init} is used to obtain an initial value for a
! per-architecture data-pointer @emph{after}. Since @var{post_init} is
! always called after architecture creation, it both receives the fully
! initialized architecture and is free to call modules that use
! per-architecture data (care needs to be taken to ensure that those
! other modules do not try to call back to this module as that will
! create in cycles in the initialization call graph).
! @end deftypefun
! These functions return a @code{struct gdbarch_data} that is used to
! identify the per-architecture data-pointer added for that module.
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{gdbarch_data_register_pre_init}
! or @code{gdbarch_data_register_post_init}), this function returns the
! current value of the per-architecture data-pointer. If the data
! pointer is @code{NULL}, it is first initialized by calling the
! corresponding @var{pre_init} or @var{post_init} method.
@end deftypefun
! The examples below assume the following definitions:
@smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
@end smallexample
! A module can extend the architecture vector, adding additional
! per-architecture data, using the @var{pre_init} method. The module's
! per-architecture data is then initialized during architecture
! creation.
!
! In the below, the module's per-architecture @emph{nozel} is added. An
! architecture can specify its nozel by calling @code{set_gdbarch_nozel}
! from @code{gdbarch_init}.
@smallexample
! static void *
! nozel_pre_init (struct obstack *obstack)
@{
! struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
! return data;
@}
@end smallexample
@smallexample
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! data->total = nozel;
@}
@end smallexample
+ A module can on-demand create architecture dependant data structures
+ using @code{post_init}.
+
+ In the below, the nozel's total is computed on-demand by
+ @code{nozel_post_init} using information obtained from the
+ architecture.
+
@smallexample
! static void *
! nozel_post_init (struct gdbarch *gdbarch)
@{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! nozel->total = gdbarch@dots{} (gdbarch);
! return data;
! @}
@end smallexample
! @smallexample
! extern int
! nozel_total (struct gdbarch *gdbarch)
! @{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! return data->total;
! @}
! @end smallexample
@section Wrapping Output Lines
@cindex line wrap in output
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-08 22:41 ` Mark Kettenis
2004-03-19 0:09 ` Mark Kettenis
@ 2004-03-19 0:09 ` Andrew Cagney
2004-03-08 23:51 ` Andrew Cagney
1 sibling, 1 reply; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: Mark Kettenis; +Cc: gdb-patches, eliz
> Date: Mon, 08 Mar 2004 14:28:00 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> The dwarf2-frame code is then modified to use the first mechanism. I've
> left the other clients alone (but did deprecate set_gdbarch_data as that
> should now be redundant).
>
> I'm not so sure that set_gdbarch_data is now redundant. I can imagine
> that one would like to set a per-architecture data thingy to a
> different value after its initial initialization.
Hmm, only one assignment has ever been possible:
> set_gdbarch_data (struct gdbarch *gdbarch,
> struct gdbarch_data *data,
> void *pointer)
> {
> gdb_assert (data->index < gdbarch->nr_data);
> gdb_assert (gdbarch->data[data->index] == NULL);
> gdbarch->data[data->index] = pointer;
> }
and being able to do otherwize wasn't the intent. Instead of trying to
modify the data thingie, code should modify the contents pointed to by
the thingie. For instance, in dwarf2-frame:
struct dwarf2_frame_ops
{
/* Pre-initialize the register state REG for register REGNUM. */
void (*init_reg) (struct gdbarch *, int, struct
dwarf2_frame_state_reg *);
};
the code can perform multiple assignments to "init_reg".
> So I'd rather you
> wouldn't deprecate the interface.
>
> Also note the name changes (better suggestions?).
>
> The names look fine to me.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-17 11:30 ` Eli Zaretskii
@ 2004-03-19 0:09 ` Eli Zaretskii
2004-03-19 0:09 ` Andrew Cagney
1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2004-03-19 0:09 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches, kettenis
> Date: Mon, 15 Mar 2004 16:13:25 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> ok?
Yes, thanks.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-08 22:41 ` Mark Kettenis
@ 2004-03-19 0:09 ` Mark Kettenis
2004-03-19 0:09 ` Andrew Cagney
1 sibling, 0 replies; 19+ messages in thread
From: Mark Kettenis @ 2004-03-19 0:09 UTC (permalink / raw)
To: cagney; +Cc: gdb-patches, eliz
Date: Mon, 08 Mar 2004 14:28:00 -0500
From: Andrew Cagney <cagney@gnu.org>
The dwarf2-frame code is then modified to use the first mechanism. I've
left the other clients alone (but did deprecate set_gdbarch_data as that
should now be redundant).
I'm not so sure that set_gdbarch_data is now redundant. I can imagine
that one would like to set a per-architecture data thingy to a
different value after its initial initialization. So I'd rather you
wouldn't deprecate the interface.
Also note the name changes (better suggestions?).
The names look fine to me.
Mark
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-08 19:28 [patch/rfc] Separate gdbarch_data_register_pre_init Andrew Cagney
` (2 preceding siblings ...)
2004-03-19 0:09 ` Andrew Cagney
@ 2004-03-19 0:09 ` Andrew Cagney
2004-03-15 17:21 ` Andrew Cagney
2004-03-15 19:55 ` Eli Zaretskii
3 siblings, 2 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: Andrew Cagney, Eli Zaretskii; +Cc: gdb-patches, Mark Kettenis
[-- Attachment #1: Type: text/plain, Size: 58 bytes --]
Eli,
How does the doco part of this change look?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 8499 bytes --]
2004-03-07 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Coding): Update section on gdbarch_data,
describe pre_init and post_init.
Index: gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.190
diff -c -r1.190 gdbint.texinfo
*** gdbint.texinfo 26 Feb 2004 20:52:08 -0000 1.190
--- gdbint.texinfo 15 Mar 2004 17:19:56 -0000
***************
*** 4872,5004 ****
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module specific
! per-architecture data-pointers to the @code{struct gdbarch} architecture
! object.
!
! A module registers one or more per-architecture data-pointers using the
! function @code{register_gdbarch_data}:
!
! @deftypefun struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *@var{init})
!
! The @var{init} function is used to obtain an initial value for a
! per-architecture data-pointer. The function is called, after the
! architecture has been created, when the data-pointer is still
! uninitialized (@code{NULL}) and its value has been requested via a call
! to @code{gdbarch_data}. A data-pointer can also be initialize
! explicitly using @code{set_gdbarch_data}.
!
! Any memory required by the @var{init} function should be allocated
! using @code{GDBARCH_OBSTACK_ZALLOC}. That memory is automatically
! released when the corresponding architecture is deleted.
!
! The function @code{register_gdbarch_data} returns a @code{struct
! gdbarch_data} that is used to identify the data-pointer that was added
! to the module.
!
@end deftypefun
! A typical module has an @code{init} function of the form:
!
! @smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
! static void *
! nozel_init (struct gdbarch *gdbarch)
! @{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! @dots{}
! return data;
! @}
! @end smallexample
!
! Since uninitialized (@code{NULL}) data-pointers are initialized
! on-demand, an @code{init} function is free to call other modules that
! use data-pointers. Those modules data-pointers will be initialized as
! needed. Care should be taken to ensure that the @code{init} call graph
! does not contain cycles.
!
! The data-pointer is registered with the call:
! @smallexample
! void
! _initialize_nozel (void)
! @{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
! @end smallexample
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{register_gdbarch_data}, this
! function returns the current value of the per-architecture data-pointer.
@end deftypefun
! The non-@code{NULL} data-pointer returned by @code{gdbarch_data} should
! be saved in a local variable and then used directly:
@smallexample
! int
! nozel_total (struct gdbarch *gdbarch)
! @{
! int total;
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! @dots{}
! return total;
! @}
@end smallexample
! It is also possible to directly initialize the data-pointer using:
! @deftypefun void set_gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{handle}, void *@var{pointer})
! Set the still @code{NULL} data-pointer corresponding to @var{handle}
! to the non-@code{NULL} @var{pointer} value.
! @end deftypefun
!
! This function is used by modules that require a mechanism for explicitly
! setting the per-architecture data-pointer during architecture creation:
@smallexample
! /* Always return a non-NULL nozel. */
! static struct nozel *
! gdbarch_nozel (struct gdbarch *gdbarch)
@{
! struct nozel *nozel = gdbarch_data (gdbarch, nozel_handle);
! if (nozel == NULL)
! @{
! nozel = nozel_init (gdbarch);
! set_gdbarch_data (gdbarch, nozel_handle, nozel);
! @}
! return nozel;
@}
@end smallexample
@smallexample
- /* Called during architecture creation. */
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_nozel (gdbarch);
! @dots{}
! data->total = total;
@}
@end smallexample
@smallexample
! void
! _initialize_nozel (void)
@{
! nozel_handle = register_gdbarch_data (nozel_init);
! @dots{}
@end smallexample
! @noindent
! Note that an @code{init} function still needs to be registered. It is
! used to initialize the data-pointer when the architecture creation phase
! fail to set an initial value.
!
@section Wrapping Output Lines
@cindex line wrap in output
--- 4872,4972 ----
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
! The multi-arch framework includes a mechanism for adding module
! specific per-architecture data-pointers to the @code{struct gdbarch}
! architecture object.
!
! A module registers one or more per-architecture data-pointers using:
!
! @deftypefun struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *@var{pre_init})
! @var{pre_init} is used to, on-demand, allocate an initial value for a
! per-architecture data-pointer using the architecture's obstack (passed
! in as a parameter). Since @var{pre_init} can be called during
! architecture creation, it is not parameterized with the architecture.
! and must not call modules that use per-architecture data.
@end deftypefun
! @deftypefun struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *@var{post_init})
! @var{post_init} is used to obtain an initial value for a
! per-architecture data-pointer @emph{after}. Since @var{post_init} is
! always called after architecture creation, it both receives the fully
! initialized architecture and is free to call modules that use
! per-architecture data (care should be taken to avoid cycles in the
! call graph).
! @end deftypefun
! These functions return a @code{struct gdbarch_data} that is used to
! identify the per-architecture data-pointer added for that module.
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
! @var{data_handle} (returned by @code{gdbarch_data_register_pre_init}
! or @code{gdbarch_data_register_post_init}), this function returns the
! current value of the per-architecture data-pointer. If the data
! pointer is @code{NULL}, it is first initialize by calling the
! corresponding @var{pre_init} or @var{post_init} method.
@end deftypefun
! The examples below assuming the following definitions:
@smallexample
! struct nozel @{ int total; @};
! static struct gdbarch_data *nozel_handle;
@end smallexample
! A module can extend the architecture vector, adding additional
! per-architecture attributes, using the @var{pre_init} method. These
! attribute being set by the architecture's @var{gdbarch_init} method
! during architecture creation.
! In the below, the attribute nozel is added. An architecture can
! specify its nozel @code{set_gdbarch_nozel}.
@smallexample
! static void *
! nozel_pre_init (struct obstack *obstack)
@{
! struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
! return data;
@}
@end smallexample
@smallexample
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! data->total = nozel;
@}
@end smallexample
+ A module can on-demand create architecture dependant data structures
+ using @code{post_init}.
+
+ In the below, the nozel's total is computed on-demand by
+ @code{nozel_post_init} using information obtained from the
+ architecture.
+
@smallexample
! static void *
! nozel_post_init (struct gdbarch *gdbarch)
@{
! struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
! nozel->total = gdbarch@dots{} (gdbarch);
! return data;
! @}
@end smallexample
! @smallexample
! extern int
! nozel_total (struct gdbarch *gdbarch)
! @{
! struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
! return data->total;
! @}
! @end smallexample
@section Wrapping Output Lines
@cindex line wrap in output
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-15 21:13 ` Andrew Cagney
2004-03-17 11:30 ` Eli Zaretskii
2004-03-19 0:09 ` Andrew Cagney
@ 2004-03-19 0:09 ` Andrew Cagney
2 siblings, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, kettenis
[-- Attachment #1: Type: text/plain, Size: 1773 bytes --]
>>> Date: Mon, 15 Mar 2004 12:21:07 -0500
>>> From: Andrew Cagney <cagney@gnu.org>
>>>
>>> How does the doco part of this change look?
>
>
> Looks okay to me, except for the following small gotchas:
>
>
>>> ! @var{post_init} is used to obtain an initial value for a
>>> ! per-architecture data-pointer @emph{after}. Since @var{post_init} is
>>> ! always called after architecture creation, it both receives the fully
>>> ! initialized architecture and is free to call modules that use
>>> ! per-architecture data (care should be taken to avoid cycles in the
>>> ! call graph).
>>> ! @end deftypefun
>
>
> This sounds like important notes, but they are worded too vaguely,
> IMHO. A question that popped up in my mind when I read that was: what
> cycles should I avoid in the call graph, and how?
>
> Perhaps an example would help drive these points home.
I've tried to make the problem more explict.
>>> ! current value of the per-architecture data-pointer. If the data
>>> ! pointer is @code{NULL}, it is first initialize by calling the
>
> ^^^^^^^^^^^^^^^^^^^^^^
> A typo: it should be "initialized".
yes.
>>> ! The examples below assuming the following definitions:
>
> ^^^^^^^^
> "The examples ... assume ..."
yes
>>> ! A module can extend the architecture vector, adding additional
>>> ! per-architecture attributes, using the @var{pre_init} method. These
>>> ! attribute being set by the architecture's @var{gdbarch_init} method
>>> ! during architecture creation.
>
>
> "These attributes are set by the architecture's @var{gdbarch_init}
> method ...".
>
> Btw, what ``attributes'' are those? The text doesn't explain that.
I've re-worded it so that it doesn't use "attribute".
ok?
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 24511 bytes --]
2004-03-15 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (gdbarch_data_pre_init_fytpe)
(gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe)
(gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype
and register_gdbarch_data.
(deprecated_set_gdbarch_data): Rename set_gdbarch_data.
(struct gdbarch_data): Replace "init" by "pre_init" and
"post_init".
* gdbarch.h, gdbarch.c: Re-generate.
* dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter
with"obstack", use OBSTACK_ZALLOC.
(dwarf2_frame_ops): Delete.
(dwarf2_frame_set_init_reg): Use gdbarch_data.
(dwarf2_frame_init_reg): Use gdbarch_data.
(_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init.
* solib-svr4.c (set_solib_svr4_fetch_link_map_offsets)
(_initialize_svr4_solib): Update.
* user-regs.c (_initialize_user_regs): Update.
* reggroups.c (_initialize_reggroup): Update.
* regcache.c (_initialize_regcache): Update.
* mips-linux-tdep.c (_initialize_mips_linux_tdep): Update.
* libunwind-frame.c (_initialize_libunwind_frame): Update.
* gnu-v3-abi.c (init_gnuv3_ops): Update.
* frame-unwind.c (_initialize_frame_unwind): Update.
* frame-base.c (_initialize_frame_base): Update.
* user-regs.c (user_reg_add): Update.
* reggroups.c (reggroup_add): Update.
* mips-linux-tdep.c (set_mips_linux_register_addr): Update.
* libunwind-frame.c (libunwind_frame_set_descr): Update.
* frame-unwind.c (frame_unwind_append_sniffer): Update.
* frame-base.c (frame_base_table): Update.
* remote.c (_initialize_remote): Update.
* gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.31
diff -u -r1.31 dwarf2-frame.c
--- dwarf2-frame.c 16 Feb 2004 20:32:01 -0000 1.31
+++ dwarf2-frame.c 15 Mar 2004 20:36:39 -0000
@@ -509,29 +509,15 @@
/* Return a default for the architecture-specific operations. */
static void *
-dwarf2_frame_init (struct gdbarch *gdbarch)
+dwarf2_frame_init (struct obstack *obstack)
{
struct dwarf2_frame_ops *ops;
- ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
+ ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
ops->init_reg = dwarf2_frame_default_init_reg;
return ops;
}
-static struct dwarf2_frame_ops *
-dwarf2_frame_ops (struct gdbarch *gdbarch)
-{
- struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- if (ops == NULL)
- {
- /* ULGH, called during architecture initialization. Patch
- things up. */
- ops = dwarf2_frame_init (gdbarch);
- set_gdbarch_data (gdbarch, dwarf2_frame_data, ops);
- }
- return ops;
-}
-
/* Set the architecture-specific register state initialization
function for GDBARCH to INIT_REG. */
@@ -540,9 +526,8 @@
void (*init_reg) (struct gdbarch *, int,
struct dwarf2_frame_state_reg *))
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg = init_reg;
}
@@ -552,9 +537,8 @@
dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg)
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg (gdbarch, regnum, reg);
}
\f
@@ -1608,6 +1592,6 @@
void
_initialize_dwarf2_frame (void)
{
- dwarf2_frame_data = register_gdbarch_data (dwarf2_frame_init);
+ dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
dwarf2_frame_objfile_data = register_objfile_data ();
}
Index: frame-base.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-base.c,v
retrieving revision 1.8
diff -u -r1.8 frame-base.c
--- frame-base.c 4 Aug 2003 22:24:44 -0000 1.8
+++ frame-base.c 15 Mar 2004 20:36:39 -0000
@@ -92,7 +92,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_base_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_base_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_base_data, table);
}
return table;
}
@@ -146,5 +146,5 @@
void
_initialize_frame_base (void)
{
- frame_base_data = register_gdbarch_data (frame_base_init);
+ frame_base_data = gdbarch_data_register_post_init (frame_base_init);
}
Index: frame-unwind.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-unwind.c,v
retrieving revision 1.8
diff -u -r1.8 frame-unwind.c
--- frame-unwind.c 22 Feb 2004 17:08:42 -0000 1.8
+++ frame-unwind.c 15 Mar 2004 20:36:39 -0000
@@ -63,7 +63,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_unwind_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_unwind_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_unwind_data, table);
}
append_predicate (table, sniffer);
}
@@ -95,5 +95,5 @@
void
_initialize_frame_unwind (void)
{
- frame_unwind_data = register_gdbarch_data (frame_unwind_init);
+ frame_unwind_data = gdbarch_data_register_post_init (frame_unwind_init);
}
Index: gdb_obstack.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_obstack.h,v
retrieving revision 1.2
diff -u -r1.2 gdb_obstack.h
--- gdb_obstack.h 9 Feb 2004 23:50:55 -0000 1.2
+++ gdb_obstack.h 15 Mar 2004 20:36:39 -0000
@@ -24,6 +24,12 @@
#include "obstack.h"
+/* Utility macros - wrap obstack alloc into something more robust. */
+
+#define OBSTACK_ZALLOC(OBSTACK,TYPE) (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE)))
+
+#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), 0, (NUMBER) * sizeof (TYPE)))
+
/* Unless explicitly specified, GDB obstacks always use xmalloc() and
xfree(). */
/* Note: ezannoni 2004-02-09: One could also specify the allocation
Index: gdbarch.c
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.c,v
retrieving revision 1.275
diff -u -r1.275 gdbarch.c
--- gdbarch.c 16 Feb 2004 21:49:21 -0000 1.275
+++ gdbarch.c 15 Mar 2004 20:36:40 -0000
@@ -5382,7 +5382,8 @@
{
unsigned index;
int init_p;
- gdbarch_data_init_ftype *init;
+ gdbarch_data_pre_init_ftype *pre_init;
+ gdbarch_data_post_init_ftype *post_init;
};
struct gdbarch_data_registration
@@ -5402,8 +5403,9 @@
0, NULL,
};
-struct gdbarch_data *
-register_gdbarch_data (gdbarch_data_init_ftype *init)
+static struct gdbarch_data *
+gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
+ gdbarch_data_post_init_ftype *post_init)
{
struct gdbarch_data_registration **curr;
/* Append the new registraration. */
@@ -5414,11 +5416,23 @@
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct gdbarch_data);
(*curr)->data->index = gdbarch_data_registry.nr++;
- (*curr)->data->init = init;
+ (*curr)->data->pre_init = pre_init;
+ (*curr)->data->post_init = post_init;
(*curr)->data->init_p = 1;
return (*curr)->data;
}
+struct gdbarch_data *
+gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
+{
+ return gdbarch_data_register (pre_init, NULL);
+}
+
+struct gdbarch_data *
+gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
+{
+ return gdbarch_data_register (NULL, post_init);
+}
/* Create/delete the gdbarch data vector. */
@@ -5434,12 +5448,13 @@
data-pointer. */
void
-set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer)
+deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer)
{
gdb_assert (data->index < gdbarch->nr_data);
gdb_assert (gdbarch->data[data->index] == NULL);
+ gdb_assert (data->pre_init == NULL);
gdbarch->data[data->index] = pointer;
}
@@ -5450,18 +5465,33 @@
gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
{
gdb_assert (data->index < gdbarch->nr_data);
- /* The data-pointer isn't initialized, call init() to get a value but
- only if the architecture initializaiton has completed. Otherwise
- punt - hope that the caller knows what they are doing. */
- if (gdbarch->data[data->index] == NULL
- && gdbarch->initialized_p)
+ if (gdbarch->data[data->index] == NULL)
{
- /* Be careful to detect an initialization cycle. */
- gdb_assert (data->init_p);
- data->init_p = 0;
- gdb_assert (data->init != NULL);
- gdbarch->data[data->index] = data->init (gdbarch);
- data->init_p = 1;
+ /* The data-pointer isn't initialized, call init() to get a
+ value. */
+ if (data->pre_init != NULL)
+ /* Mid architecture creation: pass just the obstack, and not
+ the entire architecture, as that way it isn't possible for
+ pre-init code to refer to undefined architecture
+ fields. */
+ gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
+ else if (gdbarch->initialized_p
+ && data->post_init != NULL)
+ /* Post architecture creation: pass the entire architecture
+ (as all fields are valid), but be careful to also detect
+ recursive references. */
+ {
+ gdb_assert (data->init_p);
+ data->init_p = 0;
+ gdbarch->data[data->index] = data->post_init (gdbarch);
+ data->init_p = 1;
+ }
+ else
+ /* The architecture initialization hasn't completed - punt -
+ hope that the caller knows what they are doing. Once
+ deprecated_set_gdbarch_data has been initialized, this can be
+ changed to an internal error. */
+ return NULL;
gdb_assert (gdbarch->data[data->index] != NULL);
}
return gdbarch->data[data->index];
Index: gdbarch.h
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.h,v
retrieving revision 1.238
diff -u -r1.238 gdbarch.h
--- gdbarch.h 16 Feb 2004 21:49:21 -0000 1.238
+++ gdbarch.h 15 Mar 2004 20:36:41 -0000
@@ -48,6 +48,7 @@
struct regset;
struct disassemble_info;
struct target_ops;
+struct obstack;
extern struct gdbarch *current_gdbarch;
@@ -2517,10 +2518,6 @@
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
- The per-architecture data-pointer is either initialized explicitly
- (set_gdbarch_data()) or implicitly (by INIT() via a call to
- gdbarch_data()).
-
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
@@ -2534,11 +2531,13 @@
struct gdbarch_data;
-typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
-extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init);
-extern void set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer);
+typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
+extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
+typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
+extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
+extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer);
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
@@ -2554,7 +2553,7 @@
Memory regions are swapped / initialized in the order that they are
registered. NULL DATA and/or INIT values can be specified.
- New code should use register_gdbarch_data(). */
+ New code should use gdbarch_data_register_*(). */
typedef void (gdbarch_swap_ftype) (void);
extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init);
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.301
diff -u -r1.301 gdbarch.sh
--- gdbarch.sh 16 Feb 2004 21:49:21 -0000 1.301
+++ gdbarch.sh 15 Mar 2004 20:36:41 -0000
@@ -890,6 +890,7 @@
struct regset;
struct disassemble_info;
struct target_ops;
+struct obstack;
extern struct gdbarch *current_gdbarch;
@@ -1201,10 +1202,6 @@
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
- The per-architecture data-pointer is either initialized explicitly
- (set_gdbarch_data()) or implicitly (by INIT() via a call to
- gdbarch_data()).
-
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
@@ -1218,11 +1215,13 @@
struct gdbarch_data;
-typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
-extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init);
-extern void set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer);
+typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
+extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
+typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
+extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
+extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer);
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
@@ -1238,7 +1237,7 @@
Memory regions are swapped / initialized in the order that they are
registered. NULL DATA and/or INIT values can be specified.
- New code should use register_gdbarch_data(). */
+ New code should use gdbarch_data_register_*(). */
typedef void (gdbarch_swap_ftype) (void);
extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init);
@@ -1811,7 +1810,8 @@
{
unsigned index;
int init_p;
- gdbarch_data_init_ftype *init;
+ gdbarch_data_pre_init_ftype *pre_init;
+ gdbarch_data_post_init_ftype *post_init;
};
struct gdbarch_data_registration
@@ -1831,8 +1831,9 @@
0, NULL,
};
-struct gdbarch_data *
-register_gdbarch_data (gdbarch_data_init_ftype *init)
+static struct gdbarch_data *
+gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
+ gdbarch_data_post_init_ftype *post_init)
{
struct gdbarch_data_registration **curr;
/* Append the new registraration. */
@@ -1843,11 +1844,23 @@
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct gdbarch_data);
(*curr)->data->index = gdbarch_data_registry.nr++;
- (*curr)->data->init = init;
+ (*curr)->data->pre_init = pre_init;
+ (*curr)->data->post_init = post_init;
(*curr)->data->init_p = 1;
return (*curr)->data;
}
+struct gdbarch_data *
+gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
+{
+ return gdbarch_data_register (pre_init, NULL);
+}
+
+struct gdbarch_data *
+gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
+{
+ return gdbarch_data_register (NULL, post_init);
+}
/* Create/delete the gdbarch data vector. */
@@ -1863,12 +1876,13 @@
data-pointer. */
void
-set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer)
+deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer)
{
gdb_assert (data->index < gdbarch->nr_data);
gdb_assert (gdbarch->data[data->index] == NULL);
+ gdb_assert (data->pre_init == NULL);
gdbarch->data[data->index] = pointer;
}
@@ -1879,18 +1893,33 @@
gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
{
gdb_assert (data->index < gdbarch->nr_data);
- /* The data-pointer isn't initialized, call init() to get a value but
- only if the architecture initializaiton has completed. Otherwise
- punt - hope that the caller knows what they are doing. */
- if (gdbarch->data[data->index] == NULL
- && gdbarch->initialized_p)
+ if (gdbarch->data[data->index] == NULL)
{
- /* Be careful to detect an initialization cycle. */
- gdb_assert (data->init_p);
- data->init_p = 0;
- gdb_assert (data->init != NULL);
- gdbarch->data[data->index] = data->init (gdbarch);
- data->init_p = 1;
+ /* The data-pointer isn't initialized, call init() to get a
+ value. */
+ if (data->pre_init != NULL)
+ /* Mid architecture creation: pass just the obstack, and not
+ the entire architecture, as that way it isn't possible for
+ pre-init code to refer to undefined architecture
+ fields. */
+ gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
+ else if (gdbarch->initialized_p
+ && data->post_init != NULL)
+ /* Post architecture creation: pass the entire architecture
+ (as all fields are valid), but be careful to also detect
+ recursive references. */
+ {
+ gdb_assert (data->init_p);
+ data->init_p = 0;
+ gdbarch->data[data->index] = data->post_init (gdbarch);
+ data->init_p = 1;
+ }
+ else
+ /* The architecture initialization hasn't completed - punt -
+ hope that the caller knows what they are doing. Once
+ deprecated_set_gdbarch_data has been initialized, this can be
+ changed to an internal error. */
+ return NULL;
gdb_assert (gdbarch->data[data->index] != NULL);
}
return gdbarch->data[data->index];
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.20
diff -u -r1.20 gnu-v3-abi.c
--- gnu-v3-abi.c 5 Dec 2003 04:25:09 -0000 1.20
+++ gnu-v3-abi.c 15 Mar 2004 20:36:42 -0000
@@ -422,7 +422,7 @@
static void
init_gnuv3_ops (void)
{
- vtable_type_gdbarch_data = register_gdbarch_data (build_gdb_vtable_type);
+ vtable_type_gdbarch_data = gdbarch_data_register_post_init (build_gdb_vtable_type);
gnu_v3_abi_ops.shortname = "gnu-v3";
gnu_v3_abi_ops.longname = "GNU G++ Version 3 ABI";
Index: libunwind-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/libunwind-frame.c,v
retrieving revision 1.2
diff -u -r1.2 libunwind-frame.c
--- libunwind-frame.c 13 Dec 2003 03:51:56 -0000 1.2
+++ libunwind-frame.c 15 Mar 2004 20:36:42 -0000
@@ -111,7 +111,7 @@
{
/* First time here. Must initialize data area. */
arch_descr = libunwind_descr_init (gdbarch);
- set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
+ deprecated_set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
}
/* Copy new descriptor info into arch descriptor. */
@@ -381,7 +381,7 @@
void
_initialize_libunwind_frame (void)
{
- libunwind_descr_handle = register_gdbarch_data (libunwind_descr_init);
+ libunwind_descr_handle = gdbarch_data_register_post_init (libunwind_descr_init);
libunwind_initialized = libunwind_load ();
}
Index: mips-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v
retrieving revision 1.19
diff -u -r1.19 mips-linux-tdep.c
--- mips-linux-tdep.c 14 Feb 2004 04:41:33 -0000 1.19
+++ mips-linux-tdep.c 15 Mar 2004 20:36:42 -0000
@@ -668,7 +668,7 @@
set_mips_linux_register_addr (struct gdbarch *gdbarch,
CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR))
{
- set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
+ deprecated_set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
}
static void *
@@ -844,7 +844,7 @@
const struct bfd_arch_info *arch_info;
register_addr_data =
- register_gdbarch_data (init_register_addr_data);
+ gdbarch_data_register_post_init (init_register_addr_data);
for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
arch_info != NULL;
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.109
diff -u -r1.109 regcache.c
--- regcache.c 29 Feb 2004 17:01:38 -0000 1.109
+++ regcache.c 15 Mar 2004 20:36:42 -0000
@@ -1705,7 +1705,7 @@
void
_initialize_regcache (void)
{
- regcache_descr_handle = register_gdbarch_data (init_regcache_descr);
+ regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_registers);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_register_valid);
Index: reggroups.c
===================================================================
RCS file: /cvs/src/src/gdb/reggroups.c,v
retrieving revision 1.8
diff -u -r1.8 reggroups.c
--- reggroups.c 22 Aug 2003 09:49:01 -0000 1.8
+++ reggroups.c 15 Mar 2004 20:36:42 -0000
@@ -109,7 +109,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
groups = reggroups_init (gdbarch);
- set_gdbarch_data (gdbarch, reggroups_data, groups);
+ deprecated_set_gdbarch_data (gdbarch, reggroups_data, groups);
}
add_group (groups, group,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct reggroup_el));
@@ -268,7 +268,7 @@
void
_initialize_reggroup (void)
{
- reggroups_data = register_gdbarch_data (reggroups_init);
+ reggroups_data = gdbarch_data_register_post_init (reggroups_init);
/* The pre-defined list of groups. */
add_group (&default_groups, general_reggroup, XMALLOC (struct reggroup_el));
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.130
diff -u -r1.130 remote.c
--- remote.c 25 Feb 2004 20:41:00 -0000 1.130
+++ remote.c 15 Mar 2004 20:36:44 -0000
@@ -5456,7 +5456,7 @@
struct cmd_list_element *tmpcmd;
/* architecture specific data */
- remote_gdbarch_data_handle = register_gdbarch_data (init_remote_state);
+ remote_gdbarch_data_handle = gdbarch_data_register_post_init (init_remote_state);
/* Old tacky stuff. NOTE: This comes after the remote protocol so
that the remote protocol has been initialized. */
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.42
diff -u -r1.42 solib-svr4.c
--- solib-svr4.c 11 Mar 2004 17:04:40 -0000 1.42
+++ solib-svr4.c 15 Mar 2004 20:36:44 -0000
@@ -1486,7 +1486,7 @@
set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
struct link_map_offsets *(*flmo) (void))
{
- set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
+ deprecated_set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
}
/* Initialize the architecture-specific link_map_offsets fetcher.
@@ -1584,7 +1584,7 @@
_initialize_svr4_solib (void)
{
fetch_link_map_offsets_gdbarch_data =
- register_gdbarch_data (init_fetch_link_map_offsets);
+ gdbarch_data_register_post_init (init_fetch_link_map_offsets);
svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;
Index: user-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/user-regs.c,v
retrieving revision 1.4
diff -u -r1.4 user-regs.c
--- user-regs.c 9 Mar 2004 20:03:37 -0000 1.4
+++ user-regs.c 15 Mar 2004 20:36:44 -0000
@@ -110,7 +110,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
regs = user_regs_init (gdbarch);
- set_gdbarch_data (gdbarch, user_regs_data, regs);
+ deprecated_set_gdbarch_data (gdbarch, user_regs_data, regs);
}
append_user_reg (regs, name, read,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
@@ -207,5 +207,5 @@
void
_initialize_user_regs (void)
{
- user_regs_data = register_gdbarch_data (user_regs_init);
+ user_regs_data = gdbarch_data_register_post_init (user_regs_init);
}
^ permalink raw reply [flat|nested] 19+ messages in thread
* [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-08 19:28 [patch/rfc] Separate gdbarch_data_register_pre_init Andrew Cagney
2004-03-08 22:41 ` Mark Kettenis
2004-03-15 20:44 ` Andrew Cagney
@ 2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
3 siblings, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches, Mark Kettenis; +Cc: Eli Zaretskii
[-- Attachment #1: Type: text/plain, Size: 788 bytes --]
Hello,
This patch is ment to address the problem identifed in this thread:
http://sources.redhat.com/ml/gdb-patches/2004-02/msg00517.html
It changes the gdbarch_data framework so that the data is differentiated
as being:
pre_init:
Created while the architecture object is still being initialized
(strictly speaking it can also be called after the architecture has been
initialized, however the pre_init code can't tell the difference).
post_init:
Called after the architecture has been initialized.
The dwarf2-frame code is then modified to use the first mechanism. I've
left the other clients alone (but did deprecate set_gdbarch_data as that
should now be redundant).
Also note the name changes (better suggestions?).
thoughts? this is tabled for at least a week,
Andrew
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 26079 bytes --]
2004-03-07 Andrew Cagney <cagney@redhat.com>
* gdbarch.sh (gdbarch_data_pre_init_fytpe)
(gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe)
(gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype
and register_gdbarch_data.
(deprecated_set_gdbarch_data): Rename set_gdbarch_data.
(struct gdbarch_data): Replace "init" by "pre_init" and
"post_init".
* gdbarch.h, gdbarch.c: Re-generate.
* dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter
with"obstack", use OBSTACK_ZALLOC.
(dwarf2_frame_ops): Delete.
(dwarf2_frame_set_init_reg): Use gdbarch_data.
(dwarf2_frame_init_reg): Use gdbarch_data.
(_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init.
* solib-svr4.c (set_solib_svr4_fetch_link_map_offsets)
(_initialize_svr4_solib): Update.
* user-regs.c (_initialize_user_regs): Update.
* reggroups.c (_initialize_reggroup): Update.
* regcache.c (_initialize_regcache): Update.
* mips-linux-tdep.c (_initialize_mips_linux_tdep): Update.
* libunwind-frame.c (_initialize_libunwind_frame): Update.
* gnu-v3-abi.c (init_gnuv3_ops): Update.
* frame-unwind.c (_initialize_frame_unwind): Update.
* frame-base.c (_initialize_frame_base): Update.
* user-regs.c (user_reg_add): Update.
* reggroups.c (reggroup_add): Update.
* mips-linux-tdep.c (set_mips_linux_register_addr): Update.
* libunwind-frame.c (libunwind_frame_set_descr): Update.
* frame-unwind.c (frame_unwind_append_sniffer): Update.
* frame-base.c (frame_base_table): Update.
* remote.c (_initialize_remote): Update.
* gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
Index: doc/ChangeLog
2004-03-07 Andrew Cagney <cagney@redhat.com>
* gdbint.texinfo (Coding): Update section on gdbarch_data,
describe pre_init and post_init.
Index: doc/gdbint.texinfo
===================================================================
RCS file: /cvs/src/src/gdb/doc/gdbint.texinfo,v
retrieving revision 1.190
diff -u -r1.190 gdbint.texinfo
--- doc/gdbint.texinfo 26 Feb 2004 20:52:08 -0000 1.190
+++ doc/gdbint.texinfo 8 Mar 2004 19:12:09 -0000
@@ -4872,133 +4872,101 @@
@cindex multi-arch data
@cindex data-pointer, per-architecture/per-module
-The multi-arch framework includes a mechanism for adding module specific
-per-architecture data-pointers to the @code{struct gdbarch} architecture
-object.
-
-A module registers one or more per-architecture data-pointers using the
-function @code{register_gdbarch_data}:
-
-@deftypefun struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *@var{init})
-
-The @var{init} function is used to obtain an initial value for a
-per-architecture data-pointer. The function is called, after the
-architecture has been created, when the data-pointer is still
-uninitialized (@code{NULL}) and its value has been requested via a call
-to @code{gdbarch_data}. A data-pointer can also be initialize
-explicitly using @code{set_gdbarch_data}.
-
-Any memory required by the @var{init} function should be allocated
-using @code{GDBARCH_OBSTACK_ZALLOC}. That memory is automatically
-released when the corresponding architecture is deleted.
-
-The function @code{register_gdbarch_data} returns a @code{struct
-gdbarch_data} that is used to identify the data-pointer that was added
-to the module.
-
+The multi-arch framework includes a mechanism for adding module
+specific per-architecture data-pointers to the @code{struct gdbarch}
+architecture object.
+
+A module registers one or more per-architecture data-pointers using:
+
+@deftypefun struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *@var{pre_init})
+@var{pre_init} is used to, on-demand, allocate an initial value for a
+per-architecture data-pointer using the architecture's obstack (passed
+in as a parameter). Since @var{pre_init} can be called during
+architecture creation, it is not parameterized with the architecture.
+and must not call modules that use per-architecture data.
@end deftypefun
-A typical module has an @code{init} function of the form:
-
-@smallexample
-struct nozel @{ int total; @};
-static struct gdbarch_data *nozel_handle;
-static void *
-nozel_init (struct gdbarch *gdbarch)
-@{
- struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
- @dots{}
- return data;
-@}
-@end smallexample
-
-Since uninitialized (@code{NULL}) data-pointers are initialized
-on-demand, an @code{init} function is free to call other modules that
-use data-pointers. Those modules data-pointers will be initialized as
-needed. Care should be taken to ensure that the @code{init} call graph
-does not contain cycles.
-
-The data-pointer is registered with the call:
+@deftypefun struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *@var{post_init})
+@var{post_init} is used to obtain an initial value for a
+per-architecture data-pointer @emph{after}. Since @var{post_init} is
+always called after architecture creation, it both receives the fully
+initialized architecture and is free to call modules that use
+per-architecture data (care should be taken to avoid cycles in the
+call graph).
+@end deftypefun
-@smallexample
-void
-_initialize_nozel (void)
-@{
- nozel_handle = register_gdbarch_data (nozel_init);
-@dots{}
-@end smallexample
+These functions return a @code{struct gdbarch_data} that is used to
+identify the per-architecture data-pointer added for that module.
The per-architecture data-pointer is accessed using the function:
@deftypefun void *gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{data_handle})
Given the architecture @var{arch} and module data handle
-@var{data_handle} (returned by @code{register_gdbarch_data}, this
-function returns the current value of the per-architecture data-pointer.
+@var{data_handle} (returned by @code{gdbarch_data_register_pre_init}
+or @code{gdbarch_data_register_post_init}), this function returns the
+current value of the per-architecture data-pointer. If the data
+pointer is @code{NULL}, it is first initialize by calling the
+corresponding @var{pre_init} or @var{post_init} method.
@end deftypefun
-The non-@code{NULL} data-pointer returned by @code{gdbarch_data} should
-be saved in a local variable and then used directly:
+The examples below assuming the following definitions:
@smallexample
-int
-nozel_total (struct gdbarch *gdbarch)
-@{
- int total;
- struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
- @dots{}
- return total;
-@}
+struct nozel @{ int total; @};
+static struct gdbarch_data *nozel_handle;
@end smallexample
-It is also possible to directly initialize the data-pointer using:
+A module can extend the architecture vector, adding additional
+per-architecture attributes, using the @var{pre_init} method. These
+attribute being set by the architecture's @var{gdbarch_init} method
+during architecture creation.
-@deftypefun void set_gdbarch_data (struct gdbarch *@var{gdbarch}, struct gdbarch_data *@var{handle}, void *@var{pointer})
-Set the still @code{NULL} data-pointer corresponding to @var{handle}
-to the non-@code{NULL} @var{pointer} value.
-@end deftypefun
-
-This function is used by modules that require a mechanism for explicitly
-setting the per-architecture data-pointer during architecture creation:
+In the below, the attribute nozel is added. An architecture can
+specify its nozel @code{set_gdbarch_nozel}.
@smallexample
-/* Always return a non-NULL nozel. */
-static struct nozel *
-gdbarch_nozel (struct gdbarch *gdbarch)
+static void *
+nozel_pre_init (struct obstack *obstack)
@{
- struct nozel *nozel = gdbarch_data (gdbarch, nozel_handle);
- if (nozel == NULL)
- @{
- nozel = nozel_init (gdbarch);
- set_gdbarch_data (gdbarch, nozel_handle, nozel);
- @}
- return nozel;
+ struct nozel *data = OBSTACK_ZALLOC (obstack, struct nozel);
+ return data;
@}
@end smallexample
@smallexample
-/* Called during architecture creation. */
extern void
set_gdbarch_nozel (struct gdbarch *gdbarch, int total)
@{
- struct nozel *data = gdbarch_nozel (gdbarch);
- @dots{}
- data->total = total;
+ struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
+ data->total = nozel;
@}
@end smallexample
+A module can on-demand create architecture dependant data structures
+using @code{post_init}.
+
+In the below, the nozel's total is computed on-demand by
+@code{nozel_post_init} using information obtained from the
+architecture.
+
@smallexample
-void
-_initialize_nozel (void)
+static void *
+nozel_post_init (struct gdbarch *gdbarch)
@{
- nozel_handle = register_gdbarch_data (nozel_init);
- @dots{}
+ struct nozel *data = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct nozel);
+ nozel->total = gdbarch@dots{} (gdbarch);
+ return data;
+@}
@end smallexample
-@noindent
-Note that an @code{init} function still needs to be registered. It is
-used to initialize the data-pointer when the architecture creation phase
-fail to set an initial value.
-
+@smallexample
+extern int
+nozel_total (struct gdbarch *gdbarch)
+@{
+ struct nozel *data = gdbarch_data (gdbarch, nozel_handle);
+ return data->total;
+@}
+@end smallexample
@section Wrapping Output Lines
@cindex line wrap in output
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.31
diff -u -r1.31 dwarf2-frame.c
--- dwarf2-frame.c 16 Feb 2004 20:32:01 -0000 1.31
+++ dwarf2-frame.c 8 Mar 2004 19:12:02 -0000
@@ -509,29 +509,15 @@
/* Return a default for the architecture-specific operations. */
static void *
-dwarf2_frame_init (struct gdbarch *gdbarch)
+dwarf2_frame_init (struct obstack *obstack)
{
struct dwarf2_frame_ops *ops;
- ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
+ ops = OBSTACK_ZALLOC (obstack, struct dwarf2_frame_ops);
ops->init_reg = dwarf2_frame_default_init_reg;
return ops;
}
-static struct dwarf2_frame_ops *
-dwarf2_frame_ops (struct gdbarch *gdbarch)
-{
- struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- if (ops == NULL)
- {
- /* ULGH, called during architecture initialization. Patch
- things up. */
- ops = dwarf2_frame_init (gdbarch);
- set_gdbarch_data (gdbarch, dwarf2_frame_data, ops);
- }
- return ops;
-}
-
/* Set the architecture-specific register state initialization
function for GDBARCH to INIT_REG. */
@@ -540,9 +526,8 @@
void (*init_reg) (struct gdbarch *, int,
struct dwarf2_frame_state_reg *))
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg = init_reg;
}
@@ -552,9 +537,8 @@
dwarf2_frame_init_reg (struct gdbarch *gdbarch, int regnum,
struct dwarf2_frame_state_reg *reg)
{
- struct dwarf2_frame_ops *ops;
+ struct dwarf2_frame_ops *ops = gdbarch_data (gdbarch, dwarf2_frame_data);
- ops = dwarf2_frame_ops (gdbarch);
ops->init_reg (gdbarch, regnum, reg);
}
\f
@@ -1608,6 +1592,6 @@
void
_initialize_dwarf2_frame (void)
{
- dwarf2_frame_data = register_gdbarch_data (dwarf2_frame_init);
+ dwarf2_frame_data = gdbarch_data_register_pre_init (dwarf2_frame_init);
dwarf2_frame_objfile_data = register_objfile_data ();
}
Index: frame-base.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-base.c,v
retrieving revision 1.8
diff -u -r1.8 frame-base.c
--- frame-base.c 4 Aug 2003 22:24:44 -0000 1.8
+++ frame-base.c 8 Mar 2004 19:12:02 -0000
@@ -92,7 +92,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_base_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_base_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_base_data, table);
}
return table;
}
@@ -146,5 +146,5 @@
void
_initialize_frame_base (void)
{
- frame_base_data = register_gdbarch_data (frame_base_init);
+ frame_base_data = gdbarch_data_register_post_init (frame_base_init);
}
Index: frame-unwind.c
===================================================================
RCS file: /cvs/src/src/gdb/frame-unwind.c,v
retrieving revision 1.8
diff -u -r1.8 frame-unwind.c
--- frame-unwind.c 22 Feb 2004 17:08:42 -0000 1.8
+++ frame-unwind.c 8 Mar 2004 19:12:02 -0000
@@ -63,7 +63,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
table = frame_unwind_init (gdbarch);
- set_gdbarch_data (gdbarch, frame_unwind_data, table);
+ deprecated_set_gdbarch_data (gdbarch, frame_unwind_data, table);
}
append_predicate (table, sniffer);
}
@@ -95,5 +95,5 @@
void
_initialize_frame_unwind (void)
{
- frame_unwind_data = register_gdbarch_data (frame_unwind_init);
+ frame_unwind_data = gdbarch_data_register_post_init (frame_unwind_init);
}
Index: gdb_obstack.h
===================================================================
RCS file: /cvs/src/src/gdb/gdb_obstack.h,v
retrieving revision 1.2
diff -u -r1.2 gdb_obstack.h
--- gdb_obstack.h 9 Feb 2004 23:50:55 -0000 1.2
+++ gdb_obstack.h 8 Mar 2004 19:12:02 -0000
@@ -24,6 +24,12 @@
#include "obstack.h"
+/* Utility macros - wrap obstack alloc into something more robust. */
+
+#define OBSTACK_ZALLOC(OBSTACK,TYPE) (memset (obstack_alloc ((OBSTACK), sizeof (TYPE)), 0, sizeof (TYPE)))
+
+#define OBSTACK_CALLOC(OBSTACK,NUMBER,TYPE) (memset (obstack_alloc ((OBSTACK), (NUMBER) * sizeof (TYPE)), 0, (NUMBER) * sizeof (TYPE)))
+
/* Unless explicitly specified, GDB obstacks always use xmalloc() and
xfree(). */
/* Note: ezannoni 2004-02-09: One could also specify the allocation
Index: gdbarch.sh
===================================================================
RCS file: /cvs/src/src/gdb/gdbarch.sh,v
retrieving revision 1.301
diff -u -r1.301 gdbarch.sh
--- gdbarch.sh 16 Feb 2004 21:49:21 -0000 1.301
+++ gdbarch.sh 8 Mar 2004 19:12:03 -0000
@@ -890,6 +890,7 @@
struct regset;
struct disassemble_info;
struct target_ops;
+struct obstack;
extern struct gdbarch *current_gdbarch;
@@ -1201,10 +1202,6 @@
for the reserved data-pointer is returned. That identifer should
be saved in a local static variable.
- The per-architecture data-pointer is either initialized explicitly
- (set_gdbarch_data()) or implicitly (by INIT() via a call to
- gdbarch_data()).
-
Memory for the per-architecture data shall be allocated using
gdbarch_obstack_zalloc. That memory will be deleted when the
corresponding architecture object is deleted.
@@ -1218,11 +1215,13 @@
struct gdbarch_data;
-typedef void *(gdbarch_data_init_ftype) (struct gdbarch *gdbarch);
-extern struct gdbarch_data *register_gdbarch_data (gdbarch_data_init_ftype *init);
-extern void set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer);
+typedef void *(gdbarch_data_pre_init_ftype) (struct obstack *obstack);
+extern struct gdbarch_data *gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *init);
+typedef void *(gdbarch_data_post_init_ftype) (struct gdbarch *gdbarch);
+extern struct gdbarch_data *gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *init);
+extern void deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer);
extern void *gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *);
@@ -1238,7 +1237,7 @@
Memory regions are swapped / initialized in the order that they are
registered. NULL DATA and/or INIT values can be specified.
- New code should use register_gdbarch_data(). */
+ New code should use gdbarch_data_register_*(). */
typedef void (gdbarch_swap_ftype) (void);
extern void deprecated_register_gdbarch_swap (void *data, unsigned long size, gdbarch_swap_ftype *init);
@@ -1811,7 +1810,8 @@
{
unsigned index;
int init_p;
- gdbarch_data_init_ftype *init;
+ gdbarch_data_pre_init_ftype *pre_init;
+ gdbarch_data_post_init_ftype *post_init;
};
struct gdbarch_data_registration
@@ -1831,8 +1831,9 @@
0, NULL,
};
-struct gdbarch_data *
-register_gdbarch_data (gdbarch_data_init_ftype *init)
+static struct gdbarch_data *
+gdbarch_data_register (gdbarch_data_pre_init_ftype *pre_init,
+ gdbarch_data_post_init_ftype *post_init)
{
struct gdbarch_data_registration **curr;
/* Append the new registraration. */
@@ -1843,11 +1844,23 @@
(*curr)->next = NULL;
(*curr)->data = XMALLOC (struct gdbarch_data);
(*curr)->data->index = gdbarch_data_registry.nr++;
- (*curr)->data->init = init;
+ (*curr)->data->pre_init = pre_init;
+ (*curr)->data->post_init = post_init;
(*curr)->data->init_p = 1;
return (*curr)->data;
}
+struct gdbarch_data *
+gdbarch_data_register_pre_init (gdbarch_data_pre_init_ftype *pre_init)
+{
+ return gdbarch_data_register (pre_init, NULL);
+}
+
+struct gdbarch_data *
+gdbarch_data_register_post_init (gdbarch_data_post_init_ftype *post_init)
+{
+ return gdbarch_data_register (NULL, post_init);
+}
/* Create/delete the gdbarch data vector. */
@@ -1863,12 +1876,13 @@
data-pointer. */
void
-set_gdbarch_data (struct gdbarch *gdbarch,
- struct gdbarch_data *data,
- void *pointer)
+deprecated_set_gdbarch_data (struct gdbarch *gdbarch,
+ struct gdbarch_data *data,
+ void *pointer)
{
gdb_assert (data->index < gdbarch->nr_data);
gdb_assert (gdbarch->data[data->index] == NULL);
+ gdb_assert (data->pre_init == NULL);
gdbarch->data[data->index] = pointer;
}
@@ -1879,18 +1893,33 @@
gdbarch_data (struct gdbarch *gdbarch, struct gdbarch_data *data)
{
gdb_assert (data->index < gdbarch->nr_data);
- /* The data-pointer isn't initialized, call init() to get a value but
- only if the architecture initializaiton has completed. Otherwise
- punt - hope that the caller knows what they are doing. */
- if (gdbarch->data[data->index] == NULL
- && gdbarch->initialized_p)
+ if (gdbarch->data[data->index] == NULL)
{
- /* Be careful to detect an initialization cycle. */
- gdb_assert (data->init_p);
- data->init_p = 0;
- gdb_assert (data->init != NULL);
- gdbarch->data[data->index] = data->init (gdbarch);
- data->init_p = 1;
+ /* The data-pointer isn't initialized, call init() to get a
+ value. */
+ if (data->pre_init != NULL)
+ /* Mid architecture creation: pass just the obstack, and not
+ the entire architecture, as that way it isn't possible for
+ pre-init code to refer to undefined architecture
+ fields. */
+ gdbarch->data[data->index] = data->pre_init (gdbarch->obstack);
+ else if (gdbarch->initialized_p
+ && data->post_init != NULL)
+ /* Post architecture creation: pass the entire architecture
+ (as all fields are valid), but be careful to also detect
+ recursive references. */
+ {
+ gdb_assert (data->init_p);
+ data->init_p = 0;
+ gdbarch->data[data->index] = data->post_init (gdbarch);
+ data->init_p = 1;
+ }
+ else
+ /* The architecture initialization hasn't completed - punt -
+ hope that the caller knows what they are doing. Once
+ deprecated_set_gdbarch_data has been initialized, this can be
+ changed to an internal error. */
+ return NULL;
gdb_assert (gdbarch->data[data->index] != NULL);
}
return gdbarch->data[data->index];
Index: gnu-v3-abi.c
===================================================================
RCS file: /cvs/src/src/gdb/gnu-v3-abi.c,v
retrieving revision 1.20
diff -u -r1.20 gnu-v3-abi.c
--- gnu-v3-abi.c 5 Dec 2003 04:25:09 -0000 1.20
+++ gnu-v3-abi.c 8 Mar 2004 19:12:03 -0000
@@ -422,7 +422,7 @@
static void
init_gnuv3_ops (void)
{
- vtable_type_gdbarch_data = register_gdbarch_data (build_gdb_vtable_type);
+ vtable_type_gdbarch_data = gdbarch_data_register_post_init (build_gdb_vtable_type);
gnu_v3_abi_ops.shortname = "gnu-v3";
gnu_v3_abi_ops.longname = "GNU G++ Version 3 ABI";
Index: libunwind-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/libunwind-frame.c,v
retrieving revision 1.2
diff -u -r1.2 libunwind-frame.c
--- libunwind-frame.c 13 Dec 2003 03:51:56 -0000 1.2
+++ libunwind-frame.c 8 Mar 2004 19:12:03 -0000
@@ -111,7 +111,7 @@
{
/* First time here. Must initialize data area. */
arch_descr = libunwind_descr_init (gdbarch);
- set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
+ deprecated_set_gdbarch_data (gdbarch, libunwind_descr_handle, arch_descr);
}
/* Copy new descriptor info into arch descriptor. */
@@ -381,7 +381,7 @@
void
_initialize_libunwind_frame (void)
{
- libunwind_descr_handle = register_gdbarch_data (libunwind_descr_init);
+ libunwind_descr_handle = gdbarch_data_register_post_init (libunwind_descr_init);
libunwind_initialized = libunwind_load ();
}
Index: mips-linux-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/mips-linux-tdep.c,v
retrieving revision 1.19
diff -u -r1.19 mips-linux-tdep.c
--- mips-linux-tdep.c 14 Feb 2004 04:41:33 -0000 1.19
+++ mips-linux-tdep.c 8 Mar 2004 19:12:03 -0000
@@ -668,7 +668,7 @@
set_mips_linux_register_addr (struct gdbarch *gdbarch,
CORE_ADDR (*register_addr_ptr) (int, CORE_ADDR))
{
- set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
+ deprecated_set_gdbarch_data (gdbarch, register_addr_data, register_addr_ptr);
}
static void *
@@ -844,7 +844,7 @@
const struct bfd_arch_info *arch_info;
register_addr_data =
- register_gdbarch_data (init_register_addr_data);
+ gdbarch_data_register_post_init (init_register_addr_data);
for (arch_info = bfd_lookup_arch (bfd_arch_mips, 0);
arch_info != NULL;
Index: regcache.c
===================================================================
RCS file: /cvs/src/src/gdb/regcache.c,v
retrieving revision 1.109
diff -u -r1.109 regcache.c
--- regcache.c 29 Feb 2004 17:01:38 -0000 1.109
+++ regcache.c 8 Mar 2004 19:12:03 -0000
@@ -1705,7 +1705,7 @@
void
_initialize_regcache (void)
{
- regcache_descr_handle = register_gdbarch_data (init_regcache_descr);
+ regcache_descr_handle = gdbarch_data_register_post_init (init_regcache_descr);
DEPRECATED_REGISTER_GDBARCH_SWAP (current_regcache);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_registers);
DEPRECATED_REGISTER_GDBARCH_SWAP (deprecated_register_valid);
Index: reggroups.c
===================================================================
RCS file: /cvs/src/src/gdb/reggroups.c,v
retrieving revision 1.8
diff -u -r1.8 reggroups.c
--- reggroups.c 22 Aug 2003 09:49:01 -0000 1.8
+++ reggroups.c 8 Mar 2004 19:12:03 -0000
@@ -109,7 +109,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
groups = reggroups_init (gdbarch);
- set_gdbarch_data (gdbarch, reggroups_data, groups);
+ deprecated_set_gdbarch_data (gdbarch, reggroups_data, groups);
}
add_group (groups, group,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct reggroup_el));
@@ -268,7 +268,7 @@
void
_initialize_reggroup (void)
{
- reggroups_data = register_gdbarch_data (reggroups_init);
+ reggroups_data = gdbarch_data_register_post_init (reggroups_init);
/* The pre-defined list of groups. */
add_group (&default_groups, general_reggroup, XMALLOC (struct reggroup_el));
Index: remote.c
===================================================================
RCS file: /cvs/src/src/gdb/remote.c,v
retrieving revision 1.130
diff -u -r1.130 remote.c
--- remote.c 25 Feb 2004 20:41:00 -0000 1.130
+++ remote.c 8 Mar 2004 19:12:06 -0000
@@ -5456,7 +5456,7 @@
struct cmd_list_element *tmpcmd;
/* architecture specific data */
- remote_gdbarch_data_handle = register_gdbarch_data (init_remote_state);
+ remote_gdbarch_data_handle = gdbarch_data_register_post_init (init_remote_state);
/* Old tacky stuff. NOTE: This comes after the remote protocol so
that the remote protocol has been initialized. */
Index: solib-svr4.c
===================================================================
RCS file: /cvs/src/src/gdb/solib-svr4.c,v
retrieving revision 1.41
diff -u -r1.41 solib-svr4.c
--- solib-svr4.c 21 Feb 2004 18:34:45 -0000 1.41
+++ solib-svr4.c 8 Mar 2004 19:12:06 -0000
@@ -1490,7 +1490,7 @@
set_solib_svr4_fetch_link_map_offsets (struct gdbarch *gdbarch,
struct link_map_offsets *(*flmo) (void))
{
- set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
+ deprecated_set_gdbarch_data (gdbarch, fetch_link_map_offsets_gdbarch_data, flmo);
}
/* Initialize the architecture-specific link_map_offsets fetcher.
@@ -1588,7 +1588,7 @@
_initialize_svr4_solib (void)
{
fetch_link_map_offsets_gdbarch_data =
- register_gdbarch_data (init_fetch_link_map_offsets);
+ gdbarch_data_register_post_init (init_fetch_link_map_offsets);
svr4_so_ops.relocate_section_addresses = svr4_relocate_section_addresses;
svr4_so_ops.free_so = svr4_free_so;
Index: user-regs.c
===================================================================
RCS file: /cvs/src/src/gdb/user-regs.c,v
retrieving revision 1.3
diff -u -r1.3 user-regs.c
--- user-regs.c 4 Aug 2003 22:24:44 -0000 1.3
+++ user-regs.c 8 Mar 2004 19:12:07 -0000
@@ -104,7 +104,7 @@
/* ULGH, called during architecture initialization. Patch
things up. */
regs = user_regs_init (gdbarch);
- set_gdbarch_data (gdbarch, user_regs_data, regs);
+ deprecated_set_gdbarch_data (gdbarch, user_regs_data, regs);
}
append_user_reg (regs, name, read,
GDBARCH_OBSTACK_ZALLOC (gdbarch, struct user_reg));
@@ -201,5 +201,5 @@
void
_initialize_user_regs (void)
{
- user_regs_data = register_gdbarch_data (user_regs_init);
+ user_regs_data = gdbarch_data_register_post_init (user_regs_init);
}
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-17 11:30 ` Eli Zaretskii
2004-03-19 0:09 ` Eli Zaretskii
@ 2004-03-19 0:09 ` Andrew Cagney
1 sibling, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: gdb-patches, kettenis
>>Date: Mon, 15 Mar 2004 16:13:25 -0500
>>> From: Andrew Cagney <cagney@gnu.org>
>>>
>>> ok?
>
>
> Yes, thanks.
It's in.
Andrew
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-15 20:44 ` Andrew Cagney
@ 2004-03-19 0:09 ` Andrew Cagney
0 siblings, 0 replies; 19+ messages in thread
From: Andrew Cagney @ 2004-03-19 0:09 UTC (permalink / raw)
To: gdb-patches; +Cc: Mark Kettenis, Eli Zaretskii
I've checked this part in, still working on the doco tweaks.
> 2004-03-07 Andrew Cagney <cagney@redhat.com>
>
> * gdbarch.sh (gdbarch_data_pre_init_fytpe)
> (gdbarch_data_register_pre_init, gdbarch_data_post_init_fytpe)
> (gdbarch_data_register_post_init): Replace gdbarch_data_init_ftype
> and register_gdbarch_data.
> (deprecated_set_gdbarch_data): Rename set_gdbarch_data.
> (struct gdbarch_data): Replace "init" by "pre_init" and
> "post_init".
> * gdbarch.h, gdbarch.c: Re-generate.
> * dwarf2-frame.c (dwarf2_frame_init): Replace "gdbarch" paramter
> with"obstack", use OBSTACK_ZALLOC.
> (dwarf2_frame_ops): Delete.
> (dwarf2_frame_set_init_reg): Use gdbarch_data.
> (dwarf2_frame_init_reg): Use gdbarch_data.
> (_initialize_dwarf2_frame): Use gdbarch_data_register_pre_init.
> * solib-svr4.c (set_solib_svr4_fetch_link_map_offsets)
> (_initialize_svr4_solib): Update.
> * user-regs.c (_initialize_user_regs): Update.
> * reggroups.c (_initialize_reggroup): Update.
> * regcache.c (_initialize_regcache): Update.
> * mips-linux-tdep.c (_initialize_mips_linux_tdep): Update.
> * libunwind-frame.c (_initialize_libunwind_frame): Update.
> * gnu-v3-abi.c (init_gnuv3_ops): Update.
> * frame-unwind.c (_initialize_frame_unwind): Update.
> * frame-base.c (_initialize_frame_base): Update.
> * user-regs.c (user_reg_add): Update.
> * reggroups.c (reggroup_add): Update.
> * mips-linux-tdep.c (set_mips_linux_register_addr): Update.
> * libunwind-frame.c (libunwind_frame_set_descr): Update.
> * frame-unwind.c (frame_unwind_append_sniffer): Update.
> * frame-base.c (frame_base_table): Update.
> * remote.c (_initialize_remote): Update.
> * gdb_obstack.h (OBSTACK_ZALLOC, OBSTACK_CALLOC): Define.
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: [patch/rfc] Separate gdbarch_data_register_pre_init
2004-03-15 19:55 ` Eli Zaretskii
2004-03-15 21:13 ` Andrew Cagney
@ 2004-03-19 0:09 ` Eli Zaretskii
1 sibling, 0 replies; 19+ messages in thread
From: Eli Zaretskii @ 2004-03-19 0:09 UTC (permalink / raw)
To: Andrew Cagney; +Cc: cagney, gdb-patches, kettenis
> Date: Mon, 15 Mar 2004 12:21:07 -0500
> From: Andrew Cagney <cagney@gnu.org>
>
> How does the doco part of this change look?
Looks okay to me, except for the following small gotchas:
> ! @var{post_init} is used to obtain an initial value for a
> ! per-architecture data-pointer @emph{after}. Since @var{post_init} is
> ! always called after architecture creation, it both receives the fully
> ! initialized architecture and is free to call modules that use
> ! per-architecture data (care should be taken to avoid cycles in the
> ! call graph).
> ! @end deftypefun
This sounds like important notes, but they are worded too vaguely,
IMHO. A question that popped up in my mind when I read that was: what
cycles should I avoid in the call graph, and how?
Perhaps an example would help drive these points home.
> ! current value of the per-architecture data-pointer. If the data
> ! pointer is @code{NULL}, it is first initialize by calling the
^^^^^^^^^^^^^^^^^^^^^^
A typo: it should be "initialized".
> ! The examples below assuming the following definitions:
^^^^^^^^
"The examples ... assume ..."
> ! A module can extend the architecture vector, adding additional
> ! per-architecture attributes, using the @var{pre_init} method. These
> ! attribute being set by the architecture's @var{gdbarch_init} method
> ! during architecture creation.
"These attributes are set by the architecture's @var{gdbarch_init}
method ...".
Btw, what ``attributes'' are those? The text doesn't explain that.
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2004-03-19 0:09 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-08 19:28 [patch/rfc] Separate gdbarch_data_register_pre_init Andrew Cagney
2004-03-08 22:41 ` Mark Kettenis
2004-03-19 0:09 ` Mark Kettenis
2004-03-19 0:09 ` Andrew Cagney
2004-03-08 23:51 ` Andrew Cagney
2004-03-15 20:44 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-15 17:21 ` Andrew Cagney
2004-03-15 19:55 ` Eli Zaretskii
2004-03-15 21:13 ` Andrew Cagney
2004-03-17 11:30 ` Eli Zaretskii
2004-03-19 0:09 ` Eli Zaretskii
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-15 21:18 ` Andrew Cagney
2004-03-19 0:09 ` Andrew Cagney
2004-03-19 0:09 ` Eli Zaretskii
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox