-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathgdb.sh
More file actions
executable file
·38 lines (29 loc) · 865 Bytes
/
gdb.sh
File metadata and controls
executable file
·38 lines (29 loc) · 865 Bytes
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
#!/bin/bash
CWD=$(dirname -- "$0")
ROOT_DIR=$CWD/..
OUT_DIR=$ROOT_DIR/out
GDB_FILE=$OUT_DIR/.gdb
GDBINIT=$CWD/gdbinit.gdb
ptrace_scope=$(cat /proc/sys/kernel/yama/ptrace_scope)
if [[ $ptrace_scope -ne 0 && $(id -u) -ne 0 ]]; then
cat << EOF
WARNING: You are not running as root and ptrace_scope is not set to zero. If you
run into issues when using pwndbg or gdb-pt-dump, rerun this script as root, or
alternatively run the following command:
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
EOF
fi
IFS=" " read -r ARCH ACK < $GDB_FILE
if [[ "$ACK" -eq 1 ]]; then
LINUX_OUT=$OUT_DIR/ack/common/$ARCH
else
LINUX_OUT=$OUT_DIR/linux/$ARCH
fi
OUTPUT=$(mktemp)
sed "s|##LINUX_OUT##|${LINUX_OUT}|g" "$GDBINIT" > "$OUTPUT"
if [[ $ARCH == "x86_64" ]]; then
GDB=gdb
else
GDB=gdb-multiarch
fi
exec "${GDB}" -q -ex "source ${OUTPUT}" "$@"