aboutsummaryrefslogtreecommitdiff
path: root/qemu-user-buildroot-gdb.sh
diff options
context:
space:
mode:
authorToni Uhlig <matzeton@googlemail.com>2020-08-04 14:44:58 +0200
committerToni Uhlig <matzeton@googlemail.com>2020-08-04 14:44:58 +0200
commit1691a2faf3205fc13d2e3a40814e3b181f0366ce (patch)
tree6d9761740a0891c9be935e1a4f6f5eb91cc65714 /qemu-user-buildroot-gdb.sh
parent72324466eb07101ce37a6df662857e76e8f7d693 (diff)
qemu-user debugging with buildrootHEADmaster
Signed-off-by: Toni Uhlig <matzeton@googlemail.com>
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'