* [patch/rfa] hppa stub unwinder
@ 2004-04-23 4:00 Randolph Chung
2004-04-23 4:30 ` Daniel Jacobowitz
2004-04-24 0:03 ` Andrew Cagney
0 siblings, 2 replies; 6+ messages in thread
From: Randolph Chung @ 2004-04-23 4:00 UTC (permalink / raw)
To: gdb-patches
Thanks for Andrew's hint, here's a stub unwinder for hppa. Helps us out
in the testsuites quite a bit. okay to checkin?
randolph
2004-04-22 Randolph Chung <tausq@debian.org>
* hppa-tdep.c (hppa_stub_unwind_cache, hppa_stub_frame_unwind_cache)
(hppa_stub_frame_this_id, hppa_stub_frame_prev_register)
(hppa_stub_frame_unwind, hppa_stub_unwind_sniffer): New stub unwinder
for handling stackless frames.
(hppa_gdbarch_init): Link in hppa_stub_unwind_sniffer. Rearrange the
order of unwinder registration vs init_osabi so that additional
osabi-specific unwinders can be hooked in.
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.149
diff -u -p -r1.149 hppa-tdep.c
--- hppa-tdep.c 23 Apr 2004 02:54:21 -0000 1.149
+++ hppa-tdep.c 23 Apr 2004 03:51:21 -0000
@@ -1840,6 +1921,84 @@ hppa_frame_base_sniffer (struct frame_in
return &hppa_frame_base;
}
+/* Stub frames, used for all kinds of call stubs. */
+struct hppa_stub_unwind_cache
+{
+ CORE_ADDR base;
+ struct trad_frame_saved_reg *saved_regs;
+};
+
+static struct hppa_stub_unwind_cache *
+hppa_stub_frame_unwind_cache (struct frame_info *next_frame,
+ void **this_cache)
+{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
+ struct hppa_stub_unwind_cache *info;
+
+ if (*this_cache)
+ return *this_cache;
+
+ info = FRAME_OBSTACK_ZALLOC (struct hppa_stub_unwind_cache);
+ *this_cache = info;
+ info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
+
+ info->saved_regs[PCOQ_HEAD_REGNUM].realreg = RP_REGNUM;
+ info->base = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
+
+ return info;
+}
+
+static void
+hppa_stub_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id)
+{
+ struct hppa_stub_unwind_cache *info
+ = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
+ *this_id = frame_id_build (info->base, frame_pc_unwind (next_frame));
+}
+
+static void
+hppa_stub_frame_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimizedp,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnump, void *bufferp)
+{
+ struct hppa_stub_unwind_cache *info
+ = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
+ int pcoqt = (regnum == PCOQ_TAIL_REGNUM);
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
+ int regsize = register_size (gdbarch, PCOQ_HEAD_REGNUM);
+
+ if (pcoqt)
+ regnum = PCOQ_HEAD_REGNUM;
+
+ trad_frame_prev_register (next_frame, info->saved_regs, regnum,
+ optimizedp, lvalp, addrp, realnump, bufferp);
+
+ if (pcoqt)
+ store_unsigned_integer (bufferp, regsize,
+ extract_unsigned_integer (bufferp, regsize) + 4);
+}
+
+static const struct frame_unwind hppa_stub_frame_unwind = {
+ NORMAL_FRAME,
+ hppa_stub_frame_this_id,
+ hppa_stub_frame_prev_register
+};
+
+static const struct frame_unwind *
+hppa_stub_unwind_sniffer (struct frame_info *next_frame)
+{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+
+ if (IN_SOLIB_CALL_TRAMPOLINE (pc, NULL) ||
+ IN_SOLIB_RETURN_TRAMPOLINE (pc, NULL))
+ return &hppa_stub_frame_unwind;
+ return NULL;
+}
+
static struct frame_id
hppa_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
@@ -2209,19 +2368,23 @@ hppa_gdbarch_init (struct gdbarch_info i
default:
internal_error (__FILE__, __LINE__, "bad switch");
}
-
+
set_gdbarch_breakpoint_from_pc (gdbarch, hppa_breakpoint_from_pc);
+ set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
/* Frame unwind methods. */
set_gdbarch_unwind_dummy_id (gdbarch, hppa_unwind_dummy_id);
set_gdbarch_unwind_pc (gdbarch, hppa_unwind_pc);
- frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
- frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
-
- set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
+
+ /* Hook in the default unwinders. Do this last in case the osabi
+ wants to add additional unwinders. */
+ frame_unwind_append_sniffer (gdbarch, hppa_stub_unwind_sniffer);
+ frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
+ frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
+ frame_base_set_default (gdbarch, &hppa_frame_base);
return gdbarch;
}
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch/rfa] hppa stub unwinder
2004-04-23 4:00 [patch/rfa] hppa stub unwinder Randolph Chung
@ 2004-04-23 4:30 ` Daniel Jacobowitz
2004-04-24 0:03 ` Andrew Cagney
1 sibling, 0 replies; 6+ messages in thread
From: Daniel Jacobowitz @ 2004-04-23 4:30 UTC (permalink / raw)
To: Randolph Chung; +Cc: gdb-patches
On Thu, Apr 22, 2004 at 09:01:08PM -0700, Randolph Chung wrote:
> +static const struct frame_unwind *
> +hppa_stub_unwind_sniffer (struct frame_info *next_frame)
> +{
> + CORE_ADDR pc = frame_pc_unwind (next_frame);
> +
> + if (IN_SOLIB_CALL_TRAMPOLINE (pc, NULL) ||
> + IN_SOLIB_RETURN_TRAMPOLINE (pc, NULL))
> + return &hppa_stub_frame_unwind;
> + return NULL;
> +}
Formatting - || at the beginning of the line.
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch/rfa] hppa stub unwinder
2004-04-23 4:00 [patch/rfa] hppa stub unwinder Randolph Chung
2004-04-23 4:30 ` Daniel Jacobowitz
@ 2004-04-24 0:03 ` Andrew Cagney
2004-04-24 6:17 ` Randolph Chung
2004-04-24 6:47 ` Randolph Chung
1 sibling, 2 replies; 6+ messages in thread
From: Andrew Cagney @ 2004-04-24 0:03 UTC (permalink / raw)
To: Randolph Chung; +Cc: gdb-patches
> Thanks for Andrew's hint, here's a stub unwinder for hppa. Helps us out
> in the testsuites quite a bit. okay to checkin?
(FYI, Ulrich came up with the theory. Yes it works well -> keeps each
unwinder focused and simple (far cry from the old way :-)).
It's ok as is (with coding tweaks). One option, though is to instead of:
> - frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
> - frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
> -
> - set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
>
> /* Hook in ABI-specific overrides, if they have been registered. */
> gdbarch_init_osabi (info, gdbarch);
> +
> + /* Hook in the default unwinders. Do this last in case the osabi
> + wants to add additional unwinders. */
> + frame_unwind_append_sniffer (gdbarch, hppa_stub_unwind_sniffer);
> + frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
> + frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
> + frame_base_set_default (gdbarch, &hppa_frame_base);
use frame_unwind_prepend_unwinder() which addresses the ordering
problem. If you want to convert things, it's pre-approved.
> randolph
>
>
> 2004-04-22 Randolph Chung <tausq@debian.org>
>
> * hppa-tdep.c (hppa_stub_unwind_cache, hppa_stub_frame_unwind_cache)
> (hppa_stub_frame_this_id, hppa_stub_frame_prev_register)
> (hppa_stub_frame_unwind, hppa_stub_unwind_sniffer): New stub unwinder
> for handling stackless frames.
> (hppa_gdbarch_init): Link in hppa_stub_unwind_sniffer. Rearrange the
> order of unwinder registration vs init_osabi so that additional
> osabi-specific unwinders can be hooked in.
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch/rfa] hppa stub unwinder
2004-04-24 0:03 ` Andrew Cagney
@ 2004-04-24 6:17 ` Randolph Chung
2004-04-24 6:47 ` Randolph Chung
1 sibling, 0 replies; 6+ messages in thread
From: Randolph Chung @ 2004-04-24 6:17 UTC (permalink / raw)
To: gdb-patches
> It's ok as is (with coding tweaks). One option, though is to instead of:
Final version attached.
2004-04-23 Randolph Chung <tausq@debian.org>
* hppa-tdep.c (hppa_stub_unwind_cache, hppa_stub_frame_unwind_cache)
(hppa_stub_frame_this_id, hppa_stub_frame_prev_register)
(hppa_stub_frame_unwind, hppa_stub_unwind_sniffer): New stub unwinder
for handling stackless frames.
(hppa_gdbarch_init): Link in hppa_stub_unwind_sniffer.
Index: hppa-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/hppa-tdep.c,v
retrieving revision 1.150
diff -u -p -r1.150 hppa-tdep.c
--- hppa-tdep.c 24 Apr 2004 06:10:01 -0000 1.150
+++ hppa-tdep.c 24 Apr 2004 06:12:43 -0000
@@ -1898,6 +1898,84 @@ hppa_frame_base_sniffer (struct frame_in
return &hppa_frame_base;
}
+/* Stub frames, used for all kinds of call stubs. */
+struct hppa_stub_unwind_cache
+{
+ CORE_ADDR base;
+ struct trad_frame_saved_reg *saved_regs;
+};
+
+static struct hppa_stub_unwind_cache *
+hppa_stub_frame_unwind_cache (struct frame_info *next_frame,
+ void **this_cache)
+{
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
+ struct hppa_stub_unwind_cache *info;
+
+ if (*this_cache)
+ return *this_cache;
+
+ info = FRAME_OBSTACK_ZALLOC (struct hppa_stub_unwind_cache);
+ *this_cache = info;
+ info->saved_regs = trad_frame_alloc_saved_regs (next_frame);
+
+ info->saved_regs[PCOQ_HEAD_REGNUM].realreg = RP_REGNUM;
+ info->base = frame_unwind_register_unsigned (next_frame, HPPA_SP_REGNUM);
+
+ return info;
+}
+
+static void
+hppa_stub_frame_this_id (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ struct frame_id *this_id)
+{
+ struct hppa_stub_unwind_cache *info
+ = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
+ *this_id = frame_id_build (info->base, frame_pc_unwind (next_frame));
+}
+
+static void
+hppa_stub_frame_prev_register (struct frame_info *next_frame,
+ void **this_prologue_cache,
+ int regnum, int *optimizedp,
+ enum lval_type *lvalp, CORE_ADDR *addrp,
+ int *realnump, void *bufferp)
+{
+ struct hppa_stub_unwind_cache *info
+ = hppa_stub_frame_unwind_cache (next_frame, this_prologue_cache);
+ int pcoqt = (regnum == PCOQ_TAIL_REGNUM);
+ struct gdbarch *gdbarch = get_frame_arch (next_frame);
+ int regsize = register_size (gdbarch, PCOQ_HEAD_REGNUM);
+
+ if (pcoqt)
+ regnum = PCOQ_HEAD_REGNUM;
+
+ trad_frame_prev_register (next_frame, info->saved_regs, regnum,
+ optimizedp, lvalp, addrp, realnump, bufferp);
+
+ if (pcoqt)
+ store_unsigned_integer (bufferp, regsize,
+ extract_unsigned_integer (bufferp, regsize) + 4);
+}
+
+static const struct frame_unwind hppa_stub_frame_unwind = {
+ NORMAL_FRAME,
+ hppa_stub_frame_this_id,
+ hppa_stub_frame_prev_register
+};
+
+static const struct frame_unwind *
+hppa_stub_unwind_sniffer (struct frame_info *next_frame)
+{
+ CORE_ADDR pc = frame_pc_unwind (next_frame);
+
+ if (IN_SOLIB_CALL_TRAMPOLINE (pc, NULL)
+ || IN_SOLIB_RETURN_TRAMPOLINE (pc, NULL))
+ return &hppa_stub_frame_unwind;
+ return NULL;
+}
+
static struct frame_id
hppa_unwind_dummy_id (struct gdbarch *gdbarch, struct frame_info *next_frame)
{
@@ -2267,16 +2345,18 @@ hppa_gdbarch_init (struct gdbarch_info i
default:
internal_error (__FILE__, __LINE__, "bad switch");
}
-
+
set_gdbarch_breakpoint_from_pc (gdbarch, hppa_breakpoint_from_pc);
+ set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
/* Frame unwind methods. */
set_gdbarch_unwind_dummy_id (gdbarch, hppa_unwind_dummy_id);
set_gdbarch_unwind_pc (gdbarch, hppa_unwind_pc);
+
+ /* Hook in the default unwinders. */
+ frame_unwind_append_sniffer (gdbarch, hppa_stub_unwind_sniffer);
frame_unwind_append_sniffer (gdbarch, hppa_frame_unwind_sniffer);
frame_base_append_sniffer (gdbarch, hppa_frame_base_sniffer);
-
- set_gdbarch_pseudo_register_read (gdbarch, hppa_pseudo_register_read);
/* Hook in ABI-specific overrides, if they have been registered. */
gdbarch_init_osabi (info, gdbarch);
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch/rfa] hppa stub unwinder
2004-04-24 0:03 ` Andrew Cagney
2004-04-24 6:17 ` Randolph Chung
@ 2004-04-24 6:47 ` Randolph Chung
2004-04-28 15:49 ` Andrew Cagney
1 sibling, 1 reply; 6+ messages in thread
From: Randolph Chung @ 2004-04-24 6:47 UTC (permalink / raw)
To: Andrew Cagney; +Cc: gdb-patches
> use frame_unwind_prepend_unwinder() which addresses the ordering
> problem. If you want to convert things, it's pre-approved.
I removed that chunk of the diff in the commited version. If needed will
reintroduce later.
I looked at frame_unwind_prepend_unwinder (), but it doesn't let me
prepend a *sniffer*, so I don't know how to e.g. prepend a sigtramp
unwinder -- how do i indicate that this unwinder is the wrong one
at runtime?
thanks
randolph
--
Randolph Chung
Debian GNU/Linux Developer, hppa/ia64 ports
http://www.tausq.org/
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [patch/rfa] hppa stub unwinder
2004-04-24 6:47 ` Randolph Chung
@ 2004-04-28 15:49 ` Andrew Cagney
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Cagney @ 2004-04-28 15:49 UTC (permalink / raw)
To: Randolph Chung; +Cc: gdb-patches
>>use frame_unwind_prepend_unwinder() which addresses the ordering
>>> problem. If you want to convert things, it's pre-approved.
>
>
> I removed that chunk of the diff in the commited version. If needed will
> reintroduce later.
>
> I looked at frame_unwind_prepend_unwinder (), but it doesn't let me
> prepend a *sniffer*, so I don't know how to e.g. prepend a sigtramp
> unwinder -- how do i indicate that this unwinder is the wrong one
> at runtime?
Sniffers were recently added to the unwinders as ``optional static
methods'' (I use the term loosely). "tramp-frame.c" uses this
(tramp_frame_sniffer).
Andrew
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-04-28 15:49 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-04-23 4:00 [patch/rfa] hppa stub unwinder Randolph Chung
2004-04-23 4:30 ` Daniel Jacobowitz
2004-04-24 0:03 ` Andrew Cagney
2004-04-24 6:17 ` Randolph Chung
2004-04-24 6:47 ` Randolph Chung
2004-04-28 15:49 ` Andrew Cagney
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox