GDB cannot find source code files

Hi. I’m trying to debug the hello.exe sample test on raspberry Pi (using QEMU) and remotely connecting to the GDB server. Here are the commands I’m using to run the QEMU machine and the GDB commands to connect to the GDB server:

Run QEmu with GDB Server:

qemu-system-arm.exe -M raspi2b -m 1G -kernel hello.exe -serial mon:stdio -nographic -S -s

NOTE: qemu-system-arm.exe is running on windows host.

Connect to GDB Server:

~/rtems-root/rtems/7/bin/arm-rtems7-gdb --directory /home/sulemankm/rtems-root/rtems.git/src/rtems -ex "target remote 192.168.0.100:1234" hello.exe

NOTE: arm-rtems7-gdb is running in WSL (Debian), and all RTEMS source code is inside WSL.

A sample session of the GDB is as below:

GNU gdb (GDB) 16.2
Copyright (C) 2024 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "--host=x86_64-linux-gnu --target=arm-rtems7".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
    <http://www.gnu.org/software/gdb/documentation/>.

For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from hello.exe...
RTEMS GDB Support
Remote debugging using 192.168.0.100:1234
_start () at ../../../bsps/arm/shared/start/start.S:209
warning: 209    ../../../bsps/arm/shared/start/start.S: No such file or directory
(gdb) break Init
Breakpoint 1 at 0x2006a8: file ../../../testsuites/samples/hello/init.c, line 44.
(gdb) continue
Continuing.
(gdb) ^C
Thread 4 received signal SIGINT, Interrupt.
[Switching to Thread 1.4]
bsp_vector_table_begin () at ../../../bsps/arm/shared/start/start.S:86
86      in ../../../bsps/arm/shared/start/start.S
(gdb) backtrace
#0  bsp_vector_table_begin () at ../../../bsps/arm/shared/start/start.S:86
#1  0x00203700 in save_more_context () at ../../../cpukit/score/cpu/arm/armv4-exception-default.S:118
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb) 

These are the issues/questions I have:

a. GDB cannot find the source file while debugging so source code listings are not available. It erronously tries to find source code files inside the RTEMS build directory eg /home/sulemankm/rtems-root/rtems.git/src/rtems/build/rtems-kernel-bsps-1/rtems-kernel-bsps-1-190899ee614605067233e16cc478b2b5f4833b6f/rtems-190899ee614605067233e16cc478b2b5f4833b6f/bsps/arm/shared/start/start.S, even though I tried to give the --directory command line option to GDB.

b. Why is the program stuck in the function bsp_vector_table_begin. It doesn’t seem to exit it?

Could anyone let me know what I’m doing wrong and how to correct this situation?

To modify the path GDB accesses for the source files you can try to use:
set substitute-path ../../../ <path to your rtems sources>

1 Like

Thanks, that worked.