summaryrefslogtreecommitdiff
path: root/kern/debug.c
diff options
context:
space:
mode:
Diffstat (limited to 'kern/debug.c')
-rw-r--r--kern/debug.c60
1 files changed, 47 insertions, 13 deletions
diff --git a/kern/debug.c b/kern/debug.c
index 6d760e5e..178d0788 100644
--- a/kern/debug.c
+++ b/kern/debug.c
@@ -24,6 +24,8 @@
* the rights to redistribute these changes.
*/
+#include <mach/xen.h>
+
#include <kern/printf.h>
#include <stdarg.h>
@@ -33,8 +35,10 @@
#include <kern/debug.h>
+#include <machine/loose_ends.h>
+#include <machine/model_dep.h>
+
extern void cnputc();
-void Debugger() __attribute__ ((noreturn));
#if MACH_KDB
extern int db_breakpoints_inserted;
@@ -69,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 */
@@ -100,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!");
}
@@ -124,6 +137,10 @@ panic_init(void)
}
}
+#if ! MACH_KBD
+extern boolean_t reboot_on_panic;
+#endif
+
/*VARARGS1*/
void
panic(const char *s, ...)
@@ -155,6 +172,14 @@ panic(const char *s, ...)
va_end(listp);
printf("\n");
+#if MACH_KDB
+ Debugger("panic");
+#elif MACH_GDB_STUB
+ breakpoint();
+#else
+# ifdef MACH_HYP
+ hyp_crash();
+# else
/* Give the user time to see the message */
{
int i = 1000; /* seconds */
@@ -162,12 +187,8 @@ panic(const char *s, ...)
delay (1000000); /* microseconds */
}
-#if MACH_KDB
- Debugger("panic");
-#elif MACH_GDB_STUB
- breakpoint();
-#else
- halt_all_cpus (1);
+ halt_all_cpus (reboot_on_panic);
+# endif /* MACH_HYP */
#endif
}
@@ -187,3 +208,16 @@ log(int level, const char *fmt, ...)
_doprnt(fmt, &listp, do_cnputc, 0, 0);
va_end(listp);
}
+
+unsigned char __stack_chk_guard [ sizeof (vm_offset_t) ] =
+{
+ [ sizeof (vm_offset_t) - 3 ] = '\r',
+ [ sizeof (vm_offset_t) - 2 ] = '\n',
+ [ sizeof (vm_offset_t) - 1 ] = 0xff,
+};
+
+void
+__stack_chk_fail (void)
+{
+ panic("stack smashing detected");
+}