From 7b9d0458105831a79d211f1ca98a184adedf82f5 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 21 Dec 2009 23:00:13 +0100 Subject: Add a SoftDebugger function * kern/debug.h (SoftDebugger): Add prototype. * kern/debug.c (Debugger): Move code invoking debugging trap to... (SoftDebugger): ... new function. Print the passed message. * kern/lock_mon.c (decl_simple_lock_data, retry_bit_lock): Call SoftDebugger instead of Debugger. * device/ds_routines.c (ds_device_open, device_read, device_read_inband): Call SoftDebugger instead of Debugger. * i386/i386at/model_dep.c (c_boot_entry): Call SoftDebugger instead of Debugger. * kern/syscall_sw.c (null_port, kern_invalid): Call SoftDebugger instead of Debugger. * vm/vm_object.c (vm_object_collapse): Call SoftDebugger instead of Debugger. --- device/ds_routines.c | 6 +++--- i386/i386at/model_dep.c | 2 +- kern/debug.c | 21 +++++++++++++++------ kern/debug.h | 1 + kern/lock_mon.c | 4 ++-- kern/syscall_sw.c | 4 ++-- vm/vm_object.c | 2 +- 7 files changed, 25 insertions(+), 15 deletions(-) diff --git a/device/ds_routines.c b/device/ds_routines.c index 5b57338..d0f0879 100644 --- a/device/ds_routines.c +++ b/device/ds_routines.c @@ -147,7 +147,7 @@ ds_device_open (ipc_port_t open_port, ipc_port_t reply_port, if (! IP_VALID (reply_port)) { printf ("ds_* invalid reply port\n"); - Debugger ("ds_* reply_port"); + SoftDebugger ("ds_* reply_port"); return MIG_NO_REPLY; } @@ -1092,7 +1092,7 @@ device_read(device, reply_port, reply_port_type, mode, recnum, */ if (!IP_VALID(reply_port)) { printf("ds_* invalid reply port\n"); - Debugger("ds_* reply_port"); + SoftDebugger("ds_* reply_port"); return (MIG_NO_REPLY); /* no sense in doing anything */ } @@ -1174,7 +1174,7 @@ device_read_inband(device, reply_port, reply_port_type, mode, recnum, */ if (!IP_VALID(reply_port)) { printf("ds_* invalid reply port\n"); - Debugger("ds_* reply_port"); + SoftDebugger("ds_* reply_port"); return (MIG_NO_REPLY); /* no sense in doing anything */ } diff --git a/i386/i386at/model_dep.c b/i386/i386at/model_dep.c index 61605a1..ca00078 100644 --- a/i386/i386at/model_dep.c +++ b/i386/i386at/model_dep.c @@ -560,7 +560,7 @@ void c_boot_entry(vm_offset_t bi) */ if (strstr(kernel_cmdline, "-d ")) { cninit(); /* need console for debugger */ - Debugger("init"); + SoftDebugger("init"); } #else if (strstr (kernel_cmdline, "-H ")) diff --git a/kern/debug.c b/kern/debug.c index 57a8126..26445f8 100644 --- a/kern/debug.c +++ b/kern/debug.c @@ -73,17 +73,16 @@ Assert(char *exp, char *file, int line) Debugger("assertion failure"); } -void Debugger(message) +void SoftDebugger(message) char * message; { + printf("Debugger invoked: %s\n", message); + #if !MACH_KDB - panic("Debugger invoked, but there isn't one!"); + printf("But no debugger, continuing.\n"); + return; #endif -#ifdef lint - message++; -#endif /* lint */ - #if defined(vax) || defined(PC532) asm("bpt"); #endif /* vax */ @@ -104,6 +103,16 @@ void Debugger(message) #ifdef i386 asm("int3"); #endif +} + +void Debugger(message) + char * message; +{ +#if !MACH_KDB + panic("Debugger invoked, but there isn't one!"); +#endif + + SoftDebugger(message); panic("Debugger returned!"); } diff --git a/kern/debug.h b/kern/debug.h index 287b152..f4e8200 100644 --- a/kern/debug.h +++ b/kern/debug.h @@ -60,6 +60,7 @@ extern void panic_init(void); extern void panic (const char *s, ...) __attribute__ ((noreturn)); +extern void SoftDebugger (char *message); extern void Debugger (char *message) __attribute__ ((noreturn)); #endif /* _mach_debug__debug_ */ diff --git a/kern/lock_mon.c b/kern/lock_mon.c index 7ffaeb6..1450428 100644 --- a/kern/lock_mon.c +++ b/kern/lock_mon.c @@ -348,7 +348,7 @@ decl_simple_lock_data(, *lock) return; db_printf("cpu %d looping on simple_lock(%x) called by %x\n", cpu_number(), lock, *(((int *)&lock) -1)); - Debugger("simple_lock timeout"); + SoftDebugger("simple_lock timeout"); count = 0; } } @@ -362,7 +362,7 @@ retry_bit_lock(index, addr) if (count++ > 1000000) { db_printf("cpu %d looping on bit_lock(%x, %x) called by %x\n", cpu_number(), index, addr, *(((int *)&index) -1)); - Debugger("bit_lock timeout"); + SoftDebugger("bit_lock timeout"); count = 0; } } diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c index bd3b874..b2e20e6 100644 --- a/kern/syscall_sw.c +++ b/kern/syscall_sw.c @@ -60,13 +60,13 @@ int kern_invalid_debug = 0; mach_port_t null_port() { - if (kern_invalid_debug) Debugger("null_port mach trap"); + if (kern_invalid_debug) SoftDebugger("null_port mach trap"); return(MACH_PORT_NULL); } kern_return_t kern_invalid() { - if (kern_invalid_debug) Debugger("kern_invalid mach trap"); + if (kern_invalid_debug) SoftDebugger("kern_invalid mach trap"); return(KERN_INVALID_ARGUMENT); } diff --git a/vm/vm_object.c b/vm/vm_object.c index 8da7a88..9057973 100644 --- a/vm/vm_object.c +++ b/vm/vm_object.c @@ -2543,7 +2543,7 @@ void vm_object_collapse( backing_object, backing_object->pager, backing_object->pager_request, object); if (vm_object_collapse_debug > 2) - Debugger("vm_object_collapse"); + SoftDebugger("vm_object_collapse"); } object->pager = backing_object->pager; -- cgit v1.2.3