diff --git a/tools/debugger.entitlements b/tools/debugger.entitlements new file mode 100644 index 0000000..0afe304 --- /dev/null +++ b/tools/debugger.entitlements @@ -0,0 +1,7 @@ + + + + com.apple.security.get-task-allow + + + \ No newline at end of file diff --git a/tools/run_with_leaks.sh b/tools/run_with_leaks.sh new file mode 100755 index 0000000..edfa916 --- /dev/null +++ b/tools/run_with_leaks.sh @@ -0,0 +1,20 @@ +#!/bin/bash +set -euo pipefail + +# This script is a utility on Apple platforms to run one +# of arboard's example binaries under the `leaks` CLI tool, +# which can help to diagnose memory leakage in any kind of +# native or runtime-managed code. + +example_name="$@" + +script_dir=$(dirname $BASH_SOURCE[0]) + +# Build the example +cargo build --example "$example_name" + +# Sign it with the required entitlements for process debugging. +codesign -s - -v -f --entitlements "$script_dir/debugger.entitlements" "./target/debug/examples/$example_name" + +# Run the example binary under `leaks` to look for any leaked objects. +leaks --atExit -- "./target/debug/examples/$example_name" \ No newline at end of file