Skip to content

Commit 1425898

Browse files
committed
sw: m1n1-hypervisor: Reword external debugger section
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
1 parent 0e74af2 commit 1425898

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

‎docs/sw/m1n1-hypervisor.md‎

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,24 +155,31 @@ of m1n1 from the working tree before attempting to use the hypervisor to ensure
155155
python3 proxyclient/tools/chainload.py build/m1n1.macho
156156
```
157157

158-
## Using GDB/LLDB
159-
160-
`gdbserver` command starts the server implementation that can be connected to GDB or LLDB. LLDB is more recommended because it supports pointer authentication and Darwin kernel dyld.
161-
162-
You need to load kernel extensions to get symbols on LLDB. The below shell script generates `target.lldb`, a convenient LLDB script that sets the target and loads kernel extensions:
158+
## Using a debugger
159+
m1n1 supports networked debugging. Running `gdbserver` in the hypervisor shell will start a debug
160+
server implementation that can be connected to from GDB or LLDB. We recommend using LLDB, as it
161+
has better support for Mach-O, pointer authentication, and XNU's use of dyld.
163162

163+
An LLDB script is needed to load symbols for all kernel extensions. The shell script below
164+
can be used from macOS to generate an LLDB script which will do this for you:
164165
```sh
165-
echo target create -s kernel.development.t8101.dSYM kernel.development.t8101 > target.lldb
166-
for k in $(find Extensions); do [ "$(file -b --mime-type $k)" != application/x-mach-binary ] || printf 'image add %q\n' $k; done >> target.lldb
166+
echo 'target create -s kernel.development.t8103.dSYM kernel.development.t8103' > target.lldb
167+
for k in $(find Extensions); do
168+
[ "$(file -b --mime-type $k)" != 'application/x-mach-binary' ] || printf 'image add %q\n' $k;
169+
done >> target.lldb
167170
```
168171

169-
The following commands for LLDB loads the generated script and connects to m1n1:
172+
The above assumes that you are booted on macOS and inside the KDK `Kernels` directory.
173+
174+
From LLDB, you can then run the generated script and connect to m1n1's debug server:
170175
```
171176
command source -e false target.lldb
172177
process connect unix-connect:///tmp/.m1n1-unix
173178
```
174179

175-
Do not run hypervisor console commands interfering with GDB/LLDB, or they will be out-of-sync. For example, do not edit breakpoints from both of hypervisor console and GDB/LLDB at the same time.
180+
Do not attempt to use both the hypervisor shell's builtin debugging features and an external
181+
debugger at the same time. For example, do not attempt to add or edit breakpoints from the hypervisor
182+
shell while using LLDB.
176183

177184
# Sources
178185
Source for the kernelcache creation: [https://kernelshaman.blogspot.com/2021/02/building-xnu-for-macos-112-intel-apple.html](https://kernelshaman.blogspot.com/2021/02/building-xnu-for-macos-112-intel-apple.html)

0 commit comments

Comments
 (0)