[Buildroot] uClibc debug symbols

Thomas Petazzoni thomas.petazzoni at free-electrons.com
Thu May 12 13:41:48 UTC 2016


Hello,

On Thu, 12 May 2016 12:23:52 +0200, Luca Ellero wrote:

> ifeq ($(BR2_ENABLE_DEBUG),y)
> GLIBC_EXTRA_CFLAGS += -g
> endif
> 
> But I cannot find anything similar in UClibc.

Right, we should add explicit handling for BR2_ENABLE_DEBUG in the
uClibc package.

> So my questions are:
> - what is the clean way to enable debug symbols on all packages (or at 
> least on some of them)?

Enabling BR2_ENABLE_DEBUG, as you did.

> - what is the purpose of BR2_ENABLE_DEBUG if it doesn't enable debug on 
> all packages?

The main thing that BR2_ENABLE_DEBUG does is to enable the following
piece of code from package/Makefile.in:

ifeq ($(BR2_DEBUG_1),y)
TARGET_DEBUGGING = -g1
endif
ifeq ($(BR2_DEBUG_2),y)
TARGET_DEBUGGING = -g2
endif
ifeq ($(BR2_DEBUG_3),y)
TARGET_DEBUGGING = -g3
endif

[...]

TARGET_CFLAGS = $(TARGET_CPPFLAGS) $(TARGET_ABI) $(TARGET_OPTIMIZATION) $(TARGET_DEBUGGING)
TARGET_CXXFLAGS = $(TARGET_CFLAGS)

So TARGET_CFLAGS and TARGET_CXXFLAGS will contain -g1, -g2 or -g3
depending on the debugging "level" requested.

Then, it all depends on each package whether it properly observes
TARGET_CFLAGS/TARGET_CXXFLAGS. I think most autotools-based packages
should behave fine, and all CMake-based packages should also behave
fine.

However, for other packages (mainly the ones that use the
generic-package infrastructure), it is very possible that they don't
pass TARGET_CFLAGS/TARGET_CXXFLAGS everywhere.

Actually, a very useful check to add at the end of the Buidroot build
would be to verify that all binaries have debugging symbols in
STAGING_DIR when BR2_ENABLE_DEBUG=y. This way, the autobuilders would
automatically catch packages that don't behave properly. Adding this
check is probably easy. Fixing the issues that will be found by this
check might prove to be more difficult, however.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com



More information about the buildroot mailing list