From 338d9ca7981f25099d99d280b0dd3af590d65763 Mon Sep 17 00:00:00 2001 From: Richard Braun Date: Tue, 22 Jan 2013 22:32:14 +0100 Subject: Add the mach_print debugging system call The purpose of this system call is to help debugging in situations where it's desirable to bypass the mach_msg call entirely. * include/mach/syscall_sw.h (mach_print): Generate system call code. * kern/syscall_subr.c: Include . [MACH_KDB] (mach_print): New function. * kern/syscall_subr.h (mach_print): New prototype. * kern/syscall_sw.c [MACH_KDB] (mach_trap_table): Declare mach_print system call. --- include/mach/syscall_sw.h | 1 + kern/syscall_subr.c | 16 ++++++++++++++++ kern/syscall_subr.h | 1 + kern/syscall_sw.c | 6 +++++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/include/mach/syscall_sw.h b/include/mach/syscall_sw.h index af14c8d..89597e9 100644 --- a/include/mach/syscall_sw.h +++ b/include/mach/syscall_sw.h @@ -52,6 +52,7 @@ kernel_trap(mach_reply_port,-26,0) kernel_trap(mach_thread_self,-27,0) kernel_trap(mach_task_self,-28,0) kernel_trap(mach_host_self,-29,0) +kernel_trap(mach_print,-30,1) kernel_trap(swtch_pri,-59,1) kernel_trap(swtch,-60,0) diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index 395b9b8..ae2d7d7 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -380,3 +381,18 @@ register thread_t thread; (void) splx(s); return(KERN_SUCCESS); } + +/* + * mach_print + * + * Display a null-terminated character string on the Mach console. + * This system call is meant as a debugging tool useful to circumvent + * messaging altogether. + */ +#ifdef MACH_KDB +void +mach_print(const char *s) +{ + printf("%s", s); +} +#endif /* MACH_KDB */ diff --git a/kern/syscall_subr.h b/kern/syscall_subr.h index 2b8bcd3..a2e3920 100644 --- a/kern/syscall_subr.h +++ b/kern/syscall_subr.h @@ -36,5 +36,6 @@ extern int swtch_pri(int); extern int thread_switch(mach_port_t, int, mach_msg_timeout_t); extern void thread_depress_timeout(thread_t); extern kern_return_t thread_depress_abort(thread_t); +extern void mach_print(const char *); #endif /* _KERN_SYSCALL_SUBR_H_ */ diff --git a/kern/syscall_sw.c b/kern/syscall_sw.c index b2e20e6..607d843 100644 --- a/kern/syscall_sw.c +++ b/kern/syscall_sw.c @@ -122,8 +122,12 @@ mach_trap_t mach_trap_table[] = { MACH_TRAP(mach_thread_self, 0), /* 27 */ MACH_TRAP(mach_task_self, 0), /* 28 */ MACH_TRAP(mach_host_self, 0), /* 29 */ +#ifdef MACH_KDB + MACH_TRAP_STACK(mach_print, 1), /* 30 */ +#else /* MACH_KDB */ + MACH_TRAP_STACK(kern_invalid, 0), /* 30 */ +#endif /* MACH_KDB */ - MACH_TRAP(kern_invalid, 0), /* 30 */ MACH_TRAP(kern_invalid, 0), /* 31 */ MACH_TRAP(kern_invalid, 0), /* 32 */ MACH_TRAP(kern_invalid, 0), /* 33 emul: task_by_pid */ -- cgit v1.2.3