diff options
author | Richard Braun <rbraun@sceen.net> | 2013-01-22 22:32:14 +0100 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2013-01-22 22:39:20 +0100 |
commit | 338d9ca7981f25099d99d280b0dd3af590d65763 (patch) | |
tree | fd2b513baab6f15f6a6b1cb65d49e33042fed6b3 | |
parent | 2a6b4fc29ad57a2d9127fd4095f60238ba370cab (diff) |
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 <kern/printf.h>.
[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.
-rw-r--r-- | include/mach/syscall_sw.h | 1 | ||||
-rw-r--r-- | kern/syscall_subr.c | 16 | ||||
-rw-r--r-- | kern/syscall_subr.h | 1 | ||||
-rw-r--r-- | kern/syscall_sw.c | 6 |
4 files changed, 23 insertions, 1 deletions
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 <kern/counters.h> #include <kern/ipc_kobject.h> #include <kern/mach_clock.h> +#include <kern/printf.h> #include <kern/processor.h> #include <kern/sched.h> #include <kern/sched_prim.h> @@ -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 */ |