Reputation: 11466
I am trying to develop a C++ application for the RTEMS RTOS but I am having trouble getting debugging to work. They have a basic LED blinky example written in C that I am able to debug. However, converting this to C++ causes gdb to not be able to find the source file.
If I connect gdb
to the C app and run info sources
, I can see my init.c
file right at the top followed by all the RTEMS sources. Repeating this for the C++ app, there is no mention of init.cpp
. Using objdump
on the exe/ELF files, I can see in debug_info
and debug_str
the path to init.c
. But in the C++ app, there is no mention of the path to init.cpp
.
The C app and the C++ app are nested under the same top level directory and use the same wscript
file to configure the compiler. Both apps are being compiled with -Og
and -g
. What would prevent the source path from being written to the debug section of the ELF file?
Relavant wscript
sections:
Top level script
def build(bld):
rtems.build(bld)
bld.env.CFLAGS += ['-Og','-g']
Source level script
def build(bld):
# Create include path nodes
board_inc = bld.root.find_node('/home/kyle/rtems-core/rtems/bsps/arm/atsam/contrib/libraries/libboard/')
chip_inc = bld.root.find_node('/home/kyle/rtems-core/rtems/bsps/arm/atsam/include/libchip/')
component_inc = bld.root.find_node('/home/kyle/rtems-core/rtems/bsps/arm/atsam/include/libchip/include/samv71/component/')
print(chip_inc.abspath())
rtems.build(bld)
bld(features = 'cxx cxxprogram',
target = 'timerpp.exe',
source = ['init.cpp'],
includes = ['.', board_inc, chip_inc, component_inc])
Here are the compile flags as noted by objdump
for the C version (check the DW_AT_producer
line):
<0><31>: Abbrev Number: 57 (DW_TAG_compile_unit)
<32> DW_AT_producer : (indirect string, offset: 0x939): GNU C17 13.2.1 20240412 (RTEMS 6, RSB 89172ba5819a12ea22f49a134008e949daae6c94, Newlib 176b19f) -ftls-model=local-exec -mthumb -mcpu=cortex-m7 -mfpu=fpv5-d16 -mfloat-abi=hard -march=armv7e-m+fp.dp -g -Og
<36> DW_AT_language : 29 (C11)
<37> DW_AT_name : (indirect string, offset: 0x760): ../../led/timer/init.c
<3b> DW_AT_comp_dir : (indirect string, offset: 0x2a93): /home/kyle/rtems-core/rtems-examples/build/arm-rtems6-atsamv
And the same for the C++ version:
<0><31>: Abbrev Number: 51 (DW_TAG_compile_unit)
<32> DW_AT_producer : (indirect string, offset: 0x914): GNU C17 13.2.1 20240412 (RTEMS 6, RSB 89172ba5819a12ea22f49a134008e949daae6c94, Newlib 176b19f) -ftls-model=local-exec -mthumb -mcpu=cortex-m7 -mfloat-abi=hard -march=armv7e-m+fp.dp -g -g -g -O2 -O2 -O2 -fbuilding-libgcc -fno-stack-protector -fno-inline -fexceptions -fvisibility=hidden
<36> DW_AT_language : 29 (C11)
<37> DW_AT_name : (indirect string, offset: 0x227): ../../../../../../gnu-mirror-gcc-54a235e/libgcc/config/arm/unwind-arm.c
<3b> DW_AT_comp_dir : (indirect string, offset: 0x69): /home/kyle/rtems-core/rtems-source-builder/rtems/build/arm-rtems6-gcc-54a235e-newlib-176b19f-x86_64-linux-gnu-1/build/arm-rtems6/thumb/cortex-m7/hard/libgcc
This project uses the waf
build system. This is the closest to gcc
/g++
command lines as I can get out of waf
.
15:33:09 deps scanner for kyle/shell/init.c: []; unresolved: []
{task 139852547300640: c init.c -> init.c.1.o} must run: it was never run before or the task code changed
[10/84] Compiling kyle/shell/init.c
15:33:09 runner ['/home/kyle/rtems-core/tools/bin/arm-rtems6-gcc', '-mthumb', '-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard', '-isystem/home/kyle/rtems-core/bsp-install/arm-rtems6/atsamv/lib/include', '-MMD', '-Og', '-g', '-Ikyle/shell', '-I../../kyle/shell', '-I../../../rtems/bsps/arm/atsam/contrib/libraries/libboard', '-I../../../rtems/bsps/arm/atsam/include/libchip', '-I../../../rtems/bsps/arm/atsam/include/libchip/include/samv71/component', '-DBOARD_SAMV71_XULT=1', '../../kyle/shell/init.c', '-c', '-o/home/kyle/rtems-core/rtems-examples/build/arm-rtems6-atsamv/kyle/shell/init.c.1.o']
15:33:09 deps scanner for kyle/timerpp/init.cpp: []; unresolved: []
{task 139852547300976: cxx init.cpp -> init.cpp.1.o} must run: it was never run before or the task code changed
[11/84] Compiling kyle/timerpp/init.cpp
15:33:09 runner ['/home/kyle/rtems-core/tools/bin/arm-rtems6-g++', '-mthumb', '-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard', '-isystem/home/kyle/rtems-core/bsp-install/arm-rtems6/atsamv/lib/include', '-MMD', '-Ikyle/timerpp', '-I../../kyle/timerpp', '-I../../../rtems/bsps/arm/atsam/contrib/libraries/libboard', '-I../../../rtems/bsps/arm/atsam/include/libchip', '-I../../../rtems/bsps/arm/atsam/include/libchip/include/samv71/component', '-DBOARD_SAMV71_XULT=1', '../../kyle/timerpp/init.cpp', '-c', '-o/home/kyle/rtems-core/rtems-examples/build/arm-rtems6-atsamv/kyle/timerpp/init.cpp.1.o']
15:33:09 deps scanner for led/timer/init.c: []; unresolved: []
{task 139852547301536: c init.c -> init.c.1.o} must run: it was never run before or the task code changed
[12/84] Compiling led/timer/init.c
15:33:09 runner ['/home/kyle/rtems-core/tools/bin/arm-rtems6-gcc', '-mthumb', '-mcpu=cortex-m7', '-mfpu=fpv5-d16', '-mfloat-abi=hard', '-isystem/home/kyle/rtems-core/bsp-install/arm-rtems6/atsamv/lib/include', '-MMD', '-Og', '-g', '-Iled/timer', '-I../../led/timer', '-I../../../rtems/bsps/arm/atsam/contrib/libraries/libboard', '-I../../../rtems/bsps/arm/atsam/include/libchip', '-I../../../rtems/bsps/arm/atsam/include/libchip/include/samv71/component', '-DBOARD_SAMV71_XULT=1', '../../led/timer/init.c', '-c', '-o/home/kyle/rtems-core/rtems-examples/build/arm-rtems6-atsamv/led/timer/init.c.1.o']
This shows three of the programs being compiled in the examples directory. Their example is shown on the line starting [12/84] Compiling led/timer/init.c
and shows the flags from the top-level wscript
being passed correctly.
Looking at another C program that I've created in my personal directory, [10/84] Compiling kyle/shell/init.c
, also shows the flags being passed correctly.
But when I'm trying to compile a C++ program as seen in [11/84] Compiling kyle/timerpp/init.cpp
the flags I've set are not being passed. This is further evidenced by the objdump
above showing different flags and not including the path to the init.cpp
file.
What would cause waf
to pass the flags I've defined to a C program but not a C++ program? And what is causing g++
to not include the path to the source file in the debug sections of the ELF file?
Upvotes: 0
Views: 92