Add a kluge to allow kgdb(1) to inject its own frame sniffer in the

list of frame sniffers so that trapframes can be detected. The kluge
is needed because this version of gdb only supports appending a
sniffer to the list of sniffers and the moment kgdb gets a chance to
add its own frame sniffer, the target's default frame sniffer is
already in the list. Since the default frame sniffer claims any
frame thrown at it, kgdb's frame sniffer never gets to smell (a
process much akin to tasting, but with lesser chance of hurling :-)

This commit adds dummy frame sniffers that never claim a frame and
as such don't fix anything yet. However, we now have frame sniffers
and they are being called, so it's just a matter of adding meat to
the bones and we'll be able to properly unwind across trapframes.

MFC after: 1 week
This commit is contained in:
marcel 2005-09-10 18:25:53 +00:00
parent 756320bcbb
commit d05b9c6e82
11 changed files with 188 additions and 13 deletions

View File

@ -29,7 +29,7 @@
#ifndef _KGDB_H_
#define _KGDB_H_
struct thread_info;
struct thread_info;
extern kvm_t *kvm;
extern int verbose;
@ -50,6 +50,8 @@ void kgdb_target(void);
void kgdb_trgt_fetch_registers(int);
void kgdb_trgt_store_registers(int);
frame_unwind_sniffer_ftype kgdb_trgt_trapframe_sniffer;
struct kthr *kgdb_thr_first(void);
struct kthr *kgdb_thr_init(void);
struct kthr *kgdb_thr_lookup_tid(int);

View File

@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$");
#include <stdlib.h>
#include <defs.h>
#include <frame-unwind.h>
#include "kgdb.h"

View File

@ -50,6 +50,7 @@ __FBSDID("$FreeBSD$");
/* libgdb stuff. */
#include <defs.h>
#include <frame.h>
#include <frame-unwind.h>
#include <inferior.h>
#include <interps.h>
#include <cli-out.h>
@ -61,6 +62,8 @@ __FBSDID("$FreeBSD$");
extern void (*init_ui_hook)(char *);
extern frame_unwind_sniffer_ftype *kgdb_sniffer_kluge;
extern void symbol_file_add_main (char *args, int from_tty);
#include "kgdb.h"
@ -478,5 +481,7 @@ main(int argc, char *argv[])
init_ui_hook = kgdb_init;
kgdb_sniffer_kluge = kgdb_trgt_trapframe_sniffer;
return (gdb_main(&args));
}

View File

@ -35,6 +35,7 @@ __FBSDID("$FreeBSD$");
#include <defs.h>
#include <command.h>
#include <frame-unwind.h>
#include <gdbthread.h>
#include <inferior.h>
#include <regcache.h>

View File

@ -33,13 +33,14 @@ __FBSDID("$FreeBSD$");
#include <kvm.h>
#include <string.h>
#include "kgdb.h"
#include <defs.h>
#include <target.h>
#include <gdbthread.h>
#include <inferior.h>
#include <regcache.h>
#include <frame-unwind.h>
#include "kgdb.h"
void
kgdb_trgt_fetch_registers(int regno __unused)
@ -71,3 +72,29 @@ kgdb_trgt_store_registers(int regno __unused)
{
fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__);
}
static void
kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache,
struct frame_id *this_id)
{
}
static void
kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame,
void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump, void *valuep)
{
}
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
UNKNOWN_FRAME,
&kgdb_trgt_trapframe_this_id,
&kgdb_trgt_trapframe_prev_register
};
const struct frame_unwind *
kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
{
return (NULL);
}

View File

@ -33,13 +33,14 @@ __FBSDID("$FreeBSD$");
#include <kvm.h>
#include <string.h>
#include "kgdb.h"
#include <defs.h>
#include <target.h>
#include <gdbthread.h>
#include <inferior.h>
#include <regcache.h>
#include <frame-unwind.h>
#include "kgdb.h"
void
kgdb_trgt_fetch_registers(int regno __unused)
@ -71,3 +72,29 @@ kgdb_trgt_store_registers(int regno __unused)
{
fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__);
}
static void
kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache,
struct frame_id *this_id)
{
}
static void
kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame,
void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump, void *valuep)
{
}
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
UNKNOWN_FRAME,
&kgdb_trgt_trapframe_this_id,
&kgdb_trgt_trapframe_prev_register
};
const struct frame_unwind *
kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
{
return (NULL);
}

View File

@ -33,13 +33,14 @@ __FBSDID("$FreeBSD$");
#include <kvm.h>
#include <string.h>
#include "kgdb.h"
#include <defs.h>
#include <target.h>
#include <gdbthread.h>
#include <inferior.h>
#include <regcache.h>
#include <frame-unwind.h>
#include "kgdb.h"
void
kgdb_trgt_fetch_registers(int regno __unused)
@ -67,3 +68,29 @@ kgdb_trgt_store_registers(int regno __unused)
{
fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__);
}
static void
kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache,
struct frame_id *this_id)
{
}
static void
kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame,
void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump, void *valuep)
{
}
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
UNKNOWN_FRAME,
&kgdb_trgt_trapframe_this_id,
&kgdb_trgt_trapframe_prev_register
};
const struct frame_unwind *
kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
{
return (NULL);
}

