-
-
Notifications
You must be signed in to change notification settings - Fork 218
/
Copy pathprofile-compiler.sh
executable file
·39 lines (33 loc) · 1.2 KB
/
profile-compiler.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh
tests=$(dirname "$0")
repo=$(dirname "$tests")
builddir=../build/tmp_thin-macos-arm64/frida-core
flamegraph=/Users/oleavr/src/FlameGraph
set -ex
intdir=$(mktemp -d /tmp/profile-compiler.XXXXXX)
test_log=$intdir/test.log
v8_log=$intdir/v8.log
stacks_raw=$intdir/stacks_raw
stacks_symbolicated=$intdir/stacks_symbolicated
stacks_folded=$intdir/stacks_folded
clean_up () {
rm -rf "$intdir"
}
trap clean_up EXIT
export FRIDA_TEST_LOG=$test_log
export FRIDA_V8_EXTRA_FLAGS="--logfile=$v8_log --no-logfile-per-isolate --log-code --interpreted-frames-native-stack"
sudo --preserve-env=FRIDA_TEST_LOG,FRIDA_V8_EXTRA_FLAGS dtrace \
-c "$builddir/tests/frida-tests -p /Compiler/Performance/build-simple-agent" \
-x ustackframes=100 \
-n 'profile-97 /pid == $target/ { @[ustack()] = count(); }' \
-o "$stacks_raw"
"$repo/tools/symbolicate.py" \
--input "$stacks_raw" \
--output "$stacks_symbolicated" \
--test-log "$test_log" \
--v8-log "$v8_log" \
--agent "$builddir/lib/agent/libfrida-agent-modulated.dylib"
"$flamegraph/stackcollapse.pl" "$stacks_symbolicated" \
| grep gum_script_scheduler_run_js_loop \
> "$stacks_folded"
"$flamegraph/flamegraph.pl" "$stacks_folded" > compiler-flamegraph.svg