* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
@ 2004-02-16 1:28 Ulrich Weigand
2004-02-16 1:56 ` Daniel Jacobowitz
0 siblings, 1 reply; 9+ messages in thread
From: Ulrich Weigand @ 2004-02-16 1:28 UTC (permalink / raw)
To: kettenis; +Cc: gdb-patches, cagney
Mark Kettenis wrote:
+/* Return a default for the architecture-specific operations. */
+
+static void *
+dwarf2_frame_init (struct gdbarch *gdbarch)
+{
+ struct dwarf2_frame_ops *ops;
+
+ ops = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct dwarf2_frame_ops);
+ ops->init_reg = dwarf2_frame_default_init_reg;
+ return ops;
+}
+
+/* Set the architecture-specific register state initialization
+ function for GDBARCH to INIT_REG. */
+
+void
+dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
+ void (*init_reg) (struct gdbarch *, int,
+ struct dwarf2_frame_state_reg *))
+{
+ struct dwarf2_frame_ops *ops;
+
+ ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+ ops->init_reg = init_reg;
+}
Unfortunately this now crashes on s390, because the
dwarf2_frame_init routine is called from within
_initialize_dwarf2_frame, while the s390 backend calls
dwarf2_frame_set_init_reg from within _initialize_s390_tdep.
Now, in the generated initialize_all_files routine, the
s390_tdep init routine is called *before* the dwarf2_frame
one, and hence dwarf2_frame_set_init_reg gets called before
dwarf2_frame_init.
Thus, the gdbarch_data call returns NULL, and the assignment
to ops->init_reg crashes.
Is there some usual way to solve this sort of init-order
issues with the gdb init sequence?
Bye,
Ulrich
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-16 1:28 [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks Ulrich Weigand
@ 2004-02-16 1:56 ` Daniel Jacobowitz
2004-02-16 13:01 ` Ulrich Weigand
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2004-02-16 1:56 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: kettenis, gdb-patches, cagney
On Mon, Feb 16, 2004 at 02:27:24AM +0100, Ulrich Weigand wrote:
> +void
> +dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
> + void (*init_reg) (struct gdbarch *, int,
> + struct dwarf2_frame_state_reg *))
> Unfortunately this now crashes on s390, because the
> dwarf2_frame_init routine is called from within
> _initialize_dwarf2_frame, while the s390 backend calls
> dwarf2_frame_set_init_reg from within _initialize_s390_tdep.
Er, how? You shouldn't have a gdbarch in _initialize_s390_tdep. You
don't have one until s390_gdbarch_init.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-16 1:56 ` Daniel Jacobowitz
@ 2004-02-16 13:01 ` Ulrich Weigand
2004-02-16 19:47 ` Daniel Jacobowitz
0 siblings, 1 reply; 9+ messages in thread
From: Ulrich Weigand @ 2004-02-16 13:01 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Ulrich Weigand, kettenis, gdb-patches, cagney
Daniel Jacobowitz wrote:
> On Mon, Feb 16, 2004 at 02:27:24AM +0100, Ulrich Weigand wrote:
> > +void
> > +dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
> > + void (*init_reg) (struct gdbarch *, int,
> > + struct dwarf2_frame_state_reg *))
>
> > Unfortunately this now crashes on s390, because the
> > dwarf2_frame_init routine is called from within
> > _initialize_dwarf2_frame, while the s390 backend calls
> > dwarf2_frame_set_init_reg from within _initialize_s390_tdep.
>
> Er, how? You shouldn't have a gdbarch in _initialize_s390_tdep. You
> don't have one until s390_gdbarch_init.
Sorry, my analysis wasn't completely correct. What actually happens
is an init-order problem during the initialization of the gdbarch
in initialize_current_architecture. The problem is that I call
dwarf2_frame_set_init_reg from within the s390_gdbarch_init routine
(which I gather is the right place?), and at this point in time,
the gdbarch_data call in dwarf2_frame_set_init_reg returns NULL
because the gdbarch hasn't finished initialization yet:
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)
Bye,
Ulrich
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-16 13:01 ` Ulrich Weigand
@ 2004-02-16 19:47 ` Daniel Jacobowitz
2004-02-16 20:50 ` Andrew Cagney
0 siblings, 1 reply; 9+ messages in thread
From: Daniel Jacobowitz @ 2004-02-16 19:47 UTC (permalink / raw)
To: Ulrich Weigand; +Cc: kettenis, gdb-patches, cagney
On Mon, Feb 16, 2004 at 02:01:29PM +0100, Ulrich Weigand wrote:
> Daniel Jacobowitz wrote:
>
> > On Mon, Feb 16, 2004 at 02:27:24AM +0100, Ulrich Weigand wrote:
> > > +void
> > > +dwarf2_frame_set_init_reg (struct gdbarch *gdbarch,
> > > + void (*init_reg) (struct gdbarch *, int,
> > > + struct dwarf2_frame_state_reg *))
> >
> > > Unfortunately this now crashes on s390, because the
> > > dwarf2_frame_init routine is called from within
> > > _initialize_dwarf2_frame, while the s390 backend calls
> > > dwarf2_frame_set_init_reg from within _initialize_s390_tdep.
> >
> > Er, how? You shouldn't have a gdbarch in _initialize_s390_tdep. You
> > don't have one until s390_gdbarch_init.
>
> Sorry, my analysis wasn't completely correct. What actually happens
> is an init-order problem during the initialization of the gdbarch
> in initialize_current_architecture. The problem is that I call
> dwarf2_frame_set_init_reg from within the s390_gdbarch_init routine
> (which I gather is the right place?), and at this point in time,
> the gdbarch_data call in dwarf2_frame_set_init_reg returns NULL
> because the gdbarch hasn't finished initialization yet:
>
> 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)
Oopsie. Yes, now I can see what's going on - I'm not sure what should
change here. Andrew, do you recall if the initialized_p check was for
any specific problem, or might we be able to remove it?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-16 19:47 ` Daniel Jacobowitz
@ 2004-02-16 20:50 ` Andrew Cagney
2004-02-16 20:55 ` Andrew Cagney
2004-02-16 21:31 ` [PATCH/RFC] Per-architecture DWARF CFI register state initialization Ulrich Weigand
0 siblings, 2 replies; 9+ messages in thread
From: Andrew Cagney @ 2004-02-16 20:50 UTC (permalink / raw)
To: Daniel Jacobowitz; +Cc: Ulrich Weigand, kettenis, gdb-patches
>> Sorry, my analysis wasn't completely correct. What actually happens
>> is an init-order problem during the initialization of the gdbarch
>> in initialize_current_architecture. The problem is that I call
>> dwarf2_frame_set_init_reg from within the s390_gdbarch_init routine
>> (which I gather is the right place?), and at this point in time,
>> the gdbarch_data call in dwarf2_frame_set_init_reg returns NULL
>> because the gdbarch hasn't finished initialization yet:
I've committed the attatched. It follows the convention described in
that revised doco patch I posted:
http://sources.redhat.com/ml/gdb-patches/2004-02/msg00381.html
Andrew
>> 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)
>
>
> Oopsie. Yes, now I can see what's going on - I'm not sure what should
> change here. Andrew, do you recall if the initialized_p check was for
> any specific problem, or might we be able to remove it?
>
> -- Daniel Jacobowitz MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-16 20:50 ` Andrew Cagney
@ 2004-02-16 20:55 ` Andrew Cagney
2004-02-18 16:59 ` Mark Kettenis
2004-02-16 21:31 ` [PATCH/RFC] Per-architecture DWARF CFI register state initialization Ulrich Weigand
1 sibling, 1 reply; 9+ messages in thread
From: Andrew Cagney @ 2004-02-16 20:55 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Daniel Jacobowitz, Ulrich Weigand, kettenis, gdb-patches
[-- Attachment #1: Type: text/plain, Size: 673 bytes --]
>
> Sorry, my analysis wasn't completely correct. What actually happens
> is an init-order problem during the initialization of the gdbarch
> in initialize_current_architecture. The problem is that I call
> dwarf2_frame_set_init_reg from within the s390_gdbarch_init routine
> (which I gather is the right place?), and at this point in time,
> the gdbarch_data call in dwarf2_frame_set_init_reg returns NULL
> because the gdbarch hasn't finished initialization yet:
>
> I've committed the attatched. It follows the convention described in that revised doco patch I posted:
> http://sources.redhat.com/ml/gdb-patches/2004-02/msg00381.html
>
> Andrew
with patch ...
[-- Attachment #2: diffs --]
[-- Type: text/plain, Size: 1408 bytes --]
2004-02-16 Andrew Cagney <cagney@redhat.com>
* dwarf2-frame.c (dwarf2_frame_ops): New function.
(dwarf2_frame_set_init_reg): Use, instead of gdbarch_data.
(dwarf2_frame_init_reg): Ditto.
Index: dwarf2-frame.c
===================================================================
RCS file: /cvs/src/src/gdb/dwarf2-frame.c,v
retrieving revision 1.30
diff -u -r1.30 dwarf2-frame.c
--- dwarf2-frame.c 15 Feb 2004 21:29:26 -0000 1.30
+++ dwarf2-frame.c 16 Feb 2004 20:28:01 -0000
@@ -518,6 +518,20 @@
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. */
@@ -528,7 +542,7 @@
{
struct dwarf2_frame_ops *ops;
- ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+ ops = dwarf2_frame_ops (gdbarch);
ops->init_reg = init_reg;
}
@@ -540,7 +554,7 @@
{
struct dwarf2_frame_ops *ops;
- ops = gdbarch_data (gdbarch, dwarf2_frame_data);
+ ops = dwarf2_frame_ops (gdbarch);
ops->init_reg (gdbarch, regnum, reg);
}
\f
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization
2004-02-16 20:50 ` Andrew Cagney
2004-02-16 20:55 ` Andrew Cagney
@ 2004-02-16 21:31 ` Ulrich Weigand
1 sibling, 0 replies; 9+ messages in thread
From: Ulrich Weigand @ 2004-02-16 21:31 UTC (permalink / raw)
To: Andrew Cagney; +Cc: Daniel Jacobowitz, Ulrich Weigand, kettenis, gdb-patches
Andrew Cagney wrote:
> I've committed the attatched. It follows the convention described in
> that revised doco patch I posted:
> http://sources.redhat.com/ml/gdb-patches/2004-02/msg00381.html
This fixes the problem I was seeing. Using DWARF-2 frames now works
on s390 without any changes to common code. :-)
Thanks!
Ulrich
--
Dr. Ulrich Weigand
weigand@informatik.uni-erlangen.de
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-16 20:55 ` Andrew Cagney
@ 2004-02-18 16:59 ` Mark Kettenis
2004-02-18 18:40 ` Andrew Cagney
0 siblings, 1 reply; 9+ messages in thread
From: Mark Kettenis @ 2004-02-18 16:59 UTC (permalink / raw)
To: cagney; +Cc: cagney, drow, weigand, gdb-patches
Date: Mon, 16 Feb 2004 15:55:52 -0500
From: Andrew Cagney <cagney@gnu.org>
> I've committed the attatched. It follows the convention
> described in that revised doco patch I posted:
> http://sources.redhat.com/ml/gdb-patches/2004-02/msg00381.html
>
> Andrew
with patch ...
2004-02-16 Andrew Cagney <cagney@redhat.com>
* dwarf2-frame.c (dwarf2_frame_ops): New function.
(dwarf2_frame_set_init_reg): Use, instead of gdbarch_data.
(dwarf2_frame_init_reg): Ditto.
Thanks Andrew. Can't say I'm too happy with yet another function, but
if that's the it's supposed to work... Perhaps we should revisit the
way these per-architecture keys work someday.
Mark
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks
2004-02-18 16:59 ` Mark Kettenis
@ 2004-02-18 18:40 ` Andrew Cagney
0 siblings, 0 replies; 9+ messages in thread
From: Andrew Cagney @ 2004-02-18 18:40 UTC (permalink / raw)
To: Mark Kettenis; +Cc: drow, weigand, gdb-patches
> Thanks Andrew. Can't say I'm too happy with yet another function, but
> if that's the it's supposed to work... Perhaps we should revisit the
> way these per-architecture keys work someday.
It's how it works. Revising how it is supposed to work at some stage
would be useful..
Andrew
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2004-02-18 18:40 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-16 1:28 [PATCH/RFC] Per-architecture DWARF CFI register state initialization hooks Ulrich Weigand
2004-02-16 1:56 ` Daniel Jacobowitz
2004-02-16 13:01 ` Ulrich Weigand
2004-02-16 19:47 ` Daniel Jacobowitz
2004-02-16 20:50 ` Andrew Cagney
2004-02-16 20:55 ` Andrew Cagney
2004-02-18 16:59 ` Mark Kettenis
2004-02-18 18:40 ` Andrew Cagney
2004-02-16 21:31 ` [PATCH/RFC] Per-architecture DWARF CFI register state initialization Ulrich Weigand
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox