I have a problem debugging a simple program written in assembly language for the ARM7 microcontroller (AT91SAM7S64). I use gcc, gdb and OpenOCD. My program is loaded for the correct setting of the target and works fine (the LED blinks). But gdb skips certain lines of source code when I invoke the "next" command.
Here is a snippet of source code:
Reset_Handler: LDR R0, =0x0100 LDR R1, =PIOA_PER STR R0, [R1] LDR R1, =PIOA_OER STR R0, [R1] uuu: bl wait; LDR R1, =PIOA_SODR STR R0, [R1] uuu1: bl wait; LDR R2, =PIOA_CODR STR R0, [R2] b uuu; @ one second delay wait: ............. ............. .end
To get gdb output (see below), I used the "target sim" instead of the real target, but rusults is the same.
(gdb) target sim Connected to the simulator. (gdb) load Loading section .text, size 0xc8 vma 0x100000 Start address 0x100000 Transfer rate: 1600 bits in <1 sec. (gdb) b Reset_Handler Breakpoint 1 at 0x100064: file main.s, line 59. (gdb) run Starting program: C:\Arm\Projects\Asm/./main.elf Breakpoint 1, Reset_Handler () at main.s:60 60 LDR R1, =PIOA_PER (gdb) n 61 STR R0, [R1] (gdb) n 63 LDR R1, =PIOA_OER (gdb) n 64 STR R0, [R1] (gdb) n uuu () at main.s:66 66 bl wait; (gdb) n 67 LDR R1, =PIOA_SODR (gdb) n 68 STR R0, [R1] (gdb) n <<<<<--------- Here the problem begins 67 LDR R1, =PIOA_SODR (gdb) n 68 STR R0, [R1] (gdb) n 67 LDR R1, =PIOA_SODR (gdb) n 68 STR R0, [R1] (gdb) stepi <<<<<------ Doing a 'stepi' command allows to pass below 'uuu1' label uuu1 () at main.s:70 70 bl wait; (gdb) n 71 LDR R2, =PIOA_CODR (gdb) n 72 STR R0, [R2] (gdb) n 73 b uuu; (gdb) n <<<<<--------- Here the problem begins again 71 LDR R2, =PIOA_CODR (gdb) n 72 STR R0, [R2] (gdb) n 73 b uuu; (gdb) n 71 LDR R2, =PIOA_CODR (gdb) where
Gdb seems to suggest "uuu1" as a separate function and skips it for some reason. If I remove the label "uuu1", the problem will disappear. This label is not used anywhere, but the behavior of gdb looks very strange. I tried to find a solution for a long time, but I am doing significant results. Using the gcc option "-fomit-frame-pointer" did not help. What can I do about it?
Gdb and gcc versions:
arm-none-eabi-gdb --version GNU gdb (GDB) 7.1 .......... This GDB was configured as "--host=i686-pc-mingw32 --target=arm-none-eabi". arm-none-eabi-gcc --version arm-none-eabi-gcc (GCC) 4.5.1
My MakeFile:
TRGT = arm-none-eabi- CC = $(TRGT)gcc CP = $(TRGT)objcopy AS = $(TRGT)gcc -x assembler-with-cpp
Thanks in advance for your help!