Is there a way to see the code that is being called by a syscall instruction with lldb, or otherwise, on the Mac?
I am trying to understand what goes behind the hood when a "write" syscall is called. I have compiled a simple .c program with gcc -g
:
#include <unistd.h>
#include <sys/syscall.h>
int main(void) {
syscall(SYS_write, 1, "hello, world!\n", 14);
return 0;
}
lldb does not step into the syscall
instruction even when I use:
s -a false
Is there any way?
No. If you were able to step into a kernel trap, the kernel would be stopped and the debugger would stop running as well. You can debug the kernel from a second system -- if you look for the Kernel Debug Kit on Apple's developer portal download site, there are instructions for how to do two-machine kernel debugging. The instructions are most likely aimed at people doing kernel extension (kext) development, but they'll get in you in the right ballpark.