diff options
| author | pk <pk@NetBSD.org> | 1994-05-17 14:01:44 +0000 |
|---|---|---|
| committer | pk <pk@NetBSD.org> | 1994-05-17 14:01:44 +0000 |
| commit | 67c44985d71a402ccd84434fcefae2a8efb72d13 (patch) | |
| tree | 9aa241cafd688bcb4146f1a0317e764bb2a52319 /gnu/usr.bin | |
| parent | be4f78724bb9cdaae97d8ab1532436efb84b0acb (diff) | |
Framework for kernel debugging, needs more work.
Diffstat (limited to 'gnu/usr.bin')
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/Makefile | 10 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/arch/i386/i386b-nat.c | 32 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/arch/sparc/sparc-nat.c | 57 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/defs.h | 5 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/gdbcore.h | 5 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/init.c | 3 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/main.c | 21 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/target.c | 6 | ||||
| -rw-r--r-- | gnu/usr.bin/gdb/gdb/target.h | 5 |
9 files changed, 132 insertions, 12 deletions
diff --git a/gnu/usr.bin/gdb/gdb/Makefile b/gnu/usr.bin/gdb/gdb/Makefile index d644ebb7a3a..1da950e72e2 100644 --- a/gnu/usr.bin/gdb/gdb/Makefile +++ b/gnu/usr.bin/gdb/gdb/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.4 1994/02/03 12:57:34 deraadt Exp $ +# $Id: Makefile,v 1.5 1994/05/17 14:01:44 pk Exp $ # Paths to libraries # @@ -20,14 +20,14 @@ CFLAGS+= -I$(.CURDIR)/arch/$(MACHINE_ARCH) -I$(.CURDIR)/../bfd \ -DHOST_CANONICAL=\"$(MACHINE_ARCH)-netbsd\" \ -DTARGET_CANONICAL=\"$(MACHINE_ARCH)-netbsd\" -CFLAGS+= -DNO_MMALLOC +CFLAGS+= -DNO_MMALLOC -DKERNEL_DEBUG YFLAGS+= -p $(.PREFIX:S/-exp/_/:S/ch_/chill_/) .PATH: $(.CURDIR)/arch/$(MACHINE_ARCH) SRCS= blockframe.c core.c gdbtypes.c main.c source.c \ breakpoint.c maint.c stabsread.c \ - buildsym.c corelow.c mem-break.c stack.c \ + buildsym.c corelow.c kcorelow.c mem-break.c stack.c \ c-exp.c cp-valprint.c minsyms.c symfile.c \ c-lang.c dbxread.c elfread.c infcmd.c symmisc.c \ c-typeprint.c dcache.c inflow.c symtab.c \ @@ -47,8 +47,8 @@ CLEANFILES+= y.tab.h c-exp.c ch-exp.c m2-exp.c LDADD= $(LIBBFD) $(LIBREADLINE) $(LIBIBERTY) DPADD= $(LIBBFD) $(LIBREADLINE) $(LIBIBERTY) -LDADD+= -ltermcap -DPADD+= $(LIBTERMCAP) +LDADD+= -ltermcap -lkvm +DPADD+= $(LIBTERMCAP) $(LIBKVM) .include "arch/$(MACHINE_ARCH)/Makefile.inc" diff --git a/gnu/usr.bin/gdb/gdb/arch/i386/i386b-nat.c b/gnu/usr.bin/gdb/gdb/arch/i386/i386b-nat.c index 6142fa1fe68..06b9c88b576 100644 --- a/gnu/usr.bin/gdb/gdb/arch/i386/i386b-nat.c +++ b/gnu/usr.bin/gdb/gdb/arch/i386/i386b-nat.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: i386b-nat.c,v 1.1 1994/01/28 12:41:35 pk Exp $ + $Id: i386b-nat.c,v 1.2 1994/05/17 14:02:02 pk Exp $ */ #include <sys/types.h> @@ -293,3 +293,33 @@ i386_float_info () print_387_status (0, (struct env387 *)buf); } +void +fetch_kcore_registers (pcb) +struct pcb *pcb; +{ + int i; + int *pcb_regs = (int *)pcb; + + /* + * get the register values out of the sys pcb and + * store them where `read_register' will find them. + */ + for (i = 0; i < 8; ++i) + supply_register(i, &pcb_regs[i+10]); + supply_register(8, &pcb_regs[8]); /* eip */ + supply_register(9, &pcb_regs[9]); /* eflags */ + for (i = 10; i < 13; ++i) /* cs, ss, ds */ + supply_register(i, &pcb_regs[i+9]); + supply_register(13, &pcb_regs[18]); /* es */ + for (i = 14; i < 16; ++i) /* fs, gs */ + supply_register(i, &pcb_regs[i+8]); + + /* XXX 80387 registers? */ +} + +void +clear_regs() +{ + return; +} + diff --git a/gnu/usr.bin/gdb/gdb/arch/sparc/sparc-nat.c b/gnu/usr.bin/gdb/gdb/arch/sparc/sparc-nat.c index 1cfa4e389da..8c83375555e 100644 --- a/gnu/usr.bin/gdb/gdb/arch/sparc/sparc-nat.c +++ b/gnu/usr.bin/gdb/gdb/arch/sparc/sparc-nat.c @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: sparc-nat.c,v 1.2 1994/02/04 16:48:20 pk Exp $ + $Id: sparc-nat.c,v 1.3 1994/05/17 14:02:09 pk Exp $ */ #include "defs.h" @@ -301,3 +301,58 @@ fetch_core_registers (core_reg_sect, core_reg_size, which, ignore) } } +void +fetch_kcore_registers (pcb) +struct pcb *pcb; +{ + struct rwindow win; + + /* We only do integer registers */ + + 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(PS_REGNUM, (char *)&pcb.pcb_psr); + supply_register(WIM_REGNUM, (char *)&pcb.pcb_wim); + /* + * Read last register window saved on stack. + */ + if (target_read_memory(sp, &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, &win.rw_local[i]); + for (i = 0; i < sizeof(win.rw_in); ++i) + supply_register(i + I0_REGNUM, &win.rw_in[i]); + /* + * read the globals & outs saved on the stack (for a trap frame). + */ + sp += 92 + 12; /* XXX - MINFRAME + R_Y */ + for (i = 1; i < 14; ++i) { + u_long val; + + if (target_read_memory(sp + i*4, &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 +} + +void +clear_regs() +{ + u_long reg = 0; + float freg = 0.0; + int i; + + for (i = 0; i < FP0_REGNUM; ++i) + supply_register(i, ®); + for (; i < FP0_REGNUM + 32; ++i) /* XXX */ + supply_register(i, &freg); + for (; i < NUM_REGS; ++i) + supply_register(i, ®); +} + diff --git a/gnu/usr.bin/gdb/gdb/defs.h b/gnu/usr.bin/gdb/gdb/defs.h index 834c2a3a30c..60c0dc956d2 100644 --- a/gnu/usr.bin/gdb/gdb/defs.h +++ b/gnu/usr.bin/gdb/gdb/defs.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: defs.h,v 1.1 1994/01/28 12:39:24 pk Exp $ + $Id: defs.h,v 1.2 1994/05/17 14:01:45 pk Exp $ */ #if !defined (DEFS_H) @@ -376,6 +376,9 @@ enum val_prettyprint Val_pretty_default }; +#ifdef KERNEL_DEBUG +extern int kernel_debugging; +#endif /* Host machine definition. This will be a symlink to one of the xm-*.h files, built by the `configure' script. */ diff --git a/gnu/usr.bin/gdb/gdb/gdbcore.h b/gnu/usr.bin/gdb/gdb/gdbcore.h index de33b5f09ea..cf727cd0bf5 100644 --- a/gnu/usr.bin/gdb/gdb/gdbcore.h +++ b/gnu/usr.bin/gdb/gdb/gdbcore.h @@ -17,7 +17,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: gdbcore.h,v 1.1 1994/01/28 12:39:45 pk Exp $ + $Id: gdbcore.h,v 1.2 1994/05/17 14:01:47 pk Exp $ */ /* Interface routines for core, executable, etc. */ @@ -116,6 +116,9 @@ extern CORE_ADDR kernel_u_addr; /* The target vector for core files */ extern struct target_ops core_ops; +#ifdef KERNEL_DEBUG +extern struct target_ops kcore_ops; +#endif /* target vector functions called directly from elsewhere */ void diff --git a/gnu/usr.bin/gdb/gdb/init.c b/gnu/usr.bin/gdb/gdb/init.c index 502c4bf1073..ebc59eba4d1 100644 --- a/gnu/usr.bin/gdb/gdb/init.c +++ b/gnu/usr.bin/gdb/gdb/init.c @@ -20,6 +20,9 @@ void initialize_all_files () { {extern void _initialize_inflow (); _initialize_inflow ();} {extern void _initialize_infrun (); _initialize_infrun ();} {extern void _initialize_inftarg (); _initialize_inftarg ();} +#ifdef KERNEL_DEBUG + {extern void _initialize_kcorelow (); _initialize_kcorelow ();} +#endif {extern void _initialize_language (); _initialize_language ();} {extern void _initialize_m2_language (); _initialize_m2_language ();} {extern void _initialize_maint_cmds (); _initialize_maint_cmds ();} diff --git a/gnu/usr.bin/gdb/gdb/main.c b/gnu/usr.bin/gdb/gdb/main.c index ad11789fd7c..eca2377d096 100644 --- a/gnu/usr.bin/gdb/gdb/main.c +++ b/gnu/usr.bin/gdb/gdb/main.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: main.c,v 1.1 1994/01/28 12:40:11 pk Exp $ + $Id: main.c,v 1.2 1994/05/17 14:01:49 pk Exp $ */ #include "defs.h" @@ -324,6 +324,11 @@ int baud_rate = -1; int remote_debug = 0; +#ifdef KERNEL_DEBUG +/* Non-zero means we are debugging a kernel core file */ +int kernel_debugging = 0; +#endif + /* Signal to catch ^Z typed while reading a command: SIGTSTP or SIGCONT. */ #ifndef STOP_SIGNAL @@ -608,6 +613,10 @@ main (argc, argv) {"tty", required_argument, 0, 't'}, {"baud", required_argument, 0, 'b'}, {"b", required_argument, 0, 'b'}, +#ifdef KERNEL_DEBUG + {"kernel", no_argument, &kernel_debugging, 1}, + {"k", no_argument, &kernel_debugging, 1}, +#endif /* Allow machine descriptions to add more options... */ #ifdef ADDITIONAL_OPTIONS ADDITIONAL_OPTIONS @@ -685,6 +694,11 @@ main (argc, argv) baud_rate = i; } break; +#ifdef KERNEL_DEBUG + case 'k': + kernel_debugging = 1; + break; +#endif #ifdef ADDITIONAL_OPTION_CASES ADDITIONAL_OPTION_CASES @@ -726,6 +740,11 @@ main (argc, argv) init_main (); /* But that omits this file! Do it now */ init_signals (); +#ifdef KERNEL_DEBUG + if (kernel_debugging) + prompt = savestring ("(kgdb) ", 7); +#endif + /* Do these (and anything which might call wrap_here or *_filtered) after initialize_all_files. */ if (print_version) diff --git a/gnu/usr.bin/gdb/gdb/target.c b/gnu/usr.bin/gdb/gdb/target.c index e73ced84143..0ef30873012 100644 --- a/gnu/usr.bin/gdb/gdb/target.c +++ b/gnu/usr.bin/gdb/gdb/target.c @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: target.c,v 1.1 1994/01/28 12:40:58 pk Exp $ + $Id: target.c,v 1.2 1994/05/17 14:01:51 pk Exp $ */ #include "defs.h" @@ -752,7 +752,11 @@ find_core_target () for (t = target_structs; t < target_structs + target_struct_size; ++t) { +#ifdef KERNEL_DEBUG + if ((*t)->to_stratum == (kernel_debugging ? kcore_stratum : core_stratum)) +#else if ((*t)->to_stratum == core_stratum) +#endif { runable = *t; ++count; diff --git a/gnu/usr.bin/gdb/gdb/target.h b/gnu/usr.bin/gdb/gdb/target.h index 5c20c8ae90e..8b282eaefcc 100644 --- a/gnu/usr.bin/gdb/gdb/target.h +++ b/gnu/usr.bin/gdb/gdb/target.h @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id: target.h,v 1.1 1994/01/28 12:40:59 pk Exp $ + $Id: target.h,v 1.2 1994/05/17 14:01:52 pk Exp $ */ #if !defined (TARGET_H) @@ -49,6 +49,9 @@ enum strata { dummy_stratum, /* The lowest of the low */ file_stratum, /* Executable files, etc */ core_stratum, /* Core dump files */ +#ifdef KERNEL_DEBUG + kcore_stratum, /* Kernel core files */ +#endif process_stratum /* Executing processes */ }; |
