Implementation sources

Exceptions & traps

Mach trap tableosfmk/kern/syscall_sw.c
BSD system call dispatch (arm)bsd/dev/arm/systemcalls.c
Mach exception deliveryosfmk/kern/exception.c
Saved-state (exception frame) accessorsosfmk/mach/arm/thread_status.h
Exception delivery structuresosfmk/kern/exception.h

Task & thread coordination

Task restartable ranges changedosfmk/kern/restartable.c

libpthread

pthread mutexeslibpthread/src/pthread_mutex.c
pthread condition variableslibpthread/src/pthread_cond.c
pthread read-write lockslibpthread/src/pthread_rwlock.c
Thread-specific datalibpthread/src/pthread_tsd.c
Fork handlerslibpthread/src/pthread_atfork.c
Cancellation and joinlibpthread/src/pthread_cancelable.c
pthread quality of servicelibpthread/src/qos.c

Debugging

Panic and debugger entryosfmk/kern/debug.c
Kernel core dumpsosfmk/kdp/kdp_core.h

Userspace debugging

MIG (Mach Interface Generator)

MIG compiler driverbootstrap_cmds/migcom.tproj/mig.c
MIG codegen: header (.h)bootstrap_cmds/migcom.tproj/header.c
MIG codegen: user stubsbootstrap_cmds/migcom.tproj/user.c
MIG codegen: server demuxbootstrap_cmds/migcom.tproj/server.c
MIG routine modelbootstrap_cmds/migcom.tproj/routine.c
MIG type marshalingbootstrap_cmds/migcom.tproj/type.c

LLDB debugserver

debugserver task control and exception threadllvm-project/lldb/tools/debugserver/source/MacOSX/MachTask.mm
debugserver Mach exception messages and saved portsllvm-project/lldb/tools/debugserver/source/MacOSX/MachException.cpp
debugserver process launch, attach, stop, and resumellvm-project/lldb/tools/debugserver/source/MacOSX/MachProcess.mm
debugserver per-thread suspension and resume preparationllvm-project/lldb/tools/debugserver/source/MacOSX/MachThread.cpp
debugserver all-stop thread coordinationllvm-project/lldb/tools/debugserver/source/MacOSX/MachThreadList.cpp
debugserver memory writes and instruction-cache flushesllvm-project/lldb/tools/debugserver/source/MacOSX/MachVMMemory.cpp
debugserver arm64 single-step statellvm-project/lldb/tools/debugserver/source/MacOSX/arm64/DNBArchImplARM64.cpp

Debugging references

GNU Mach kernel debugger (ddb)the built-in interactive kernel debugger — commands, variables, expressions