-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgdb.sh
executable file
·45 lines (39 loc) · 1.16 KB
/
gdb.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
40
41
42
43
44
45
#!/bin/bash
GDB=gdb
LUCET_WASI=../lucet-spectre-repro/target/release/lucet-wasi
LUCET_WASI_ARGS='--heap-address-space 8GiB --max-heap-size 4GiB --stack-size 8MiB --dir /:/'
if [[ $1 == "leakage" ]]; then
SO=btb_leakage.so
GDBSCRIPT=copycode_leakage.gdbcommands
elif [[ $1 == "breakout" ]]; then
SO=btb_breakout.so
GDBSCRIPT=copycode_breakout.gdbcommands
else
echo 'error: First argument should be either "leakage" or "breakout"'
exit 1
fi
if [[ $2 == "" ]]; then
echo "error: Requires a second argument, which should be the name of one of the build directories"
exit 1
elif [ ! -d "./$2" ]; then
echo "error: Second argument should be the name of one of the build directories"
exit 1
fi
if [[ $2 == *aslr ]]; then
ASLR_FLAGS="--spectre-mitigation-aslr"
else
ASLR_FLAGS=
fi
if [[ $2 == "sfi_full" || $2 == "sfi_aslr" || $2 == "cet_aslr" ]]; then
MAYBE_ADD_BTB_FLUSHES= -ex "add_btb_flushes"
else
MAYBE_ADD_BTB_FLUSHES=
fi
taskset -c 1 $GDB \
-ex "set pagination off" \
-ex "set breakpoint pending on" \
-ex "b *(lucet_context_bootstrap+49)" \
-ex "r" \
-x $GDBSCRIPT \
$MAYBE_ADD_BTB_FLUSHES \
--args $LUCET_WASI $LUCET_WASI_ARGS $ASLR_FLAGS ./$2/$SO