]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/doc/gdbinv-s.m4.in
More conditional markup so HMS (Hitachi) can have the configuration
[thirdparty/binutils-gdb.git] / gdb / doc / gdbinv-s.m4.in
1 _dnl__ -*- Texinfo -*-
2 _dnl__ Copyright (c) 1990 1991 1992 Free Software Foundation, Inc.
3 _dnl__ This file is part of the source for the GDB manual.
4 _dnl__ M4 FRAGMENT $Id$
5 _dnl__ This text diverted to "Remote Debugging" section in general case;
6 _dnl__ however, if we're doing a manual specifically for one of these, it
7 _dnl__ belongs up front (in "Getting In and Out" chapter).
8 _if__(_REMOTESTUB__)
9 @node Remote Serial
10 @subsection The _GDBN__ remote serial protocol
11
12 @cindex remote serial debugging, overview
13 To debug a program running on another machine (the debugging
14 @dfn{target} machine), you must first arrange for all the usual
15 prerequisites for the program to run by itself. For example, for a C
16 program, you need
17
18 @enumerate
19 @item
20 A startup routine to set up the C runtime environment; these usually
21 have a name like @file{crt0}. The startup routine may be supplied by
22 your hardware supplier, or you may have to write your own.
23
24 @item
25 You probably need a C subroutine library to support your program's
26 subroutine calls, notably managing input and output.
27
28 @item
29 A way of getting your program to the other machine---for example, a
30 download program. These are often supplied by the hardware
31 manufacturer, but you may have to write your own from hardware
32 documentation.
33 @end enumerate
34
35 The next step is to arrange for your program to use a serial port to
36 communicate with the machine where _GDBN__ is running (the @dfn{host}
37 machine). In general terms, the scheme looks like this:
38
39 @table @emph
40 @item On the host,
41 _GDBN__ already understands how to use this protocol; when everything
42 else is set up, you can simply use the @samp{target remote} command
43 (@pxref{Targets,,Specifying a Debugging Target}).
44
45 @item On the target,
46 you must link with your program a few special-purpose subroutines that
47 implement the _GDBN__ remote serial protocol. The file containing these
48 subroutines is called a @dfn{debugging stub}.
49 @end table
50
51 The debugging stub is specific to the architecture of the remote
52 machine; for example, use @file{sparc-stub.c} to debug programs on
53 @sc{sparc} boards.
54
55 @cindex remote serial stub list
56 These working remote stubs are distributed with _GDBN__:
57
58 @c FIXME! verify these...
59 @table @code
60 @item sparc-stub.c
61 @kindex sparc-stub.c
62 For @sc{sparc} architectures.
63
64 @item m68k-stub.c
65 @kindex m68-stub.c
66 For Motorola 680x0 architectures.
67
68 @item i386-stub.c
69 @kindex i36-stub.c
70 For Intel 386 and compatible architectures.
71 @end table
72
73 The @file{README} file in the _GDBN__ distribution may list other
74 recently added stubs.
75
76 @menu
77 * stub contents:: What the stub can do for you
78 * bootstrapping:: What you must do for the stub
79 * debug session:: Putting it all together
80 * protocol:: Outline of the communication protocol
81 @end menu
82
83 @node stub contents
84 @subsubsection What the stub can do for you
85
86 @cindex remote serial stub
87 The debugging stub for your architecture supplies these three
88 subroutines:
89
90 @table @code
91 @item set_debug_traps
92 @kindex set_debug_traps
93 @cindex remote serial stub, initialization
94 This routine arranges to transfer control to @code{handle_exception}
95 when your program stops. You must call this subroutine explicitly near
96 the beginning of your program.
97
98 @item handle_exception
99 @kindex handle_exception
100 @cindex remote serial stub, main routine
101 This is the central workhorse, but your program never calls it
102 explicitly---the setup code arranges for @code{handle_exception} to
103 run when a trap is triggered.
104
105 @code{handle_exception} takes control when your program stops during
106 execution (for example, on a breakpoint), and mediates communications
107 with _GDBN__ on the host machine. This is where the communications
108 protocol is implemented; @code{handle_exception} acts as the _GDBN__
109 representative on the target machine; it begins by sending summary
110 information on the state of your program, then continues to execute,
111 retrieving and transmitting any information _GDBN__ needs, until you
112 execute a _GDBN__ command that makes your program resume; at that point,
113 @code{handle_exception} returns control to your own code on the target
114 machine.
115
116 @item breakpoint
117 @cindex @code{breakpoint} subroutine, remote
118 Use this auxiliary subroutine to make your program contain a
119 breakpoint. Depending on the particular situation, this may be the only
120 way for _GDBN__ to get control. For instance, if your target
121 machine has some sort of interrupt button, you won't need to call this;
122 pressing the interrupt button will transfer control to
123 @code{handle_exception}---in efect, to _GDBN__. On some machines,
124 simply receiving characters on the serial port may also trigger a trap;
125 again, in that situation, you don't need to call @code{breakpoint} from
126 your own program---simply running @samp{target remote} from the host
127 _GDBN__ session will get control.
128
129 Call @code{breakpoint} if none of these is true, or if you simply want
130 to make certain your program stops at a predetermined point for the
131 start of your debugging session.
132 @end table
133
134 @node bootstrapping
135 @subsubsection What you must do for the stub
136
137 @cindex remote stub, support routines
138 The debugging stubs that come with _GDBN__ are set up for a particular
139 chip architecture, but they have no information about the rest of your
140 debugging target machine. To allow the stub to work, you must supply
141 these special low-level subroutines:
142
143 @table @code
144 @item int getDebugChar()
145 @kindex getDebugChar
146 Write this subroutine to read a single character from the serial port.
147 It may be identical to @code{getchar} for your target system; a
148 different name is used to allow you to distinguish the two if you wish.
149
150 @item void putDebugChar(int)
151 @kindex putDebugChar
152 Write this subroutine to write a single character to the serial port.
153 It may be identical to @code{putchar} for your target system; a
154 different name is used to allow you to distinguish the two if you wish.
155
156 @item void flush_i_cache()
157 @kindex flush_i_cache
158 Write this subroutine to flush the instruction cache, if any, on your
159 target machine. If there is no instruction cache, this subroutine may
160 be a no-op.
161
162 On target machines that have instruction caches, _GDBN__ requires this
163 function to make certain that the state of your program is stable.
164 @end table
165
166 @noindent
167 You must also make sure this library routine is available:
168
169 @table @code
170 @item void *memset(void *, int, int)
171 @kindex memset
172 This is the standard library function @code{memset} that sets an area of
173 memory to a known value. If you have one of the free versions of
174 @code{libc.a}, @code{memset} can be found there; otherwise, you must
175 either obtain it from your hardware manufacturer, or write your own.
176 @end table
177
178 If you do not use the GNU C compiler, you may need other standard
179 library subroutines as well; this will vary from one stub to another,
180 but in general the stubs are likely to use any of the common library
181 subroutines which @code{gcc} generates as inline code.
182
183
184 @node debug session
185 @subsubsection Putting it all together
186
187 @cindex remote serial debugging summary
188 In summary, when your program is ready to debug, you must follow these
189 steps.
190
191 @enumerate
192 @item
193 Make sure you have the supporting low-level routines:
194 @code{getDebugChar}, @code{putDebugChar}, @code{flush_i_cache},
195 @code{memset}.
196
197 @item
198 Insert these lines near the top of your program:
199
200 @example
201 set_debug_traps();
202 breakpoint();
203 @end example
204
205 @item
206 Compile and link together: your program, the _GDBN__ debugging stub for
207 your target architecture, and the supporting subroutines.
208
209 @item
210 Make sure you have a serial connection between your target machine and
211 the _GDBN__ host, and identify the serial port used for this on the host.
212
213 @item
214 Download your program to your target machine (or get it there by
215 whatever means the manufacturer provides), and start it.
216
217 @item
218 To start remote debugging, run _GDBN__ on the host machine, and specify
219 as an executable file the program that is running in the remote machine.
220 This tells _GDBN__ how to find your program's symbols and the contents
221 of its pure text.
222
223 Then establish communication using the @code{target remote} command.
224 Its argument is the name of the device you're using to control the
225 target machine. For example:
226
227 @example
228 target remote /dev/ttyb
229 @end example
230
231 @noindent
232 if the serial line is connected to the device named @file{/dev/ttyb}.
233 @ignore
234 @c this is from the old text, but it doesn't seem to make sense now that I've
235 @c seen an example... pesch 4sep1992
236 This will stop the remote machine if it is not already stopped.
237 @end ignore
238
239 @end enumerate
240
241 Now you can use all the usual commands to examine and change data and to
242 step and continue the remote program.
243
244 To resume the remote program and stop debugging it, use the @code{detach}
245 command.
246
247 @node protocol
248 @subsubsection Outline of the communication protocol
249
250 @cindex debugging stub, example
251 @cindex remote stub, example
252 @cindex stub example, remote debugging
253 The stub files provided with _GDBN__ implement the target side of the
254 communication protocol, and the _GDBN__ side is implemented in the
255 _GDBN__ source file @file{remote.c}. Normally, you can simply allow
256 these subroutines to communicate, and ignore the details. (If you're
257 implementing your own stub file, you can still ignore the details: start
258 with one of the existing stub files. @file{sparc-stub.c} is the best
259 organized, and therefore the easiest to read.)
260
261 However, there may be occasions when you need to know something about
262 the protocol---for example, if there is only one serial port to your
263 target machine, you might want your program to do something special if
264 it recognizes a packet meant for _GDBN__.
265
266 @cindex protocol, _GDBN__ remote serial
267 @cindex serial protocol, _GDBN__ remote
268 @cindex remote serial protocol
269 All _GDBN__ commands and responses (other than acknowledgements, which
270 are single characters) are sent as a packet which includes a
271 checksum. A packet is introduced with the character @samp{$}, and ends
272 with the character @samp{#} followed by a two-digit checksum:
273
274 @example
275 $@var{packet info}#@var{checksum}
276 @end example
277
278 @cindex checksum, for _GDBN__ remote
279 @noindent
280 @var{checksum} is computed as the modulo 256 sum of the @var{packet
281 info} characters.
282
283 When either the host or the target machine receives a packet, the first
284 response expected is an acknowledgement: a single character, either
285 @samp{+} (to indicate the package was received correctly) or @samp{-}
286 (to request retransmission).
287
288 The host (_GDBN__) sends commands, and the target (the debugging stub
289 incorporated in your program) sends data in response. The target also
290 sends data when your program stops.
291
292 Command packets are distinguished by their first character, which
293 identifies the kind of command.
294
295 These are the commands currently supported:
296
297 @table @code
298 @item g
299 Requests the values of CPU registers.
300
301 @item G
302 Sets the values of CPU registers.
303
304 @item m@var{addr},@var{count}
305 Read @var{count} bytes at location @var{addr}.
306
307 @item M@var{addr},@var{count}:@dots{}
308 Write @var{count} bytes at location @var{addr}.
309
310 @item c
311 @itemx c@var{addr}
312 Resume execution at the current address (or at @var{addr} if supplied).
313
314 @item s
315 @itemx s@var{addr}
316 Step the target program for one instruction, from either the current
317 program counter or from @var{addr} if supplied.
318
319 @item k
320 Kill the target program.
321
322 @item ?
323 Report the most recent signal. To allow you to take advantage of the
324 _GDBN__ signal handling commands, one of the functions of the debugging
325 stub is to report CPU traps as the corresponding POSIX signal values.
326 @end table
327
328 @kindex set remotedebug
329 @kindex show remotedebug
330 @cindex packets, reporting on stdout
331 @cindex serial connections, debugging
332 If you have trouble with the serial connection, you can use the command
333 @code{set remotedebug}. This makes _GDBN__ report on all packets sent
334 back and forth across the serial line to the remote machine. The
335 packet-debugging information is printed on the _GDBN__ standard output
336 stream. @code{set remotedebug off} turns it off, and @code{show
337 remotedebug} will show you its current state.
338 _fi__(_REMOTESTUB__)
339
340 _if__(_I960__)
341 @node i960-Nindy Remote
342 @subsection _GDBN__ with a Remote i960 (Nindy)
343
344 @cindex Nindy
345 @cindex i960
346 @dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When
347 _GDBN__ is configured to control a remote Intel 960 using Nindy, you can
348 tell _GDBN__ how to connect to the 960 in several ways:
349
350 @itemize @bullet
351 @item
352 Through command line options specifying serial port, version of the
353 Nindy protocol, and communications speed;
354
355 @item
356 By responding to a prompt on startup;
357
358 @item
359 By using the @code{target} command at any point during your _GDBN__
360 session. @xref{Target Commands, ,Commands for Managing Targets}.
361
362 @end itemize
363
364 @menu
365 * Nindy Startup:: Startup with Nindy
366 * Nindy Options:: Options for Nindy
367 * Nindy reset:: Nindy Reset Command
368 @end menu
369
370 @node Nindy Startup
371 @subsubsection Startup with Nindy
372
373 If you simply start @code{_GDBP__} without using any command-line
374 options, you are prompted for what serial port to use, @emph{before} you
375 reach the ordinary _GDBN__ prompt:
376
377 @example
378 Attach /dev/ttyNN -- specify NN, or "quit" to quit:
379 @end example
380
381 @noindent
382 Respond to the prompt with whatever suffix (after @samp{/dev/tty})
383 identifies the serial port you want to use. You can, if you choose,
384 simply start up with no Nindy connection by responding to the prompt
385 with an empty line. If you do this, and later wish to attach to Nindy,
386 use @code{target} (@pxref{Target Commands, ,Commands for Managing Targets}).
387
388 @node Nindy Options
389 @subsubsection Options for Nindy
390
391 These are the startup options for beginning your _GDBN__ session with a
392 Nindy-960 board attached:
393
394 @table @code
395 @item -r @var{port}
396 Specify the serial port name of a serial interface to be used to connect
397 to the target system. This option is only available when _GDBN__ is
398 configured for the Intel 960 target architecture. You may specify
399 @var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a
400 device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique
401 suffix for a specific @code{tty} (e.g. @samp{-r a}).
402
403 @item -O
404 (An uppercase letter ``O'', not a zero.) Specify that _GDBN__ should use
405 the ``old'' Nindy monitor protocol to connect to the target system.
406 This option is only available when _GDBN__ is configured for the Intel 960
407 target architecture.
408
409 @quotation
410 @emph{Warning:} if you specify @samp{-O}, but are actually trying to
411 connect to a target system that expects the newer protocol, the connection
412 will fail, appearing to be a speed mismatch. _GDBN__ will repeatedly
413 attempt to reconnect at several different line speeds. You can abort
414 this process with an interrupt.
415 @end quotation
416
417 @item -brk
418 Specify that _GDBN__ should first send a @code{BREAK} signal to the target
419 system, in an attempt to reset it, before connecting to a Nindy target.
420
421 @quotation
422 @emph{Warning:} Many target systems do not have the hardware that this
423 requires; it only works with a few boards.
424 @end quotation
425 @end table
426
427 The standard @samp{-b} option controls the line speed used on the serial
428 port.
429
430 @c @group
431 @node Nindy reset
432 @subsubsection Nindy Reset Command
433
434 @table @code
435 @item reset
436 @kindex reset
437 For a Nindy target, this command sends a ``break'' to the remote target
438 system; this is only useful if the target has been equipped with a
439 circuit to perform a hard reset (or some other interesting action) when
440 a break is detected.
441 @end table
442 @c @end group
443 _fi__(_I960__)
444
445 _if__(_AMD29K__)
446 @node EB29K Remote
447 @subsection _GDBN__ with a Remote EB29K
448
449 @cindex EB29K board
450 @cindex running 29K programs
451
452 To use _GDBN__ from a Unix system to run programs on AMD's EB29K
453 board in a PC, you must first connect a serial cable between the PC
454 and a serial port on the Unix system. In the following, we assume
455 you've hooked the cable between the PC's @file{COM1} port and
456 @file{/dev/ttya} on the Unix system.
457
458 @menu
459 * Comms (EB29K):: Communications Setup
460 * _GDBP__-EB29K:: EB29K cross-debugging
461 * Remote Log:: Remote Log
462 @end menu
463
464 @node Comms (EB29K)
465 @subsubsection Communications Setup
466
467 The next step is to set up the PC's port, by doing something like the
468 following in DOS on the PC:
469
470 _0__@example
471 C:\> MODE com1:9600,n,8,1,none
472 _1__@end example
473
474 @noindent
475 This example---run on an MS DOS 4.0 system---sets the PC port to 9600
476 bps, no parity, eight data bits, one stop bit, and no ``retry'' action;
477 you must match the communications parameters when establishing the Unix
478 end of the connection as well.
479 @c FIXME: Who knows what this "no retry action" crud from the DOS manual may
480 @c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91
481
482 To give control of the PC to the Unix side of the serial line, type
483 the following at the DOS console:
484
485 _0__@example
486 C:\> CTTY com1
487 _1__@end example
488
489 @noindent
490 (Later, if you wish to return control to the DOS console, you can use
491 the command @code{CTTY con}---but you must send it over the device that
492 had control, in our example over the @file{COM1} serial line).
493
494 From the Unix host, use a communications program such as @code{tip} or
495 @code{cu} to communicate with the PC; for example,
496
497 @example
498 cu -s 9600 -l /dev/ttya
499 @end example
500
501 @noindent
502 The @code{cu} options shown specify, respectively, the linespeed and the
503 serial port to use. If you use @code{tip} instead, your command line
504 may look something like the following:
505
506 @example
507 tip -9600 /dev/ttya
508 @end example
509
510 @noindent
511 Your system may define a different name where our example uses
512 @file{/dev/ttya} as the argument to @code{tip}. The communications
513 parameters, including which port to use, are associated with the
514 @code{tip} argument in the ``remote'' descriptions file---normally the
515 system table @file{/etc/remote}.
516 @c FIXME: What if anything needs doing to match the "n,8,1,none" part of
517 @c the DOS side's comms setup? cu can support -o (odd
518 @c parity), -e (even parity)---apparently no settings for no parity or
519 @c for character size. Taken from stty maybe...? John points out tip
520 @c can set these as internal variables, eg ~s parity=none; man stty
521 @c suggests that it *might* work to stty these options with stdin or
522 @c stdout redirected... ---pesch@cygnus.com, 25feb91
523
524 @kindex EBMON
525 Using the @code{tip} or @code{cu} connection, change the DOS working
526 directory to the directory containing a copy of your 29K program, then
527 start the PC program @code{EBMON} (an EB29K control program supplied
528 with your board by AMD). You should see an initial display from
529 @code{EBMON} similar to the one that follows, ending with the
530 @code{EBMON} prompt @samp{#}---
531
532 _0__@example
533 C:\> G:
534
535 G:\> CD \usr\joe\work29k
536
537 G:\USR\JOE\WORK29K> EBMON
538 Am29000 PC Coprocessor Board Monitor, version 3.0-18
539 Copyright 1990 Advanced Micro Devices, Inc.
540 Written by Gibbons and Associates, Inc.
541
542 Enter '?' or 'H' for help
543
544 PC Coprocessor Type = EB29K
545 I/O Base = 0x208
546 Memory Base = 0xd0000
547
548 Data Memory Size = 2048KB
549 Available I-RAM Range = 0x8000 to 0x1fffff
550 Available D-RAM Range = 0x80002000 to 0x801fffff
551
552 PageSize = 0x400
553 Register Stack Size = 0x800
554 Memory Stack Size = 0x1800
555
556 CPU PRL = 0x3
557 Am29027 Available = No
558 Byte Write Available = Yes
559
560 # ~.
561 _1__@end example
562
563 Then exit the @code{cu} or @code{tip} program (done in the example by
564 typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep
565 running, ready for _GDBN__ to take over.
566
567 For this example, we've assumed what is probably the most convenient
568 way to make sure the same 29K program is on both the PC and the Unix
569 system: a PC/NFS connection that establishes ``drive @code{G:}'' on the
570 PC as a file system on the Unix host. If you do not have PC/NFS or
571 something similar connecting the two systems, you must arrange some
572 other way---perhaps floppy-disk transfer---of getting the 29K program
573 from the Unix system to the PC; _GDBN__ will @emph{not} download it over the
574 serial line.
575
576 @node _GDBP__-EB29K
577 @subsubsection EB29K cross-debugging
578
579 Finally, @code{cd} to the directory containing an image of your 29K
580 program on the Unix system, and start _GDBN__---specifying as argument the
581 name of your 29K program:
582
583 @example
584 cd /usr/joe/work29k
585 _GDBP__ myfoo
586 @end example
587
588 Now you can use the @code{target} command:
589
590 @example
591 target amd-eb /dev/ttya 9600 MYFOO
592 @c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to
593 @c emphasize that this is the name as seen by DOS (since I think DOS is
594 @c single-minded about case of letters). ---pesch@cygnus.com, 25feb91
595 @end example
596
597 @noindent
598 In this example, we've assumed your program is in a file called
599 @file{myfoo}. Note that the filename given as the last argument to
600 @code{target amd-eb} should be the name of the program as it appears to DOS.
601 In our example this is simply @code{MYFOO}, but in general it can include
602 a DOS path, and depending on your transfer mechanism may not resemble
603 the name on the Unix side.
604
605 At this point, you can set any breakpoints you wish; when you are ready
606 to see your program run on the 29K board, use the _GDBN__ command
607 @code{run}.
608
609 To stop debugging the remote program, use the _GDBN__ @code{detach}
610 command.
611
612 To return control of the PC to its console, use @code{tip} or @code{cu}
613 once again, after your _GDBN__ session has concluded, to attach to
614 @code{EBMON}. You can then type the command @code{q} to shut down
615 @code{EBMON}, returning control to the DOS command-line interpreter.
616 Type @code{CTTY con} to return command input to the main DOS console,
617 and type @kbd{~.} to leave @code{tip} or @code{cu}.
618
619 @node Remote Log
620 @subsubsection Remote Log
621 @kindex eb.log
622 @cindex log file for EB29K
623
624 The @code{target amd-eb} command creates a file @file{eb.log} in the
625 current working directory, to help debug problems with the connection.
626 @file{eb.log} records all the output from @code{EBMON}, including echoes
627 of the commands sent to it. Running @samp{tail -f} on this file in
628 another window often helps to understand trouble with @code{EBMON}, or
629 unexpected events on the PC side of the connection.
630
631 @node UDI29K Remote
632 @subsection _GDBN__ and the UDI 29K protocol
633
634 If your 29K development system supports the UDI (``Universal Debug
635 Interface'') protocol, using _GDBN__ is almost transparent. UDI is a
636 TCP/IP based protocol. On some 29K development systens that do not
637 support TCP/IP directly, however, the manufacturer supplies an interface
638 adapter daemon, which translates UDI to whatever communications
639 interface---typically a serial port---is available.
640
641 Please see the manufacturer's documentation for your 29K system for how
642 to set up the UDI connection for your hardware.
643
644 Once the UDI connection is established, use @samp{target udi} from _GDBN__
645 to start using it. All the usual facilities of _GDBN__ are immediately
646 available: use @code{load} to get your program to the board,
647 @code{breakpoint} to say where to stop, @code{run} to start the program,
648 and so on.
649 _fi__(_AMD29K__)
650
651 _if__(_ST2000__)
652 @node ST2000 Remote
653 @subsection _GDBN__ with a Tandem ST2000
654
655 To connect your ST2000 to the host system, see the manufacturer's
656 manual. Once the ST2000 is physically attached, you can run
657
658 @example
659 target st2000 @var{dev} @var{speed}
660 @end example
661
662 @noindent
663 to establish it as your debugging environment.
664
665 The @code{load} and @code{attach} commands are @emph{not} defined for
666 this target; you must load your program into the ST2000 as you normally
667 would for standalone operation. _GDBN__ will read debugging information
668 (such as symbols) from a separate, debugging version of the program
669 available on your host computer.
670 @c FIXME!! This is terribly vague; what little content is here is
671 @c basically hearsay.
672
673 @cindex ST2000 auxiliary commands
674 These auxiliary _GDBN__ commands are available to help you with the ST2000
675 environment:
676
677 @table @code
678 @item st2000 @var{command}
679 @kindex st2000 @var{cmd}
680 @cindex STDBUG commands (ST2000)
681 @cindex commands to STDBUG (ST2000)
682 Send a @var{command} to the STDBUG monitor. See the manufacturer's
683 manual for available commands.
684
685 @item connect
686 @cindex connect (to STDBUG)
687 Connect the controlling terminal to the STDBUG command monitor. When
688 you are done interacting with STDBUG, typing either of two character
689 sequences will get you back to the _GDBN__ command prompt:
690 @kbd{@key{RET}~.} (Return, followed by tilde and period) or
691 @kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D).
692 @end table
693 _fi__(_ST2000__)
694
695 _if__(_VXWORKS__)
696 @node VxWorks Remote
697 @subsection _GDBN__ and VxWorks
698 @cindex VxWorks
699
700 _GDBN__ enables developers to spawn and debug tasks running on networked
701 VxWorks targets from a Unix host. Already-running tasks spawned from
702 the VxWorks shell can also be debugged. _GDBN__ uses code that runs on
703 both the UNIX host and on the VxWorks target. The program
704 @code{_GDBP__} is installed and executed on the UNIX host.
705
706 The following information on connecting to VxWorks was current when
707 this manual was produced; newer releases of VxWorks may use revised
708 procedures.
709
710 The remote debugging interface (RDB) routines are installed and executed
711 on the VxWorks target. These routines are included in the VxWorks library
712 @file{rdb.a} and are incorporated into the system image when source-level
713 debugging is enabled in the VxWorks configuration.
714
715 @kindex INCLUDE_RDB
716 If you wish, you can define @code{INCLUDE_RDB} in the VxWorks
717 configuration file @file{configAll.h} to include the RDB interface
718 routines and spawn the source debugging task @code{tRdbTask} when
719 VxWorks is booted. For more information on configuring and remaking
720 _if__(_FSF__)
721 VxWorks, see the manufacturer's manual.
722 _fi__(_FSF__)
723 _if__(!_FSF__)
724 VxWorks, see the @cite{VxWorks Programmer's Guide}.
725 _fi__(!_FSF__)
726
727 Once you have included the RDB interface in your VxWorks system image
728 and set your Unix execution search path to find _GDBN__, you are ready
729 to run _GDBN__. From your UNIX host, type:
730
731 @smallexample
732 % _GDBP__
733 @end smallexample
734
735 _GDBN__ will come up showing the prompt:
736
737 @smallexample
738 (_GDBP__)
739 @end smallexample
740
741 @menu
742 * VxWorks connection:: Connecting to VxWorks
743 * VxWorks download:: VxWorks Download
744 * VxWorks attach:: Running Tasks
745 @end menu
746
747 @node VxWorks connection
748 @subsubsection Connecting to VxWorks
749
750 The _GDBN__ command @code{target} lets you connect to a VxWorks target on the
751 network. To connect to a target whose host name is ``@code{tt}'', type:
752
753 @smallexample
754 (_GDBP__) target vxworks tt
755 @end smallexample
756
757 _GDBN__ will display a message similar to the following:
758
759 @smallexample
760 Attaching remote machine across net... Success!
761 @end smallexample
762
763 _GDBN__ will then attempt to read the symbol tables of any object modules
764 loaded into the VxWorks target since it was last booted. _GDBN__ locates
765 these files by searching the directories listed in the command search
766 path (@pxref{Environment, ,Your Program's Environment}); if it fails
767 to find an object file, it will display a message such as:
768
769 @smallexample
770 prog.o: No such file or directory.
771 @end smallexample
772
773 This will cause the @code{target} command to abort. When this happens,
774 you should add the appropriate directory to the search path, with the
775 _GDBN__ command @code{path}, and execute the @code{target} command
776 again.
777
778 @node VxWorks download
779 @subsubsection VxWorks Download
780
781 @cindex download to VxWorks
782 If you have connected to the VxWorks target and you want to debug an
783 object that has not yet been loaded, you can use the _GDBN__ @code{load}
784 command to download a file from UNIX to VxWorks incrementally. The
785 object file given as an argument to the @code{load} command is actually
786 opened twice: first by the VxWorks target in order to download the code,
787 then by _GDBN__ in order to read the symbol table. This can lead to
788 problems if the current working directories on the two systems differ.
789 It is simplest to set the working directory on both systems to the
790 directory in which the object file resides, and then to reference the
791 file by its name, without any path. Thus, to load a program
792 @file{prog.o}, residing in @file{wherever/vw/demo/rdb}, on VxWorks type:
793
794 @smallexample
795 -> cd "wherever/vw/demo/rdb"
796 @end smallexample
797
798 On _GDBN__ type:
799
800 @smallexample
801 (_GDBP__) cd wherever/vw/demo/rdb
802 (_GDBP__) load prog.o
803 @end smallexample
804
805 _GDBN__ will display a response similar to the following:
806
807 @smallexample
808 Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
809 @end smallexample
810
811 You can also use the @code{load} command to reload an object module
812 after editing and recompiling the corresponding source file. Note that
813 this will cause _GDBN__ to delete all currently-defined breakpoints,
814 auto-displays, and convenience variables, and to clear the value
815 history. (This is necessary in order to preserve the integrity of
816 debugger data structures that reference the target system's symbol
817 table.)
818
819 @node VxWorks attach
820 @subsubsection Running Tasks
821
822 @cindex running VxWorks tasks
823 You can also attach to an existing task using the @code{attach} command as
824 follows:
825
826 @smallexample
827 (_GDBP__) attach @var{task}
828 @end smallexample
829
830 @noindent
831 where @var{task} is the VxWorks hexadecimal task ID. The task can be running
832 or suspended when you attach to it. If running, it will be suspended at
833 the time of attachment.
834 _fi__(_VXWORKS__)
835
836 _if__(_H8__)
837 @node Hitachi H8/300 Remote
838 @subsection _GDBN__ and the Hitachi H8/300
839 _GDBN__ needs to know these things to talk to your H8/300:
840
841 @enumerate
842 @item
843 that you want to use @samp{target hms}, the remote debugging
844 interface for the H8/300 (this is the default when
845 GDB is configured specifically for the H8/300);
846
847 @item
848 what serial device connects your host to your H8/300 (the first serial
849 device available on your host is the default);
850
851 @ignore
852 @c this is only for Unix hosts, not currently of interest.
853 @item
854 what speed to use over the serial device.
855 @end ignore
856 @end enumerate
857
858 @kindex device
859 @cindex serial device for H8/300
860 @ignore
861 @c only for Unix hosts
862 Use the special @code{gdb83} command @samp{device @var{port}} if you
863 need to explicitly set the serial device. The default @var{port} is the
864 first available port on your host. This is only necessary on Unix
865 hosts, where it is typically something like @file{/dev/ttya}.
866
867 @kindex speed
868 @cindex serial line speed for H8/300
869 @code{gdb83} has another special command to set the communications speed
870 for the H8/300: @samp{speed @var{bps}}. This command also is only used
871 from Unix hosts; on DOS hosts, set the line speed as usual from outside
872 GDB with the DOS @kbd{mode} command (for instance, @w{@samp{mode
873 com2:9600,n,8,1,p}} for a 9600 bps connection).
874 @end ignore
875
876 _GDBN__ depends on an auxiliary terminate-and-stay-resident program
877 called @code{asynctsr} to communicate with the H8/300 development board
878 through a PC serial port. You must also use the DOS @code{mode} command
879 to set up the serial port on the DOS side.
880
881 The following sample session illustrates the steps needed to start a
882 program under _GDBN__ control on your H8/300. The example uses a sample
883 H8/300 program called @file{t.x}.
884
885 First hook up your H8/300 development board. In this example, we use a
886 board attached to serial port @code{COM2}; if you use a different serial
887 port, substitute its name in the argument of the @code{mode} command.
888 When you call @code{asynctsr}, the auxiliary comms program used by the
889 degugger, you give it just the numeric part of the serial port's name;
890 for example, @samp{asyncstr 2} below runs @code{asyncstr} on
891 @code{COM2}.
892
893 @smallexample
894 (eg-C:\H8300\TEST) mode com2:9600,n,8,1,p
895
896 Resident portion of MODE loaded
897
898 COM2: 9600, n, 8, 1, p
899
900 (eg-C:\H8300\TEST) asynctsr 2
901 @end smallexample
902
903 @quotation
904 @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with
905 @code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to
906 disable it, or even boot without it, to use @code{asynctsr} to control
907 your H8/300 board.
908 @end quotation
909
910 Now that serial communications are set up, and the H8/300 is connected,
911 you can start up _GDBN__. Call @code{_GDBP__} with the name of your
912 program as the argument. @code{_GDBP__} prompts you, as usual, with the
913 prompt @samp{(_GDBP__)}. Use two special commands to begin your debugging
914 session: @samp{target hms} to specify cross-debugging to the Hitachi board,
915 and the @code{load} command to download your program to the board.
916 @code{load} displays the names of the
917 program's sections, and a @samp{*} for each 2K of data downloaded. (If
918 you want to refresh _GDBN__ data on symbols or on the executable file
919 without downloading, use the _GDBN__ commands @code{file} or
920 @code{symbol-file}. These commands, and @code{load} itself, are
921 described in @ref{Files,,Commands to Specify Files}.)
922
923 @smallexample
924 (eg-C:\H8300\TEST) _GDBP__ t.x
925 GDB is free software and you are welcome to distribute copies
926 of it under certain conditions; type "show copying" to see
927 the conditions.
928 There is absolutely no warranty for GDB; type "show warranty"
929 for details.
930 GDB _GDB_VN__, Copyright 1992 Free Software Foundation, Inc...
931 (gdb) target hms
932 Connected to remote H8/300 HMS system.
933 (gdb) load t.x
934 .text : 0x8000 .. 0xabde ***********
935 .data : 0xabde .. 0xad30 *
936 .stack : 0xf000 .. 0xf014 *
937 @end smallexample
938
939 At this point, you're ready to run or debug your program. From here on,
940 you can use all the usual _GDBN__ commands. The @code{break} command
941 sets breakpoints; the @code{run} command starts your program;
942 @code{print} or @code{x} display data; the @code{continue} command
943 resumes execution after stopping at a breakpoint. You can use the
944 @code{help} command at any time to find out more about _GDBN__ commands.
945
946 Remember, however, that @emph{operating system} facilities aren't
947 available on your H8/300; for example, if your program hangs, you can't
948 send an interrupt---but you can press the @sc{reset} switch!
949
950 Use the @sc{reset} button on the H8/300 board
951 @itemize @bullet
952 @item
953 to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has
954 no way to pass an interrupt signal to the H8/300); and
955
956 @item
957 to return to the _GDBN__ command prompt after your program finishes
958 normally. The communications protocol provides no other way for _GDBN__
959 to detect program completion.
960 @end itemize
961
962 In either case, _GDBN__ will see the effect of a @sc{reset} on the
963 H8/300 board as a ``normal exit'' of your program.
964 _fi__(_H8__)