158
Chapter 19. Debugging remote programs
int getDebugChar()
Write this subroutine to read a single character from the serial port. It may be identical to
getchar
for your target system; a different name is used to allow you to distinguish the two
if you wish.
void putDebugChar(int)
Write this subroutine to write a single character to the serial port. It may be identical to
putchar
for your target system; a different name is used to allow you to distinguish the two if you wish.
If you want gdb to be able to stop your program while it is running, you need to use an interrupt-driven
serial driver, and arrange for it to stop when it receives a
^C
(
\003
, the control-C character). That is
the character which gdb uses to tell the remote system to stop.
Getting the debugging target to return the proper status to gdb probably requires changes to the stan-
dard stub; one quick and dirty way is to just execute a breakpoint instruction (the "dirty" part is that
gdb reports a
SIGTRAP
instead of a
SIGINT
).
Other routines you need to supply are:
void exceptionHandler (int
exception_number
, void *
exception_address
)
Write this function to install
exception_address
in the exception handling tables. You need to
do this because the stub does not have any way of knowing what the exception handling tables on
your target system are like (for example, the processor’s table might be in rom, containing entries
which point to a table in ram).
exception_number
is the exception number which should be
changed; its meaning is architecture-dependent (for example, different numbers might represent
divide by zero, misaligned access, etc). When this exception occurs, control should be transferred
directly to
exception_address
, and the processor state (stack, registers, and so on) should be
just as it is when a processor exception occurs. So if you want to use a jump instruction to reach
exception_address
, it should be a simple jump, not a jump to subroutine.
For the 386,
exception_address
should be installed as an interrupt gate so that interrupts
are masked while the handler runs. The gate should be at privilege level 0 (the most privi-
leged level). The sparc and 68k stubs are able to mask interrupts themselves without help from
exceptionHandler
.
void flush_i_cache()
On sparc and sparclite only, write this subroutine to flush the instruction cache, if any, on your
target machine. If there is no instruction cache, this subroutine may be a no-op.
On target machines that have instruction caches, gdb requires this function to make certain that
the state of your program is stable.
You must also make sure this library routine is available:
void *memset(void *, int, int)
This is the standard library function
memset
that sets an area of memory to a known value. If
you have one of the free versions of
libc.a
,
memset
can be found there; otherwise, you must
either obtain it from your hardware manufacturer, or write your own.
If you do not use the GNU C compiler, you may need other standard library subroutines as well; this
varies from one stub to another, but in general the stubs are likely to use any of the common library
subroutines which
gcc
generates as inline code.
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: ......