Implementation sources

Exceptions & traps

The arm64 exception path, the Mach trap and BSD syscall dispatch tables, and the register and saved-state accessors behind them.

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

Debugging

Panic, the in-kernel debugger, and the Kernel Debug Protocol (KDP) used by remote debuggers and core dumps.

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

Userspace debugging

Task-port authorization, task and thread suspension, exception-port ownership, arm64 debug state, and executable-memory updates. These implementation references use the pinned XNU checkout; current SDK declarations remain in the API reference.

MIG (Mach Interface Generator)

The migcom compiler (from Apple’s bootstrap_cmds) that turns .defs interface files into the C stubs and Request/Reply message structs behind the Mach routines — the code generating what you see on the header pages.

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

Apple’s user-space debugger server implementation: acquiring a task port, installing and restoring exception ports, coordinating task and thread suspension, writing executable memory, and arm64 hardware single stepping.

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

Register spotlights

The x18 registerevery use of it in the hosted sources

Debugging references

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