Skip to content
Snippets Groups Projects
Commit 129d3df8 authored by Jerome Forissier's avatar Jerome Forissier Committed by Jérôme Forissier
Browse files

buildroot: add support for debugging Normal World applications


Build with GDBSERVER=y to enable remote debugging of Normal World
applications. gdbserver is added to the root filesystem.

Signed-off-by: default avatarJerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: default avatarJoakim Bech <joakim.bech@linaro.org>
parent 5e35a058
No related branches found
No related tags found
No related merge requests found
BR2_ENABLE_DEBUG=y
BR2_PACKAGE_GDB=y
BR2_PACKAGE_HOST_GDB=y
BR2_TOOLCHAIN_BUILDROOT_CXX=y
BR2_TOOLCHAIN_BUILDROOT_GLIBC=y
BR2_PACKAGE_GLIBC=y
BR2_TOOLCHAIN_BUILDROOT=y
BR2_GCC_VERSION_6_X=y
BR2_KERNEL_HEADERS_4_10=y
......@@ -183,11 +183,17 @@ busybox-cleaner-common:
# Build root
################################################################################
BUILDROOT_ARCH=aarch$(COMPILE_NS_USER)
ifeq ($(GDBSERVER),y)
BUILDROOT_TOOLCHAIN=toolchain-br # Use toolchain supplied by buildroot
DEFCONFIG_GDBSERVER=--br-defconfig build/br-ext/configs/gdbserver.conf
else
# Local toolchains (downloaded by "make toolchains")
ifeq ($(COMPILE_LEGACY),)
BUILDROOT_TOOLCHAIN=toolchain-aarch$(COMPILE_NS_USER)
else
BUILDROOT_TOOLCHAIN=toolchain-aarch$(COMPILE_NS_USER)-legacy
endif
endif
BUILDROOT_GETTY_PORT ?= \
$(if $(CFG_NW_CONSOLE_UART),ttyAMA$(CFG_NW_CONSOLE_UART),ttyAMA0)
.PHONY: buildroot
......@@ -230,6 +236,7 @@ endif
--br-defconfig build/br-ext/configs/optee_$(BUILDROOT_ARCH) \
--br-defconfig build/br-ext/configs/optee_generic \
--br-defconfig build/br-ext/configs/$(BUILDROOT_TOOLCHAIN) \
$(DEFCONFIG_GDBSERVER) \
--br-defconfig out-br/extra.conf \
--make-cmd $(MAKE))
@$(MAKE) -C ../out-br all
......@@ -306,8 +313,12 @@ QEMU_EXTRA_ARGS +=\
-device virtio-9p-device,fsdev=fsdev0,mount_tag=host
endif
ifeq ($(GDBSERVER),y)
HOSTFWD := ,hostfwd=tcp::12345-:12345
endif
# Enable QEMU SLiRP user networking
QEMU_EXTRA_ARGS += -netdev user,id=vmnic -device virtio-net-device,netdev=vmnic
QEMU_EXTRA_ARGS +=\
-netdev user,id=vmnic$(HOSTFWD) -device virtio-net-device,netdev=vmnic
define run-help
@echo
......
......@@ -53,6 +53,38 @@ gateway to the host network [SLiRP].
Please note that ICMP won't work in the guest unless additional configuration is
made, so the `ping` utility won't work.
# 6. Remote debugging of Normal World applications
If you need to debug a client application, using GDB in a remote debugging
configuration may be useful. Remote debugging means `gdb` runs on your PC, where
it can access the source code, while the program being debugged runs on the remote
system (in this case, in the QEMU environment in normal world).
Here is how to do that. On your PC, build with `GDBSERVER=y`:
```
$ cd build
$ make -j8 run GDBSERVER=y
[...]
(qemu) c
```
Inside QEMU, run your application with gdbserver (for example `xtest 4002`):
```
# gdbserver :12345 xtest 4002
Process xtest created; pid = 654
Listening on port 12345
```
Back on your PC, in another terminal, start GDB and connect to the target:
```
$ ../out-br/host/bin/arm-buildroot-linux-gnueabihf-gdb
(gdb) set sysroot ../out-br/host/arm-buildroot-linux-gnueabihf/sysroot
(gdb) target remote :12345
```
Now GDB is connected to the remote application. You may use GDB normally.
```
(gdb) b main
(gdb) c
etc.
```
[bios]: https://github.com/linaro-swg/bios_qemu_tz_arm
[README.md]: ../README.md
[SLiRP]: https://wiki.qemu.org/Documentation/Networking#User_Networking_.28SLIRP.29
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment