Enabling debugging symbols when compiling packages with Turris-OS

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

An OpenWrt user had the same kind of problem and never got the answer:

This might be an OpenWrt problem instead of being specific to Turris-OS but I’m hoping that someone here has gotten debugging to work recently.

1 Like

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.

1 Like

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.

Thank you for your responses.

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”.

How did you determine the binary doesn’t have the symbols? By running gdb on Omnia or by objdump?

I ran gdb on Omnia. I have run objdump on the binary now, though, and that also doesn’t show any debugging symbols.

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.