Some mail from some mailing list:
I've built crossgcc for target
arm-linux and gdb for target arm-elf. (couldn't match the two targets
for some reasons but i thought it wouldn't matter. I couldn't find
any difference between them. Is there any difference?)
I tried a simple example for debugging
with gdb target as simulator and gdb ignores the breakpoints as
follows. I'll appreciate any kind of advice. Thanks in advance.
$ arm-linux-gcc -g foo.c -o foo
$ arm-elf-gdb
GNU gdb 4.18
Copyright 1998 Free Software
Foundation, Inc.
GDB is free software, covered by the
GNU General Public License, and you are
welcome to change it and/or distribute
copies of it under certain conditions.
Type "show copying" to see
the conditions.
There is absolutely no warranty for
GDB. Type "show warranty" for details.
This GDB was configured as
"--host=i686-pc-linux-gnu --target=arm-elf".
(gdb) file foo
Reading symbols from foo...done.
(gdb) target sim
Connected to the simulator.
(gdb) load foo
Loading section .interp, size 0x27 vma
0x20000f4
Loading section .note.ABI-tag, size
0x20 vma 0x2000120
Loading section .hash, size 0x24 vma
0x2000140
Loading section .dynsym, size 0x40 vma
0x2000164
Loading section .dynstr, size 0x3c vma
0x20001a4
Loading section .gnu.version, size 0x8
vma 0x20001e0
Loading section .gnu.version_r, size
0x20 vma 0x20001e8
Loading section .rel.plt, size 0x10 vma
0x2000208
Loading section .init, size 0x18 vma
0x2000218
Loading section .plt, size 0x30 vma
0x2000230
Loading section .text, size 0x350 vma
0x2000260
Loading section .fini, size 0x14 vma
0x20005b0
Loading section .rodata, size 0x4 vma
0x20005c4
Loading section .data, size 0xc vma
0x20085c8
Loading section .ctors, size 0x8 vma
0x20085d4
Loading section .dtors, size 0x8 vma
0x20085dc
Loading section .got, size 0x14 vma
0x20085e4
Loading section .dynamic, size 0x88 vma
0x20085f8
Start address 0x2000260
Transfer rate: 11320 bits in <1 sec.
(gdb) list main
1 int main()
2 {
3 int a=27;
4 int b=4;
5 int c;
6 c=a*b;
(gdb)
7 c=a%b;
8 c=a/b;
9 }
(gdb) br 7
Breakpoint 1 at 0x200036c: file foo.c,
line 7.
(gdb) run
Starting program:
/home/totohero/test/foo
Program exited with code 074.
(gdb) quit
From gdb manual:
For some configurations, GDB includes a CPU simulator that you can
use instead of a hardware CPU to debug your programs. Currently,
simulators are available for ARM, D10V, D30V, FR30, H8/300, H8/500,
i960, M32R, MIPS, MN10200, MN10300, PowerPC, SH, Sparc, V850, W65,
and Z8000.
For the Z8000 family, `target sim' simulates either
the Z8002 (the unsegmented variant of the Z8000 architecture) or the
Z8001 (the segmented variant). The simulator recognizes which
architecture is appropriate by inspecting the object code.
target sim
args
Debug programs on a
simulated CPU. If the simulator supports setup options, specify them
via args.
After specifying this target, you can debug programs for the
simulated CPU in the same style as programs for your host computer;
use the file
command to load a new program image, the
run
command to run your program, and so on.
As well as making available all the usual machine registers (see
info reg
), the Z8000 simulator provides three additional
items of information as specially named registers:
cycles
Counts clock-ticks in the simulator.
insts
Counts instructions run in the simulator.
time
Execution time in 60ths of a second.
You can refer to these values in GDB expressions with the usual
conventions; for example, `b fputc if $cycles>5000'
sets a conditional breakpoint that suspends only after at least 5000
simulated clock ticks.