]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - gdb/doc/gdbinv-s.texi
* gdbinv-s.texi (Remote Serial): describe new ^C behavior in
[thirdparty/binutils-gdb.git] / gdb / doc / gdbinv-s.texi
1 @c -*- Texinfo -*-
2 @c Copyright (c) 1990 1991 1992 1993 Free Software Foundation, Inc.
3 @c This file is part of the source for the GDB manual.
4 @c This text diverted to "Remote Debugging" section in general case;
5 @c however, if we're doing a manual specifically for one of these, it
6 @c belongs up front (in "Getting In and Out" chapter).
7
8 @ifset REMOTESTUB
9 @node Remote Serial
10 @subsection The @value{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 @value{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 @value{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 @value{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 @value{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 @value{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 for @code{handle_exception} to run when your
95 program stops. You must call this subroutine explicitly near the
96 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 @value{GDBN} on the host machine. This is where the communications
108 protocol is implemented; @code{handle_exception} acts as the @value{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 @value{GDBN} needs, until you
112 execute a @value{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 @value{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 @value{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 @value{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 @value{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, @value{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 @display
195 @code{getDebugChar}, @code{putDebugChar},
196 @code{flush_i_cache}, @code{memset}.
197 @end display
198
199 @item
200 Insert these lines near the top of your program:
201
202 @example
203 set_debug_traps();
204 breakpoint();
205 @end example
206
207 @item
208 Compile and link together: your program, the @value{GDBN} debugging stub for
209 your target architecture, and the supporting subroutines.
210
211 @item
212 Make sure you have a serial connection between your target machine and
213 the @value{GDBN} host, and identify the serial port used for this on the host.
214
215 @item
216 Download your program to your target machine (or get it there by
217 whatever means the manufacturer provides), and start it.
218
219 @item
220 To start remote debugging, run @value{GDBN} on the host machine, and specify
221 as an executable file the program that is running in the remote machine.
222 This tells @value{GDBN} how to find your program's symbols and the contents
223 of its pure text.
224
225 Then establish communication using the @code{target remote} command.
226 Its argument is the name of the device you're using to control the
227 target machine. For example:
228
229 @example
230 target remote /dev/ttyb
231 @end example
232
233 @noindent
234 if the serial line is connected to the device named @file{/dev/ttyb}.
235 @ignore
236 @c this is from the old text, but it doesn't seem to make sense now that I've
237 @c seen an example... pesch 4sep1992
238 This will stop the remote machine if it is not already stopped.
239 @end ignore
240 @end enumerate
241
242 Now you can use all the usual commands to examine and change data and to
243 step and continue the remote program.
244
245 To resume the remote program and stop debugging it, use the @code{detach}
246 command.
247
248 @cindex interrupting remote programs
249 @cindex remote programs, interrupting
250 Whenever @value{GDBN} is waiting for the remote program, if you type the
251 interrupt character (often @key{C-C}), @value{GDBN} attempts to stop the
252 program. This may or may not succeed, depending in part on the hardware
253 and the serial drivers the remote system uses. If you type the
254 interrupt character once again, @value{GDBN} displays this prompt:
255
256 @example
257 Interrupted while waiting for the program.
258 Give up (and stop debugging it)? (y or n)
259 @end example
260
261 If you type @kbd{y}, @value{GDBN} abandons the remote debugging session.
262 (If you decide you want to try again later, you can use @samp{target
263 remote} again to connect once more.) If you type @kbd{n}, @value{GDBN}
264 goes back to waiting.
265
266 @node Protocol
267 @subsubsection Outline of the communication protocol
268
269 @cindex debugging stub, example
270 @cindex remote stub, example
271 @cindex stub example, remote debugging
272 The stub files provided with @value{GDBN} implement the target side of the
273 communication protocol, and the @value{GDBN} side is implemented in the
274 @value{GDBN} source file @file{remote.c}. Normally, you can simply allow
275 these subroutines to communicate, and ignore the details. (If you're
276 implementing your own stub file, you can still ignore the details: start
277 with one of the existing stub files. @file{sparc-stub.c} is the best
278 organized, and therefore the easiest to read.)
279
280 However, there may be occasions when you need to know something about
281 the protocol---for example, if there is only one serial port to your
282 target machine, you might want your program to do something special if
283 it recognizes a packet meant for @value{GDBN}.
284
285 @cindex protocol, @value{GDBN} remote serial
286 @cindex serial protocol, @value{GDBN} remote
287 @cindex remote serial protocol
288 All @value{GDBN} commands and responses (other than acknowledgements, which
289 are single characters) are sent as a packet which includes a
290 checksum. A packet is introduced with the character @samp{$}, and ends
291 with the character @samp{#} followed by a two-digit checksum:
292
293 @example
294 $@var{packet info}#@var{checksum}
295 @end example
296
297 @cindex checksum, for @value{GDBN} remote
298 @noindent
299 @var{checksum} is computed as the modulo 256 sum of the @var{packet
300 info} characters.
301
302 When either the host or the target machine receives a packet, the first
303 response expected is an acknowledgement: a single character, either
304 @samp{+} (to indicate the package was received correctly) or @samp{-}
305 (to request retransmission).
306
307 The host (@value{GDBN}) sends commands, and the target (the debugging stub
308 incorporated in your program) sends data in response. The target also
309 sends data when your program stops.
310
311 Command packets are distinguished by their first character, which
312 identifies the kind of command.
313
314 These are the commands currently supported:
315
316 @table @code
317 @item g
318 Requests the values of CPU registers.
319
320 @item G
321 Sets the values of CPU registers.
322
323 @item m@var{addr},@var{count}
324 Read @var{count} bytes at location @var{addr}.
325
326 @item M@var{addr},@var{count}:@dots{}
327 Write @var{count} bytes at location @var{addr}.
328
329 @item c
330 @itemx c@var{addr}
331 Resume execution at the current address (or at @var{addr} if supplied).
332
333 @item s
334 @itemx s@var{addr}
335 Step the target program for one instruction, from either the current
336 program counter or from @var{addr} if supplied.
337
338 @item k
339 Kill the target program.
340
341 @item ?
342 Report the most recent signal. To allow you to take advantage of the
343 @value{GDBN} signal handling commands, one of the functions of the debugging
344 stub is to report CPU traps as the corresponding POSIX signal values.
345 @end table
346
347 @kindex set remotedebug
348 @kindex show remotedebug
349 @cindex packets, reporting on stdout
350 @cindex serial connections, debugging
351 If you have trouble with the serial connection, you can use the command
352 @code{set remotedebug}. This makes @value{GDBN} report on all packets sent
353 back and forth across the serial line to the remote machine. The
354 packet-debugging information is printed on the @value{GDBN} standard output
355 stream. @code{set remotedebug off} turns it off, and @code{show
356 remotedebug} will show you its current state.
357 @end ifset
358
359 @ifset I960
360 @node i960-Nindy Remote
361 @subsection @value{GDBN} with a remote i960 (Nindy)
362
363 @cindex Nindy
364 @cindex i960
365 @dfn{Nindy} is a ROM Monitor program for Intel 960 target systems. When
366 @value{GDBN} is configured to control a remote Intel 960 using Nindy, you can
367 tell @value{GDBN} how to connect to the 960 in several ways:
368
369 @itemize @bullet
370 @item
371 Through command line options specifying serial port, version of the
372 Nindy protocol, and communications speed;
373
374 @item
375 By responding to a prompt on startup;
376
377 @item
378 By using the @code{target} command at any point during your @value{GDBN}
379 session. @xref{Target Commands, ,Commands for managing targets}.
380
381 @end itemize
382
383 @menu
384 * Nindy Startup:: Startup with Nindy
385 * Nindy Options:: Options for Nindy
386 * Nindy Reset:: Nindy reset command
387 @end menu
388
389 @node Nindy Startup
390 @subsubsection Startup with Nindy
391
392 If you simply start @code{@value{GDBP}} without using any command-line
393 options, you are prompted for what serial port to use, @emph{before} you
394 reach the ordinary @value{GDBN} prompt:
395
396 @example
397 Attach /dev/ttyNN -- specify NN, or "quit" to quit:
398 @end example
399
400 @noindent
401 Respond to the prompt with whatever suffix (after @samp{/dev/tty})
402 identifies the serial port you want to use. You can, if you choose,
403 simply start up with no Nindy connection by responding to the prompt
404 with an empty line. If you do this and later wish to attach to Nindy,
405 use @code{target} (@pxref{Target Commands, ,Commands for managing targets}).
406
407 @node Nindy Options
408 @subsubsection Options for Nindy
409
410 These are the startup options for beginning your @value{GDBN} session with a
411 Nindy-960 board attached:
412
413 @table @code
414 @item -r @var{port}
415 Specify the serial port name of a serial interface to be used to connect
416 to the target system. This option is only available when @value{GDBN} is
417 configured for the Intel 960 target architecture. You may specify
418 @var{port} as any of: a full pathname (e.g. @samp{-r /dev/ttya}), a
419 device name in @file{/dev} (e.g. @samp{-r ttya}), or simply the unique
420 suffix for a specific @code{tty} (e.g. @samp{-r a}).
421
422 @item -O
423 (An uppercase letter ``O'', not a zero.) Specify that @value{GDBN} should use
424 the ``old'' Nindy monitor protocol to connect to the target system.
425 This option is only available when @value{GDBN} is configured for the Intel 960
426 target architecture.
427
428 @quotation
429 @emph{Warning:} if you specify @samp{-O}, but are actually trying to
430 connect to a target system that expects the newer protocol, the connection
431 fails, appearing to be a speed mismatch. @value{GDBN} repeatedly
432 attempts to reconnect at several different line speeds. You can abort
433 this process with an interrupt.
434 @end quotation
435
436 @item -brk
437 Specify that @value{GDBN} should first send a @code{BREAK} signal to the target
438 system, in an attempt to reset it, before connecting to a Nindy target.
439
440 @quotation
441 @emph{Warning:} Many target systems do not have the hardware that this
442 requires; it only works with a few boards.
443 @end quotation
444 @end table
445
446 The standard @samp{-b} option controls the line speed used on the serial
447 port.
448
449 @c @group
450 @node Nindy Reset
451 @subsubsection Nindy reset command
452
453 @table @code
454 @item reset
455 @kindex reset
456 For a Nindy target, this command sends a ``break'' to the remote target
457 system; this is only useful if the target has been equipped with a
458 circuit to perform a hard reset (or some other interesting action) when
459 a break is detected.
460 @end table
461 @c @end group
462 @end ifset
463
464 @ifset AMD29K
465 @node UDI29K Remote
466 @subsection @value{GDBN} and the UDI protocol for AMD29K
467
468 @cindex UDI
469 @cindex AMD29K via UDI
470 @value{GDBN} supports AMD's UDI (``Universal Debugger Interface'')
471 protocol for debugging the a29k processor family. To use this
472 configuration with AMD targets running the MiniMON monitor, you need the
473 program @code{MONTIP}, available from AMD at no charge. You can also
474 use @value{GDBN} with the UDI conformant a29k simulator program
475 @code{ISSTIP}, also available from AMD.
476
477 @table @code
478 @item target udi @var{keyword}
479 @kindex udi
480 Select the UDI interface to a remote a29k board or simulator, where
481 @var{keyword} is an entry in the AMD configuration file @file{udi_soc}.
482 This file contains keyword entries which specify parameters used to
483 connect to a29k targets. If the @file{udi_soc} file is not in your
484 working directory, you must set the environment variable @samp{UDICONF}
485 to its pathname.
486 @end table
487
488 @node EB29K Remote
489 @subsection @value{GDBN} with a remote EB29K
490
491 @cindex EB29K board
492 @cindex running 29K programs
493
494 To use @value{GDBN} from a Unix system to run programs on AMD's EB29K
495 board in a PC, you must first connect a serial cable between the PC
496 and a serial port on the Unix system. In the following, we assume
497 you've hooked the cable between the PC's @file{COM1} port and
498 @file{/dev/ttya} on the Unix system.
499
500 @menu
501 * Comms (EB29K):: Communications setup
502 * gdb-EB29K:: EB29K cross-debugging
503 * Remote Log:: Remote log
504 @end menu
505
506 @node Comms (EB29K)
507 @subsubsection Communications setup
508
509 The next step is to set up the PC's port, by doing something like this
510 in DOS on the PC:
511
512 @example
513 C:\> MODE com1:9600,n,8,1,none
514 @end example
515
516 @noindent
517 This example---run on an MS DOS 4.0 system---sets the PC port to 9600
518 bps, no parity, eight data bits, one stop bit, and no ``retry'' action;
519 you must match the communications parameters when establishing the Unix
520 end of the connection as well.
521 @c FIXME: Who knows what this "no retry action" crud from the DOS manual may
522 @c mean? It's optional; leave it out? ---pesch@cygnus.com, 25feb91
523
524 To give control of the PC to the Unix side of the serial line, type
525 the following at the DOS console:
526
527 @example
528 C:\> CTTY com1
529 @end example
530
531 @noindent
532 (Later, if you wish to return control to the DOS console, you can use
533 the command @code{CTTY con}---but you must send it over the device that
534 had control, in our example over the @file{COM1} serial line).
535
536 From the Unix host, use a communications program such as @code{tip} or
537 @code{cu} to communicate with the PC; for example,
538
539 @example
540 cu -s 9600 -l /dev/ttya
541 @end example
542
543 @noindent
544 The @code{cu} options shown specify, respectively, the linespeed and the
545 serial port to use. If you use @code{tip} instead, your command line
546 may look something like the following:
547
548 @example
549 tip -9600 /dev/ttya
550 @end example
551
552 @noindent
553 Your system may require a different name where we show
554 @file{/dev/ttya} as the argument to @code{tip}. The communications
555 parameters, including which port to use, are associated with the
556 @code{tip} argument in the ``remote'' descriptions file---normally the
557 system table @file{/etc/remote}.
558 @c FIXME: What if anything needs doing to match the "n,8,1,none" part of
559 @c the DOS side's comms setup? cu can support -o (odd
560 @c parity), -e (even parity)---apparently no settings for no parity or
561 @c for character size. Taken from stty maybe...? John points out tip
562 @c can set these as internal variables, eg ~s parity=none; man stty
563 @c suggests that it *might* work to stty these options with stdin or
564 @c stdout redirected... ---pesch@cygnus.com, 25feb91
565
566 @kindex EBMON
567 Using the @code{tip} or @code{cu} connection, change the DOS working
568 directory to the directory containing a copy of your 29K program, then
569 start the PC program @code{EBMON} (an EB29K control program supplied
570 with your board by AMD). You should see an initial display from
571 @code{EBMON} similar to the one that follows, ending with the
572 @code{EBMON} prompt @samp{#}---
573
574 @example
575 C:\> G:
576
577 G:\> CD \usr\joe\work29k
578
579 G:\USR\JOE\WORK29K> EBMON
580 Am29000 PC Coprocessor Board Monitor, version 3.0-18
581 Copyright 1990 Advanced Micro Devices, Inc.
582 Written by Gibbons and Associates, Inc.
583
584 Enter '?' or 'H' for help
585
586 PC Coprocessor Type = EB29K
587 I/O Base = 0x208
588 Memory Base = 0xd0000
589
590 Data Memory Size = 2048KB
591 Available I-RAM Range = 0x8000 to 0x1fffff
592 Available D-RAM Range = 0x80002000 to 0x801fffff
593
594 PageSize = 0x400
595 Register Stack Size = 0x800
596 Memory Stack Size = 0x1800
597
598 CPU PRL = 0x3
599 Am29027 Available = No
600 Byte Write Available = Yes
601
602 # ~.
603 @end example
604
605 Then exit the @code{cu} or @code{tip} program (done in the example by
606 typing @code{~.} at the @code{EBMON} prompt). @code{EBMON} will keep
607 running, ready for @value{GDBN} to take over.
608
609 For this example, we've assumed what is probably the most convenient
610 way to make sure the same 29K program is on both the PC and the Unix
611 system: a PC/NFS connection that establishes ``drive @code{G:}'' on the
612 PC as a file system on the Unix host. If you do not have PC/NFS or
613 something similar connecting the two systems, you must arrange some
614 other way---perhaps floppy-disk transfer---of getting the 29K program
615 from the Unix system to the PC; @value{GDBN} will @emph{not} download it over the
616 serial line.
617
618 @node gdb-EB29K
619 @subsubsection EB29K cross-debugging
620
621 Finally, @code{cd} to the directory containing an image of your 29K
622 program on the Unix system, and start @value{GDBN}---specifying as argument the
623 name of your 29K program:
624
625 @example
626 cd /usr/joe/work29k
627 @value{GDBP} myfoo
628 @end example
629
630 Now you can use the @code{target} command:
631
632 @example
633 target amd-eb /dev/ttya 9600 MYFOO
634 @c FIXME: test above 'target amd-eb' as spelled, with caps! caps are meant to
635 @c emphasize that this is the name as seen by DOS (since I think DOS is
636 @c single-minded about case of letters). ---pesch@cygnus.com, 25feb91
637 @end example
638
639 @noindent
640 In this example, we've assumed your program is in a file called
641 @file{myfoo}. Note that the filename given as the last argument to
642 @code{target amd-eb} should be the name of the program as it appears to DOS.
643 In our example this is simply @code{MYFOO}, but in general it can include
644 a DOS path, and depending on your transfer mechanism may not resemble
645 the name on the Unix side.
646
647 At this point, you can set any breakpoints you wish; when you are ready
648 to see your program run on the 29K board, use the @value{GDBN} command
649 @code{run}.
650
651 To stop debugging the remote program, use the @value{GDBN} @code{detach}
652 command.
653
654 To return control of the PC to its console, use @code{tip} or @code{cu}
655 once again, after your @value{GDBN} session has concluded, to attach to
656 @code{EBMON}. You can then type the command @code{q} to shut down
657 @code{EBMON}, returning control to the DOS command-line interpreter.
658 Type @code{CTTY con} to return command input to the main DOS console,
659 and type @kbd{~.} to leave @code{tip} or @code{cu}.
660
661 @node Remote Log
662 @subsubsection Remote log
663 @kindex eb.log
664 @cindex log file for EB29K
665
666 The @code{target amd-eb} command creates a file @file{eb.log} in the
667 current working directory, to help debug problems with the connection.
668 @file{eb.log} records all the output from @code{EBMON}, including echoes
669 of the commands sent to it. Running @samp{tail -f} on this file in
670 another window often helps to understand trouble with @code{EBMON}, or
671 unexpected events on the PC side of the connection.
672
673 @end ifset
674
675 @ifset ST2000
676 @node ST2000 Remote
677 @subsection @value{GDBN} with a Tandem ST2000
678
679 To connect your ST2000 to the host system, see the manufacturer's
680 manual. Once the ST2000 is physically attached, you can run
681
682 @example
683 target st2000 @var{dev} @var{speed}
684 @end example
685
686 @noindent
687 to establish it as your debugging environment.
688
689 The @code{load} and @code{attach} commands are @emph{not} defined for
690 this target; you must load your program into the ST2000 as you normally
691 would for standalone operation. @value{GDBN} will read debugging information
692 (such as symbols) from a separate, debugging version of the program
693 available on your host computer.
694 @c FIXME!! This is terribly vague; what little content is here is
695 @c basically hearsay.
696
697 @cindex ST2000 auxiliary commands
698 These auxiliary @value{GDBN} commands are available to help you with the ST2000
699 environment:
700
701 @table @code
702 @item st2000 @var{command}
703 @kindex st2000 @var{cmd}
704 @cindex STDBUG commands (ST2000)
705 @cindex commands to STDBUG (ST2000)
706 Send a @var{command} to the STDBUG monitor. See the manufacturer's
707 manual for available commands.
708
709 @item connect
710 @cindex connect (to STDBUG)
711 Connect the controlling terminal to the STDBUG command monitor. When
712 you are done interacting with STDBUG, typing either of two character
713 sequences will get you back to the @value{GDBN} command prompt:
714 @kbd{@key{RET}~.} (Return, followed by tilde and period) or
715 @kbd{@key{RET}~@key{C-d}} (Return, followed by tilde and control-D).
716 @end table
717 @end ifset
718
719 @ifset VXWORKS
720 @node VxWorks Remote
721 @subsection @value{GDBN} and VxWorks
722 @cindex VxWorks
723
724 @value{GDBN} enables developers to spawn and debug tasks running on networked
725 VxWorks targets from a Unix host. Already-running tasks spawned from
726 the VxWorks shell can also be debugged. @value{GDBN} uses code that runs on
727 both the UNIX host and on the VxWorks target. The program
728 @code{@value{GDBP}} is installed and executed on the UNIX host.
729
730 The following information on connecting to VxWorks was current when
731 this manual was produced; newer releases of VxWorks may use revised
732 procedures.
733
734 The remote debugging interface (RDB) routines are installed and executed
735 on the VxWorks target. These routines are included in the VxWorks library
736 @file{rdb.a} and are incorporated into the system image when source-level
737 debugging is enabled in the VxWorks configuration.
738
739 @kindex INCLUDE_RDB
740 If you wish, you can define @code{INCLUDE_RDB} in the VxWorks
741 configuration file @file{configAll.h} to include the RDB interface
742 routines and spawn the source debugging task @code{tRdbTask} when
743 VxWorks is booted. For more information on configuring and remaking
744 VxWorks, see the manufacturer's manual.
745 @c VxWorks, see the @cite{VxWorks Programmer's Guide}.
746
747 Once you have included the RDB interface in your VxWorks system image
748 and set your Unix execution search path to find @value{GDBN}, you are ready
749 to run @value{GDBN}. From your UNIX host, type:
750
751 @example
752 % @value{GDBP}
753 @end example
754
755 @value{GDBN} will come up showing the prompt:
756
757 @example
758 (@value{GDBP})
759 @end example
760
761 @menu
762 * VxWorks Connection:: Connecting to VxWorks
763 * VxWorks Download:: VxWorks download
764 * VxWorks Attach:: Running tasks
765 @end menu
766
767 @node VxWorks Connection
768 @subsubsection Connecting to VxWorks
769
770 The @value{GDBN} command @code{target} lets you connect to a VxWorks target on the
771 network. To connect to a target whose host name is ``@code{tt}'', type:
772
773 @example
774 (@value{GDBP}) target vxworks tt
775 @end example
776
777 @value{GDBN} will display a message similar to the following:
778
779 @smallexample
780 Attaching remote machine across net... Success!
781 @end smallexample
782
783 @value{GDBN} will then attempt to read the symbol tables of any object modules
784 loaded into the VxWorks target since it was last booted. @value{GDBN} locates
785 these files by searching the directories listed in the command search
786 path (@pxref{Environment, ,Your program's environment}); if it fails
787 to find an object file, it will display a message such as:
788
789 @example
790 prog.o: No such file or directory.
791 @end example
792
793 This will cause the @code{target} command to abort. When this happens,
794 you should add the appropriate directory to the search path, with the
795 @value{GDBN} command @code{path}, and execute the @code{target} command
796 again.
797
798 @node VxWorks Download
799 @subsubsection VxWorks download
800
801 @cindex download to VxWorks
802 If you have connected to the VxWorks target and you want to debug an
803 object that has not yet been loaded, you can use the @value{GDBN} @code{load}
804 command to download a file from UNIX to VxWorks incrementally. The
805 object file given as an argument to the @code{load} command is actually
806 opened twice: first by the VxWorks target in order to download the code,
807 then by @value{GDBN} in order to read the symbol table. This can lead to
808 problems if the current working directories on the two systems differ.
809 It is simplest to set the working directory on both systems to the
810 directory in which the object file resides, and then to reference the
811 file by its name, without any path. Thus, to load a program
812 @file{prog.o}, residing in @file{wherever/vw/demo/rdb}, on VxWorks type:
813
814 @example
815 -> cd "wherever/vw/demo/rdb"
816 @end example
817
818 On @value{GDBN} type:
819
820 @example
821 (@value{GDBP}) cd wherever/vw/demo/rdb
822 (@value{GDBP}) load prog.o
823 @end example
824
825 @value{GDBN} will display a response similar to the following:
826
827 @smallexample
828 Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
829 @end smallexample
830
831 You can also use the @code{load} command to reload an object module
832 after editing and recompiling the corresponding source file. Note that
833 this will cause @value{GDBN} to delete all currently-defined breakpoints,
834 auto-displays, and convenience variables, and to clear the value
835 history. (This is necessary in order to preserve the integrity of
836 debugger data structures that reference the target system's symbol
837 table.)
838
839 @node VxWorks Attach
840 @subsubsection Running tasks
841
842 @cindex running VxWorks tasks
843 You can also attach to an existing task using the @code{attach} command as
844 follows:
845
846 @example
847 (@value{GDBP}) attach @var{task}
848 @end example
849
850 @noindent
851 where @var{task} is the VxWorks hexadecimal task ID. The task can be running
852 or suspended when you attach to it. If running, it will be suspended at
853 the time of attachment.
854 @end ifset
855
856 @ifset H8
857 @node Hitachi Remote
858 @subsection @value{GDBN} and Hitachi Microprocessors
859 @value{GDBN} needs to know these things to talk to your
860 Hitachi SH, H8/300, or H8/500:
861
862 @enumerate
863 @item
864 that you want to use @samp{target hms}, the remote debugging interface
865 for Hitachi microprocessors (this is the default when GDB is configured
866 specifically for the Hitachi SH, H8/300, or H8/500);
867
868 @item
869 what serial device connects your host to your Hitachi board (the first
870 serial device available on your host is the default);
871
872 @ignore
873 @c this is only for Unix hosts, not currently of interest.
874 @item
875 what speed to use over the serial device.
876 @end ignore
877 @end enumerate
878
879 @ifclear H8EXCLUSIVE
880 @c only for Unix hosts
881 @kindex device
882 @cindex serial device, Hitachi micros
883 Use the special @code{@value{GDBP}} command @samp{device @var{port}} if you
884 need to explicitly set the serial device. The default @var{port} is the
885 first available port on your host. This is only necessary on Unix
886 hosts, where it is typically something like @file{/dev/ttya}.
887
888 @kindex speed
889 @cindex serial line speed, Hitachi micros
890 @code{@value{GDBP}} has another special command to set the communications
891 speed: @samp{speed @var{bps}}. This command also is only used from Unix
892 hosts; on DOS hosts, set the line speed as usual from outside GDB with
893 the DOS @kbd{mode} command (for instance, @w{@samp{mode
894 com2:9600,n,8,1,p}} for a 9600 bps connection).
895
896 The @samp{device} and @samp{speed} commands are available only when you
897 use a Unix host to debug your Hitachi microprocessor programs. If you
898 use a DOS host,
899 @end ifclear
900 @value{GDBN} depends on an auxiliary terminate-and-stay-resident program
901 called @code{asynctsr} to communicate with the development board
902 through a PC serial port. You must also use the DOS @code{mode} command
903 to set up the serial port on the DOS side.
904
905 @ifset DOSHOST
906 The following sample session illustrates the steps needed to start a
907 program under @value{GDBN} control on an H8/300. The example uses a
908 sample H8/300 program called @file{t.x}. The procedure is the same for
909 the Hitachi SH and the H8/500.
910
911 First hook up your development board. In this example, we use a
912 board attached to serial port @code{COM2}; if you use a different serial
913 port, substitute its name in the argument of the @code{mode} command.
914 When you call @code{asynctsr}, the auxiliary comms program used by the
915 degugger, you give it just the numeric part of the serial port's name;
916 for example, @samp{asyncstr 2} below runs @code{asyncstr} on
917 @code{COM2}.
918
919 @example
920 (eg-C:\H8300\TEST) mode com2:9600,n,8,1,p
921
922 Resident portion of MODE loaded
923
924 COM2: 9600, n, 8, 1, p
925
926 (eg-C:\H8300\TEST) asynctsr 2
927 @end example
928
929 @quotation
930 @emph{Warning:} We have noticed a bug in PC-NFS that conflicts with
931 @code{asynctsr}. If you also run PC-NFS on your DOS host, you may need to
932 disable it, or even boot without it, to use @code{asynctsr} to control
933 your development board.
934 @end quotation
935
936 @kindex target hms
937 Now that serial communications are set up, and the development board is
938 connected, you can start up @value{GDBN}. Call @code{@value{GDBP}} with
939 the name of your program as the argument. @code{@value{GDBP}} prompts
940 you, as usual, with the prompt @samp{(@value{GDBP})}. Use two special
941 commands to begin your debugging session: @samp{target hms} to specify
942 cross-debugging to the Hitachi board, and the @code{load} command to
943 download your program to the board. @code{load} displays the names of
944 the program's sections, and a @samp{*} for each 2K of data downloaded.
945 (If you want to refresh @value{GDBN} data on symbols or on the
946 executable file without downloading, use the @value{GDBN} commands
947 @code{file} or @code{symbol-file}. These commands, and @code{load}
948 itself, are described in @ref{Files,,Commands to specify files}.)
949
950 @smallexample
951 (eg-C:\H8300\TEST) @value{GDBP} t.x
952 GDB is free software and you are welcome to distribute copies
953 of it under certain conditions; type "show copying" to see
954 the conditions.
955 There is absolutely no warranty for GDB; type "show warranty"
956 for details.
957 GDB @value{GDBVN}, Copyright 1992 Free Software Foundation, Inc...
958 (gdb) target hms
959 Connected to remote H8/300 HMS system.
960 (gdb) load t.x
961 .text : 0x8000 .. 0xabde ***********
962 .data : 0xabde .. 0xad30 *
963 .stack : 0xf000 .. 0xf014 *
964 @end smallexample
965
966 At this point, you're ready to run or debug your program. From here on,
967 you can use all the usual @value{GDBN} commands. The @code{break} command
968 sets breakpoints; the @code{run} command starts your program;
969 @code{print} or @code{x} display data; the @code{continue} command
970 resumes execution after stopping at a breakpoint. You can use the
971 @code{help} command at any time to find out more about @value{GDBN} commands.
972
973 Remember, however, that @emph{operating system} facilities aren't
974 available on your development board; for example, if your program hangs,
975 you can't send an interrupt---but you can press the @sc{reset} switch!
976
977 Use the @sc{reset} button on the development board
978 @itemize @bullet
979 @item
980 to interrupt your program (don't use @kbd{ctl-C} on the DOS host---it has
981 no way to pass an interrupt signal to the development board); and
982
983 @item
984 to return to the @value{GDBN} command prompt after your program finishes
985 normally. The communications protocol provides no other way for @value{GDBN}
986 to detect program completion.
987 @end itemize
988
989 In either case, @value{GDBN} will see the effect of a @sc{reset} on the
990 development board as a ``normal exit'' of your program.
991 @end ifset
992 @end ifset
993
994 @ifset MIPS
995 @node MIPS Remote
996 @subsection @value{GDBN} and remote MIPS boards
997
998 @cindex MIPS boards
999 @value{GDBN} can use the MIPS remote debugging protocol to talk to a
1000 MIPS board attached to a serial line. This is available when
1001 you configure @value{GDBN} with @samp{--target=mips-idt-ecoff}.
1002
1003 @kindex target mips @var{port}
1004 To run a program on the board, start up @code{@value{GDBP}} with the
1005 name of your program as the argument. To connect to the board, use the
1006 command @samp{target mips @var{port}}, where @var{port} is the name of
1007 the serial port connected to the board. If the program has not already
1008 been downloaded to the board, you may use the @code{load} command to
1009 download it. You can then use all the usual @value{GDBN} commands.
1010
1011 @cindex @code{remotedebug}, MIPS protocol
1012 @c FIXME! For this to be useful, you must know something about the MIPS
1013 @c FIXME...protocol. Where is it described?
1014 You can see some debugging information about communications with the board
1015 by setting the @code{remotedebug} variable. If you set it to 1 using
1016 @samp{set remotedebug 1} every packet will be displayed. If you set it
1017 to 2 every character will be displayed. You can check the current value
1018 at any time with the command @samp{show remotedebug}.
1019
1020 @kindex set mipsfpu off
1021 @cindex MIPS remote floating point
1022 @cindex floating point, MIPS remote
1023 If your target board does not support the MIPS floating point
1024 coprocessor, you should use the command @samp{set mipsfpu off} (you may
1025 wish to put this in your @value{GDBINIT} file). This will tell
1026 @value{GDBN} how to find the return value of functions which return
1027 floating point values, and tell it to call functions on the board
1028 without saving the floating point registers.
1029 @end ifset
1030
1031 @ifset SIMS
1032 @node Simulator
1033 @subsection Simulated CPU target
1034
1035 @ifset GENERIC
1036 @cindex simulator
1037 @cindex simulator, Z8000
1038 @cindex Z8000 simulator
1039 @cindex simulator, H8/300 or H8/500
1040 @cindex H8/300 or H8/500 simulator
1041 @cindex simulator, Hitachi SH
1042 @cindex Hitachi SH simulator
1043 @cindex CPU simulator
1044 For some configurations, @value{GDBN} includes a CPU simulator that you
1045 can use instead of a hardware CPU to debug your programs. Currently,
1046 a simulator is available when @value{GDBN} is configured to debug Zilog
1047 Z8000 or Hitachi microprocessor targets.
1048 @end ifset
1049
1050 @ifclear GENERIC
1051 @ifset H8
1052 @cindex simulator, H8/300 or H8/500
1053 @cindex Hitachi H8/300 or H8/500 simulator
1054 @cindex simulator, Hitachi SH
1055 @cindex Hitachi SH simulator
1056 When configured for debugging Hitachi microprocessor targets,
1057 @value{GDBN} includes a CPU simulator for the target chip (a Hitachi SH,
1058 H8/300, or H8/500).
1059 @end ifset
1060
1061 @ifset Z8K
1062 @cindex simulator, Z8000
1063 @cindex Zilog Z8000 simulator
1064 When configured for debugging Zilog Z8000 targets, @value{GDBN} includes
1065 a Z8000 simulator.
1066 @end ifset
1067 @end ifclear
1068
1069 @ifset Z8K
1070 For the Z8000 family, @samp{target sim} simulates either the Z8002 (the
1071 unsegmented variant of the Z8000 architecture) or the Z8001 (the
1072 segmented variant). The simulator recognizes which architecture is
1073 appropriate by inspecting the object code.
1074 @end ifset
1075
1076 @table @code
1077 @item target sim
1078 @kindex sim
1079 @kindex target sim
1080 Debug programs on a simulated CPU
1081 @ifset GENERIC
1082 (which CPU depends on the @value{GDBN} configuration)
1083 @end ifset
1084 @end table
1085
1086 @noindent
1087 After specifying this target, you can debug programs for the simulated
1088 CPU in the same style as programs for your host computer; use the
1089 @code{file} command to load a new program image, the @code{run} command
1090 to run your program, and so on.
1091
1092 As well as making available all the usual machine registers (see
1093 @code{info reg}), this debugging target provides three additional items
1094 of information as specially named registers:
1095
1096 @table @code
1097 @item cycles
1098 Counts clock-ticks in the simulator.
1099
1100 @item insts
1101 Counts instructions run in the simulator.
1102
1103 @item time
1104 Execution time in 60ths of a second.
1105 @end table
1106
1107 You can refer to these values in @value{GDBN} expressions with the usual
1108 conventions; for example, @w{@samp{b fputc if $cycles>5000}} sets a
1109 conditional breakpoint that will suspend only after at least 5000
1110 simulated clock ticks.
1111 @end ifset