Compile Legato application with debug information to print readable stack backtrace

I am trying to print a readable stack backtrace when handling signals (e.g. SIGV).
Currently the backtrace does not contain any references to functions in my source code:

 0) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x34400) [0xb6eb6400]
 1) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x344e8) [0xb6eb64e8]
 2) /lib/libc.so.6(__default_sa_restorer+0) [0xb6c191e0]
 3) /lib/libpthread.so.0(+0x12194) [0xb6dd4194]
 4) /lib/libpthread.so.0(+0x122e8) [0xb6dd42e8]
 5) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x2315c) [0xb6ea515c]
 6) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x1b210) [0xb6e9d210]
 7) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0xf62c) [0xb6e9162c]
 8) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x12d94) [0xb6e94d94]
 9) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x12ed4) [0xb6e94ed4]
10) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x10968) [0xb6e92968]
11) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x35788) [0xb6eb7788]
12) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(+0x3462c) [0xb6eb662c]
13) /legato/systems/current/appsWriteable/CollectorApp/bin/../lib/libComponent_CollectorComponent.so(_CollectorComponent_COMPONENT_INIT+0xb4) [0xb6e85a78]

Upon further inspection I found that the executable in /legato/systems/current/appsWriteable/collectorApp/bin is stripped, which would explain why I don’t get any function names.

I have tried running mkapp with the -d option but that generates a seperate .debug file and I want this information to be included in the binary itself.

I have checked in the target:

root@swi-mdm9x28-wp:~# ls -l /legato/systems/current/appsWriteable/hello1/bin/he
llo1
lrwxrwxrwx    1 root     root            56 Jan  6 08:05 /legato/systems/current/appsWriteable/hello1/bin/hello1 -> /legato/systems/current/apps/hello1/read-only/bin/hello1
root@swi-mdm9x28-wp:~# ls -l /legato/systems/current/apps/hello1/read-only/bin/h
ello1
-rwxr-xr-x    1 root     root         17156 Jan  6 08:05 /legato/systems/current/apps/hello1/read-only/bin/hello1

Then I checked the same file in build folder:

owner@ubuntu:~/leaf$ ls -l _build_hello1/wp76xx/app/hello1/obj/hello1/hello1 
-rwxrwxr-x 1 owner owner 17156 Nov 13 14:49 _build_hello1/wp76xx/app/hello1/obj/
owner@ubuntu:~/leaf$ file  _build_hello1/wp76xx/app/hello1/obj/hello1/hello1 
_build_hello1/wp76xx/app/hello1/obj/hello1/hello1: ELF 32-bit LSB shared object, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.3, for GNU/Linux 3.2.0, BuildID[sha1]=ff606e2ffebae987cbec835562a22357ed8b057d, with debug_info, not stripped

By default, It is already “not stripped”.

BTW, you might also take a look here: