i want to debug stepwise through the sources of a program that is formed by the linker from multiple object files.
For simplicity i assume that one source is an assembly-file, where the startup routines are located and the other is a c-file. The program is build by the following makefile
PREFIX=/opt/arm/bin
LDSCRIPT=ld.script
AS_BASEN=$(basename startup.s)
C_BASEN=$(basename main.c)
ASFLAGS=-g
CCFLAGS=-g -nostartfiles
LDFLAGS=--fatal-warnings
$(C_BASEN).bin: $(C_BASEN).elf
$(PREFIX)/arm-objcopy -O binary $< $@
$(C_BASEN).elf: $(LDSCRIPT) $(AS_BASEN).o $(C_BASEN).o
$(PREFIX)/arm-ld $(LDFLAGS) -T $(LDSCRIPT) $(AS_BASEN).o $(C_BASEN).o -o $@
$(C_BASEN).o: $(C_BASEN).c
$(PREFIX)/arm-gcc $(CFLAGS) -c $< -o $@
$(AS_BASEN).o: $(AS_BASEN).s Makefile
$(PREFIX)/arm-as $(ASFLAGS) $< -o $@
Altough i think that my problem is independet of openocd i state the openocd specific part for the sake of completeness. I initiate the debugging session with the following commands, after the openocd daemon is started.
nc localhost 4444 <<eof
soft_reset_halt
load_image `pwd`/main.bin $memory_location
step $memory_location
exit
eof
ddd --debugger 'arm-gdb -ex "target remote localhost:3333"'
where $memory_location is the first address of the .text section. After ddd
is open the program halts at the desired address and i can single step through the assembly lines as usual. Finally i arrive at the jump instruction, that jumps to the function that is located in the c-file. After one more step gdb doesn't respond anylonger whereas the program is executed.
Maybe one of you experts can give me a hint what i have to change, so that gdb switch at this point to the c-source, where i can continue the stepwise execution.