View File

@ -34,13 +34,14 @@ __FBSDID("$FreeBSD$");
#include <kvm.h>
#include <string.h>
#include "kgdb.h"
#include <defs.h>
#include <target.h>
#include <gdbthread.h>
#include <inferior.h>
#include <regcache.h>
#include <frame-unwind.h>
#include "kgdb.h"
void
kgdb_trgt_fetch_registers(int regno __unused)
@ -131,3 +132,29 @@ kgdb_trgt_store_registers(int regno __unused)
{
fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__);
}
static void
kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache,
struct frame_id *this_id)
{
}
static void
kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame,
void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump, void *valuep)
{
}
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
UNKNOWN_FRAME,
&kgdb_trgt_trapframe_this_id,
&kgdb_trgt_trapframe_prev_register
};
const struct frame_unwind *
kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
{
return (NULL);
}

View File

@ -34,16 +34,17 @@ __FBSDID("$FreeBSD$");
#include <kvm.h>
#include <string.h>
#include "kgdb.h"
#include <defs.h>
#include <target.h>
#include <gdbthread.h>
#include <inferior.h>
#include <regcache.h>
#include <frame-unwind.h>
#include <sparc-tdep.h>
#include <sparc64-tdep.h>
#include "kgdb.h"
void
kgdb_trgt_fetch_registers(int regno __unused)
{
@ -70,3 +71,29 @@ kgdb_trgt_store_registers(int regno __unused)
{
fprintf_unfiltered(gdb_stderr, "XXX: %s\n", __func__);
}
static void
kgdb_trgt_trapframe_this_id(struct frame_info *next_frame, void **this_cache,
struct frame_id *this_id)
{
}
static void
kgdb_trgt_trapframe_prev_register(struct frame_info *next_frame,
void **this_cache, int regnum, int *optimizedp, enum lval_type *lvalp,
CORE_ADDR *addrp, int *realnump, void *valuep)
{
}
static const struct frame_unwind kgdb_trgt_trapframe_unwind = {
UNKNOWN_FRAME,
&kgdb_trgt_trapframe_this_id,
&kgdb_trgt_trapframe_prev_register
};
const struct frame_unwind *
kgdb_trgt_trapframe_sniffer(struct frame_info *next_frame)
{
return (NULL);
}

View File

@ -18,7 +18,7 @@ SRCS= annotate.c arch-utils.c auxv.c ax-gdb.c ax-general.c \
elfread.c environ.c eval.c event-loop.c event-top.c exec.c \
expprint.c \
f-exp.y f-lang.c f-typeprint.c f-valprint.c findvar.c \
${_fork_child} frame-base.c frame-unwind.c frame.c \
${_fork_child} frame-base.c frame-unwind-kluge.c frame.c \
gdb-events.c gdbarch.c gdbtypes.c gnu-v2-abi.c gnu-v3-abi.c \
hpacc-abi.c \
inf-loop.c infcall.c infcmd.c inflow.c ${_infptrace} infrun.c \
@ -59,7 +59,11 @@ _infptrace= infptrace.c
_inftarg= inftarg.c
.endif
GENSRCS= version.c
GENSRCS= frame-unwind-kluge.c version.c
frame-unwind-kluge.c: frame-unwind.diff
cat ${CNTRB_GDB}/gdb/frame-unwind.c > ${.TARGET}
patch ${.TARGET} ${.ALLSRC}
version.c:
echo '#include "version.h"' > ${.TARGET}

View File

@ -0,0 +1,27 @@
$FreeBSD$
Index: frame-unwind.c
===================================================================
RCS file: /home/ncvs/src/contrib/gdb/gdb/frame-unwind.c,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 frame-unwind.c
--- frame-unwind.c 20 Jun 2004 18:16:58 -0000 1.1.1.1
+++ frame-unwind.c 10 Sep 2005 06:36:55 -0000
@@ -27,6 +27,8 @@
static struct gdbarch_data *frame_unwind_data;
+frame_unwind_sniffer_ftype *kgdb_sniffer_kluge;
+
struct frame_unwind_table
{
frame_unwind_sniffer_ftype **sniffer;
@@ -49,6 +51,8 @@
{
struct frame_unwind_table *table = XCALLOC (1, struct frame_unwind_table);
append_predicate (table, dummy_frame_sniffer);
+ if (kgdb_sniffer_kluge != NULL)
+ append_predicate (table, kgdb_sniffer_kluge);
return table;
}