I would like to remotely debug a program which I am developing. It is running on a Turris Omnia and has been cross-compiled with the toolchain in Turris-OS.
The debugging symbols are getting stripped from the executable.
So far I have tried:
Adding ‘TARGET_CFLAGS += -ggdb3’ to the Makefile
Global build settings -> Compile packages with debugging info
Global build settings -> Binary stripping method (none)
Advanced configuration options -> Toolchain options -> (C Library) Build with debug information
OpenWRT does not sypport debugging on router. It strips down all symbols durring install phase of package creation (when package is created). Only way to debug programs on router is to use unstripped bimaries in OpenWRT SDK and gdb server on router. OpenWRT has script fot that: scripts/remote-gdb. Its usage is briefly described here: https://wiki.openwrt.org/doc/devel/gdb
It works but sometimes it stucks for unknown reason and you have to restart both ends but it is at least something.
I think using the OpenWRT build system for development is not very optimal. I found out it’s better to have standard build scripts that just use the OpenWRT toolchain and then deploy the debug binary. The OpenWRT-specific build scripts can be written later. Depending on what your program requires/uses, you also might be able to use a LXC container for building and debugging, which is even more convenient.
I think I have seen that page before, cynerd, and it is where I got some of the things I tried out with CFLAGS and changing the settings in ‘make menuconfig’. Would I be correct in thinking that the *.ipk file which gets constructed will have no debugging symbols but the executable which is in the build_dir should still have debugging symbols? I have tried copying the executable directly to the Turris still no debugging symbols.
I have now also tried building it manually with a more detailed Makefile which explicitly states where the include files, libraries and cross-compilation version of gcc is – so only relying on the bare minimum of the build system that I think I need. The build works, the executable runs on the Omnia, but again no debugging symbols.
I’m really hoping I can get this to work on the Omnia because the program relies on processing captured packets as they go past. I can simulate that in an LXC container but I am finding it is quite different when it is “in the wild”.
I’ve had some problems with gdb on Omnia being out of sync with the SDK I was using for build. It’s strange your binary wouldn’t have debug symbols. I think you could try inspecting your binary with objdump or building debug a hello world with your toolchain and directly on Omnia and compare the results.