Add "target kcore" to gdb53/sparc64.

Taken verbatim from the old gdb in src/gnu/dist/toolchain/gdb.

Approved by: Christos Zoulas <christos@netbsd.org>
This commit is contained in:
hannken 2003-11-04 19:33:39 +00:00
parent a60cfa8cd7
commit 83bd54e877
3 changed files with 61 additions and 1 deletions

View File

@ -28,6 +28,8 @@
#include <sys/types.h>
#include <sys/ptrace.h>
#include <machine/reg.h>
#include <machine/frame.h>
#include <machine/pcb.h>
#ifndef HAVE_GREGSET_T
typedef struct reg gregset_t;
@ -256,3 +258,58 @@ fill_fpregset (fpregset_t *fpregsetp, int regno)
sparcnbsd_fill_fpreg64((char *)fpregsetp, regno);
}
#ifdef FETCH_KCORE_REGISTERS
/*
* Get registers from a kernel crash dump or live kernel.
* Called by kcore-nbsd.c:get_kcore_registers().
*/
void
fetch_kcore_registers (pcb)
struct pcb *pcb;
{
struct rwindow64 win;
int i;
u_long sp;
/* We only do integer registers */
sp = pcb->pcb_sp;
supply_register(SP_REGNUM, (char *)&pcb->pcb_sp);
supply_register(PC_REGNUM, (char *)&pcb->pcb_pc);
supply_register(O7_REGNUM, (char *)&pcb->pcb_pc);
supply_register(PSTATE_REGNUM, (char *)&pcb->pcb_pstate);
supply_register(CWP_REGNUM, (char *)&pcb->pcb_cwp);
/*
* Read last register window saved on stack.
*/
if (sp & 1)
sp += BIAS;
if (target_read_memory(sp, (char *)&win, sizeof win)) {
printf("cannot read register window at sp=%x\n", pcb->pcb_sp);
bzero((char *)&win, sizeof win);
}
for (i = 0; i < sizeof(win.rw_local); ++i)
supply_register(i + L0_REGNUM, (char *)&win.rw_local[i]);
for (i = 0; i < sizeof(win.rw_in); ++i)
supply_register(i + I0_REGNUM, (char *)&win.rw_in[i]);
/*
* read the globals & outs saved on the stack (for a trap frame).
*
* XXXXX This is completely bogus for sparc64.
*/
sp += CC64FSZ; /* XXX - MINFRAME + R_Y */
for (i = 1; i < 14; ++i) {
u_long val;
if (target_read_memory(sp + i*4, (char *)&val, sizeof val) == 0)
supply_register(i, (char *)&val);
}
#if 0
if (kvread(pcb.pcb_cpctxp, &cps) == 0)
supply_register(CPS_REGNUM, (char *)&cps);
#endif
/* The kernel does not use the FPU, so ignore it. */
registers_fetched ();
}
#endif /* FETCH_KCORE_REGISTERS */

View File

@ -1,4 +1,4 @@
# $NetBSD: defs.mk,v 1.3 2003/09/26 17:37:56 christos Exp $
# $NetBSD: defs.mk,v 1.4 2003/11/04 19:33:39 hannken Exp $
#
G_GDB_OBJS=\
annotate.o \
@ -67,6 +67,7 @@ jv-exp.tab.o \
jv-lang.o \
jv-typeprint.o \
jv-valprint.o \
kcore-nbsd.o \
kod-cisco.o \
kod.o \
language.o \

View File

@ -36,6 +36,7 @@ extern initialize_file_ftype _initialize_ser_tcp;
extern initialize_file_ftype _initialize_kernel_u_addr;
extern initialize_file_ftype _initialize_infptrace;
extern initialize_file_ftype _initialize_inftarg;
extern initialize_file_ftype _initialize_kcore_nbsd;
extern initialize_file_ftype _initialize_remote;
extern initialize_file_ftype _initialize_dcache;
extern initialize_file_ftype _initialize_sr_support;
@ -130,6 +131,7 @@ initialize_all_files (void)
_initialize_kernel_u_addr ();
_initialize_infptrace ();
_initialize_inftarg ();
_initialize_kcore_nbsd ();
_initialize_remote ();
_initialize_dcache ();
_initialize_sr_support ();