It's not always possible to directly access user memory from kernel mode. While it's in theory a lot more expensive to fetch each character to be printed separately, mach_print() is only a debugging facility, and it's not supposed to be used for printing large amounts of data. --- kern/syscall_subr.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/kern/syscall_subr.c b/kern/syscall_subr.c index e0057d94..0027be29 100644 --- a/kern/syscall_subr.c +++ b/kern/syscall_subr.c @@ -43,6 +43,7 @@ #include <kern/task.h> #include <kern/thread.h> #include <machine/spl.h> /* for splsched */ +#include <machine/locore.h> /* for copyin */ #if MACH_FIXPRI #include <mach/policy.h> @@ -381,6 +382,14 @@ thread_depress_abort(thread_t thread) void mach_print(const char *s) { - printf("%s", s); + char c; + while (TRUE) { + if (copyin(s, &c, 1)) + return; + if (c == 0) + break; + printf("%c", c); + s++; + } } #endif /* MACH_KDB */ -- 2.44.0