Chapter 13. Debugging Programs That Use Overlays
107
In addition, your overlay manager may define a function called
_ovly_debug_event
. If this function
is defined, gdb will silently set a breakpoint there. If the overlay manager then calls this function
whenever it has changed the overlay table, this will enable gdb to accurately keep track of which
overlays are in program memory, and update any breakpoints that may be set in overlays. This will
allow breakpoints to work even if the overlays are kept in ROM or other non-writable memory while
they are not being executed.
13.4. Overlay Sample Program
When linking a program which uses overlays, you must place the overlays at their load addresses,
while relocating them to run at their mapped addresses. To do this, you must write a linker script
(). Unfortunately, since linker scripts are specific to a particular host system, target architecture, and
target memory layout, this manual cannot provide portable sample code demonstrating gdb’s overlay
support.
However, the gdb source distribution does contain an overlaid program, with linker scripts
for a few systems, as part of its test suite. The program consists of the following files from
gdb/testsuite/gdb.base
:
overlays.c
The main program file.
ovlymgr.c
A simple overlay manager, used by
overlays.c
.
foo.c
bar.c
baz.c
grbx.c
Overlay modules, loaded and used by
overlays.c
.
d10v.ld
m32r.ld
Linker scripts for linking the test program on the
d10v-elf
and
m32r-elf
targets.
You can build the test program using the
d10v-elf
GCC cross-compiler like this:
$ d10v-elf-gcc -g -c overlays.c
$ d10v-elf-gcc -g -c ovlymgr.c
$ d10v-elf-gcc -g -c foo.c
$ d10v-elf-gcc -g -c bar.c
$ d10v-elf-gcc -g -c baz.c
$ d10v-elf-gcc -g -c grbx.c
$ d10v-elf-gcc -g overlays.o ovlymgr.o foo.o bar.o \
baz.o grbx.o -Wl,-Td10v.ld -o overlays
The build process is identical for any other architecture, except that you must substitute the appropriate
compiler and linker script for the target system for
d10v-elf-gcc
and
d10v.ld
.
Summary of Contents for ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Page 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......