aboutsummaryrefslogtreecommitdiff
path: root/qemu-user-buildroot-gdb.sh
diff options
context:
space:
mode:
Diffstat (limited to 'qemu-user-buildroot-gdb.sh')
-rwxr-xr-xqemu-user-buildroot-gdb.sh19
1 files changed, 19 insertions, 0 deletions
diff --git a/qemu-user-buildroot-gdb.sh b/qemu-user-buildroot-gdb.sh
new file mode 100755
index 0000000..463e9ea
--- /dev/null
+++ b/qemu-user-buildroot-gdb.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env sh
+
+SYSROOT="${1}"
+EXEC="${2}"
+
+if [ -z "${SYSROOT}" -o -z "${EXEC}" ]; then
+ printf 'usage: NOCHROOT=[0|1] GDB=[0|1] %s [BUILDROOT-BUILDDIR] [BINARY-YOU-WANT-TO-DEBUG]\n' "${0}"
+ exit 1
+fi
+
+SOLIB_SEARCH_PATHS="$(patchelf --print-rpath "${EXEC}")"
+
+gdb-multiarch -q --nh \
+ -ex "auto-load safe-path" \
+ -ex "add-auto-load-safe-path $debugdir:$datadir/auto-load" \
+ -ex "set solib-search-path ${SOLIB_SEARCH_PATHS}" \
+ -ex "set sysroot ${SYSROOT}/output/target" \
+ -ex "file ${EXEC}" \
+ -ex 'target remote localhost:31337'