I am trying to debug a simple assembly language program in gdb and setting a breakpoint at the _start label(line 5), but when I run it, the program stops one line after on line 6, not on line 5.
I cannot find the reason for this behaviour on google or from my searches on the Raspbian bug database.
To repeat the steps below, run the program on a Raspberry Pi 3 running Raspbian 8.0 Jessie and gdb version 7.7.1
1 @filename: P2_1.s -- program adds contents of two registers together. 2 3 .text 4 .global _start 5 _start: MOV R1, #0x25 @storing 25 hex in R1 6 MOV R2, #0x34 @storing 34 hex in R2 7 ADD R3, R2, R1 @adding R1 and R2 8 HERE: B HERE @infinite loop 9 .end
Compile and link including debug symbols like this:
$ as -g -o P2_1.o P2_1.s; ld -o P2_1 P2_1.o
Then run gdb like this:
$ gdb P2_1
Then in gdb add a breakpoint at the _start label like this:
(gdb) break _start Breakpoint 1 at 0x10058: file P2_1.s, line 6.
The breakpoint is added to line 6 not line 5. When you run it, it should stop at line 5, but it doesnt. It stops at line 6.
Is this normal behaviour of gdb or is it a bug?