| 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" |