diff options
Diffstat (limited to 'kern')
-rw-r--r-- | kern/bootstrap.c | 18 | ||||
-rw-r--r-- | kern/debug.c | 2 | ||||
-rw-r--r-- | kern/gdb.c | 37 | ||||
-rw-r--r-- | kern/startup.c | 4 |
4 files changed, 60 insertions, 1 deletions
diff --git a/kern/bootstrap.c b/kern/bootstrap.c index c07b032d..7dd7c140 100644 --- a/kern/bootstrap.c +++ b/kern/bootstrap.c @@ -54,6 +54,11 @@ #include <ddb/db_sym.h> #endif +#if MACH_GDB_STUB +extern void set_debug_traps(); +extern void breakpoint(); +#endif + #if OSKIT_MACH #include <stddef.h> #include <oskit/machine/base_multiboot.h> @@ -122,8 +127,19 @@ void bootstrap_create() #else /* MACH_XEN */ struct multiboot_module *bmods = ((struct multiboot_module *) phystokv(boot_info.mods_addr)); - #endif /* MACH_XEN */ + +#ifdef MACH_GDB_STUB + /* + * FIXME: Change this so its only + * run if -d is passed to mach + */ + + printf("Waiting for debugger connection on com0\n"); + breakpoint(); + printf("Back from GDB\n"); +#endif /* MACH_GDB_STUB */ + if (!(boot_info.flags & MULTIBOOT_MODS) || (boot_info.mods_count == 0)) panic ("No bootstrap code loaded with the kernel!"); diff --git a/kern/debug.c b/kern/debug.c index 26445f83..178d0788 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -174,6 +174,8 @@ panic(const char *s, ...) #if MACH_KDB Debugger("panic"); +#elif MACH_GDB_STUB + breakpoint(); #else # ifdef MACH_HYP hyp_crash(); diff --git a/kern/gdb.c b/kern/gdb.c new file mode 100644 index 00000000..250bf8d8 --- /dev/null +++ b/kern/gdb.c @@ -0,0 +1,37 @@ +/* + * Mach Kernel - GDB Stub Code + * Copyright (c) 2007 Free Software Foundation + */ + +#include <mach/std_types.h> +#include <sys/types.h> + +/** + * We don't have a header file for the com + * functions, so extern them here, and talk + * about on bug-hurd about making the header + */ + +extern int comcnputc(dev_t dev, int c); +extern int comcngetc(dev_t dev, int wait); + +/** + * putDebugChar puts a character over the serial port + * for the GDB stub. Its prototyped in stub-i386.c + */ + +void putDebugChar(int character) +{ + comcnputc(0, character); +} + +/** + * getDebugChar gets a character over the serial port + * for the GDB stub. Its prototyped in stub-i386.c. + * It uses + */ + +int getDebugChar() +{ + return comcngetc(0, 10); +} diff --git a/kern/startup.c b/kern/startup.c index 417fa4a1..81626dbf 100644 --- a/kern/startup.c +++ b/kern/startup.c @@ -112,6 +112,10 @@ void setup_main() init_timers(); init_timeout(); +#ifdef MACH_GDB_STUB + set_debug_traps(); +#endif + #if XPR_DEBUG xprbootstrap(); #endif /* XPR_DEBUG */ |