Hi,
I'm trying to use GDB with XDS GDB agent to debug a program running in RAM on an RM46 LaunchPad. I'm seeing all kinds of weird behavior related to software breakpoints and stepping through the code. I've been trying to come up with a minimal test example. This is what I've got.
I have a simple assembly program loaded that has some instructions in ARM mode, some instructions in THUMB mode:
.syntax unified
.arm
start:
b test1
test1:
blx test2
.thumb
test2:
b test3
test3:
b test2
Note that "test1" is in ARM mode, but "test2" and "test3" are in THUMB mode. Here's a disassembled version of the code:
$ arm-none-eabi-objdump -d main.elf
main.elf: file format elf32-littlearm
Disassembly of section .text:
08000000 <start>:
8000000: eaffffff b 8000004 <test1>
08000004 <test1>:
8000004: faffffff blx 8000008 <test2>
08000008 <test2>:
8000008: e7ff b.n 800000a <test3>
0800000a <test3>:
800000a: e7fd b.n 8000008 <test2>
I load the assembled program at 0x8000000 (using GDB's "load"). I set a breakpoint on "test2" and try to single step through the program with "stepi". It works for a few steps, but then suddenly I find the PC has jumped ahead. Here's the console log from gdb:
$ arm-none-eabi-gdb -ex 'target remote :55000' -ex 'set confirm off' -ex 'file main.elf'
GNU gdb (GNU Tools for ARM Embedded Processors) 7.10.1.20160923-cvs
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <gnu.org/.../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-apple-darwin10 --target=arm-none-eabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
Find the GDB manual and other documentation resources online at:
For help, type "help".
Type "apropos word" to search for commands related to "word".
Remote debugging using :55000
0x00000020 in ?? ()
Reading symbols from main.elf...done.
(gdb) load
Loading section .text, size 0xc lma 0x8000000
Start address 0x8000000, load size 12
Transfer rate: 363 bytes/sec, 12 bytes/write.
(gdb) break test2
Breakpoint 1 at 0x8000008: file main.S, line 12.
(gdb) stepi
test1 () at main.S:8
8 blx test2
(gdb) stepi
Breakpoint 1, test2 () at main.S:12
12 b test3
(gdb) stepi
test3 () at main.S:15
15 b test2
(gdb) stepi
0x0800024e in ?? ()
(gdb) print $pc
$1 = (void (*)()) 0x800024e
(gdb) disas start
Dump of assembler code for function start:
0x08000000 <+0>: b 0x8000004 <test1>
End of assembler dump.
(gdb) disas test1
Dump of assembler code for function test1:
0x08000004 <+0>: blx 0x8000008 <test2>
End of assembler dump.
(gdb) disas test2
Dump of assembler code for function test2:
0x08000008 <+0>: b.n 0x800000a <test3>
End of assembler dump.
(gdb) disas test3
Dump of assembler code for function test3:
0x0800000a <+0>: b.n 0x8000008 <test2>
End of assembler dump.
(gdb)
Any ideas what is going on? To me, it looks like XDS GDB agent is setting software breakpoints incorrectly somehow. Perhaps it is not invalidating some instruction cache or pipeline after writing to RAM?
Thanks,
Girts