Skip to content

Commit 06d19b4

Browse files
authored
Add debugging instructions for XPC helpers
Added instructions for debugging XPC helpers using launchd service labels.
1 parent 9c5cf82 commit 06d19b4

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

BUILDING.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,42 @@ To revert to using the Containerization dependency from your `Package.swift`:
119119
bin/container system start
120120
```
121121

122+
## Debug XPC Helpers
123+
124+
Attach debugger to the XPC helpers using their launchd service labels:
125+
126+
1. Find launchd service labels:
127+
128+
```console
129+
% container system start
130+
% container run -d --name test debian:bookworm sleep infinity
131+
test
132+
% launchd list | grep container
133+
27068 0 com.apple.container.container-network-vmnet.default
134+
27072 0 com.apple.container.container-core-images
135+
26980 0 com.apple.container.apiserver
136+
27331 0 com.apple.container.container-runtime-linux.test
137+
```
138+
139+
2. Stop container and start again after setting the environment variable `CONTAINER_DEBUG_LAUNCHD_LABEL` to the label of service to attach debugger. Services whose label starts with the `CONTAINER_DEBUG_LAUNCHD_LABEL` will wait the debugger:
140+
141+
```console
142+
% export CONTAINER_DEBUG_LAUNCHD_LABEL=com.apple.container.container-runtime-linux.test
143+
% container system start # Only the service `com.apple.container.container-runtime-linux.test` waits debugger
144+
```
145+
146+
```console
147+
% export CONTAINER_DEBUG_LAUNCHD_LABEL=com.apple.container.container-runtime-linux
148+
% container system start # Every service starting with `com.apple.container.container-runtime-linux` waits debugger
149+
```
150+
151+
3. Run the command to launch the service, and attach debugger:
152+
153+
```console
154+
% container run -it --name test debian:bookworm
155+
⠧ [6/6] Starting container [0s] # It hangs as the service is waiting for debugger
156+
```
157+
122158
## Pre-commit hook
123159

124160
Run `make pre-commit` to install a pre-commit hook that ensures that your changes have correct formatting and license headers when you run `git commit`.

0 commit comments

Comments
 (0)