Skip to content

Commit f409d08

Browse files
committed
Add helper script for diagnosing any future leak issues
1 parent 1e9c093 commit f409d08

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

tools/debugger.entitlements

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"\>
2+
<plist version="1.0">
3+
<dict>
4+
<key>com.apple.security.get-task-allow</key>
5+
<true/>
6+
</dict>
7+
</plist>

tools/run_with_leaks.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# This script is a utility on Apple platforms to run one
5+
# of arboard's example binaries under the `leaks` CLI tool,
6+
# which can help to diagnose memory leakage in any kind of
7+
# native or runtime-managed code.
8+
9+
example_name="$@"
10+
11+
script_dir=$(dirname $BASH_SOURCE[0])
12+
13+
# Build the example
14+
cargo build --example "$example_name"
15+
16+
# Sign it with the required entitlements for process debugging.
17+
codesign -s - -v -f --entitlements "$script_dir/debugger.entitlements" "./target/debug/examples/$example_name"
18+
19+
# Run the example binary under `leaks` to look for any leaked objects.
20+
leaks --atExit -- "./target/debug/examples/$example_name"

0 commit comments

Comments
 (0)