Sync usage with man page.
[netbsd-mini2440.git] / gnu / dist / gdb6 / gdb / doc / gdb.info-2
blob9407444d3df3065c189c207067649c5cc6ad7090
1 This is gdb.info, produced by makeinfo version 4.8 from
2 ../.././gdb/doc/gdb.texinfo.
4 INFO-DIR-SECTION Software development
5 START-INFO-DIR-ENTRY
6 * Gdb: (gdb).                     The GNU debugger.
7 END-INFO-DIR-ENTRY
9    This file documents the GNU debugger GDB.
11    This is the Ninth Edition, of `Debugging with GDB: the GNU
12 Source-Level Debugger' for GDB Version 6.5.
14    Copyright (C) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996,
15 1998,
16 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006
17 Free Software Foundation, Inc.
19    Permission is granted to copy, distribute and/or modify this document
20 under the terms of the GNU Free Documentation License, Version 1.1 or
21 any later version published by the Free Software Foundation; with the
22 Invariant Sections being "Free Software" and "Free Software Needs Free
23 Documentation", with the Front-Cover Texts being "A GNU Manual," and
24 with the Back-Cover Texts as in (a) below.
26    (a) The Free Software Foundation's Back-Cover Text is: "You have
27 freedom to copy and modify this GNU Manual, like GNU software.  Copies
28 published by the Free Software Foundation raise funds for GNU
29 development."
31 \x1f
32 File: gdb.info,  Node: Supported languages,  Next: Unsupported languages,  Prev: Checks,  Up: Languages
34 12.4 Supported languages
35 ========================
37 GDB supports C, C++, Objective-C, Fortran, Java, Pascal, assembly,
38 Modula-2, and Ada.  Some GDB features may be used in expressions
39 regardless of the language you use: the GDB `@' and `::' operators, and
40 the `{type}addr' construct (*note Expressions: Expressions.) can be
41 used with the constructs of any supported language.
43    The following sections detail to what degree each source language is
44 supported by GDB.  These sections are not meant to be language
45 tutorials or references, but serve only as a reference guide to what the
46 GDB expression parser accepts, and what input and output formats should
47 look like for different languages.  There are many good books written
48 on each of these languages; please look to these for a language
49 reference or tutorial.
51 * Menu:
53 * C::                           C and C++
54 * Objective-C::                 Objective-C
55 * Fortran::                     Fortran
56 * Pascal::                      Pascal
57 * Modula-2::                    Modula-2
58 * Ada::                         Ada
60 \x1f
61 File: gdb.info,  Node: C,  Next: Objective-C,  Up: Supported languages
63 12.4.1 C and C++
64 ----------------
66 Since C and C++ are so closely related, many features of GDB apply to
67 both languages.  Whenever this is the case, we discuss those languages
68 together.
70    The C++ debugging facilities are jointly implemented by the C++
71 compiler and GDB.  Therefore, to debug your C++ code effectively, you
72 must compile your C++ programs with a supported C++ compiler, such as
73 GNU `g++', or the HP ANSI C++ compiler (`aCC').
75    For best results when using GNU C++, use the DWARF 2 debugging
76 format; if it doesn't work on your system, try the stabs+ debugging
77 format.  You can select those formats explicitly with the `g++'
78 command-line options `-gdwarf-2' and `-gstabs+'.  *Note Options for
79 Debugging Your Program or GNU CC: (gcc.info)Debugging Options.
81 * Menu:
83 * C Operators::                 C and C++ operators
84 * C Constants::                 C and C++ constants
85 * C plus plus expressions::     C++ expressions
86 * C Defaults::                  Default settings for C and C++
87 * C Checks::                    C and C++ type and range checks
88 * Debugging C::                 GDB and C
89 * Debugging C plus plus::       GDB features for C++
91 \x1f
92 File: gdb.info,  Node: C Operators,  Next: C Constants,  Up: C
94 12.4.1.1 C and C++ operators
95 ............................
97 Operators must be defined on values of specific types.  For instance,
98 `+' is defined on numbers, but not on structures.  Operators are often
99 defined on groups of types.
101    For the purposes of C and C++, the following definitions hold:
103    * _Integral types_ include `int' with any of its storage-class
104      specifiers; `char'; `enum'; and, for C++, `bool'.
106    * _Floating-point types_ include `float', `double', and `long
107      double' (if supported by the target platform).
109    * _Pointer types_ include all types defined as `(TYPE *)'.
111    * _Scalar types_ include all of the above.
114 The following operators are supported.  They are listed here in order
115 of increasing precedence:
118      The comma or sequencing operator.  Expressions in a
119      comma-separated list are evaluated from left to right, with the
120      result of the entire expression being the last expression
121      evaluated.
124      Assignment.  The value of an assignment expression is the value
125      assigned.  Defined on scalar types.
127 `OP='
128      Used in an expression of the form `A OP= B', and translated to
129      `A = A OP B'.  `OP=' and `=' have the same precedence.  OP is any
130      one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
131      `/', `%'.
133 `?:'
134      The ternary operator.  `A ? B : C' can be thought of as:  if A
135      then B else C.  A should be of an integral type.
137 `||'
138      Logical OR.  Defined on integral types.
140 `&&'
141      Logical AND.  Defined on integral types.
144      Bitwise OR.  Defined on integral types.
147      Bitwise exclusive-OR.  Defined on integral types.
150      Bitwise AND.  Defined on integral types.
152 `==, !='
153      Equality and inequality.  Defined on scalar types.  The value of
154      these expressions is 0 for false and non-zero for true.
156 `<, >, <=, >='
157      Less than, greater than, less than or equal, greater than or equal.
158      Defined on scalar types.  The value of these expressions is 0 for
159      false and non-zero for true.
161 `<<, >>'
162      left shift, and right shift.  Defined on integral types.
165      The GDB "artificial array" operator (*note Expressions:
166      Expressions.).
168 `+, -'
169      Addition and subtraction.  Defined on integral types,
170      floating-point types and pointer types.
172 `*, /, %'
173      Multiplication, division, and modulus.  Multiplication and
174      division are defined on integral and floating-point types.
175      Modulus is defined on integral types.
177 `++, --'
178      Increment and decrement.  When appearing before a variable, the
179      operation is performed before the variable is used in an
180      expression; when appearing after it, the variable's value is used
181      before the operation takes place.
184      Pointer dereferencing.  Defined on pointer types.  Same precedence
185      as `++'.
188      Address operator.  Defined on variables.  Same precedence as `++'.
190      For debugging C++, GDB implements a use of `&' beyond what is
191      allowed in the C++ language itself: you can use `&(&REF)' (or, if
192      you prefer, simply `&&REF') to examine the address where a C++
193      reference variable (declared with `&REF') is stored.
196      Negative.  Defined on integral and floating-point types.  Same
197      precedence as `++'.
200      Logical negation.  Defined on integral types.  Same precedence as
201      `++'.
204      Bitwise complement operator.  Defined on integral types.  Same
205      precedence as `++'.
207 `., ->'
208      Structure member, and pointer-to-structure member.  For
209      convenience, GDB regards the two as equivalent, choosing whether
210      to dereference a pointer based on the stored type information.
211      Defined on `struct' and `union' data.
213 `.*, ->*'
214      Dereferences of pointers to members.
216 `[]'
217      Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
218      as `->'.
220 `()'
221      Function parameter list.  Same precedence as `->'.
223 `::'
224      C++ scope resolution operator.  Defined on `struct', `union', and
225      `class' types.
227 `::'
228      Doubled colons also represent the GDB scope operator (*note
229      Expressions: Expressions.).  Same precedence as `::', above.
231    If an operator is redefined in the user code, GDB usually attempts
232 to invoke the redefined version instead of using the operator's
233 predefined meaning.
235 * Menu:
237 * C Constants::
239 \x1f
240 File: gdb.info,  Node: C Constants,  Next: C plus plus expressions,  Prev: C Operators,  Up: C
242 12.4.1.2 C and C++ constants
243 ............................
245 GDB allows you to express the constants of C and C++ in the following
246 ways:
248    * Integer constants are a sequence of digits.  Octal constants are
249      specified by a leading `0' (i.e. zero), and hexadecimal constants
250      by a leading `0x' or `0X'.  Constants may also end with a letter
251      `l', specifying that the constant should be treated as a `long'
252      value.
254    * Floating point constants are a sequence of digits, followed by a
255      decimal point, followed by a sequence of digits, and optionally
256      followed by an exponent.  An exponent is of the form:
257      `e[[+]|-]NNN', where NNN is another sequence of digits.  The `+'
258      is optional for positive exponents.  A floating-point constant may
259      also end with a letter `f' or `F', specifying that the constant
260      should be treated as being of the `float' (as opposed to the
261      default `double') type; or with a letter `l' or `L', which
262      specifies a `long double' constant.
264    * Enumerated constants consist of enumerated identifiers, or their
265      integral equivalents.
267    * Character constants are a single character surrounded by single
268      quotes (`''), or a number--the ordinal value of the corresponding
269      character (usually its ASCII value).  Within quotes, the single
270      character may be represented by a letter or by "escape sequences",
271      which are of the form `\NNN', where NNN is the octal representation
272      of the character's ordinal value; or of the form `\X', where `X'
273      is a predefined special character--for example, `\n' for newline.
275    * String constants are a sequence of character constants surrounded
276      by double quotes (`"').  Any valid character constant (as described
277      above) may appear.  Double quotes within the string must be
278      preceded by a backslash, so for instance `"a\"b'c"' is a string of
279      five characters.
281    * Pointer constants are an integral value.  You can also write
282      pointers to constants using the C operator `&'.
284    * Array constants are comma-separated lists surrounded by braces `{'
285      and `}'; for example, `{1,2,3}' is a three-element array of
286      integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
287      `{&"hi", &"there", &"fred"}' is a three-element array of pointers.
289 * Menu:
291 * C plus plus expressions::
292 * C Defaults::
293 * C Checks::
295 * Debugging C::
297 \x1f
298 File: gdb.info,  Node: C plus plus expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
300 12.4.1.3 C++ expressions
301 ........................
303 GDB expression handling can interpret most C++ expressions.
305      _Warning:_ GDB can only debug C++ code if you use the proper
306      compiler and the proper debug format.  Currently, GDB works best
307      when debugging C++ code that is compiled with GCC 2.95.3 or with
308      GCC 3.1 or newer, using the options `-gdwarf-2' or `-gstabs+'.
309      DWARF 2 is preferred over stabs+.  Most configurations of GCC emit
310      either DWARF 2 or stabs+ as their default debug format, so you
311      usually don't need to specify a debug format explicitly.  Other
312      compilers and/or debug formats are likely to work badly or not at
313      all when using GDB to debug C++ code.
315   1. Member function calls are allowed; you can use expressions like
317           count = aml->GetOriginal(x, y)
319   2. While a member function is active (in the selected stack frame),
320      your expressions have the same namespace available as the member
321      function; that is, GDB allows implicit references to the class
322      instance pointer `this' following the same rules as C++.
324   3. You can call overloaded functions; GDB resolves the function call
325      to the right definition, with some restrictions.  GDB does not
326      perform overload resolution involving user-defined type
327      conversions, calls to constructors, or instantiations of templates
328      that do not exist in the program.  It also cannot handle ellipsis
329      argument lists or default arguments.
331      It does perform integral conversions and promotions, floating-point
332      promotions, arithmetic conversions, pointer conversions,
333      conversions of class objects to base classes, and standard
334      conversions such as those of functions or arrays to pointers; it
335      requires an exact match on the number of function arguments.
337      Overload resolution is always performed, unless you have specified
338      `set overload-resolution off'.  *Note GDB features for C++:
339      Debugging C plus plus.
341      You must specify `set overload-resolution off' in order to use an
342      explicit function signature to call an overloaded function, as in
343           p 'foo(char,int)'('x', 13)
345      The GDB command-completion facility can simplify this; see *Note
346      Command completion: Completion.
348   4. GDB understands variables declared as C++ references; you can use
349      them in expressions just as you do in C++ source--they are
350      automatically dereferenced.
352      In the parameter list shown when GDB displays a frame, the values
353      of reference variables are not displayed (unlike other variables);
354      this avoids clutter, since references are often used for large
355      structures.  The _address_ of a reference variable is always
356      shown, unless you have specified `set print address off'.
358   5. GDB supports the C++ name resolution operator `::'--your
359      expressions can use it just as expressions in your program do.
360      Since one scope may be defined in another, you can use `::'
361      repeatedly if necessary, for example in an expression like
362      `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope by
363      reference to source files, in both C and C++ debugging (*note
364      Program variables: Variables.).
366    In addition, when used with HP's C++ compiler, GDB supports calling
367 virtual functions correctly, printing out virtual bases of objects,
368 calling functions in a base subobject, casting objects, and invoking
369 user-defined operators.
371 \x1f
372 File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: C plus plus expressions,  Up: C
374 12.4.1.4 C and C++ defaults
375 ...........................
377 If you allow GDB to set type and range checking automatically, they
378 both default to `off' whenever the working language changes to C or
379 C++.  This happens regardless of whether you or GDB selects the working
380 language.
382    If you allow GDB to set the language automatically, it recognizes
383 source files whose names end with `.c', `.C', or `.cc', etc, and when
384 GDB enters code compiled from one of these files, it sets the working
385 language to C or C++.  *Note Having GDB infer the source language:
386 Automatically, for further details.
388 \x1f
389 File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C
391 12.4.1.5 C and C++ type and range checks
392 ........................................
394 By default, when GDB parses C or C++ expressions, type checking is not
395 used.  However, if you turn type checking on, GDB considers two
396 variables type equivalent if:
398    * The two variables are structured and have the same structure,
399      union, or enumerated tag.
401    * The two variables have the same type name, or types that have been
402      declared equivalent through `typedef'.
405    Range checking, if turned on, is done on mathematical operations.
406 Array indices are not checked, since they are often used to index a
407 pointer that is not itself an array.
409 \x1f
410 File: gdb.info,  Node: Debugging C,  Next: Debugging C plus plus,  Prev: C Checks,  Up: C
412 12.4.1.6 GDB and C
413 ..................
415 The `set print union' and `show print union' commands apply to the
416 `union' type.  When set to `on', any `union' that is inside a `struct'
417 or `class' is also printed.  Otherwise, it appears as `{...}'.
419    The `@' operator aids in the debugging of dynamic arrays, formed
420 with pointers and a memory allocation function.  *Note Expressions:
421 Expressions.
423 * Menu:
425 * Debugging C plus plus::
427 \x1f
428 File: gdb.info,  Node: Debugging C plus plus,  Prev: Debugging C,  Up: C
430 12.4.1.7 GDB features for C++
431 .............................
433 Some GDB commands are particularly useful with C++, and some are
434 designed specifically for use with C++.  Here is a summary:
436 `breakpoint menus'
437      When you want a breakpoint in a function whose name is overloaded,
438      GDB breakpoint menus help you specify which function definition
439      you want.  *Note Breakpoint menus: Breakpoint Menus.
441 `rbreak REGEX'
442      Setting breakpoints using regular expressions is helpful for
443      setting breakpoints on overloaded functions that are not members
444      of any special classes.  *Note Setting breakpoints: Set Breaks.
446 `catch throw'
447 `catch catch'
448      Debug C++ exception handling using these commands.  *Note Setting
449      catchpoints: Set Catchpoints.
451 `ptype TYPENAME'
452      Print inheritance relationships as well as other information for
453      type TYPENAME.  *Note Examining the Symbol Table: Symbols.
455 `set print demangle'
456 `show print demangle'
457 `set print asm-demangle'
458 `show print asm-demangle'
459      Control whether C++ symbols display in their source form, both when
460      displaying code as C++ source and when displaying disassemblies.
461      *Note Print settings: Print Settings.
463 `set print object'
464 `show print object'
465      Choose whether to print derived (actual) or declared types of
466      objects.  *Note Print settings: Print Settings.
468 `set print vtbl'
469 `show print vtbl'
470      Control the format for printing virtual function tables.  *Note
471      Print settings: Print Settings.  (The `vtbl' commands do not work
472      on programs compiled with the HP ANSI C++ compiler (`aCC').)
474 `set overload-resolution on'
475      Enable overload resolution for C++ expression evaluation.  The
476      default is on.  For overloaded functions, GDB evaluates the
477      arguments and searches for a function whose signature matches the
478      argument types, using the standard C++ conversion rules (see *Note
479      C++ expressions: C plus plus expressions, for details).  If it
480      cannot find a match, it emits a message.
482 `set overload-resolution off'
483      Disable overload resolution for C++ expression evaluation.  For
484      overloaded functions that are not class member functions, GDB
485      chooses the first function of the specified name that it finds in
486      the symbol table, whether or not its arguments are of the correct
487      type.  For overloaded functions that are class member functions,
488      GDB searches for a function whose signature _exactly_ matches the
489      argument types.
491 `show overload-resolution'
492      Show the current setting of overload resolution.
494 `Overloaded symbol names'
495      You can specify a particular definition of an overloaded symbol,
496      using the same notation that is used to declare such symbols in
497      C++: type `SYMBOL(TYPES)' rather than just SYMBOL.  You can also
498      use the GDB command-line word completion facilities to list the
499      available choices, or to finish the type list for you.  *Note
500      Command completion: Completion, for details on how to do this.
502 \x1f
503 File: gdb.info,  Node: Objective-C,  Next: Fortran,  Prev: C,  Up: Supported languages
505 12.4.2 Objective-C
506 ------------------
508 This section provides information about some commands and command
509 options that are useful for debugging Objective-C code.  See also *Note
510 info classes: Symbols, and *Note info selectors: Symbols, for a few
511 more commands specific to Objective-C support.
513 * Menu:
515 * Method Names in Commands::
516 * The Print Command with Objective-C::
518 \x1f
519 File: gdb.info,  Node: Method Names in Commands,  Next: The Print Command with Objective-C,  Prev: Objective-C,  Up: Objective-C
521 12.4.2.1 Method Names in Commands
522 .................................
524 The following commands have been extended to accept Objective-C method
525 names as line specifications:
527    * `clear'
529    * `break'
531    * `info line'
533    * `jump'
535    * `list'
537    A fully qualified Objective-C method name is specified as
539      -[CLASS METHODNAME]
541    where the minus sign is used to indicate an instance method and a
542 plus sign (not shown) is used to indicate a class method.  The class
543 name CLASS and method name METHODNAME are enclosed in brackets, similar
544 to the way messages are specified in Objective-C source code.  For
545 example, to set a breakpoint at the `create' instance method of class
546 `Fruit' in the program currently being debugged, enter:
548      break -[Fruit create]
550    To list ten program lines around the `initialize' class method,
551 enter:
553      list +[NSText initialize]
555    In the current version of GDB, the plus or minus sign is required.
556 In future versions of GDB, the plus or minus sign will be optional, but
557 you can use it to narrow the search.  It is also possible to specify
558 just a method name:
560      break create
562    You must specify the complete method name, including any colons.  If
563 your program's source files contain more than one `create' method,
564 you'll be presented with a numbered list of classes that implement that
565 method.  Indicate your choice by number, or type `0' to exit if none
566 apply.
568    As another example, to clear a breakpoint established at the
569 `makeKeyAndOrderFront:' method of the `NSWindow' class, enter:
571      clear -[NSWindow makeKeyAndOrderFront:]
573 \x1f
574 File: gdb.info,  Node: The Print Command with Objective-C,  Prev: Method Names in Commands,  Up: Objective-C
576 12.4.2.2 The Print Command With Objective-C
577 ...........................................
579 The print command has also been extended to accept methods.  For
580 example:
582      print -[OBJECT hash]
584 will tell GDB to send the `hash' message to OBJECT and print the
585 result.  Also, an additional command has been added, `print-object' or
586 `po' for short, which is meant to print the description of an object.
587 However, this command may only work with certain Objective-C libraries
588 that have a particular hook function, `_NSPrintForDebugger', defined.
590 \x1f
591 File: gdb.info,  Node: Fortran,  Next: Pascal,  Prev: Objective-C,  Up: Supported languages
593 12.4.3 Fortran
594 --------------
596 GDB can be used to debug programs written in Fortran, but it currently
597 supports only the features of Fortran 77 language.
599    Some Fortran compilers (GNU Fortran 77 and Fortran 95 compilers
600 among them) append an underscore to the names of variables and
601 functions.  When you debug programs compiled by those compilers, you
602 will need to refer to variables and functions with a trailing
603 underscore.
605 * Menu:
607 * Fortran Operators::           Fortran operators and expressions
608 * Fortran Defaults::            Default settings for Fortran
609 * Special Fortran commands::    Special GDB commands for Fortran
611 \x1f
612 File: gdb.info,  Node: Fortran Operators,  Next: Fortran Defaults,  Up: Fortran
614 12.4.3.1 Fortran operators and expressions
615 ..........................................
617 Operators must be defined on values of specific types.  For instance,
618 `+' is defined on numbers, but not on characters or other non-
619 arithmetic types.  Operators are often defined on groups of types.
621 `**'
622      The exponentiation operator. It raises the first operand to the
623      power of the second one.
626      The range operator.  Normally used in the form of array(low:high)
627      to represent a section of array.
629 \x1f
630 File: gdb.info,  Node: Fortran Defaults,  Next: Special Fortran commands,  Prev: Fortran Operators,  Up: Fortran
632 12.4.3.2 Fortran Defaults
633 .........................
635 Fortran symbols are usually case-insensitive, so GDB by default uses
636 case-insensitive matches for Fortran symbols.  You can change that with
637 the `set case-insensitive' command, see *Note Symbols::, for the
638 details.
640 \x1f
641 File: gdb.info,  Node: Special Fortran commands,  Prev: Fortran Defaults,  Up: Fortran
643 12.4.3.3 Special Fortran commands
644 .................................
646 GDB had some commands to support Fortran specific feature, such as
647 common block displaying.
649 `info common [COMMON-NAME]'
650      This command prints the values contained in the Fortran `COMMON'
651      block whose name is COMMON-NAME.  With no argument, the names of
652      all `COMMON' blocks visible at current program location are
653      printed.
655 \x1f
656 File: gdb.info,  Node: Pascal,  Next: Modula-2,  Prev: Fortran,  Up: Supported languages
658 12.4.4 Pascal
659 -------------
661 Debugging Pascal programs which use sets, subranges, file variables, or
662 nested functions does not currently work.  GDB does not support
663 entering expressions, printing values, or similar features using Pascal
664 syntax.
666    The Pascal-specific command `set print pascal_static-members'
667 controls whether static members of Pascal objects are displayed.  *Note
668 pascal_static-members: Print Settings.
670 \x1f
671 File: gdb.info,  Node: Modula-2,  Next: Ada,  Prev: Pascal,  Up: Supported languages
673 12.4.5 Modula-2
674 ---------------
676 The extensions made to GDB to support Modula-2 only support output from
677 the GNU Modula-2 compiler (which is currently being developed).  Other
678 Modula-2 compilers are not currently supported, and attempting to debug
679 executables produced by them is most likely to give an error as GDB
680 reads in the executable's symbol table.
682 * Menu:
684 * M2 Operators::                Built-in operators
685 * Built-In Func/Proc::          Built-in functions and procedures
686 * M2 Constants::                Modula-2 constants
687 * M2 Types::                    Modula-2 types
688 * M2 Defaults::                 Default settings for Modula-2
689 * Deviations::                  Deviations from standard Modula-2
690 * M2 Checks::                   Modula-2 type and range checks
691 * M2 Scope::                    The scope operators `::' and `.'
692 * GDB/M2::                      GDB and Modula-2
694 \x1f
695 File: gdb.info,  Node: M2 Operators,  Next: Built-In Func/Proc,  Up: Modula-2
697 12.4.5.1 Operators
698 ..................
700 Operators must be defined on values of specific types.  For instance,
701 `+' is defined on numbers, but not on structures.  Operators are often
702 defined on groups of types.  For the purposes of Modula-2, the
703 following definitions hold:
705    * _Integral types_ consist of `INTEGER', `CARDINAL', and their
706      subranges.
708    * _Character types_ consist of `CHAR' and its subranges.
710    * _Floating-point types_ consist of `REAL'.
712    * _Pointer types_ consist of anything declared as `POINTER TO TYPE'.
714    * _Scalar types_ consist of all of the above.
716    * _Set types_ consist of `SET' and `BITSET' types.
718    * _Boolean types_ consist of `BOOLEAN'.
720 The following operators are supported, and appear in order of
721 increasing precedence:
724      Function argument or array index separator.
726 `:='
727      Assignment.  The value of VAR `:=' VALUE is VALUE.
729 `<, >'
730      Less than, greater than on integral, floating-point, or enumerated
731      types.
733 `<=, >='
734      Less than or equal to, greater than or equal to on integral,
735      floating-point and enumerated types, or set inclusion on set
736      types.  Same precedence as `<'.
738 `=, <>, #'
739      Equality and two ways of expressing inequality, valid on scalar
740      types.  Same precedence as `<'.  In GDB scripts, only `<>' is
741      available for inequality, since `#' conflicts with the script
742      comment character.
744 `IN'
745      Set membership.  Defined on set types and the types of their
746      members.  Same precedence as `<'.
748 `OR'
749      Boolean disjunction.  Defined on boolean types.
751 `AND, &'
752      Boolean conjunction.  Defined on boolean types.
755      The GDB "artificial array" operator (*note Expressions:
756      Expressions.).
758 `+, -'
759      Addition and subtraction on integral and floating-point types, or
760      union and difference on set types.
763      Multiplication on integral and floating-point types, or set
764      intersection on set types.
767      Division on floating-point types, or symmetric set difference on
768      set types.  Same precedence as `*'.
770 `DIV, MOD'
771      Integer division and remainder.  Defined on integral types.  Same
772      precedence as `*'.
775      Negative. Defined on `INTEGER' and `REAL' data.
778      Pointer dereferencing.  Defined on pointer types.
780 `NOT'
781      Boolean negation.  Defined on boolean types.  Same precedence as
782      `^'.
785      `RECORD' field selector.  Defined on `RECORD' data.  Same
786      precedence as `^'.
788 `[]'
789      Array indexing.  Defined on `ARRAY' data.  Same precedence as `^'.
791 `()'
792      Procedure argument list.  Defined on `PROCEDURE' objects.  Same
793      precedence as `^'.
795 `::, .'
796      GDB and Modula-2 scope operators.
798      _Warning:_ Set expressions and their operations are not yet
799      supported, so GDB treats the use of the operator `IN', or the use
800      of operators `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>='
801      on sets as an error.
803 \x1f
804 File: gdb.info,  Node: Built-In Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
806 12.4.5.2 Built-in functions and procedures
807 ..........................................
809 Modula-2 also makes available several built-in procedures and functions.
810 In describing these, the following metavariables are used:
813      represents an `ARRAY' variable.
816      represents a `CHAR' constant or variable.
819      represents a variable or constant of integral type.
822      represents an identifier that belongs to a set.  Generally used in
823      the same function with the metavariable S.  The type of S should
824      be `SET OF MTYPE' (where MTYPE is the type of M).
827      represents a variable or constant of integral or floating-point
828      type.
831      represents a variable or constant of floating-point type.
834      represents a type.
837      represents a variable.
840      represents a variable or constant of one of many types.  See the
841      explanation of the function for details.
843    All Modula-2 built-in procedures also return a result, described
844 below.
846 `ABS(N)'
847      Returns the absolute value of N.
849 `CAP(C)'
850      If C is a lower case letter, it returns its upper case equivalent,
851      otherwise it returns its argument.
853 `CHR(I)'
854      Returns the character whose ordinal value is I.
856 `DEC(V)'
857      Decrements the value in the variable V by one.  Returns the new
858      value.
860 `DEC(V,I)'
861      Decrements the value in the variable V by I.  Returns the new
862      value.
864 `EXCL(M,S)'
865      Removes the element M from the set S.  Returns the new set.
867 `FLOAT(I)'
868      Returns the floating point equivalent of the integer I.
870 `HIGH(A)'
871      Returns the index of the last member of A.
873 `INC(V)'
874      Increments the value in the variable V by one.  Returns the new
875      value.
877 `INC(V,I)'
878      Increments the value in the variable V by I.  Returns the new
879      value.
881 `INCL(M,S)'
882      Adds the element M to the set S if it is not already there.
883      Returns the new set.
885 `MAX(T)'
886      Returns the maximum value of the type T.
888 `MIN(T)'
889      Returns the minimum value of the type T.
891 `ODD(I)'
892      Returns boolean TRUE if I is an odd number.
894 `ORD(X)'
895      Returns the ordinal value of its argument.  For example, the
896      ordinal value of a character is its ASCII value (on machines
897      supporting the ASCII character set).  X must be of an ordered
898      type, which include integral, character and enumerated types.
900 `SIZE(X)'
901      Returns the size of its argument.  X can be a variable or a type.
903 `TRUNC(R)'
904      Returns the integral part of R.
906 `VAL(T,I)'
907      Returns the member of the type T whose ordinal value is I.
909      _Warning:_  Sets and their operations are not yet supported, so
910      GDB treats the use of procedures `INCL' and `EXCL' as an error.
912 \x1f
913 File: gdb.info,  Node: M2 Constants,  Next: M2 Types,  Prev: Built-In Func/Proc,  Up: Modula-2
915 12.4.5.3 Constants
916 ..................
918 GDB allows you to express the constants of Modula-2 in the following
919 ways:
921    * Integer constants are simply a sequence of digits.  When used in an
922      expression, a constant is interpreted to be type-compatible with
923      the rest of the expression.  Hexadecimal integers are specified by
924      a trailing `H', and octal integers by a trailing `B'.
926    * Floating point constants appear as a sequence of digits, followed
927      by a decimal point and another sequence of digits.  An optional
928      exponent can then be specified, in the form `E[+|-]NNN', where
929      `[+|-]NNN' is the desired exponent.  All of the digits of the
930      floating point constant must be valid decimal (base 10) digits.
932    * Character constants consist of a single character enclosed by a
933      pair of like quotes, either single (`'') or double (`"').  They may
934      also be expressed by their ordinal value (their ASCII value,
935      usually) followed by a `C'.
937    * String constants consist of a sequence of characters enclosed by a
938      pair of like quotes, either single (`'') or double (`"').  Escape
939      sequences in the style of C are also allowed.  *Note C and C++
940      constants: C Constants, for a brief explanation of escape
941      sequences.
943    * Enumerated constants consist of an enumerated identifier.
945    * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
947    * Pointer constants consist of integral values only.
949    * Set constants are not yet supported.
951 \x1f
952 File: gdb.info,  Node: M2 Types,  Next: M2 Defaults,  Prev: M2 Constants,  Up: Modula-2
954 12.4.5.4 Modula-2 Types
955 .......................
957 Currently GDB can print the following data types in Modula-2 syntax:
958 array types, record types, set types, pointer types, procedure types,
959 enumerated types, subrange types and base types.  You can also print
960 the contents of variables declared using these type.  This section
961 gives a number of simple source code examples together with sample GDB
962 sessions.
964    The first example contains the following section of code:
966      VAR
967         s: SET OF CHAR ;
968         r: [20..40] ;
970 and you can request GDB to interrogate the type and value of `r' and
971 `s'.
973      (gdb) print s
974      {'A'..'C', 'Z'}
975      (gdb) ptype s
976      SET OF CHAR
977      (gdb) print r
978      21
979      (gdb) ptype r
980      [20..40]
982 Likewise if your source code declares `s' as:
984      VAR
985         s: SET ['A'..'Z'] ;
987 then you may query the type of `s' by:
989      (gdb) ptype s
990      type = SET ['A'..'Z']
992 Note that at present you cannot interactively manipulate set
993 expressions using the debugger.
995    The following example shows how you might declare an array in
996 Modula-2 and how you can interact with GDB to print its type and
997 contents:
999      VAR
1000         s: ARRAY [-10..10] OF CHAR ;
1002      (gdb) ptype s
1003      ARRAY [-10..10] OF CHAR
1005    Note that the array handling is not yet complete and although the
1006 type is printed correctly, expression handling still assumes that all
1007 arrays have a lower bound of zero and not `-10' as in the example
1008 above.  Unbounded arrays are also not yet recognized in GDB.
1010    Here are some more type related Modula-2 examples:
1012      TYPE
1013         colour = (blue, red, yellow, green) ;
1014         t = [blue..yellow] ;
1015      VAR
1016         s: t ;
1017      BEGIN
1018         s := blue ;
1020 The GDB interaction shows how you can query the data type and value of
1021 a variable.
1023      (gdb) print s
1024      $1 = blue
1025      (gdb) ptype t
1026      type = [blue..yellow]
1028 In this example a Modula-2 array is declared and its contents
1029 displayed.  Observe that the contents are written in the same way as
1030 their `C' counterparts.
1032      VAR
1033         s: ARRAY [1..5] OF CARDINAL ;
1034      BEGIN
1035         s[1] := 1 ;
1037      (gdb) print s
1038      $1 = {1, 0, 0, 0, 0}
1039      (gdb) ptype s
1040      type = ARRAY [1..5] OF CARDINAL
1042    The Modula-2 language interface to GDB also understands pointer
1043 types as shown in this example:
1045      VAR
1046         s: POINTER TO ARRAY [1..5] OF CARDINAL ;
1047      BEGIN
1048         NEW(s) ;
1049         s^[1] := 1 ;
1051 and you can request that GDB describes the type of `s'.
1053      (gdb) ptype s
1054      type = POINTER TO ARRAY [1..5] OF CARDINAL
1056    GDB handles compound types as we can see in this example.  Here we
1057 combine array types, record types, pointer types and subrange types:
1059      TYPE
1060         foo = RECORD
1061                  f1: CARDINAL ;
1062                  f2: CHAR ;
1063                  f3: myarray ;
1064               END ;
1066         myarray = ARRAY myrange OF CARDINAL ;
1067         myrange = [-2..2] ;
1068      VAR
1069         s: POINTER TO ARRAY myrange OF foo ;
1071 and you can ask GDB to describe the type of `s' as shown below.
1073      (gdb) ptype s
1074      type = POINTER TO ARRAY [-2..2] OF foo = RECORD
1075          f1 : CARDINAL;
1076          f2 : CHAR;
1077          f3 : ARRAY [-2..2] OF CARDINAL;
1078      END
1080 \x1f
1081 File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Types,  Up: Modula-2
1083 12.4.5.5 Modula-2 defaults
1084 ..........................
1086 If type and range checking are set automatically by GDB, they both
1087 default to `on' whenever the working language changes to Modula-2.
1088 This happens regardless of whether you or GDB selected the working
1089 language.
1091    If you allow GDB to set the language automatically, then entering
1092 code compiled from a file whose name ends with `.mod' sets the working
1093 language to Modula-2.  *Note Having GDB set the language automatically:
1094 Automatically, for further details.
1096 \x1f
1097 File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
1099 12.4.5.6 Deviations from standard Modula-2
1100 ..........................................
1102 A few changes have been made to make Modula-2 programs easier to debug.
1103 This is done primarily via loosening its type strictness:
1105    * Unlike in standard Modula-2, pointer constants can be formed by
1106      integers.  This allows you to modify pointer variables during
1107      debugging.  (In standard Modula-2, the actual address contained in
1108      a pointer variable is hidden from you; it can only be modified
1109      through direct assignment to another pointer variable or
1110      expression that returned a pointer.)
1112    * C escape sequences can be used in strings and characters to
1113      represent non-printable characters.  GDB prints out strings with
1114      these escape sequences embedded.  Single non-printable characters
1115      are printed using the `CHR(NNN)' format.
1117    * The assignment operator (`:=') returns the value of its right-hand
1118      argument.
1120    * All built-in procedures both modify _and_ return their argument.
1122 \x1f
1123 File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
1125 12.4.5.7 Modula-2 type and range checks
1126 .......................................
1128      _Warning:_ in this release, GDB does not yet perform type or range
1129      checking.
1131    GDB considers two Modula-2 variables type equivalent if:
1133    * They are of types that have been declared equivalent via a `TYPE
1134      T1 = T2' statement
1136    * They have been declared on the same line.  (Note:  This is true of
1137      the GNU Modula-2 compiler, but it may not be true of other
1138      compilers.)
1140    As long as type checking is enabled, any attempt to combine variables
1141 whose types are not equivalent is an error.
1143    Range checking is done on all mathematical operations, assignment,
1144 array index bounds, and all built-in functions and procedures.
1146 \x1f
1147 File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
1149 12.4.5.8 The scope operators `::' and `.'
1150 .........................................
1152 There are a few subtle differences between the Modula-2 scope operator
1153 (`.') and the GDB scope operator (`::').  The two have similar syntax:
1156      MODULE . ID
1157      SCOPE :: ID
1159 where SCOPE is the name of a module or a procedure, MODULE the name of
1160 a module, and ID is any declared identifier within your program, except
1161 another module.
1163    Using the `::' operator makes GDB search the scope specified by
1164 SCOPE for the identifier ID.  If it is not found in the specified
1165 scope, then GDB searches all scopes enclosing the one specified by
1166 SCOPE.
1168    Using the `.' operator makes GDB search the current scope for the
1169 identifier specified by ID that was imported from the definition module
1170 specified by MODULE.  With this operator, it is an error if the
1171 identifier ID was not imported from definition module MODULE, or if ID
1172 is not an identifier in MODULE.
1174 \x1f
1175 File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
1177 12.4.5.9 GDB and Modula-2
1178 .........................
1180 Some GDB commands have little use when debugging Modula-2 programs.
1181 Five subcommands of `set print' and `show print' apply specifically to
1182 C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
1183 The first four apply to C++, and the last to the C `union' type, which
1184 has no direct analogue in Modula-2.
1186    The `@' operator (*note Expressions: Expressions.), while available
1187 with any language, is not useful with Modula-2.  Its intent is to aid
1188 the debugging of "dynamic arrays", which cannot be created in Modula-2
1189 as they can in C or C++.  However, because an address can be specified
1190 by an integral constant, the construct `{TYPE}ADREXP' is still useful.
1192    In GDB scripts, the Modula-2 inequality operator `#' is interpreted
1193 as the beginning of a comment.  Use `<>' instead.
1195 \x1f
1196 File: gdb.info,  Node: Ada,  Prev: Modula-2,  Up: Supported languages
1198 12.4.6 Ada
1199 ----------
1201 The extensions made to GDB for Ada only support output from the GNU Ada
1202 (GNAT) compiler.  Other Ada compilers are not currently supported, and
1203 attempting to debug executables produced by them is most likely to be
1204 difficult.
1206 * Menu:
1208 * Ada Mode Intro::              General remarks on the Ada syntax
1209                                    and semantics supported by Ada mode
1210                                    in GDB.
1211 * Omissions from Ada::          Restrictions on the Ada expression syntax.
1212 * Additions to Ada::            Extensions of the Ada expression syntax.
1213 * Stopping Before Main Program:: Debugging the program during elaboration.
1214 * Ada Glitches::                Known peculiarities of Ada mode.
1216 \x1f
1217 File: gdb.info,  Node: Ada Mode Intro,  Next: Omissions from Ada,  Up: Ada
1219 12.4.6.1 Introduction
1220 .....................
1222 The Ada mode of GDB supports a fairly large subset of Ada expression
1223 syntax, with some extensions.  The philosophy behind the design of this
1224 subset is
1226    * That GDB should provide basic literals and access to operations for
1227      arithmetic, dereferencing, field selection, indexing, and
1228      subprogram calls, leaving more sophisticated computations to
1229      subprograms written into the program (which therefore may be
1230      called from GDB).
1232    * That type safety and strict adherence to Ada language restrictions
1233      are not particularly important to the GDB user.
1235    * That brevity is important to the GDB user.
1237    Thus, for brevity, the debugger acts as if there were implicit
1238 `with' and `use' clauses in effect for all user-written packages,
1239 making it unnecessary to fully qualify most names with their packages,
1240 regardless of context.  Where this causes ambiguity, GDB asks the
1241 user's intent.
1243    The debugger will start in Ada mode if it detects an Ada main
1244 program.  As for other languages, it will enter Ada mode when stopped
1245 in a program that was translated from an Ada source file.
1247    While in Ada mode, you may use `-' for comments.  This is useful
1248 mostly for documenting command files.  The standard GDB comment (`#')
1249 still works at the beginning of a line in Ada mode, but not in the
1250 middle (to allow based literals).
1252    The debugger supports limited overloading.  Given a subprogram call
1253 in which the function symbol has multiple definitions, it will use the
1254 number of actual parameters and some information about their types to
1255 attempt to narrow the set of definitions.  It also makes very limited
1256 use of context, preferring procedures to functions in the context of
1257 the `call' command, and functions to procedures elsewhere.
1259 \x1f
1260 File: gdb.info,  Node: Omissions from Ada,  Next: Additions to Ada,  Prev: Ada Mode Intro,  Up: Ada
1262 12.4.6.2 Omissions from Ada
1263 ...........................
1265 Here are the notable omissions from the subset:
1267    * Only a subset of the attributes are supported:
1269         - 'First, 'Last, and 'Length  on array objects (not on types
1270           and subtypes).
1272         - 'Min and 'Max.
1274         - 'Pos and 'Val.
1276         - 'Tag.
1278         - 'Range on array objects (not subtypes), but only as the right
1279           operand of the membership (`in') operator.
1281         - 'Access, 'Unchecked_Access, and 'Unrestricted_Access (a GNAT
1282           extension).
1284         - 'Address.
1286    * The names in `Characters.Latin_1' are not available and
1287      concatenation is not implemented.  Thus, escape characters in
1288      strings are not currently available.
1290    * Equality tests (`=' and `/=') on arrays test for bitwise equality
1291      of representations.  They will generally work correctly for
1292      strings and arrays whose elements have integer or enumeration
1293      types.  They may not work correctly for arrays whose element types
1294      have user-defined equality, for arrays of real values (in
1295      particular, IEEE-conformant floating point, because of negative
1296      zeroes and NaNs), and for arrays whose elements contain unused
1297      bits with indeterminate values.
1299    * The other component-by-component array operations (`and', `or',
1300      `xor', `not', and relational tests other than equality) are not
1301      implemented.
1303    * There is limited support for array and record aggregates.  They are
1304      permitted only on the right sides of assignments, as in these
1305      examples:
1307           set An_Array := (1, 2, 3, 4, 5, 6)
1308           set An_Array := (1, others => 0)
1309           set An_Array := (0|4 => 1, 1..3 => 2, 5 => 6)
1310           set A_2D_Array := ((1, 2, 3), (4, 5, 6), (7, 8, 9))
1311           set A_Record := (1, "Peter", True);
1312           set A_Record := (Name => "Peter", Id => 1, Alive => True)
1314      Changing a discriminant's value by assigning an aggregate has an
1315      undefined effect if that discriminant is used within the record.
1316      However, you can first modify discriminants by directly assigning
1317      to them (which normally would not be allowed in Ada), and then
1318      performing an aggregate assignment.  For example, given a variable
1319      `A_Rec' declared to have a type such as:
1321           type Rec (Len : Small_Integer := 0) is record
1322               Id : Integer;
1323               Vals : IntArray (1 .. Len);
1324           end record;
1326      you can assign a value with a different size of `Vals' with two
1327      assignments:
1329           set A_Rec.Len := 4
1330           set A_Rec := (Id => 42, Vals => (1, 2, 3, 4))
1332      As this example also illustrates, GDB is very loose about the usual
1333      rules concerning aggregates.  You may leave out some of the
1334      components of an array or record aggregate (such as the `Len'
1335      component in the assignment to `A_Rec' above); they will retain
1336      their original values upon assignment.  You may freely use dynamic
1337      values as indices in component associations.  You may even use
1338      overlapping or redundant component associations, although which
1339      component values are assigned in such cases is not defined.
1341    * Calls to dispatching subprograms are not implemented.
1343    * The overloading algorithm is much more limited (i.e., less
1344      selective) than that of real Ada.  It makes only limited use of
1345      the context in which a subexpression appears to resolve its
1346      meaning, and it is much looser in its rules for allowing type
1347      matches.  As a result, some function calls will be ambiguous, and
1348      the user will be asked to choose the proper resolution.
1350    * The `new' operator is not implemented.
1352    * Entry calls are not implemented.
1354    * Aside from printing, arithmetic operations on the native VAX
1355      floating-point formats are not supported.
1357    * It is not possible to slice a packed array.
1359 \x1f
1360 File: gdb.info,  Node: Additions to Ada,  Next: Stopping Before Main Program,  Prev: Omissions from Ada,  Up: Ada
1362 12.4.6.3 Additions to Ada
1363 .........................
1365 As it does for other languages, GDB makes certain generic extensions to
1366 Ada (*note Expressions::):
1368    * If the expression E is a variable residing in memory (typically a
1369      local variable or array element) and N is a positive integer, then
1370      `E@N' displays the values of E and the N-1 adjacent variables
1371      following it in memory as an array.  In Ada, this operator is
1372      generally not necessary, since its prime use is in displaying
1373      parts of an array, and slicing will usually do this in Ada.
1374      However, there are occasional uses when debugging programs in
1375      which certain debugging information has been optimized away.
1377    * `B::VAR' means "the variable named VAR that appears in function or
1378      file B."  When B is a file name, you must typically surround it in
1379      single quotes.
1381    * The expression `{TYPE} ADDR' means "the variable of type TYPE that
1382      appears at address ADDR."
1384    * A name starting with `$' is a convenience variable (*note
1385      Convenience Vars::) or a machine register (*note Registers::).
1387    In addition, GDB provides a few other shortcuts and outright
1388 additions specific to Ada:
1390    * The assignment statement is allowed as an expression, returning
1391      its right-hand operand as its value.  Thus, you may enter
1393           set x := y + 3
1394           print A(tmp := y + 1)
1396    * The semicolon is allowed as an "operator,"  returning as its value
1397      the value of its right-hand operand.  This allows, for example,
1398      complex conditional breaks:
1400           break f
1401           condition 1 (report(i); k += 1; A(k) > 100)
1403    * Rather than use catenation and symbolic character names to
1404      introduce special characters into strings, one may instead use a
1405      special bracket notation, which is also used to print strings.  A
1406      sequence of characters of the form `["XX"]' within a string or
1407      character literal denotes the (single) character whose numeric
1408      encoding is XX in hexadecimal.  The sequence of characters `["""]'
1409      also denotes a single quotation mark in strings.   For example,
1410              "One line.["0a"]Next line.["0a"]"
1411      contains an ASCII newline character (`Ada.Characters.Latin_1.LF')
1412      after each period.
1414    * The subtype used as a prefix for the attributes 'Pos, 'Min, and
1415      'Max is optional (and is ignored in any case).  For example, it is
1416      valid to write
1418           print 'max(x, y)
1420    * When printing arrays, GDB uses positional notation when the array
1421      has a lower bound of 1, and uses a modified named notation
1422      otherwise.  For example, a one-dimensional array of three integers
1423      with a lower bound of 3 might print as
1425           (3 => 10, 17, 1)
1427      That is, in contrast to valid Ada, only the first component has a
1428      `=>' clause.
1430    * You may abbreviate attributes in expressions with any unique,
1431      multi-character subsequence of their names (an exact match gets
1432      preference).  For example, you may use a'len, a'gth, or a'lh in
1433      place of  a'length.
1435    * Since Ada is case-insensitive, the debugger normally maps
1436      identifiers you type to lower case.  The GNAT compiler uses
1437      upper-case characters for some of its internal identifiers, which
1438      are normally of no interest to users.  For the rare occasions when
1439      you actually have to look at them, enclose them in angle brackets
1440      to avoid the lower-case mapping.  For example,
1441           gdb print <JMPBUF_SAVE>[0]
1443    * Printing an object of class-wide type or dereferencing an
1444      access-to-class-wide value will display all the components of the
1445      object's specific type (as indicated by its run-time tag).
1446      Likewise, component selection on such a value will operate on the
1447      specific type of the object.
1450 \x1f
1451 File: gdb.info,  Node: Stopping Before Main Program,  Next: Ada Glitches,  Prev: Additions to Ada,  Up: Ada
1453 12.4.6.4 Stopping at the Very Beginning
1454 .......................................
1456 It is sometimes necessary to debug the program during elaboration, and
1457 before reaching the main procedure.  As defined in the Ada Reference
1458 Manual, the elaboration code is invoked from a procedure called
1459 `adainit'.  To run your program up to the beginning of elaboration,
1460 simply use the following two commands: `tbreak adainit' and `run'.
1462 \x1f
1463 File: gdb.info,  Node: Ada Glitches,  Prev: Stopping Before Main Program,  Up: Ada
1465 12.4.6.5 Known Peculiarities of Ada Mode
1466 ........................................
1468 Besides the omissions listed previously (*note Omissions from Ada::),
1469 we know of several problems with and limitations of Ada mode in GDB,
1470 some of which will be fixed with planned future releases of the debugger
1471 and the GNU Ada compiler.
1473    * Currently, the debugger has insufficient information to determine
1474      whether certain pointers represent pointers to objects or the
1475      objects themselves.  Thus, the user may have to tack an extra
1476      `.all' after an expression to get it printed properly.
1478    * Static constants that the compiler chooses not to materialize as
1479      objects in storage are invisible to the debugger.
1481    * Named parameter associations in function argument lists are
1482      ignored (the argument lists are treated as positional).
1484    * Many useful library packages are currently invisible to the
1485      debugger.
1487    * Fixed-point arithmetic, conversions, input, and output is carried
1488      out using floating-point arithmetic, and may give results that
1489      only approximate those on the host machine.
1491    * The type of the 'Address attribute may not be `System.Address'.
1493    * The GNAT compiler never generates the prefix `Standard' for any of
1494      the standard symbols defined by the Ada language.  GDB knows about
1495      this: it will strip the prefix from names when you use it, and
1496      will never look for a name you have so qualified among local
1497      symbols, nor match against symbols in other packages or
1498      subprograms.  If you have defined entities anywhere in your
1499      program other than parameters and local variables whose simple
1500      names match names in `Standard', GNAT's lack of qualification here
1501      can cause confusion.  When this happens, you can usually resolve
1502      the confusion by qualifying the problematic names with package
1503      `Standard' explicitly.
1505 \x1f
1506 File: gdb.info,  Node: Unsupported languages,  Prev: Supported languages,  Up: Languages
1508 12.5 Unsupported languages
1509 ==========================
1511 In addition to the other fully-supported programming languages, GDB
1512 also provides a pseudo-language, called `minimal'.  It does not
1513 represent a real programming language, but provides a set of
1514 capabilities close to what the C or assembly languages provide.  This
1515 should allow most simple operations to be performed while debugging an
1516 application that uses a language currently not supported by GDB.
1518    If the language is set to `auto', GDB will automatically select this
1519 language if the current frame corresponds to an unsupported language.
1521 \x1f
1522 File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Languages,  Up: Top
1524 13 Examining the Symbol Table
1525 *****************************
1527 The commands described in this chapter allow you to inquire about the
1528 symbols (names of variables, functions and types) defined in your
1529 program.  This information is inherent in the text of your program and
1530 does not change as your program executes.  GDB finds it in your
1531 program's symbol table, in the file indicated when you started GDB
1532 (*note Choosing files: File Options.), or by one of the file-management
1533 commands (*note Commands to specify files: Files.).
1535    Occasionally, you may need to refer to symbols that contain unusual
1536 characters, which GDB ordinarily treats as word delimiters.  The most
1537 frequent case is in referring to static variables in other source files
1538 (*note Program variables: Variables.).  File names are recorded in
1539 object files as debugging symbols, but GDB would ordinarily parse a
1540 typical file name, like `foo.c', as the three words `foo' `.' `c'.  To
1541 allow GDB to recognize `foo.c' as a single symbol, enclose it in single
1542 quotes; for example,
1544      p 'foo.c'::x
1546 looks up the value of `x' in the scope of the file `foo.c'.
1548 `set case-sensitive on'
1549 `set case-sensitive off'
1550 `set case-sensitive auto'
1551      Normally, when GDB looks up symbols, it matches their names with
1552      case sensitivity determined by the current source language.
1553      Occasionally, you may wish to control that.  The command `set
1554      case-sensitive' lets you do that by specifying `on' for
1555      case-sensitive matches or `off' for case-insensitive ones.  If you
1556      specify `auto', case sensitivity is reset to the default suitable
1557      for the source language.  The default is case-sensitive matches
1558      for all languages except for Fortran, for which the default is
1559      case-insensitive matches.
1561 `show case-sensitive'
1562      This command shows the current setting of case sensitivity for
1563      symbols lookups.
1565 `info address SYMBOL'
1566      Describe where the data for SYMBOL is stored.  For a register
1567      variable, this says which register it is kept in.  For a
1568      non-register local variable, this prints the stack-frame offset at
1569      which the variable is always stored.
1571      Note the contrast with `print &SYMBOL', which does not work at all
1572      for a register variable, and for a stack local variable prints the
1573      exact address of the current instantiation of the variable.
1575 `info symbol ADDR'
1576      Print the name of a symbol which is stored at the address ADDR.
1577      If no symbol is stored exactly at ADDR, GDB prints the nearest
1578      symbol and an offset from it:
1580           (gdb) info symbol 0x54320
1581           _initialize_vx + 396 in section .text
1583      This is the opposite of the `info address' command.  You can use
1584      it to find out the name of a variable or a function given its
1585      address.
1587 `whatis [ARG]'
1588      Print the data type of ARG, which can be either an expression or a
1589      data type.  With no argument, print the data type of `$', the last
1590      value in the value history.  If ARG is an expression, it is not
1591      actually evaluated, and any side-effecting operations (such as
1592      assignments or function calls) inside it do not take place.  If
1593      ARG is a type name, it may be the name of a type or typedef, or
1594      for C code it may have the form `class CLASS-NAME', `struct
1595      STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.  *Note
1596      Expressions: Expressions.
1598 `ptype [ARG]'
1599      `ptype' accepts the same arguments as `whatis', but prints a
1600      detailed description of the type, instead of just the name of the
1601      type.  *Note Expressions: Expressions.
1603      For example, for this variable declaration:
1605           struct complex {double real; double imag;} v;
1607      the two commands give this output:
1609           (gdb) whatis v
1610           type = struct complex
1611           (gdb) ptype v
1612           type = struct complex {
1613               double real;
1614               double imag;
1615           }
1617      As with `whatis', using `ptype' without an argument refers to the
1618      type of `$', the last value in the value history.
1620      Sometimes, programs use opaque data types or incomplete
1621      specifications of complex data structure.  If the debug
1622      information included in the program does not allow GDB to display
1623      a full declaration of the data type, it will say `<incomplete
1624      type>'.  For example, given these declarations:
1626               struct foo;
1627               struct foo *fooptr;
1629      but no definition for `struct foo' itself, GDB will say:
1631             (gdb) ptype foo
1632             $1 = <incomplete type>
1634      "Incomplete type" is C terminology for data types that are not
1635      completely specified.
1637 `info types REGEXP'
1638 `info types'
1639      Print a brief description of all types whose names match the
1640      regular expression REGEXP (or all types in your program, if you
1641      supply no argument).  Each complete typename is matched as though
1642      it were a complete line; thus, `i type value' gives information on
1643      all types in your program whose names include the string `value',
1644      but `i type ^value$' gives information only on types whose complete
1645      name is `value'.
1647      This command differs from `ptype' in two ways: first, like
1648      `whatis', it does not print a detailed description; second, it
1649      lists all source files where a type is defined.
1651 `info scope LOCATION'
1652      List all the variables local to a particular scope.  This command
1653      accepts a LOCATION argument--a function name, a source line, or an
1654      address preceded by a `*', and prints all the variables local to
1655      the scope defined by that location.  For example:
1657           (gdb) info scope command_line_handler
1658           Scope for command_line_handler:
1659           Symbol rl is an argument at stack/frame offset 8, length 4.
1660           Symbol linebuffer is in static storage at address 0x150a18, length 4.
1661           Symbol linelength is in static storage at address 0x150a1c, length 4.
1662           Symbol p is a local variable in register $esi, length 4.
1663           Symbol p1 is a local variable in register $ebx, length 4.
1664           Symbol nline is a local variable in register $edx, length 4.
1665           Symbol repeat is a local variable at frame offset -8, length 4.
1667      This command is especially useful for determining what data to
1668      collect during a "trace experiment", see *Note collect: Tracepoint
1669      Actions.
1671 `info source'
1672      Show information about the current source file--that is, the
1673      source file for the function containing the current point of
1674      execution:
1675         * the name of the source file, and the directory containing it,
1677         * the directory it was compiled in,
1679         * its length, in lines,
1681         * which programming language it is written in,
1683         * whether the executable includes debugging information for
1684           that file, and if so, what format the information is in
1685           (e.g., STABS, Dwarf 2, etc.), and
1687         * whether the debugging information includes information about
1688           preprocessor macros.
1690 `info sources'
1691      Print the names of all source files in your program for which
1692      there is debugging information, organized into two lists: files
1693      whose symbols have already been read, and files whose symbols will
1694      be read when needed.
1696 `info functions'
1697      Print the names and data types of all defined functions.
1699 `info functions REGEXP'
1700      Print the names and data types of all defined functions whose
1701      names contain a match for regular expression REGEXP.  Thus, `info
1702      fun step' finds all functions whose names include `step'; `info
1703      fun ^step' finds those whose names start with `step'.  If a
1704      function name contains characters that conflict with the regular
1705      expression language (e.g.  `operator*()'), they may be quoted with
1706      a backslash.
1708 `info variables'
1709      Print the names and data types of all variables that are declared
1710      outside of functions (i.e. excluding local variables).
1712 `info variables REGEXP'
1713      Print the names and data types of all variables (except for local
1714      variables) whose names contain a match for regular expression
1715      REGEXP.
1717 `info classes'
1718 `info classes REGEXP'
1719      Display all Objective-C classes in your program, or (with the
1720      REGEXP argument) all those matching a particular regular
1721      expression.
1723 `info selectors'
1724 `info selectors REGEXP'
1725      Display all Objective-C selectors in your program, or (with the
1726      REGEXP argument) all those matching a particular regular
1727      expression.
1729      Some systems allow individual object files that make up your
1730      program to be replaced without stopping and restarting your
1731      program.  For example, in VxWorks you can simply recompile a
1732      defective object file and keep on running.  If you are running on
1733      one of these systems, you can allow GDB to reload the symbols for
1734      automatically relinked modules:
1736     `set symbol-reloading on'
1737           Replace symbol definitions for the corresponding source file
1738           when an object file with a particular name is seen again.
1740     `set symbol-reloading off'
1741           Do not replace symbol definitions when encountering object
1742           files of the same name more than once.  This is the default
1743           state; if you are not running on a system that permits
1744           automatic relinking of modules, you should leave
1745           `symbol-reloading' off, since otherwise GDB may discard
1746           symbols when linking large programs, that may contain several
1747           modules (from different directories or libraries) with the
1748           same name.
1750     `show symbol-reloading'
1751           Show the current `on' or `off' setting.
1753 `set opaque-type-resolution on'
1754      Tell GDB to resolve opaque types.  An opaque type is a type
1755      declared as a pointer to a `struct', `class', or `union'--for
1756      example, `struct MyType *'--that is used in one source file
1757      although the full declaration of `struct MyType' is in another
1758      source file.  The default is on.
1760      A change in the setting of this subcommand will not take effect
1761      until the next time symbols for a file are loaded.
1763 `set opaque-type-resolution off'
1764      Tell GDB not to resolve opaque types.  In this case, the type is
1765      printed as follows:
1766           {<no data fields>}
1768 `show opaque-type-resolution'
1769      Show whether opaque types are resolved or not.
1771 `maint print symbols FILENAME'
1772 `maint print psymbols FILENAME'
1773 `maint print msymbols FILENAME'
1774      Write a dump of debugging symbol data into the file FILENAME.
1775      These commands are used to debug the GDB symbol-reading code.  Only
1776      symbols with debugging data are included.  If you use `maint print
1777      symbols', GDB includes all the symbols for which it has already
1778      collected full details: that is, FILENAME reflects symbols for
1779      only those files whose symbols GDB has read.  You can use the
1780      command `info sources' to find out which files these are.  If you
1781      use `maint print psymbols' instead, the dump shows information
1782      about symbols that GDB only knows partially--that is, symbols
1783      defined in files that GDB has skimmed, but not yet read
1784      completely.  Finally, `maint print msymbols' dumps just the
1785      minimal symbol information required for each object file from
1786      which GDB has read some symbols.  *Note Commands to specify files:
1787      Files, for a discussion of how GDB reads symbols (in the
1788      description of `symbol-file').
1790 `maint info symtabs [ REGEXP ]'
1791 `maint info psymtabs [ REGEXP ]'
1792      List the `struct symtab' or `struct partial_symtab' structures
1793      whose names match REGEXP.  If REGEXP is not given, list them all.
1794      The output includes expressions which you can copy into a GDB
1795      debugging this one to examine a particular structure in more
1796      detail.  For example:
1798           (gdb) maint info psymtabs dwarf2read
1799           { objfile /home/gnu/build/gdb/gdb
1800             ((struct objfile *) 0x82e69d0)
1801             { psymtab /home/gnu/src/gdb/dwarf2read.c
1802               ((struct partial_symtab *) 0x8474b10)
1803               readin no
1804               fullname (null)
1805               text addresses 0x814d3c8 -- 0x8158074
1806               globals (* (struct partial_symbol **) 0x8507a08 @ 9)
1807               statics (* (struct partial_symbol **) 0x40e95b78 @ 2882)
1808               dependencies (none)
1809             }
1810           }
1811           (gdb) maint info symtabs
1812           (gdb)
1813      We see that there is one partial symbol table whose filename
1814      contains the string `dwarf2read', belonging to the `gdb'
1815      executable; and we see that GDB has not read in any symtabs yet at
1816      all.  If we set a breakpoint on a function, that will cause GDB to
1817      read the symtab for the compilation unit containing that function:
1819           (gdb) break dwarf2_psymtab_to_symtab
1820           Breakpoint 1 at 0x814e5da: file /home/gnu/src/gdb/dwarf2read.c,
1821           line 1574.
1822           (gdb) maint info symtabs
1823           { objfile /home/gnu/build/gdb/gdb
1824             ((struct objfile *) 0x82e69d0)
1825             { symtab /home/gnu/src/gdb/dwarf2read.c
1826               ((struct symtab *) 0x86c1f38)
1827               dirname (null)
1828               fullname (null)
1829               blockvector ((struct blockvector *) 0x86c1bd0) (primary)
1830               debugformat DWARF 2
1831             }
1832           }
1833           (gdb)
1835 \x1f
1836 File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
1838 14 Altering Execution
1839 *********************
1841 Once you think you have found an error in your program, you might want
1842 to find out for certain whether correcting the apparent error would
1843 lead to correct results in the rest of the run.  You can find the
1844 answer by experiment, using the GDB features for altering execution of
1845 the program.
1847    For example, you can store new values into variables or memory
1848 locations, give your program a signal, restart it at a different
1849 address, or even return prematurely from a function.
1851 * Menu:
1853 * Assignment::                  Assignment to variables
1854 * Jumping::                     Continuing at a different address
1855 * Signaling::                   Giving your program a signal
1856 * Returning::                   Returning from a function
1857 * Calling::                     Calling your program's functions
1858 * Patching::                    Patching your program
1860 \x1f
1861 File: gdb.info,  Node: Assignment,  Next: Jumping,  Up: Altering
1863 14.1 Assignment to variables
1864 ============================
1866 To alter the value of a variable, evaluate an assignment expression.
1867 *Note Expressions: Expressions.  For example,
1869      print x=4
1871 stores the value 4 into the variable `x', and then prints the value of
1872 the assignment expression (which is 4).  *Note Using GDB with Different
1873 Languages: Languages, for more information on operators in supported
1874 languages.
1876    If you are not interested in seeing the value of the assignment, use
1877 the `set' command instead of the `print' command.  `set' is really the
1878 same as `print' except that the expression's value is not printed and
1879 is not put in the value history (*note Value history: Value History.).
1880 The expression is evaluated only for its effects.
1882    If the beginning of the argument string of the `set' command appears
1883 identical to a `set' subcommand, use the `set variable' command instead
1884 of just `set'.  This command is identical to `set' except for its lack
1885 of subcommands.  For example, if your program has a variable `width',
1886 you get an error if you try to set a new value with just `set
1887 width=13', because GDB has the command `set width':
1889      (gdb) whatis width
1890      type = double
1891      (gdb) p width
1892      $4 = 13
1893      (gdb) set width=47
1894      Invalid syntax in expression.
1896 The invalid expression, of course, is `=47'.  In order to actually set
1897 the program's variable `width', use
1899      (gdb) set var width=47
1901    Because the `set' command has many subcommands that can conflict
1902 with the names of program variables, it is a good idea to use the `set
1903 variable' command instead of just `set'.  For example, if your program
1904 has a variable `g', you run into problems if you try to set a new value
1905 with just `set g=4', because GDB has the command `set gnutarget',
1906 abbreviated `set g':
1908      (gdb) whatis g
1909      type = double
1910      (gdb) p g
1911      $1 = 1
1912      (gdb) set g=4
1913      (gdb) p g
1914      $2 = 1
1915      (gdb) r
1916      The program being debugged has been started already.
1917      Start it from the beginning? (y or n) y
1918      Starting program: /home/smith/cc_progs/a.out
1919      "/home/smith/cc_progs/a.out": can't open to read symbols:
1920                                       Invalid bfd target.
1921      (gdb) show g
1922      The current BFD target is "=4".
1924 The program variable `g' did not change, and you silently set the
1925 `gnutarget' to an invalid value.  In order to set the variable `g', use
1927      (gdb) set var g=4
1929    GDB allows more implicit conversions in assignments than C; you can
1930 freely store an integer value into a pointer variable or vice versa,
1931 and you can convert any structure to any other structure that is the
1932 same length or shorter.
1934    To store values into arbitrary places in memory, use the `{...}'
1935 construct to generate a value of specified type at a specified address
1936 (*note Expressions: Expressions.).  For example, `{int}0x83040' refers
1937 to memory location `0x83040' as an integer (which implies a certain size
1938 and representation in memory), and
1940      set {int}0x83040 = 4
1942 stores the value 4 into that memory location.
1944 \x1f
1945 File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
1947 14.2 Continuing at a different address
1948 ======================================
1950 Ordinarily, when you continue your program, you do so at the place where
1951 it stopped, with the `continue' command.  You can instead continue at
1952 an address of your own choosing, with the following commands:
1954 `jump LINESPEC'
1955      Resume execution at line LINESPEC.  Execution stops again
1956      immediately if there is a breakpoint there.  *Note Printing source
1957      lines: List, for a description of the different forms of LINESPEC.
1958      It is common practice to use the `tbreak' command in conjunction
1959      with `jump'.  *Note Setting breakpoints: Set Breaks.
1961      The `jump' command does not change the current stack frame, or the
1962      stack pointer, or the contents of any memory location or any
1963      register other than the program counter.  If line LINESPEC is in a
1964      different function from the one currently executing, the results
1965      may be bizarre if the two functions expect different patterns of
1966      arguments or of local variables.  For this reason, the `jump'
1967      command requests confirmation if the specified line is not in the
1968      function currently executing.  However, even bizarre results are
1969      predictable if you are well acquainted with the machine-language
1970      code of your program.
1972 `jump *ADDRESS'
1973      Resume execution at the instruction at address ADDRESS.
1975    On many systems, you can get much the same effect as the `jump'
1976 command by storing a new value into the register `$pc'.  The difference
1977 is that this does not start your program running; it only changes the
1978 address of where it _will_ run when you continue.  For example,
1980      set $pc = 0x485
1982 makes the next `continue' command or stepping command execute at
1983 address `0x485', rather than at the address where your program stopped.
1984 *Note Continuing and stepping: Continuing and Stepping.
1986    The most common occasion to use the `jump' command is to back
1987 up--perhaps with more breakpoints set--over a portion of a program that
1988 has already executed, in order to examine its execution in more detail.
1990 \x1f
1991 File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
1993 14.3 Giving your program a signal
1994 =================================
1996 `signal SIGNAL'
1997      Resume execution where your program stopped, but immediately give
1998      it the signal SIGNAL.  SIGNAL can be the name or the number of a
1999      signal.  For example, on many systems `signal 2' and `signal
2000      SIGINT' are both ways of sending an interrupt signal.
2002      Alternatively, if SIGNAL is zero, continue execution without
2003      giving a signal.  This is useful when your program stopped on
2004      account of a signal and would ordinary see the signal when resumed
2005      with the `continue' command; `signal 0' causes it to resume
2006      without a signal.
2008      `signal' does not repeat when you press <RET> a second time after
2009      executing the command.
2011    Invoking the `signal' command is not the same as invoking the `kill'
2012 utility from the shell.  Sending a signal with `kill' causes GDB to
2013 decide what to do with the signal depending on the signal handling
2014 tables (*note Signals::).  The `signal' command passes the signal
2015 directly to your program.
2017 \x1f
2018 File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
2020 14.4 Returning from a function
2021 ==============================
2023 `return'
2024 `return EXPRESSION'
2025      You can cancel execution of a function call with the `return'
2026      command.  If you give an EXPRESSION argument, its value is used as
2027      the function's return value.
2029    When you use `return', GDB discards the selected stack frame (and
2030 all frames within it).  You can think of this as making the discarded
2031 frame return prematurely.  If you wish to specify a value to be
2032 returned, give that value as the argument to `return'.
2034    This pops the selected stack frame (*note Selecting a frame:
2035 Selection.), and any other frames inside of it, leaving its caller as
2036 the innermost remaining frame.  That frame becomes selected.  The
2037 specified value is stored in the registers used for returning values of
2038 functions.
2040    The `return' command does not resume execution; it leaves the
2041 program stopped in the state that would exist if the function had just
2042 returned.  In contrast, the `finish' command (*note Continuing and
2043 stepping: Continuing and Stepping.) resumes execution until the
2044 selected stack frame returns naturally.
2046 \x1f
2047 File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
2049 14.5 Calling program functions
2050 ==============================
2052 `print EXPR'
2053      Evaluate the expression EXPR and display the resuling value.  EXPR
2054      may include calls to functions in the program being debugged.
2056 `call EXPR'
2057      Evaluate the expression EXPR without displaying `void' returned
2058      values.
2060      You can use this variant of the `print' command if you want to
2061      execute a function from your program that does not return anything
2062      (a.k.a. "a void function"), but without cluttering the output with
2063      `void' returned values that GDB will otherwise print.  If the
2064      result is not void, it is printed and saved in the value history.
2066    It is possible for the function you call via the `print' or `call'
2067 command to generate a signal (e.g., if there's a bug in the function,
2068 or if you passed it incorrect arguments).  What happens in that case is
2069 controlled by the `set unwindonsignal' command.
2071 `set unwindonsignal'
2072      Set unwinding of the stack if a signal is received while in a
2073      function that GDB called in the program being debugged.  If set to
2074      on, GDB unwinds the stack it created for the call and restores the
2075      context to what it was before the call.  If set to off (the
2076      default), GDB stops in the frame where the signal was received.
2078 `show unwindonsignal'
2079      Show the current setting of stack unwinding in the functions
2080      called by GDB.
2082    Sometimes, a function you wish to call is actually a "weak alias"
2083 for another function.  In such case, GDB might not pick up the type
2084 information, including the types of the function arguments, which
2085 causes GDB to call the inferior function incorrectly.  As a result, the
2086 called function will function erroneously and may even crash.  A
2087 solution to that is to use the name of the aliased function instead.
2089 \x1f
2090 File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
2092 14.6 Patching programs
2093 ======================
2095 By default, GDB opens the file containing your program's executable
2096 code (or the corefile) read-only.  This prevents accidental alterations
2097 to machine code; but it also prevents you from intentionally patching
2098 your program's binary.
2100    If you'd like to be able to patch the binary, you can specify that
2101 explicitly with the `set write' command.  For example, you might want
2102 to turn on internal debugging flags, or even to make emergency repairs.
2104 `set write on'
2105 `set write off'
2106      If you specify `set write on', GDB opens executable and core files
2107      for both reading and writing; if you specify `set write off' (the
2108      default), GDB opens them read-only.
2110      If you have already loaded a file, you must load it again (using
2111      the `exec-file' or `core-file' command) after changing `set
2112      write', for your new setting to take effect.
2114 `show write'
2115      Display whether executable files and core files are opened for
2116      writing as well as reading.
2118 \x1f
2119 File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
2121 15 GDB Files
2122 ************
2124 GDB needs to know the file name of the program to be debugged, both in
2125 order to read its symbol table and in order to start your program.  To
2126 debug a core dump of a previous run, you must also tell GDB the name of
2127 the core dump file.
2129 * Menu:
2131 * Files::                       Commands to specify files
2132 * Separate Debug Files::        Debugging information in separate files
2133 * Symbol Errors::               Errors reading symbol files
2135 \x1f
2136 File: gdb.info,  Node: Files,  Next: Separate Debug Files,  Up: GDB Files
2138 15.1 Commands to specify files
2139 ==============================
2141 You may want to specify executable and core dump file names.  The usual
2142 way to do this is at start-up time, using the arguments to GDB's
2143 start-up commands (*note Getting In and Out of GDB: Invocation.).
2145    Occasionally it is necessary to change to a different file during a
2146 GDB session.  Or you may run GDB and forget to specify a file you want
2147 to use.  Or you are debugging a remote target via `gdbserver' (*note
2148 file: Server.).  In these situations the GDB commands to specify new
2149 files are useful.
2151 `file FILENAME'
2152      Use FILENAME as the program to be debugged.  It is read for its
2153      symbols and for the contents of pure memory.  It is also the
2154      program executed when you use the `run' command.  If you do not
2155      specify a directory and the file is not found in the GDB working
2156      directory, GDB uses the environment variable `PATH' as a list of
2157      directories to search, just as the shell does when looking for a
2158      program to run.  You can change the value of this variable, for
2159      both GDB and your program, using the `path' command.
2161      You can load unlinked object `.o' files into GDB using the `file'
2162      command.  You will not be able to "run" an object file, but you
2163      can disassemble functions and inspect variables.  Also, if the
2164      underlying BFD functionality supports it, you could use `gdb
2165      -write' to patch object files using this technique.  Note that GDB
2166      can neither interpret nor modify relocations in this case, so
2167      branches and some initialized variables will appear to go to the
2168      wrong place.  But this feature is still handy from time to time.
2170 `file'
2171      `file' with no argument makes GDB discard any information it has
2172      on both executable file and the symbol table.
2174 `exec-file [ FILENAME ]'
2175      Specify that the program to be run (but not the symbol table) is
2176      found in FILENAME.  GDB searches the environment variable `PATH'
2177      if necessary to locate your program.  Omitting FILENAME means to
2178      discard information on the executable file.
2180 `symbol-file [ FILENAME ]'
2181      Read symbol table information from file FILENAME.  `PATH' is
2182      searched when necessary.  Use the `file' command to get both symbol
2183      table and program to run from the same file.
2185      `symbol-file' with no argument clears out GDB information on your
2186      program's symbol table.
2188      The `symbol-file' command causes GDB to forget the contents of
2189      some breakpoints and auto-display expressions.  This is because
2190      they may contain pointers to the internal data recording symbols
2191      and data types, which are part of the old symbol table data being
2192      discarded inside GDB.
2194      `symbol-file' does not repeat if you press <RET> again after
2195      executing it once.
2197      When GDB is configured for a particular environment, it
2198      understands debugging information in whatever format is the
2199      standard generated for that environment; you may use either a GNU
2200      compiler, or other compilers that adhere to the local conventions.
2201      Best results are usually obtained from GNU compilers; for example,
2202      using `gcc' you can generate debugging information for optimized
2203      code.
2205      For most kinds of object files, with the exception of old SVR3
2206      systems using COFF, the `symbol-file' command does not normally
2207      read the symbol table in full right away.  Instead, it scans the
2208      symbol table quickly to find which source files and which symbols
2209      are present.  The details are read later, one source file at a
2210      time, as they are needed.
2212      The purpose of this two-stage reading strategy is to make GDB
2213      start up faster.  For the most part, it is invisible except for
2214      occasional pauses while the symbol table details for a particular
2215      source file are being read.  (The `set verbose' command can turn
2216      these pauses into messages if desired.  *Note Optional warnings
2217      and messages: Messages/Warnings.)
2219      We have not implemented the two-stage strategy for COFF yet.  When
2220      the symbol table is stored in COFF format, `symbol-file' reads the
2221      symbol table data in full right away.  Note that "stabs-in-COFF"
2222      still does the two-stage strategy, since the debug info is actually
2223      in stabs format.
2225 `symbol-file FILENAME [ -readnow ]'
2226 `file FILENAME [ -readnow ]'
2227      You can override the GDB two-stage strategy for reading symbol
2228      tables by using the `-readnow' option with any of the commands that
2229      load symbol table information, if you want to be sure GDB has the
2230      entire symbol table available.
2232 `core-file [FILENAME]'
2233 `core'
2234      Specify the whereabouts of a core dump file to be used as the
2235      "contents of memory".  Traditionally, core files contain only some
2236      parts of the address space of the process that generated them; GDB
2237      can access the executable file itself for other parts.
2239      `core-file' with no argument specifies that no core file is to be
2240      used.
2242      Note that the core file is ignored when your program is actually
2243      running under GDB.  So, if you have been running your program and
2244      you wish to debug a core file instead, you must kill the
2245      subprocess in which the program is running.  To do this, use the
2246      `kill' command (*note Killing the child process: Kill Process.).
2248 `add-symbol-file FILENAME ADDRESS'
2249 `add-symbol-file FILENAME ADDRESS [ -readnow ]'
2250 `add-symbol-file FILENAME -sSECTION ADDRESS ...'
2251      The `add-symbol-file' command reads additional symbol table
2252      information from the file FILENAME.  You would use this command
2253      when FILENAME has been dynamically loaded (by some other means)
2254      into the program that is running.  ADDRESS should be the memory
2255      address at which the file has been loaded; GDB cannot figure this
2256      out for itself.  You can additionally specify an arbitrary number
2257      of `-sSECTION ADDRESS' pairs, to give an explicit section name and
2258      base address for that section.  You can specify any ADDRESS as an
2259      expression.
2261      The symbol table of the file FILENAME is added to the symbol table
2262      originally read with the `symbol-file' command.  You can use the
2263      `add-symbol-file' command any number of times; the new symbol data
2264      thus read keeps adding to the old.  To discard all old symbol data
2265      instead, use the `symbol-file' command without any arguments.
2267      Although FILENAME is typically a shared library file, an
2268      executable file, or some other object file which has been fully
2269      relocated for loading into a process, you can also load symbolic
2270      information from relocatable `.o' files, as long as:
2272         * the file's symbolic information refers only to linker symbols
2273           defined in that file, not to symbols defined by other object
2274           files,
2276         * every section the file's symbolic information refers to has
2277           actually been loaded into the inferior, as it appears in the
2278           file, and
2280         * you can determine the address at which every section was
2281           loaded, and provide these to the `add-symbol-file' command.
2283      Some embedded operating systems, like Sun Chorus and VxWorks, can
2284      load relocatable files into an already running program; such
2285      systems typically make the requirements above easy to meet.
2286      However, it's important to recognize that many native systems use
2287      complex link procedures (`.linkonce' section factoring and C++
2288      constructor table assembly, for example) that make the
2289      requirements difficult to meet.  In general, one cannot assume
2290      that using `add-symbol-file' to read a relocatable object file's
2291      symbolic information will have the same effect as linking the
2292      relocatable object file into the program in the normal way.
2294      `add-symbol-file' does not repeat if you press <RET> after using
2295      it.
2297 `add-symbol-file-from-memory ADDRESS'
2298      Load symbols from the given ADDRESS in a dynamically loaded object
2299      file whose image is mapped directly into the inferior's memory.
2300      For example, the Linux kernel maps a `syscall DSO' into each
2301      process's address space; this DSO provides kernel-specific code for
2302      some system calls.  The argument can be any expression whose
2303      evaluation yields the address of the file's shared object file
2304      header.  For this command to work, you must have used
2305      `symbol-file' or `exec-file' commands in advance.
2307 `add-shared-symbol-files LIBRARY-FILE'
2308 `assf LIBRARY-FILE'
2309      The `add-shared-symbol-files' command can currently be used only
2310      in the Cygwin build of GDB on MS-Windows OS, where it is an alias
2311      for the `dll-symbols' command (*note Cygwin Native::).  GDB
2312      automatically looks for shared libraries, however if GDB does not
2313      find yours, you can invoke `add-shared-symbol-files'.  It takes
2314      one argument: the shared library's file name.  `assf' is a
2315      shorthand alias for `add-shared-symbol-files'.
2317 `section SECTION ADDR'
2318      The `section' command changes the base address of the named
2319      SECTION of the exec file to ADDR.  This can be used if the exec
2320      file does not contain section addresses, (such as in the `a.out'
2321      format), or when the addresses specified in the file itself are
2322      wrong.  Each section must be changed separately.  The `info files'
2323      command, described below, lists all the sections and their
2324      addresses.
2326 `info files'
2327 `info target'
2328      `info files' and `info target' are synonymous; both print the
2329      current target (*note Specifying a Debugging Target: Targets.),
2330      including the names of the executable and core dump files
2331      currently in use by GDB, and the files from which symbols were
2332      loaded.  The command `help target' lists all possible targets
2333      rather than current ones.
2335 `maint info sections'
2336      Another command that can give you extra information about program
2337      sections is `maint info sections'.  In addition to the section
2338      information displayed by `info files', this command displays the
2339      flags and file offset of each section in the executable and core
2340      dump files.  In addition, `maint info sections' provides the
2341      following command options (which may be arbitrarily combined):
2343     `ALLOBJ'
2344           Display sections for all loaded object files, including
2345           shared libraries.
2347     `SECTIONS'
2348           Display info only for named SECTIONS.
2350     `SECTION-FLAGS'
2351           Display info only for sections for which SECTION-FLAGS are
2352           true.  The section flags that GDB currently knows about are:
2353          `ALLOC'
2354                Section will have space allocated in the process when
2355                loaded.  Set for all sections except those containing
2356                debug information.
2358          `LOAD'
2359                Section will be loaded from the file into the child
2360                process memory.  Set for pre-initialized code and data,
2361                clear for `.bss' sections.
2363          `RELOC'
2364                Section needs to be relocated before loading.
2366          `READONLY'
2367                Section cannot be modified by the child process.
2369          `CODE'
2370                Section contains executable code only.
2372          `DATA'
2373                Section contains data only (no executable code).
2375          `ROM'
2376                Section will reside in ROM.
2378          `CONSTRUCTOR'
2379                Section contains data for constructor/destructor lists.
2381          `HAS_CONTENTS'
2382                Section is not empty.
2384          `NEVER_LOAD'
2385                An instruction to the linker to not output the section.
2387          `COFF_SHARED_LIBRARY'
2388                A notification to the linker that the section contains
2389                COFF shared library information.
2391          `IS_COMMON'
2392                Section contains common symbols.
2393      
2394 `set trust-readonly-sections on'
2395      Tell GDB that readonly sections in your object file really are
2396      read-only (i.e. that their contents will not change).  In that
2397      case, GDB can fetch values from these sections out of the object
2398      file, rather than from the target program.  For some targets
2399      (notably embedded ones), this can be a significant enhancement to
2400      debugging performance.
2402      The default is off.
2404 `set trust-readonly-sections off'
2405      Tell GDB not to trust readonly sections.  This means that the
2406      contents of the section might change while the program is running,
2407      and must therefore be fetched from the target when needed.
2409 `show trust-readonly-sections'
2410      Show the current setting of trusting readonly sections.
2412    All file-specifying commands allow both absolute and relative file
2413 names as arguments.  GDB always converts the file name to an absolute
2414 file name and remembers it that way.
2416    GDB supports GNU/Linux, MS-Windows, HP-UX, SunOS, SVr4, Irix, and
2417 IBM RS/6000 AIX shared libraries.
2419    GDB automatically loads symbol definitions from shared libraries
2420 when you use the `run' command, or when you examine a core file.
2421 (Before you issue the `run' command, GDB does not understand references
2422 to a function in a shared library, however--unless you are debugging a
2423 core file).
2425    On HP-UX, if the program loads a library explicitly, GDB
2426 automatically loads the symbols at the time of the `shl_load' call.
2428    There are times, however, when you may wish to not automatically load
2429 symbol definitions from shared libraries, such as when they are
2430 particularly large or there are many of them.
2432    To control the automatic loading of shared library symbols, use the
2433 commands:
2435 `set auto-solib-add MODE'
2436      If MODE is `on', symbols from all shared object libraries will be
2437      loaded automatically when the inferior begins execution, you
2438      attach to an independently started inferior, or when the dynamic
2439      linker informs GDB that a new library has been loaded.  If MODE is
2440      `off', symbols must be loaded manually, using the `sharedlibrary'
2441      command.  The default value is `on'.
2443      If your program uses lots of shared libraries with debug info that
2444      takes large amounts of memory, you can decrease the GDB memory
2445      footprint by preventing it from automatically loading the symbols
2446      from shared libraries.  To that end, type `set auto-solib-add off'
2447      before running the inferior, then load each library whose debug
2448      symbols you do need with `sharedlibrary REGEXP', where REGEXP is a
2449      regular expresion that matches the libraries whose symbols you
2450      want to be loaded.
2452 `show auto-solib-add'
2453      Display the current autoloading mode.
2455    To explicitly load shared library symbols, use the `sharedlibrary'
2456 command:
2458 `info share'
2459 `info sharedlibrary'
2460      Print the names of the shared libraries which are currently loaded.
2462 `sharedlibrary REGEX'
2463 `share REGEX'
2464      Load shared object library symbols for files matching a Unix
2465      regular expression.  As with files loaded automatically, it only
2466      loads shared libraries required by your program for a core file or
2467      after typing `run'.  If REGEX is omitted all shared libraries
2468      required by your program are loaded.
2470 `nosharedlibrary'
2471      Unload all shared object library symbols.  This discards all
2472      symbols that have been loaded from all shared libraries.  Symbols
2473      from shared libraries that were loaded by explicit user requests
2474      are not discarded.
2476    Sometimes you may wish that GDB stops and gives you control when any
2477 of shared library events happen.  Use the `set stop-on-solib-events'
2478 command for this:
2480 `set stop-on-solib-events'
2481      This command controls whether GDB should give you control when the
2482      dynamic linker notifies it about some shared library event.  The
2483      most common event of interest is loading or unloading of a new
2484      shared library.
2486 `show stop-on-solib-events'
2487      Show whether GDB stops and gives you control when shared library
2488      events happen.
2490    Shared libraries are also supported in many cross or remote debugging
2491 configurations.  A copy of the target's libraries need to be present on
2492 the host system; they need to be the same as the target libraries,
2493 although the copies on the target can be stripped as long as the copies
2494 on the host are not.
2496    For remote debugging, you need to tell GDB where the target
2497 libraries are, so that it can load the correct copies--otherwise, it
2498 may try to load the host's libraries.  GDB has two variables to specify
2499 the search directories for target libraries.
2501 `set solib-absolute-prefix PATH'
2502      If this variable is set, PATH will be used as a prefix for any
2503      absolute shared library paths; many runtime loaders store the
2504      absolute paths to the shared library in the target program's
2505      memory.  If you use `solib-absolute-prefix' to find shared
2506      libraries, they need to be laid out in the same way that they are
2507      on the target, with e.g. a `/usr/lib' hierarchy under PATH.
2509      You can set the default value of `solib-absolute-prefix' by using
2510      the configure-time `--with-sysroot' option.
2512 `show solib-absolute-prefix'
2513      Display the current shared library prefix.
2515 `set solib-search-path PATH'
2516      If this variable is set, PATH is a colon-separated list of
2517      directories to search for shared libraries.  `solib-search-path'
2518      is used after `solib-absolute-prefix' fails to locate the library,
2519      or if the path to the library is relative instead of absolute.  If
2520      you want to use `solib-search-path' instead of
2521      `solib-absolute-prefix', be sure to set `solib-absolute-prefix' to
2522      a nonexistant directory to prevent GDB from finding your host's
2523      libraries.
2525 `show solib-search-path'
2526      Display the current shared library search path.
2528 \x1f
2529 File: gdb.info,  Node: Separate Debug Files,  Next: Symbol Errors,  Prev: Files,  Up: GDB Files
2531 15.2 Debugging Information in Separate Files
2532 ============================================
2534 GDB allows you to put a program's debugging information in a file
2535 separate from the executable itself, in a way that allows GDB to find
2536 and load the debugging information automatically.  Since debugging
2537 information can be very large -- sometimes larger than the executable
2538 code itself -- some systems distribute debugging information for their
2539 executables in separate files, which users can install only when they
2540 need to debug a problem.
2542    If an executable's debugging information has been extracted to a
2543 separate file, the executable should contain a "debug link" giving the
2544 name of the debugging information file (with no directory components),
2545 and a checksum of its contents.  (The exact form of a debug link is
2546 described below.)  If the full name of the directory containing the
2547 executable is EXECDIR, and the executable has a debug link that
2548 specifies the name DEBUGFILE, then GDB will automatically search for
2549 the debugging information file in three places:
2551    * the directory containing the executable file (that is, it will look
2552      for a file named `EXECDIR/DEBUGFILE',
2554    * a subdirectory of that directory named `.debug' (that is, the file
2555      `EXECDIR/.debug/DEBUGFILE', and
2557    * a subdirectory of the global debug file directory that includes the
2558      executable's full path, and the name from the link (that is, the
2559      file `GLOBALDEBUGDIR/EXECDIR/DEBUGFILE', where GLOBALDEBUGDIR is
2560      the global debug file directory, and EXECDIR has been turned into
2561      a relative path).
2562    GDB checks under each of these names for a debugging information
2563 file whose checksum matches that given in the link, and reads the
2564 debugging information from the first one it finds.
2566    So, for example, if you ask GDB to debug `/usr/bin/ls', which has a
2567 link containing the name `ls.debug', and the global debug directory is
2568 `/usr/lib/debug', then GDB will look for debug information in
2569 `/usr/bin/ls.debug', `/usr/bin/.debug/ls.debug', and
2570 `/usr/lib/debug/usr/bin/ls.debug'.
2572    You can set the global debugging info directory's name, and view the
2573 name GDB is currently using.
2575 `set debug-file-directory DIRECTORY'
2576      Set the directory which GDB searches for separate debugging
2577      information files to DIRECTORY.
2579 `show debug-file-directory'
2580      Show the directory GDB searches for separate debugging information
2581      files.
2584    A debug link is a special section of the executable file named
2585 `.gnu_debuglink'.  The section must contain:
2587    * A filename, with any leading directory components removed,
2588      followed by a zero byte,
2590    * zero to three bytes of padding, as needed to reach the next
2591      four-byte boundary within the section, and
2593    * a four-byte CRC checksum, stored in the same endianness used for
2594      the executable file itself.  The checksum is computed on the
2595      debugging information file's full contents by the function given
2596      below, passing zero as the CRC argument.
2598    Any executable file format can carry a debug link, as long as it can
2599 contain a section named `.gnu_debuglink' with the contents described
2600 above.
2602    The debugging information file itself should be an ordinary
2603 executable, containing a full set of linker symbols, sections, and
2604 debugging information.  The sections of the debugging information file
2605 should have the same names, addresses and sizes as the original file,
2606 but they need not contain any data -- much like a `.bss' section in an
2607 ordinary executable.
2609    As of December 2002, there is no standard GNU utility to produce
2610 separated executable / debugging information file pairs.  Ulrich
2611 Drepper's `elfutils' package, starting with version 0.53, contains a
2612 version of the `strip' command such that the command `strip foo -f
2613 foo.debug' removes the debugging information from the executable file
2614 `foo', places it in the file `foo.debug', and leaves behind a debug
2615 link in `foo'.
2617    Since there are many different ways to compute CRC's (different
2618 polynomials, reversals, byte ordering, etc.), the simplest way to
2619 describe the CRC used in `.gnu_debuglink' sections is to give the
2620 complete code for a function that computes it:
2622      unsigned long
2623      gnu_debuglink_crc32 (unsigned long crc,
2624                           unsigned char *buf, size_t len)
2625      {
2626        static const unsigned long crc32_table[256] =
2627          {
2628            0x00000000, 0x77073096, 0xee0e612c, 0x990951ba, 0x076dc419,
2629            0x706af48f, 0xe963a535, 0x9e6495a3, 0x0edb8832, 0x79dcb8a4,
2630            0xe0d5e91e, 0x97d2d988, 0x09b64c2b, 0x7eb17cbd, 0xe7b82d07,
2631            0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de,
2632            0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856,
2633            0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9,
2634            0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4,
2635            0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b,
2636            0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3,
2637            0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a,
2638            0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599,
2639            0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924,
2640            0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190,
2641            0x01db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x06b6b51f,
2642            0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0x0f00f934, 0x9609a88e,
2643            0xe10e9818, 0x7f6a0dbb, 0x086d3d2d, 0x91646c97, 0xe6635c01,
2644            0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed,
2645            0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950,
2646            0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3,
2647            0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2,
2648            0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a,
2649            0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5,
2650            0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010,
2651            0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f,
2652            0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17,
2653            0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6,
2654            0x03b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x04db2615,
2655            0x73dc1683, 0xe3630b12, 0x94643b84, 0x0d6d6a3e, 0x7a6a5aa8,
2656            0xe40ecf0b, 0x9309ff9d, 0x0a00ae27, 0x7d079eb1, 0xf00f9344,
2657            0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb,
2658            0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a,
2659            0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5,
2660            0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1,
2661            0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c,
2662            0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef,
2663            0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236,
2664            0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe,
2665            0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31,
2666            0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c,
2667            0x026d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x05005713,
2668            0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0x0cb61b38, 0x92d28e9b,
2669            0xe5d5be0d, 0x7cdcefb7, 0x0bdbdf21, 0x86d3d2d4, 0xf1d4e242,
2670            0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1,
2671            0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c,
2672            0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278,
2673            0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7,
2674            0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66,
2675            0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9,
2676            0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605,
2677            0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8,
2678            0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b,
2679            0x2d02ef8d
2680          };
2681        unsigned char *end;
2683        crc = ~crc & 0xffffffff;
2684        for (end = buf + len; buf < end; ++buf)
2685          crc = crc32_table[(crc ^ *buf) & 0xff] ^ (crc >> 8);
2686        return ~crc & 0xffffffff;
2687      }
2689 \x1f
2690 File: gdb.info,  Node: Symbol Errors,  Prev: Separate Debug Files,  Up: GDB Files
2692 15.3 Errors reading symbol files
2693 ================================
2695 While reading a symbol file, GDB occasionally encounters problems, such
2696 as symbol types it does not recognize, or known bugs in compiler
2697 output.  By default, GDB does not notify you of such problems, since
2698 they are relatively common and primarily of interest to people
2699 debugging compilers.  If you are interested in seeing information about
2700 ill-constructed symbol tables, you can either ask GDB to print only one
2701 message about each such type of problem, no matter how many times the
2702 problem occurs; or you can ask GDB to print more messages, to see how
2703 many times the problems occur, with the `set complaints' command (*note
2704 Optional warnings and messages: Messages/Warnings.).
2706    The messages currently printed, and their meanings, include:
2708 `inner block not inside outer block in SYMBOL'
2709      The symbol information shows where symbol scopes begin and end
2710      (such as at the start of a function or a block of statements).
2711      This error indicates that an inner scope block is not fully
2712      contained in its outer scope blocks.
2714      GDB circumvents the problem by treating the inner block as if it
2715      had the same scope as the outer block.  In the error message,
2716      SYMBOL may be shown as "`(don't know)'" if the outer block is not a
2717      function.
2719 `block at ADDRESS out of order'
2720      The symbol information for symbol scope blocks should occur in
2721      order of increasing addresses.  This error indicates that it does
2722      not do so.
2724      GDB does not circumvent this problem, and has trouble locating
2725      symbols in the source file whose symbols it is reading.  (You can
2726      often determine what source file is affected by specifying `set
2727      verbose on'.  *Note Optional warnings and messages:
2728      Messages/Warnings.)
2730 `bad block start address patched'
2731      The symbol information for a symbol scope block has a start address
2732      smaller than the address of the preceding source line.  This is
2733      known to occur in the SunOS 4.1.1 (and earlier) C compiler.
2735      GDB circumvents the problem by treating the symbol scope block as
2736      starting on the previous source line.
2738 `bad string table offset in symbol N'
2739      Symbol number N contains a pointer into the string table which is
2740      larger than the size of the string table.
2742      GDB circumvents the problem by considering the symbol to have the
2743      name `foo', which may cause other problems if many symbols end up
2744      with this name.
2746 `unknown symbol type `0xNN''
2747      The symbol information contains new data types that GDB does not
2748      yet know how to read.  `0xNN' is the symbol type of the
2749      uncomprehended information, in hexadecimal.
2751      GDB circumvents the error by ignoring this symbol information.
2752      This usually allows you to debug your program, though certain
2753      symbols are not accessible.  If you encounter such a problem and
2754      feel like debugging it, you can debug `gdb' with itself, breakpoint
2755      on `complain', then go up to the function `read_dbx_symtab' and
2756      examine `*bufp' to see the symbol.
2758 `stub type has NULL name'
2759      GDB could not find the full definition for a struct or class.
2761 `const/volatile indicator missing (ok if using g++ v1.x), got...'
2762      The symbol information for a C++ member function is missing some
2763      information that recent versions of the compiler should have
2764      output for it.
2766 `info mismatch between compiler and debugger'
2767      GDB could not parse a type specification output by the compiler.
2770 \x1f
2771 File: gdb.info,  Node: Targets,  Next: Remote Debugging,  Prev: GDB Files,  Up: Top
2773 16 Specifying a Debugging Target
2774 ********************************
2776 A "target" is the execution environment occupied by your program.
2778    Often, GDB runs in the same host environment as your program; in
2779 that case, the debugging target is specified as a side effect when you
2780 use the `file' or `core' commands.  When you need more flexibility--for
2781 example, running GDB on a physically separate host, or controlling a
2782 standalone system over a serial port or a realtime system over a TCP/IP
2783 connection--you can use the `target' command to specify one of the
2784 target types configured for GDB (*note Commands for managing targets:
2785 Target Commands.).
2787    It is possible to build GDB for several different "target
2788 architectures".  When GDB is built like that, you can choose one of the
2789 available architectures with the `set architecture' command.
2791 `set architecture ARCH'
2792      This command sets the current target architecture to ARCH.  The
2793      value of ARCH can be `"auto"', in addition to one of the supported
2794      architectures.
2796 `show architecture'
2797      Show the current target architecture.
2799 `set processor'
2800 `processor'
2801      These are alias commands for, respectively, `set architecture' and
2802      `show architecture'.
2804 * Menu:
2806 * Active Targets::              Active targets
2807 * Target Commands::             Commands for managing targets
2808 * Byte Order::                  Choosing target byte order
2809 * Remote::                      Remote debugging
2810 * KOD::                         Kernel Object Display
2812 \x1f
2813 File: gdb.info,  Node: Active Targets,  Next: Target Commands,  Up: Targets
2815 16.1 Active targets
2816 ===================
2818 There are three classes of targets: processes, core files, and
2819 executable files.  GDB can work concurrently on up to three active
2820 targets, one in each class.  This allows you to (for example) start a
2821 process and inspect its activity without abandoning your work on a core
2822 file.
2824    For example, if you execute `gdb a.out', then the executable file
2825 `a.out' is the only active target.  If you designate a core file as
2826 well--presumably from a prior run that crashed and coredumped--then GDB
2827 has two active targets and uses them in tandem, looking first in the
2828 corefile target, then in the executable file, to satisfy requests for
2829 memory addresses.  (Typically, these two classes of target are
2830 complementary, since core files contain only a program's read-write
2831 memory--variables and so on--plus machine status, while executable
2832 files contain only the program text and initialized data.)
2834    When you type `run', your executable file becomes an active process
2835 target as well.  When a process target is active, all GDB commands
2836 requesting memory addresses refer to that target; addresses in an
2837 active core file or executable file target are obscured while the
2838 process target is active.
2840    Use the `core-file' and `exec-file' commands to select a new core
2841 file or executable target (*note Commands to specify files: Files.).
2842 To specify as a target a process that is already running, use the
2843 `attach' command (*note Debugging an already-running process: Attach.).
2845 \x1f
2846 File: gdb.info,  Node: Target Commands,  Next: Byte Order,  Prev: Active Targets,  Up: Targets
2848 16.2 Commands for managing targets
2849 ==================================
2851 `target TYPE PARAMETERS'
2852      Connects the GDB host environment to a target machine or process.
2853      A target is typically a protocol for talking to debugging
2854      facilities.  You use the argument TYPE to specify the type or
2855      protocol of the target machine.
2857      Further PARAMETERS are interpreted by the target protocol, but
2858      typically include things like device names or host names to connect
2859      with, process numbers, and baud rates.
2861      The `target' command does not repeat if you press <RET> again
2862      after executing the command.
2864 `help target'
2865      Displays the names of all targets available.  To display targets
2866      currently selected, use either `info target' or `info files'
2867      (*note Commands to specify files: Files.).
2869 `help target NAME'
2870      Describe a particular target, including any parameters necessary to
2871      select it.
2873 `set gnutarget ARGS'
2874      GDB uses its own library BFD to read your files.  GDB knows
2875      whether it is reading an "executable", a "core", or a ".o" file;
2876      however, you can specify the file format with the `set gnutarget'
2877      command.  Unlike most `target' commands, with `gnutarget' the
2878      `target' refers to a program, not a machine.
2880           _Warning:_ To specify a file format with `set gnutarget', you
2881           must know the actual BFD name.
2883      *Note Commands to specify files: Files.
2885 `show gnutarget'
2886      Use the `show gnutarget' command to display what file format
2887      `gnutarget' is set to read.  If you have not set `gnutarget', GDB
2888      will determine the file format for each file automatically, and
2889      `show gnutarget' displays `The current BDF target is "auto"'.
2891    Here are some common targets (available, or not, depending on the GDB
2892 configuration):
2894 `target exec PROGRAM'
2895      An executable file.  `target exec PROGRAM' is the same as
2896      `exec-file PROGRAM'.
2898 `target core FILENAME'
2899      A core dump file.  `target core FILENAME' is the same as
2900      `core-file FILENAME'.
2902 `target remote MEDIUM'
2903      A remote system connected to GDB via a serial line or network
2904      connection.  This command tells GDB to use its own remote protocol
2905      over MEDIUM for debugging.  *Note Remote Debugging::.
2907      For example, if you have a board connected to `/dev/ttya' on the
2908      machine running GDB, you could say:
2910           target remote /dev/ttya
2912      `target remote' supports the `load' command.  This is only useful
2913      if you have some other way of getting the stub to the target
2914      system, and you can put it somewhere in memory where it won't get
2915      clobbered by the download.
2917 `target sim'
2918      Builtin CPU simulator.  GDB includes simulators for most
2919      architectures.  In general,
2920                   target sim
2921                   load
2922                   run
2923      works; however, you cannot assume that a specific memory map,
2924      device drivers, or even basic I/O is available, although some
2925      simulators do provide these.  For info about any
2926      processor-specific simulator details, see the appropriate section
2927      in *Note Embedded Processors: Embedded Processors.
2930    Some configurations may include these targets as well:
2932 `target nrom DEV'
2933      NetROM ROM emulator.  This target only supports downloading.
2936    Different targets are available on different configurations of GDB;
2937 your configuration may have more or fewer targets.
2939    Many remote targets require you to download the executable's code
2940 once you've successfully established a connection.  You may wish to
2941 control various aspects of this process, such as the size of the data
2942 chunks used by GDB to download program parts to the remote target.
2944 `set download-write-size SIZE'
2945      Set the write size used when downloading a program.  Only used when
2946      downloading a program onto a remote target.  Specify zero or a
2947      negative value to disable blocked writes.  The actual size of each
2948      transfer is also limited by the size of the target packet and the
2949      memory cache.
2951 `show download-write-size'
2952      Show the current value of the write size.
2954 `set hash'
2955      This command controls whether a hash mark `#' is displayed while
2956      downloading a file to the remote monitor.  If on, a hash mark is
2957      displayed after each S-record is successfully downloaded to the
2958      monitor.
2960 `show hash'
2961      Show the current status of displaying the hash mark.
2963 `set debug monitor'
2964      Enable or disable display of communications messages between GDB
2965      and the remote monitor.
2967 `show debug monitor'
2968      Show the current status of displaying communications between GDB
2969      and the remote monitor.
2971 `load FILENAME'
2972      Depending on what remote debugging facilities are configured into
2973      GDB, the `load' command may be available.  Where it exists, it is
2974      meant to make FILENAME (an executable) available for debugging on
2975      the remote system--by downloading, or dynamic linking, for example.
2976      `load' also records the FILENAME symbol table in GDB, like the
2977      `add-symbol-file' command.
2979      If your GDB does not have a `load' command, attempting to execute
2980      it gets the error message "`You can't do that when your target is
2981      ...'"
2983      The file is loaded at whatever address is specified in the
2984      executable.  For some object file formats, you can specify the
2985      load address when you link the program; for other formats, like
2986      a.out, the object file format specifies a fixed address.
2988      `load' does not repeat if you press <RET> again after using it.
2990 \x1f
2991 File: gdb.info,  Node: Byte Order,  Next: Remote,  Prev: Target Commands,  Up: Targets
2993 16.3 Choosing target byte order
2994 ===============================
2996 Some types of processors, such as the MIPS, PowerPC, and Renesas SH,
2997 offer the ability to run either big-endian or little-endian byte
2998 orders.  Usually the executable or symbol will include a bit to
2999 designate the endian-ness, and you will not need to worry about which
3000 to use.  However, you may still find it useful to adjust GDB's idea of
3001 processor endian-ness manually.
3003 `set endian big'
3004      Instruct GDB to assume the target is big-endian.
3006 `set endian little'
3007      Instruct GDB to assume the target is little-endian.
3009 `set endian auto'
3010      Instruct GDB to use the byte order associated with the executable.
3012 `show endian'
3013      Display GDB's current idea of the target byte order.
3016    Note that these commands merely adjust interpretation of symbolic
3017 data on the host, and that they have absolutely no effect on the target
3018 system.
3020 \x1f
3021 File: gdb.info,  Node: Remote,  Next: KOD,  Prev: Byte Order,  Up: Targets
3023 16.4 Remote debugging
3024 =====================
3026 If you are trying to debug a program running on a machine that cannot
3027 run GDB in the usual way, it is often useful to use remote debugging.
3028 For example, you might use remote debugging on an operating system
3029 kernel, or on a small system which does not have a general purpose
3030 operating system powerful enough to run a full-featured debugger.
3032    Some configurations of GDB have special serial or TCP/IP interfaces
3033 to make this work with particular debugging targets.  In addition, GDB
3034 comes with a generic serial protocol (specific to GDB, but not specific
3035 to any particular target system) which you can use if you write the
3036 remote stubs--the code that runs on the remote system to communicate
3037 with GDB.
3039    Other remote targets may be available in your configuration of GDB;
3040 use `help target' to list them.
3042    Once you've connected to the remote target, GDB allows you to send
3043 arbitrary commands to the remote monitor:
3045 `remote COMMAND'
3046      Send an arbitrary COMMAND string to the remote monitor.
3048 \x1f
3049 File: gdb.info,  Node: KOD,  Prev: Remote,  Up: Targets
3051 16.5 Kernel Object Display
3052 ==========================
3054 Some targets support kernel object display.  Using this facility, GDB
3055 communicates specially with the underlying operating system and can
3056 display information about operating system-level objects such as
3057 mutexes and other synchronization objects.  Exactly which objects can be
3058 displayed is determined on a per-OS basis.
3060    Use the `set os' command to set the operating system.  This tells
3061 GDB which kernel object display module to initialize:
3063      (gdb) set os cisco
3065    The associated command `show os' displays the operating system set
3066 with the `set os' command; if no operating system has been set, `show
3067 os' will display an empty string `""'.
3069    If `set os' succeeds, GDB will display some information about the
3070 operating system, and will create a new `info' command which can be
3071 used to query the target.  The `info' command is named after the
3072 operating system:
3074      (gdb) info cisco
3075      List of Cisco Kernel Objects
3076      Object     Description
3077      any        Any and all objects
3079    Further subcommands can be used to query about particular objects
3080 known by the kernel.
3082    There is currently no way to determine whether a given operating
3083 system is supported other than to try setting it with `set os NAME',
3084 where NAME is the name of the operating system you want to try.
3086 \x1f
3087 File: gdb.info,  Node: Remote Debugging,  Next: Configurations,  Prev: Targets,  Up: Top
3089 17 Debugging remote programs
3090 ****************************
3092 * Menu:
3094 * Connecting::                  Connecting to a remote target
3095 * Server::                      Using the gdbserver program
3096 * Remote configuration::        Remote configuration
3097 * remote stub::                 Implementing a remote stub
3099 \x1f
3100 File: gdb.info,  Node: Connecting,  Next: Server,  Up: Remote Debugging
3102 17.1 Connecting to a remote target
3103 ==================================
3105 On the GDB host machine, you will need an unstripped copy of your
3106 program, since GDB needs symobl and debugging information.  Start up
3107 GDB as usual, using the name of the local copy of your program as the
3108 first argument.
3110    GDB can communicate with the target over a serial line, or over an
3111 IP network using TCP or UDP.  In each case, GDB uses the same protocol
3112 for debugging your program; only the medium carrying the debugging
3113 packets varies.  The `target remote' command establishes a connection
3114 to the target.  Its arguments indicate which medium to use:
3116 `target remote SERIAL-DEVICE'
3117      Use SERIAL-DEVICE to communicate with the target.  For example, to
3118      use a serial line connected to the device named `/dev/ttyb':
3120           target remote /dev/ttyb
3122      If you're using a serial line, you may want to give GDB the
3123      `--baud' option, or use the `set remotebaud' command (*note set
3124      remotebaud: Remote configuration.) before the `target' command.
3126 `target remote `HOST:PORT''
3127 `target remote `tcp:HOST:PORT''
3128      Debug using a TCP connection to PORT on HOST.  The HOST may be
3129      either a host name or a numeric IP address; PORT must be a decimal
3130      number.  The HOST could be the target machine itself, if it is
3131      directly connected to the net, or it might be a terminal server
3132      which in turn has a serial line to the target.
3134      For example, to connect to port 2828 on a terminal server named
3135      `manyfarms':
3137           target remote manyfarms:2828
3139      If your remote target is actually running on the same machine as
3140      your debugger session (e.g. a simulator for your target running on
3141      the same host), you can omit the hostname.  For example, to
3142      connect to port 1234 on your local machine:
3144           target remote :1234
3145      Note that the colon is still required here.
3147 `target remote `udp:HOST:PORT''
3148      Debug using UDP packets to PORT on HOST.  For example, to connect
3149      to UDP port 2828 on a terminal server named `manyfarms':
3151           target remote udp:manyfarms:2828
3153      When using a UDP connection for remote debugging, you should keep
3154      in mind that the `U' stands for "Unreliable".  UDP can silently
3155      drop packets on busy or unreliable networks, which will cause
3156      havoc with your debugging session.
3158 `target remote | COMMAND'
3159      Run COMMAND in the background and communicate with it using a
3160      pipe.  The COMMAND is a shell command, to be parsed and expanded
3161      by the system's command shell, `/bin/sh'; it should expect remote
3162      protocol packets on its standard input, and send replies on its
3163      standard output.  You could use this to run a stand-alone simulator
3164      that speaks the remote debugging protocol, to make net connections
3165      using programs like `ssh', or for other similar tricks.
3167      If COMMAND closes its standard output (perhaps by exiting), GDB
3168      will try to send it a `SIGTERM' signal.  (If the program has
3169      already exited, this will have no effect.)
3172    Once the connection has been established, you can use all the usual
3173 commands to examine and change data and to step and continue the remote
3174 program.
3176    Whenever GDB is waiting for the remote program, if you type the
3177 interrupt character (often <C-C>), GDB attempts to stop the program.
3178 This may or may not succeed, depending in part on the hardware and the
3179 serial drivers the remote system uses.  If you type the interrupt
3180 character once again, GDB displays this prompt:
3182      Interrupted while waiting for the program.
3183      Give up (and stop debugging it)?  (y or n)
3185    If you type `y', GDB abandons the remote debugging session.  (If you
3186 decide you want to try again later, you can use `target remote' again
3187 to connect once more.)  If you type `n', GDB goes back to waiting.
3189 `detach'
3190      When you have finished debugging the remote program, you can use
3191      the `detach' command to release it from GDB control.  Detaching
3192      from the target normally resumes its execution, but the results
3193      will depend on your particular remote stub.  After the `detach'
3194      command, GDB is free to connect to another target.
3196 `disconnect'
3197      The `disconnect' command behaves like `detach', except that the
3198      target is generally not resumed.  It will wait for GDB (this
3199      instance or another one) to connect and continue debugging.  After
3200      the `disconnect' command, GDB is again free to connect to another
3201      target.
3203 `monitor CMD'
3204      This command allows you to send arbitrary commands directly to the
3205      remote monitor.  Since GDB doesn't care about the commands it
3206      sends like this, this command is the way to extend GDB--you can
3207      add new commands that only the external monitor will understand
3208      and implement.
3210 \x1f
3211 File: gdb.info,  Node: Server,  Next: Remote configuration,  Prev: Connecting,  Up: Remote Debugging
3213 17.2 Using the `gdbserver' program
3214 ==================================
3216 `gdbserver' is a control program for Unix-like systems, which allows
3217 you to connect your program with a remote GDB via `target remote'--but
3218 without linking in the usual debugging stub.
3220    `gdbserver' is not a complete replacement for the debugging stubs,
3221 because it requires essentially the same operating-system facilities
3222 that GDB itself does.  In fact, a system that can run `gdbserver' to
3223 connect to a remote GDB could also run GDB locally!  `gdbserver' is
3224 sometimes useful nevertheless, because it is a much smaller program
3225 than GDB itself.  It is also easier to port than all of GDB, so you may
3226 be able to get started more quickly on a new system by using
3227 `gdbserver'.  Finally, if you develop code for real-time systems, you
3228 may find that the tradeoffs involved in real-time operation make it
3229 more convenient to do as much development work as possible on another
3230 system, for example by cross-compiling.  You can use `gdbserver' to
3231 make a similar choice for debugging.
3233    GDB and `gdbserver' communicate via either a serial line or a TCP
3234 connection, using the standard GDB remote serial protocol.
3236 _On the target machine,_
3237      you need to have a copy of the program you want to debug.
3238      `gdbserver' does not need your program's symbol table, so you can
3239      strip the program if necessary to save space.  GDB on the host
3240      system does all the symbol handling.
3242      To use the server, you must tell it how to communicate with GDB;
3243      the name of your program; and the arguments for your program.  The
3244      usual syntax is:
3246           target> gdbserver COMM PROGRAM [ ARGS ... ]
3248      COMM is either a device name (to use a serial line) or a TCP
3249      hostname and portnumber.  For example, to debug Emacs with the
3250      argument `foo.txt' and communicate with GDB over the serial port
3251      `/dev/com1':
3253           target> gdbserver /dev/com1 emacs foo.txt
3255      `gdbserver' waits passively for the host GDB to communicate with
3256      it.
3258      To use a TCP connection instead of a serial line:
3260           target> gdbserver host:2345 emacs foo.txt
3262      The only difference from the previous example is the first
3263      argument, specifying that you are communicating with the host GDB
3264      via TCP.  The `host:2345' argument means that `gdbserver' is to
3265      expect a TCP connection from machine `host' to local TCP port 2345.
3266      (Currently, the `host' part is ignored.)  You can choose any number
3267      you want for the port number as long as it does not conflict with
3268      any TCP ports already in use on the target system (for example,
3269      `23' is reserved for `telnet').(1)  You must use the same port
3270      number with the host GDB `target remote' command.
3272      On some targets, `gdbserver' can also attach to running programs.
3273      This is accomplished via the `--attach' argument.  The syntax is:
3275           target> gdbserver COMM --attach PID
3277      PID is the process ID of a currently running process.  It isn't
3278      necessary to point `gdbserver' at a binary for the running process.
3280      You can debug processes by name instead of process ID if your
3281      target has the `pidof' utility:
3283           target> gdbserver COMM --attach `pidof PROGRAM`
3285      In case more than one copy of PROGRAM is running, or PROGRAM has
3286      multiple threads, most versions of `pidof' support the `-s' option
3287      to only return the first process ID.
3289 _On the host machine,_
3290      connect to your target (*note Connecting to a remote target:
3291      Connecting.).  For TCP connections, you must start up `gdbserver'
3292      prior to using the `target remote' command.  Otherwise you may get
3293      an error whose text depends on the host system, but which usually
3294      looks something like `Connection refused'.  You don't need to use
3295      the `load' command in GDB when using `gdbserver', since the
3296      program is already on the target.  However, if you want to load
3297      the symbols (as you normally would), do that with the `file'
3298      command, and issue it _before_ connecting to the server;
3299      otherwise, you will get an error message saying `"Program is
3300      already running"', since the program is considered running after
3301      the connection.
3304    ---------- Footnotes ----------
3306    (1) If you choose a port number that conflicts with another service,
3307 `gdbserver' prints an error message and exits.
3309 \x1f
3310 File: gdb.info,  Node: Remote configuration,  Next: remote stub,  Prev: Server,  Up: Remote Debugging
3312 17.3 Remote configuration
3313 =========================
3315 This section documents the configuration options available when
3316 debugging remote programs.  For the options related to the File I/O
3317 extensions of the remote protocol, see *Note system-call-allowed: The
3318 system call.
3320 `set remoteaddresssize BITS'
3321      Set the maximum size of address in a memory packet to the specified
3322      number of bits.  GDB will mask off the address bits above that
3323      number, when it passes addresses to the remote target.  The
3324      default value is the number of bits in the target's address.
3326 `show remoteaddresssize'
3327      Show the current value of remote address size in bits.
3329 `set remotebaud N'
3330      Set the baud rate for the remote serial I/O to N baud.  The value
3331      is used to set the speed of the serial port used for debugging
3332      remote targets.
3334 `show remotebaud'
3335      Show the current speed of the remote connection.
3337 `set remotebreak'
3338      If set to on, GDB sends a `BREAK' signal to the remote when you
3339      press the <Ctrl-C> key to interrupt the program running on the
3340      remote.  If set to off, GDB sends the `Ctrl-C' character instead.
3341      The default is off, since most remote systems expect to see
3342      `Ctrl-C' as the interrupt signal.
3344 `show remotebreak'
3345      Show whether GDB sends `BREAK' or `Ctrl-C' to interrupt the remote
3346      program.
3348 `set remotedevice DEVICE'
3349      Set the name of the serial port through which to communicate to the
3350      remote target to DEVICE.  This is the device used by GDB to open
3351      the serial communications line to the remote target.  There's no
3352      default, so you must set a valid port name for the remote serial
3353      communications to work.  (Some varieties of the `target' command
3354      accept the port name as part of their arguments.)
3356 `show remotedevice'
3357      Show the current name of the serial port.
3359 `set remotelogbase BASE'
3360      Set the base (a.k.a. radix) of logging serial protocol
3361      communications to BASE.  Supported values of BASE are: `ascii',
3362      `octal', and `hex'.  The default is `ascii'.
3364 `show remotelogbase'
3365      Show the current setting of the radix for logging remote serial
3366      protocol.
3368 `set remotelogfile FILE'
3369      Record remote serial communications on the named FILE.  The
3370      default is not to record at all.
3372 `show remotelogfile.'
3373      Show the current setting  of the file name on which to record the
3374      serial communications.
3376 `set remotetimeout NUM'
3377      Set the timeout limit to wait for the remote target to respond to
3378      NUM seconds.  The default is 2 seconds.
3380 `show remotetimeout'
3381      Show the current number of seconds to wait for the remote target
3382      responses.
3384 `set remote hardware-watchpoint-limit LIMIT'
3385 `set remote hardware-breakpoint-limit LIMIT'
3386      Restrict GDB to using LIMIT remote hardware breakpoint or
3387      watchpoints.  A limit of -1, the default, is treated as unlimited.
3389 `set remote fetch-register-packet'
3390 `set remote set-register-packet'
3391 `set remote P-packet'
3392 `set remote p-packet'
3393      Determine whether GDB can set and fetch registers from the remote
3394      target using the `P' packets.  The default depends on the remote
3395      stub's support of the `P' packets (GDB queries the stub when this
3396      packet is first required).
3398 `show remote fetch-register-packet'
3399 `show remote set-register-packet'
3400 `show remote P-packet'
3401 `show remote p-packet'
3402      Show the current setting of using the `P' packets for setting and
3403      fetching registers from the remote target.
3405 `set remote binary-download-packet'
3406 `set remote X-packet'
3407      Determine whether GDB sends downloads in binary mode using the `X'
3408      packets.  The default is on.
3410 `show remote binary-download-packet'
3411 `show remote X-packet'
3412      Show the current setting of using the `X' packets for binary
3413      downloads.
3415 `set remote read-aux-vector-packet'
3416      Set the use of the remote protocol's `qPart:auxv:read' (target
3417      auxiliary vector read) request.  This request is used to fetch the
3418      remote target's "auxiliary vector", see *Note Auxiliary Vector: OS
3419      Information.  The default setting depends on the remote stub's
3420      support of this request (GDB queries the stub when this request is
3421      first required).  *Note qPart: General Query Packets, for more
3422      information about this request.
3424 `show remote read-aux-vector-packet'
3425      Show the current setting of use of the `qPart:auxv:read' request.
3427 `set remote symbol-lookup-packet'
3428      Set the use of the remote protocol's `qSymbol' (target symbol
3429      lookup) request.  This request is used to communicate symbol
3430      information to the remote target, e.g., whenever a new shared
3431      library is loaded by the remote (*note shared libraries: Files.).
3432      The default setting depends on the remote stub's support of this
3433      request (GDB queries the stub when this request is first required).
3434      *Note qSymbol: General Query Packets, for more information about
3435      this request.
3437 `show remote symbol-lookup-packet'
3438      Show the current setting of use of the `qSymbol' request.
3440 `set remote verbose-resume-packet'
3441      Set the use of the remote protocol's `vCont' (descriptive resume)
3442      request.  This request is used to resume specific threads in the
3443      remote target, and to single-step or signal them.  The default
3444      setting depends on the remote stub's support of this request (GDB
3445      queries the stub when this request is first required).  This
3446      setting affects debugging of multithreaded programs: if `vCont'
3447      cannot be used, GDB might be unable to single-step a specific
3448      thread, especially under `set scheduler-locking off'; it is also
3449      impossible to pause a specific thread.  *Note vCont: Packets, for
3450      more details.
3452 `show remote verbose-resume-packet'
3453      Show the current setting of use of the `vCont' request
3455 `set remote software-breakpoint-packet'
3456 `set remote hardware-breakpoint-packet'
3457 `set remote write-watchpoint-packet'
3458 `set remote read-watchpoint-packet'
3459 `set remote access-watchpoint-packet'
3460 `set remote Z-packet'
3461      These commands enable or disable the use of `Z' packets for
3462      setting breakpoints and watchpoints in the remote target.  The
3463      default depends on the remote stub's support of the `Z' packets
3464      (GDB queries the stub when each packet is first required).  The
3465      command `set remote Z-packet', kept for back-compatibility, turns
3466      on or off all the features that require the use of `Z' packets.
3468 `show remote software-breakpoint-packet'
3469 `show remote hardware-breakpoint-packet'
3470 `show remote write-watchpoint-packet'
3471 `show remote read-watchpoint-packet'
3472 `show remote access-watchpoint-packet'
3473 `show remote Z-packet'
3474      Show the current setting of `Z' packets usage.
3476 `set remote get-thread-local-storage-address'
3477      This command enables or disables the use of the `qGetTLSAddr' (Get
3478      Thread Local Storage Address) request packet.  The default depends
3479      on whether the remote stub supports this request.  *Note
3480      qGetTLSAddr: General Query Packets, for more details about this
3481      packet.
3483 `show remote get-thread-local-storage-address'
3484      Show the current setting of `qGetTLSAddr' packet usage.
3486 \x1f
3487 File: gdb.info,  Node: remote stub,  Prev: Remote configuration,  Up: Remote Debugging
3489 17.4 Implementing a remote stub
3490 ===============================
3492 The stub files provided with GDB implement the target side of the
3493 communication protocol, and the GDB side is implemented in the GDB
3494 source file `remote.c'.  Normally, you can simply allow these
3495 subroutines to communicate, and ignore the details.  (If you're
3496 implementing your own stub file, you can still ignore the details: start
3497 with one of the existing stub files.  `sparc-stub.c' is the best
3498 organized, and therefore the easiest to read.)
3500    To debug a program running on another machine (the debugging
3501 "target" machine), you must first arrange for all the usual
3502 prerequisites for the program to run by itself.  For example, for a C
3503 program, you need:
3505   1. A startup routine to set up the C runtime environment; these
3506      usually have a name like `crt0'.  The startup routine may be
3507      supplied by your hardware supplier, or you may have to write your
3508      own.
3510   2. A C subroutine library to support your program's subroutine calls,
3511      notably managing input and output.
3513   3. A way of getting your program to the other machine--for example, a
3514      download program.  These are often supplied by the hardware
3515      manufacturer, but you may have to write your own from hardware
3516      documentation.
3518    The next step is to arrange for your program to use a serial port to
3519 communicate with the machine where GDB is running (the "host" machine).
3520 In general terms, the scheme looks like this:
3522 _On the host,_
3523      GDB already understands how to use this protocol; when everything
3524      else is set up, you can simply use the `target remote' command
3525      (*note Specifying a Debugging Target: Targets.).
3527 _On the target,_
3528      you must link with your program a few special-purpose subroutines
3529      that implement the GDB remote serial protocol.  The file
3530      containing these subroutines is called  a "debugging stub".
3532      On certain remote targets, you can use an auxiliary program
3533      `gdbserver' instead of linking a stub into your program.  *Note
3534      Using the `gdbserver' program: Server, for details.
3536    The debugging stub is specific to the architecture of the remote
3537 machine; for example, use `sparc-stub.c' to debug programs on SPARC
3538 boards.
3540    These working remote stubs are distributed with GDB:
3542 `i386-stub.c'
3543      For Intel 386 and compatible architectures.
3545 `m68k-stub.c'
3546      For Motorola 680x0 architectures.
3548 `sh-stub.c'
3549      For Renesas SH architectures.
3551 `sparc-stub.c'
3552      For SPARC architectures.
3554 `sparcl-stub.c'
3555      For Fujitsu SPARCLITE architectures.
3558    The `README' file in the GDB distribution may list other recently
3559 added stubs.
3561 * Menu:
3563 * Stub Contents::       What the stub can do for you
3564 * Bootstrapping::       What you must do for the stub
3565 * Debug Session::       Putting it all together
3567 \x1f
3568 File: gdb.info,  Node: Stub Contents,  Next: Bootstrapping,  Up: remote stub
3570 17.4.1 What the stub can do for you
3571 -----------------------------------
3573 The debugging stub for your architecture supplies these three
3574 subroutines:
3576 `set_debug_traps'
3577      This routine arranges for `handle_exception' to run when your
3578      program stops.  You must call this subroutine explicitly near the
3579      beginning of your program.
3581 `handle_exception'
3582      This is the central workhorse, but your program never calls it
3583      explicitly--the setup code arranges for `handle_exception' to run
3584      when a trap is triggered.
3586      `handle_exception' takes control when your program stops during
3587      execution (for example, on a breakpoint), and mediates
3588      communications with GDB on the host machine.  This is where the
3589      communications protocol is implemented; `handle_exception' acts as
3590      the GDB representative on the target machine.  It begins by
3591      sending summary information on the state of your program, then
3592      continues to execute, retrieving and transmitting any information
3593      GDB needs, until you execute a GDB command that makes your program
3594      resume; at that point, `handle_exception' returns control to your
3595      own code on the target machine.
3597 `breakpoint'
3598      Use this auxiliary subroutine to make your program contain a
3599      breakpoint.  Depending on the particular situation, this may be
3600      the only way for GDB to get control.  For instance, if your target
3601      machine has some sort of interrupt button, you won't need to call
3602      this; pressing the interrupt button transfers control to
3603      `handle_exception'--in effect, to GDB.  On some machines, simply
3604      receiving characters on the serial port may also trigger a trap;
3605      again, in that situation, you don't need to call `breakpoint' from
3606      your own program--simply running `target remote' from the host GDB
3607      session gets control.
3609      Call `breakpoint' if none of these is true, or if you simply want
3610      to make certain your program stops at a predetermined point for the
3611      start of your debugging session.
3613 \x1f
3614 File: gdb.info,  Node: Bootstrapping,  Next: Debug Session,  Prev: Stub Contents,  Up: remote stub
3616 17.4.2 What you must do for the stub
3617 ------------------------------------
3619 The debugging stubs that come with GDB are set up for a particular chip
3620 architecture, but they have no information about the rest of your
3621 debugging target machine.
3623    First of all you need to tell the stub how to communicate with the
3624 serial port.
3626 `int getDebugChar()'
3627      Write this subroutine to read a single character from the serial
3628      port.  It may be identical to `getchar' for your target system; a
3629      different name is used to allow you to distinguish the two if you
3630      wish.
3632 `void putDebugChar(int)'
3633      Write this subroutine to write a single character to the serial
3634      port.  It may be identical to `putchar' for your target system; a
3635      different name is used to allow you to distinguish the two if you
3636      wish.
3638    If you want GDB to be able to stop your program while it is running,
3639 you need to use an interrupt-driven serial driver, and arrange for it
3640 to stop when it receives a `^C' (`\003', the control-C character).
3641 That is the character which GDB uses to tell the remote system to stop.
3643    Getting the debugging target to return the proper status to GDB
3644 probably requires changes to the standard stub; one quick and dirty way
3645 is to just execute a breakpoint instruction (the "dirty" part is that
3646 GDB reports a `SIGTRAP' instead of a `SIGINT').
3648    Other routines you need to supply are:
3650 `void exceptionHandler (int EXCEPTION_NUMBER, void *EXCEPTION_ADDRESS)'
3651      Write this function to install EXCEPTION_ADDRESS in the exception
3652      handling tables.  You need to do this because the stub does not
3653      have any way of knowing what the exception handling tables on your
3654      target system are like (for example, the processor's table might
3655      be in ROM, containing entries which point to a table in RAM).
3656      EXCEPTION_NUMBER is the exception number which should be changed;
3657      its meaning is architecture-dependent (for example, different
3658      numbers might represent divide by zero, misaligned access, etc).
3659      When this exception occurs, control should be transferred directly
3660      to EXCEPTION_ADDRESS, and the processor state (stack, registers,
3661      and so on) should be just as it is when a processor exception
3662      occurs.  So if you want to use a jump instruction to reach
3663      EXCEPTION_ADDRESS, it should be a simple jump, not a jump to
3664      subroutine.
3666      For the 386, EXCEPTION_ADDRESS should be installed as an interrupt
3667      gate so that interrupts are masked while the handler runs.  The
3668      gate should be at privilege level 0 (the most privileged level).
3669      The SPARC and 68k stubs are able to mask interrupts themselves
3670      without help from `exceptionHandler'.
3672 `void flush_i_cache()'
3673      On SPARC and SPARCLITE only, write this subroutine to flush the
3674      instruction cache, if any, on your target machine.  If there is no
3675      instruction cache, this subroutine may be a no-op.
3677      On target machines that have instruction caches, GDB requires this
3678      function to make certain that the state of your program is stable.
3680 You must also make sure this library routine is available:
3682 `void *memset(void *, int, int)'
3683      This is the standard library function `memset' that sets an area of
3684      memory to a known value.  If you have one of the free versions of
3685      `libc.a', `memset' can be found there; otherwise, you must either
3686      obtain it from your hardware manufacturer, or write your own.
3688    If you do not use the GNU C compiler, you may need other standard
3689 library subroutines as well; this varies from one stub to another, but
3690 in general the stubs are likely to use any of the common library
3691 subroutines which `gcc' generates as inline code.
3693 \x1f
3694 File: gdb.info,  Node: Debug Session,  Prev: Bootstrapping,  Up: remote stub
3696 17.4.3 Putting it all together
3697 ------------------------------
3699 In summary, when your program is ready to debug, you must follow these
3700 steps.
3702   1. Make sure you have defined the supporting low-level routines
3703      (*note What you must do for the stub: Bootstrapping.):
3704           `getDebugChar', `putDebugChar',
3705           `flush_i_cache', `memset', `exceptionHandler'.
3707   2. Insert these lines near the top of your program:
3709           set_debug_traps();
3710           breakpoint();
3712   3. For the 680x0 stub only, you need to provide a variable called
3713      `exceptionHook'.  Normally you just use:
3715           void (*exceptionHook)() = 0;
3717      but if before calling `set_debug_traps', you set it to point to a
3718      function in your program, that function is called when `GDB'
3719      continues after stopping on a trap (for example, bus error).  The
3720      function indicated by `exceptionHook' is called with one
3721      parameter: an `int' which is the exception number.
3723   4. Compile and link together: your program, the GDB debugging stub for
3724      your target architecture, and the supporting subroutines.
3726   5. Make sure you have a serial connection between your target machine
3727      and the GDB host, and identify the serial port on the host.
3729   6. Download your program to your target machine (or get it there by
3730      whatever means the manufacturer provides), and start it.
3732   7. Start GDB on the host, and connect to the target (*note Connecting
3733      to a remote target: Connecting.).
3736 \x1f
3737 File: gdb.info,  Node: Configurations,  Next: Controlling GDB,  Prev: Remote Debugging,  Up: Top
3739 18 Configuration-Specific Information
3740 *************************************
3742 While nearly all GDB commands are available for all native and cross
3743 versions of the debugger, there are some exceptions.  This chapter
3744 describes things that are only available in certain configurations.
3746    There are three major categories of configurations: native
3747 configurations, where the host and target are the same, embedded
3748 operating system configurations, which are usually the same for several
3749 different processor architectures, and bare embedded processors, which
3750 are quite different from each other.
3752 * Menu:
3754 * Native::
3755 * Embedded OS::
3756 * Embedded Processors::
3757 * Architectures::
3759 \x1f
3760 File: gdb.info,  Node: Native,  Next: Embedded OS,  Up: Configurations
3762 18.1 Native
3763 ===========
3765 This section describes details specific to particular native
3766 configurations.
3768 * Menu:
3770 * HP-UX::                       HP-UX
3771 * BSD libkvm Interface::        Debugging BSD kernel memory images
3772 * SVR4 Process Information::    SVR4 process information
3773 * DJGPP Native::                Features specific to the DJGPP port
3774 * Cygwin Native::               Features specific to the Cygwin port
3775 * Hurd Native::                 Features specific to GNU Hurd
3776 * Neutrino::                    Features specific to QNX Neutrino
3778 \x1f
3779 File: gdb.info,  Node: HP-UX,  Next: BSD libkvm Interface,  Up: Native
3781 18.1.1 HP-UX
3782 ------------
3784 On HP-UX systems, if you refer to a function or variable name that
3785 begins with a dollar sign, GDB searches for a user or system name
3786 first, before it searches for a convenience variable.
3788 \x1f
3789 File: gdb.info,  Node: BSD libkvm Interface,  Next: SVR4 Process Information,  Prev: HP-UX,  Up: Native
3791 18.1.2 BSD libkvm Interface
3792 ---------------------------
3794 BSD-derived systems (FreeBSD/NetBSD/OpenBSD) have a kernel memory
3795 interface that provides a uniform interface for accessing kernel virtual
3796 memory images, including live systems and crash dumps.  GDB uses this
3797 interface to allow you to debug live kernels and kernel crash dumps on
3798 many native BSD configurations.  This is implemented as a special `kvm'
3799 debugging target.  For debugging a live system, load the currently
3800 running kernel into GDB and connect to the `kvm' target:
3802      (gdb) target kvm
3804    For debugging crash dumps, provide the file name of the crash dump
3805 as an argument:
3807      (gdb) target kvm /var/crash/bsd.0
3809    Once connected to the `kvm' target, the following commands are
3810 available:
3812 `kvm pcb'
3813      Set current context from the "Process Control Block" (PCB) address.
3815 `kvm proc'
3816      Set current context from proc address.  This command isn't
3817      available on modern FreeBSD systems.
3819 \x1f
3820 File: gdb.info,  Node: SVR4 Process Information,  Next: DJGPP Native,  Prev: BSD libkvm Interface,  Up: Native
3822 18.1.3 SVR4 process information
3823 -------------------------------
3825 Many versions of SVR4 and compatible systems provide a facility called
3826 `/proc' that can be used to examine the image of a running process
3827 using file-system subroutines.  If GDB is configured for an operating
3828 system with this facility, the command `info proc' is available to
3829 report information about the process running your program, or about any
3830 process running on your system.  `info proc' works only on SVR4 systems
3831 that include the `procfs' code.  This includes, as of this writing,
3832 GNU/Linux, OSF/1 (Digital Unix), Solaris, Irix, and Unixware, but not
3833 HP-UX, for example.
3835 `info proc'
3836 `info proc PROCESS-ID'
3837      Summarize available information about any running process.  If a
3838      process ID is specified by PROCESS-ID, display information about
3839      that process; otherwise display information about the program being
3840      debugged.  The summary includes the debugged process ID, the
3841      command line used to invoke it, its current working directory, and
3842      its executable file's absolute file name.
3844      On some systems, PROCESS-ID can be of the form `[PID]/TID' which
3845      specifies a certain thread ID within a process.  If the optional
3846      PID part is missing, it means a thread from the process being
3847      debugged (the leading `/' still needs to be present, or else GDB
3848      will interpret the number as a process ID rather than a thread ID).
3850 `info proc mappings'
3851      Report the memory address space ranges accessible in the program,
3852      with information on whether the process has read, write, or
3853      execute access rights to each range.  On GNU/Linux systems, each
3854      memory range includes the object file which is mapped to that
3855      range, instead of the memory access rights to that range.
3857 `info proc stat'
3858 `info proc status'
3859      These subcommands are specific to GNU/Linux systems.  They show
3860      the process-related information, including the user ID and group
3861      ID; how many threads are there in the process; its virtual memory
3862      usage; the signals that are pending, blocked, and ignored; its
3863      TTY; its consumption of system and user time; its stack size; its
3864      `nice' value; etc.  For more information, see the `proc' man page
3865      (type `man 5 proc' from your shell prompt).
3867 `info proc all'
3868      Show all the information about the process described under all of
3869      the above `info proc' subcommands.
3871 `set procfs-trace'
3872      This command enables and disables tracing of `procfs' API calls.
3874 `show procfs-trace'
3875      Show the current state of `procfs' API call tracing.
3877 `set procfs-file FILE'
3878      Tell GDB to write `procfs' API trace to the named FILE.  GDB
3879      appends the trace info to the previous contents of the file.  The
3880      default is to display the trace on the standard output.
3882 `show procfs-file'
3883      Show the file to which `procfs' API trace is written.
3885 `proc-trace-entry'
3886 `proc-trace-exit'
3887 `proc-untrace-entry'
3888 `proc-untrace-exit'
3889      These commands enable and disable tracing of entries into and exits
3890      from the `syscall' interface.
3892 `info pidlist'
3893      For QNX Neutrino only, this command displays the list of all the
3894      processes and all the threads within each process.
3896 `info meminfo'
3897      For QNX Neutrino only, this command displays the list of all
3898      mapinfos.
3900 \x1f
3901 File: gdb.info,  Node: DJGPP Native,  Next: Cygwin Native,  Prev: SVR4 Process Information,  Up: Native
3903 18.1.4 Features for Debugging DJGPP Programs
3904 --------------------------------------------
3906 DJGPP is a port of the GNU development tools to MS-DOS and MS-Windows.
3907 DJGPP programs are 32-bit protected-mode programs that use the "DPMI"
3908 (DOS Protected-Mode Interface) API to run on top of real-mode DOS
3909 systems and their emulations.
3911    GDB supports native debugging of DJGPP programs, and defines a few
3912 commands specific to the DJGPP port.  This subsection describes those
3913 commands.
3915 `info dos'
3916      This is a prefix of DJGPP-specific commands which print
3917      information about the target system and important OS structures.
3919 `info dos sysinfo'
3920      This command displays assorted information about the underlying
3921      platform: the CPU type and features, the OS version and flavor, the
3922      DPMI version, and the available conventional and DPMI memory.
3924 `info dos gdt'
3925 `info dos ldt'
3926 `info dos idt'
3927      These 3 commands display entries from, respectively, Global, Local,
3928      and Interrupt Descriptor Tables (GDT, LDT, and IDT).  The
3929      descriptor tables are data structures which store a descriptor for
3930      each segment that is currently in use.  The segment's selector is
3931      an index into a descriptor table; the table entry for that index
3932      holds the descriptor's base address and limit, and its attributes
3933      and access rights.
3935      A typical DJGPP program uses 3 segments: a code segment, a data
3936      segment (used for both data and the stack), and a DOS segment
3937      (which allows access to DOS/BIOS data structures and absolute
3938      addresses in conventional memory).  However, the DPMI host will
3939      usually define additional segments in order to support the DPMI
3940      environment.
3942      These commands allow to display entries from the descriptor tables.
3943      Without an argument, all entries from the specified table are
3944      displayed.  An argument, which should be an integer expression,
3945      means display a single entry whose index is given by the argument.
3946      For example, here's a convenient way to display information about
3947      the debugged program's data segment:
3949      `(gdb) info dos ldt $ds'
3950      `0x13f: base=0x11970000 limit=0x0009ffff 32-Bit Data (Read/Write, Exp-up)'
3953      This comes in handy when you want to see whether a pointer is
3954      outside the data segment's limit (i.e. "garbled").
3956 `info dos pde'
3957 `info dos pte'
3958      These two commands display entries from, respectively, the Page
3959      Directory and the Page Tables.  Page Directories and Page Tables
3960      are data structures which control how virtual memory addresses are
3961      mapped into physical addresses.  A Page Table includes an entry
3962      for every page of memory that is mapped into the program's address
3963      space; there may be several Page Tables, each one holding up to
3964      4096 entries.  A Page Directory has up to 4096 entries, one each
3965      for every Page Table that is currently in use.
3967      Without an argument, `info dos pde' displays the entire Page
3968      Directory, and `info dos pte' displays all the entries in all of
3969      the Page Tables.  An argument, an integer expression, given to the
3970      `info dos pde' command means display only that entry from the Page
3971      Directory table.  An argument given to the `info dos pte' command
3972      means display entries from a single Page Table, the one pointed to
3973      by the specified entry in the Page Directory.
3975      These commands are useful when your program uses "DMA" (Direct
3976      Memory Access), which needs physical addresses to program the DMA
3977      controller.
3979      These commands are supported only with some DPMI servers.
3981 `info dos address-pte ADDR'
3982      This command displays the Page Table entry for a specified linear
3983      address.  The argument ADDR is a linear address which should
3984      already have the appropriate segment's base address added to it,
3985      because this command accepts addresses which may belong to _any_
3986      segment.  For example, here's how to display the Page Table entry
3987      for the page where a variable `i' is stored:
3989      `(gdb) info dos address-pte __djgpp_base_address + (char *)&i'
3990      `Page Table entry for address 0x11a00d30:'
3991      `Base=0x02698000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0xd30'
3994      This says that `i' is stored at offset `0xd30' from the page whose
3995      physical base address is `0x02698000', and shows all the
3996      attributes of that page.
3998      Note that you must cast the addresses of variables to a `char *',
3999      since otherwise the value of `__djgpp_base_address', the base
4000      address of all variables and functions in a DJGPP program, will be
4001      added using the rules of C pointer arithmetics: if `i' is declared
4002      an `int', GDB will add 4 times the value of `__djgpp_base_address'
4003      to the address of `i'.
4005      Here's another example, it displays the Page Table entry for the
4006      transfer buffer:
4008      `(gdb) info dos address-pte *((unsigned *)&_go32_info_block + 3)'
4009      `Page Table entry for address 0x29110:'
4010      `Base=0x00029000 Dirty Acc. Not-Cached Write-Back Usr Read-Write +0x110'
4013      (The `+ 3' offset is because the transfer buffer's address is the
4014      3rd member of the `_go32_info_block' structure.)  The output
4015      clearly shows that this DPMI server maps the addresses in
4016      conventional memory 1:1, i.e. the physical (`0x00029000' +
4017      `0x110') and linear (`0x29110') addresses are identical.
4019      This command is supported only with some DPMI servers.
4021    In addition to native debugging, the DJGPP port supports remote
4022 debugging via a serial data link.  The following commands are specific
4023 to remote serial debugging in the DJGPP port of GDB.
4025 `set com1base ADDR'
4026      This command sets the base I/O port address of the `COM1' serial
4027      port.
4029 `set com1irq IRQ'
4030      This command sets the "Interrupt Request" (`IRQ') line to use for
4031      the `COM1' serial port.
4033      There are similar commands `set com2base', `set com3irq', etc. for
4034      setting the port address and the `IRQ' lines for the other 3 COM
4035      ports.
4037      The related commands `show com1base', `show com1irq' etc.  display
4038      the current settings of the base address and the `IRQ' lines used
4039      by the COM ports.
4041 `info serial'
4042      This command prints the status of the 4 DOS serial ports.  For each
4043      port, it prints whether it's active or not, its I/O base address
4044      and IRQ number, whether it uses a 16550-style FIFO, its baudrate,
4045      and the counts of various errors encountered so far.
4047 \x1f
4048 File: gdb.info,  Node: Cygwin Native,  Next: Hurd Native,  Prev: DJGPP Native,  Up: Native
4050 18.1.5 Features for Debugging MS Windows PE executables
4051 -------------------------------------------------------
4053 GDB supports native debugging of MS Windows programs, including DLLs
4054 with and without symbolic debugging information. There are various
4055 additional Cygwin-specific commands, described in this subsection.  The
4056 subsubsection *note Non-debug DLL symbols:: describes working with DLLs
4057 that have no debugging symbols.
4059 `info w32'
4060      This is a prefix of MS Windows specific commands which print
4061      information about the target system and important OS structures.
4063 `info w32 selector'
4064      This command displays information returned by the Win32 API
4065      `GetThreadSelectorEntry' function.  It takes an optional argument
4066      that is evaluated to a long value to give the information about
4067      this given selector.  Without argument, this command displays
4068      information about the the six segment registers.
4070 `info dll'
4071      This is a Cygwin specific alias of info shared.
4073 `dll-symbols'
4074      This command loads symbols from a dll similarly to add-sym command
4075      but without the need to specify a base address.
4077 `set new-console MODE'
4078      If MODE is `on' the debuggee will be started in a new console on
4079      next start.  If MODE is `off'i, the debuggee will be started in
4080      the same console as the debugger.
4082 `show new-console'
4083      Displays whether a new console is used when the debuggee is
4084      started.
4086 `set new-group MODE'
4087      This boolean value controls whether the debuggee should start a
4088      new group or stay in the same group as the debugger.  This affects
4089      the way the Windows OS handles Ctrl-C.
4091 `show new-group'
4092      Displays current value of new-group boolean.
4094 `set debugevents'
4095      This boolean value adds debug output concerning kernel events
4096      related to the debuggee seen by the debugger.  This includes
4097      events that signal thread and process creation and exit, DLL
4098      loading and unloading, console interrupts, and debugging messages
4099      produced by the Windows `OutputDebugString' API call.
4101 `set debugexec'
4102      This boolean value adds debug output concerning execute events
4103      (such as resume thread) seen by the debugger.
4105 `set debugexceptions'
4106      This boolean value adds debug output concerning exceptions in the
4107      debuggee seen by the debugger.
4109 `set debugmemory'
4110      This boolean value adds debug output concerning debuggee memory
4111      reads and writes by the debugger.
4113 `set shell'
4114      This boolean values specifies whether the debuggee is called via a
4115      shell or directly (default value is on).
4117 `show shell'
4118      Displays if the debuggee will be started with a shell.
4121 * Menu:
4123 * Non-debug DLL symbols::  Support for DLLs without debugging symbols
4125 \x1f
4126 File: gdb.info,  Node: Non-debug DLL symbols,  Up: Cygwin Native
4128 18.1.5.1 Support for DLLs without debugging symbols
4129 ...................................................
4131 Very often on windows, some of the DLLs that your program relies on do
4132 not include symbolic debugging information (for example,
4133 `kernel32.dll'). When GDB doesn't recognize any debugging symbols in a
4134 DLL, it relies on the minimal amount of symbolic information contained
4135 in the DLL's export table. This subsubsection describes working with
4136 such symbols, known internally to GDB as "minimal symbols".
4138    Note that before the debugged program has started execution, no DLLs
4139 will have been loaded. The easiest way around this problem is simply to
4140 start the program -- either by setting a breakpoint or letting the
4141 program run once to completion. It is also possible to force GDB to
4142 load a particular DLL before starting the executable -- see the shared
4143 library information in *note Files:: or the `dll-symbols' command in
4144 *note Cygwin Native::. Currently, explicitly loading symbols from a DLL
4145 with no debugging information will cause the symbol names to be
4146 duplicated in GDB's lookup table, which may adversely affect symbol
4147 lookup performance.
4149 18.1.5.2 DLL name prefixes
4150 ..........................
4152 In keeping with the naming conventions used by the Microsoft debugging
4153 tools, DLL export symbols are made available with a prefix based on the
4154 DLL name, for instance `KERNEL32!CreateFileA'.  The plain name is also
4155 entered into the symbol table, so `CreateFileA' is often sufficient. In
4156 some cases there will be name clashes within a program (particularly if
4157 the executable itself includes full debugging symbols) necessitating
4158 the use of the fully qualified name when referring to the contents of
4159 the DLL. Use single-quotes around the name to avoid the exclamation
4160 mark ("!")  being interpreted as a language operator.
4162    Note that the internal name of the DLL may be all upper-case, even
4163 though the file name of the DLL is lower-case, or vice-versa. Since
4164 symbols within GDB are _case-sensitive_ this may cause some confusion.
4165 If in doubt, try the `info functions' and `info variables' commands or
4166 even `maint print msymbols' (see *note Symbols::). Here's an example:
4168      (gdb) info function CreateFileA
4169      All functions matching regular expression "CreateFileA":
4171      Non-debugging symbols:
4172      0x77e885f4  CreateFileA
4173      0x77e885f4  KERNEL32!CreateFileA
4175      (gdb) info function !
4176      All functions matching regular expression "!":
4178      Non-debugging symbols:
4179      0x6100114c  cygwin1!__assert
4180      0x61004034  cygwin1!_dll_crt0@0
4181      0x61004240  cygwin1!dll_crt0(per_process *)
4182      [etc...]
4184 18.1.5.3 Working with minimal symbols
4185 .....................................
4187 Symbols extracted from a DLL's export table do not contain very much
4188 type information. All that GDB can do is guess whether a symbol refers
4189 to a function or variable depending on the linker section that contains
4190 the symbol. Also note that the actual contents of the memory contained
4191 in a DLL are not available unless the program is running. This means
4192 that you cannot examine the contents of a variable or disassemble a
4193 function within a DLL without a running program.
4195    Variables are generally treated as pointers and dereferenced
4196 automatically. For this reason, it is often necessary to prefix a
4197 variable name with the address-of operator ("&") and provide explicit
4198 type information in the command. Here's an example of the type of
4199 problem:
4201      (gdb) print 'cygwin1!__argv'
4202      $1 = 268572168
4204      (gdb) x 'cygwin1!__argv'
4205      0x10021610:      "\230y\""
4207    And two possible solutions:
4209      (gdb) print ((char **)'cygwin1!__argv')[0]
4210      $2 = 0x22fd98 "/cygdrive/c/mydirectory/myprogram"
4212      (gdb) x/2x &'cygwin1!__argv'
4213      0x610c0aa8 <cygwin1!__argv>:    0x10021608      0x00000000
4214      (gdb) x/x 0x10021608
4215      0x10021608:     0x0022fd98
4216      (gdb) x/s 0x0022fd98
4217      0x22fd98:        "/cygdrive/c/mydirectory/myprogram"
4219    Setting a break point within a DLL is possible even before the
4220 program starts execution. However, under these circumstances, GDB can't
4221 examine the initial instructions of the function in order to skip the
4222 function's frame set-up code. You can work around this by using "*&" to
4223 set the breakpoint at a raw memory address:
4225      (gdb) break *&'python22!PyOS_Readline'
4226      Breakpoint 1 at 0x1e04eff0
4228    The author of these extensions is not entirely convinced that
4229 setting a break point within a shared DLL like `kernel32.dll' is
4230 completely safe.
4232 \x1f
4233 File: gdb.info,  Node: Hurd Native,  Next: Neutrino,  Prev: Cygwin Native,  Up: Native
4235 18.1.6 Commands specific to GNU Hurd systems
4236 --------------------------------------------
4238 This subsection describes GDB commands specific to the GNU Hurd native
4239 debugging.
4241 `set signals'
4242 `set sigs'
4243      This command toggles the state of inferior signal interception by
4244      GDB.  Mach exceptions, such as breakpoint traps, are not affected
4245      by this command.  `sigs' is a shorthand alias for `signals'.
4247 `show signals'
4248 `show sigs'
4249      Show the current state of intercepting inferior's signals.
4251 `set signal-thread'
4252 `set sigthread'
4253      This command tells GDB which thread is the `libc' signal thread.
4254      That thread is run when a signal is delivered to a running
4255      process.  `set sigthread' is the shorthand alias of `set
4256      signal-thread'.
4258 `show signal-thread'
4259 `show sigthread'
4260      These two commands show which thread will run when the inferior is
4261      delivered a signal.
4263 `set stopped'
4264      This commands tells GDB that the inferior process is stopped, as
4265      with the `SIGSTOP' signal.  The stopped process can be continued
4266      by delivering a signal to it.
4268 `show stopped'
4269      This command shows whether GDB thinks the debuggee is stopped.
4271 `set exceptions'
4272      Use this command to turn off trapping of exceptions in the
4273      inferior.  When exception trapping is off, neither breakpoints nor
4274      single-stepping will work.  To restore the default, set exception
4275      trapping on.
4277 `show exceptions'
4278      Show the current state of trapping exceptions in the inferior.
4280 `set task pause'
4281      This command toggles task suspension when GDB has control.
4282      Setting it to on takes effect immediately, and the task is
4283      suspended whenever GDB gets control.  Setting it to off will take
4284      effect the next time the inferior is continued.  If this option is
4285      set to off, you can use `set thread default pause on' or `set
4286      thread pause on' (see below) to pause individual threads.
4288 `show task pause'
4289      Show the current state of task suspension.
4291 `set task detach-suspend-count'
4292      This command sets the suspend count the task will be left with when
4293      GDB detaches from it.
4295 `show task detach-suspend-count'
4296      Show the suspend count the task will be left with when detaching.
4298 `set task exception-port'
4299 `set task excp'
4300      This command sets the task exception port to which GDB will
4301      forward exceptions.  The argument should be the value of the "send
4302      rights" of the task.  `set task excp' is a shorthand alias.
4304 `set noninvasive'
4305      This command switches GDB to a mode that is the least invasive as
4306      far as interfering with the inferior is concerned.  This is the
4307      same as using `set task pause', `set exceptions', and `set
4308      signals' to values opposite to the defaults.
4310 `info send-rights'
4311 `info receive-rights'
4312 `info port-rights'
4313 `info port-sets'
4314 `info dead-names'
4315 `info ports'
4316 `info psets'
4317      These commands display information about, respectively, send
4318      rights, receive rights, port rights, port sets, and dead names of
4319      a task.  There are also shorthand aliases: `info ports' for `info
4320      port-rights' and `info psets' for `info port-sets'.
4322 `set thread pause'
4323      This command toggles current thread suspension when GDB has
4324      control.  Setting it to on takes effect immediately, and the
4325      current thread is suspended whenever GDB gets control.  Setting it
4326      to off will take effect the next time the inferior is continued.
4327      Normally, this command has no effect, since when GDB has control,
4328      the whole task is suspended.  However, if you used `set task pause
4329      off' (see above), this command comes in handy to suspend only the
4330      current thread.
4332 `show thread pause'
4333      This command shows the state of current thread suspension.
4335 `set thread run'
4336      This comamnd sets whether the current thread is allowed to run.
4338 `show thread run'
4339      Show whether the current thread is allowed to run.
4341 `set thread detach-suspend-count'
4342      This command sets the suspend count GDB will leave on a thread
4343      when detaching.  This number is relative to the suspend count
4344      found by GDB when it notices the thread; use `set thread
4345      takeover-suspend-count' to force it to an absolute value.
4347 `show thread detach-suspend-count'
4348      Show the suspend count GDB will leave on the thread when detaching.
4350 `set thread exception-port'
4351 `set thread excp'
4352      Set the thread exception port to which to forward exceptions.  This
4353      overrides the port set by `set task exception-port' (see above).
4354      `set thread excp' is the shorthand alias.
4356 `set thread takeover-suspend-count'
4357      Normally, GDB's thread suspend counts are relative to the value
4358      GDB finds when it notices each thread.  This command changes the
4359      suspend counts to be absolute instead.
4361 `set thread default'
4362 `show thread default'
4363      Each of the above `set thread' commands has a `set thread default'
4364      counterpart (e.g., `set thread default pause', `set thread default
4365      exception-port', etc.).  The `thread default' variety of commands
4366      sets the default thread properties for all threads; you can then
4367      change the properties of individual threads with the non-default
4368      commands.
4370 \x1f
4371 File: gdb.info,  Node: Neutrino,  Prev: Hurd Native,  Up: Native
4373 18.1.7 QNX Neutrino
4374 -------------------
4376 GDB provides the following commands specific to the QNX Neutrino target:
4378 `set debug nto-debug'
4379      When set to on, enables debugging messages specific to the QNX
4380      Neutrino support.
4382 `show debug nto-debug'
4383      Show the current state of QNX Neutrino messages.
4385 \x1f
4386 File: gdb.info,  Node: Embedded OS,  Next: Embedded Processors,  Prev: Native,  Up: Configurations
4388 18.2 Embedded Operating Systems
4389 ===============================
4391 This section describes configurations involving the debugging of
4392 embedded operating systems that are available for several different
4393 architectures.
4395 * Menu:
4397 * VxWorks::                     Using GDB with VxWorks
4399    GDB includes the ability to debug programs running on various
4400 real-time operating systems.
4402 \x1f
4403 File: gdb.info,  Node: VxWorks,  Up: Embedded OS
4405 18.2.1 Using GDB with VxWorks
4406 -----------------------------
4408 `target vxworks MACHINENAME'
4409      A VxWorks system, attached via TCP/IP.  The argument MACHINENAME
4410      is the target system's machine name or IP address.
4413    On VxWorks, `load' links FILENAME dynamically on the current target
4414 system as well as adding its symbols in GDB.
4416    GDB enables developers to spawn and debug tasks running on networked
4417 VxWorks targets from a Unix host.  Already-running tasks spawned from
4418 the VxWorks shell can also be debugged.  GDB uses code that runs on
4419 both the Unix host and on the VxWorks target.  The program `gdb' is
4420 installed and executed on the Unix host.  (It may be installed with the
4421 name `vxgdb', to distinguish it from a GDB for debugging programs on
4422 the host itself.)
4424 `VxWorks-timeout ARGS'
4425      All VxWorks-based targets now support the option `vxworks-timeout'.
4426      This option is set by the user, and  ARGS represents the number of
4427      seconds GDB waits for responses to rpc's.  You might use this if
4428      your VxWorks target is a slow software simulator or is on the far
4429      side of a thin network line.
4431    The following information on connecting to VxWorks was current when
4432 this manual was produced; newer releases of VxWorks may use revised
4433 procedures.
4435    To use GDB with VxWorks, you must rebuild your VxWorks kernel to
4436 include the remote debugging interface routines in the VxWorks library
4437 `rdb.a'.  To do this, define `INCLUDE_RDB' in the VxWorks configuration
4438 file `configAll.h' and rebuild your VxWorks kernel.  The resulting
4439 kernel contains `rdb.a', and spawns the source debugging task
4440 `tRdbTask' when VxWorks is booted.  For more information on configuring
4441 and remaking VxWorks, see the manufacturer's manual.
4443    Once you have included `rdb.a' in your VxWorks system image and set
4444 your Unix execution search path to find GDB, you are ready to run GDB.
4445 From your Unix host, run `gdb' (or `vxgdb', depending on your
4446 installation).
4448    GDB comes up showing the prompt:
4450      (vxgdb)
4452 * Menu:
4454 * VxWorks Connection::          Connecting to VxWorks
4455 * VxWorks Download::            VxWorks download
4456 * VxWorks Attach::              Running tasks
4458 \x1f
4459 File: gdb.info,  Node: VxWorks Connection,  Next: VxWorks Download,  Up: VxWorks
4461 18.2.1.1 Connecting to VxWorks
4462 ..............................
4464 The GDB command `target' lets you connect to a VxWorks target on the
4465 network.  To connect to a target whose host name is "`tt'", type:
4467      (vxgdb) target vxworks tt
4469    GDB displays messages like these:
4471      Attaching remote machine across net...
4472      Connected to tt.
4474    GDB then attempts to read the symbol tables of any object modules
4475 loaded into the VxWorks target since it was last booted.  GDB locates
4476 these files by searching the directories listed in the command search
4477 path (*note Your program's environment: Environment.); if it fails to
4478 find an object file, it displays a message such as:
4480      prog.o: No such file or directory.
4482    When this happens, add the appropriate directory to the search path
4483 with the GDB command `path', and execute the `target' command again.
4485 \x1f
4486 File: gdb.info,  Node: VxWorks Download,  Next: VxWorks Attach,  Prev: VxWorks Connection,  Up: VxWorks
4488 18.2.1.2 VxWorks download
4489 .........................
4491 If you have connected to the VxWorks target and you want to debug an
4492 object that has not yet been loaded, you can use the GDB `load' command
4493 to download a file from Unix to VxWorks incrementally.  The object file
4494 given as an argument to the `load' command is actually opened twice:
4495 first by the VxWorks target in order to download the code, then by GDB
4496 in order to read the symbol table.  This can lead to problems if the
4497 current working directories on the two systems differ.  If both systems
4498 have NFS mounted the same filesystems, you can avoid these problems by
4499 using absolute paths.  Otherwise, it is simplest to set the working
4500 directory on both systems to the directory in which the object file
4501 resides, and then to reference the file by its name, without any path.
4502 For instance, a program `prog.o' may reside in `VXPATH/vw/demo/rdb' in
4503 VxWorks and in `HOSTPATH/vw/demo/rdb' on the host.  To load this
4504 program, type this on VxWorks:
4506      -> cd "VXPATH/vw/demo/rdb"
4508 Then, in GDB, type:
4510      (vxgdb) cd HOSTPATH/vw/demo/rdb
4511      (vxgdb) load prog.o
4513    GDB displays a response similar to this:
4515      Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
4517    You can also use the `load' command to reload an object module after
4518 editing and recompiling the corresponding source file.  Note that this
4519 makes GDB delete all currently-defined breakpoints, auto-displays, and
4520 convenience variables, and to clear the value history.  (This is
4521 necessary in order to preserve the integrity of debugger's data
4522 structures that reference the target system's symbol table.)
4524 \x1f
4525 File: gdb.info,  Node: VxWorks Attach,  Prev: VxWorks Download,  Up: VxWorks
4527 18.2.1.3 Running tasks
4528 ......................
4530 You can also attach to an existing task using the `attach' command as
4531 follows:
4533      (vxgdb) attach TASK
4535 where TASK is the VxWorks hexadecimal task ID.  The task can be running
4536 or suspended when you attach to it.  Running tasks are suspended at the
4537 time of attachment.
4539 \x1f
4540 File: gdb.info,  Node: Embedded Processors,  Next: Architectures,  Prev: Embedded OS,  Up: Configurations
4542 18.3 Embedded Processors
4543 ========================
4545 This section goes into details specific to particular embedded
4546 configurations.
4548    Whenever a specific embedded processor has a simulator, GDB allows
4549 to send an arbitrary command to the simulator.
4551 `sim COMMAND'
4552      Send an arbitrary COMMAND string to the simulator.  Consult the
4553      documentation for the specific simulator in use for information
4554      about acceptable commands.
4556 * Menu:
4558 * ARM::                         ARM RDI
4559 * H8/300::                      Renesas H8/300
4560 * H8/500::                      Renesas H8/500
4561 * M32R/D::                      Renesas M32R/D
4562 * M68K::                        Motorola M68K
4563 * MIPS Embedded::               MIPS Embedded
4564 * OpenRISC 1000::               OpenRisc 1000
4565 * PA::                          HP PA Embedded
4566 * PowerPC:                      PowerPC
4567 * SH::                          Renesas SH
4568 * Sparclet::                    Tsqware Sparclet
4569 * Sparclite::                   Fujitsu Sparclite
4570 * ST2000::                      Tandem ST2000
4571 * Z8000::                       Zilog Z8000
4572 * AVR::                         Atmel AVR
4573 * CRIS::                        CRIS
4574 * Super-H::                     Renesas Super-H
4575 * WinCE::                       Windows CE child processes
4577 \x1f
4578 File: gdb.info,  Node: ARM,  Next: H8/300,  Up: Embedded Processors
4580 18.3.1 ARM
4581 ----------
4583 `target rdi DEV'
4584      ARM Angel monitor, via RDI library interface to ADP protocol.  You
4585      may use this target to communicate with both boards running the
4586      Angel monitor, or with the EmbeddedICE JTAG debug device.
4588 `target rdp DEV'
4589      ARM Demon monitor.
4592    GDB provides the following ARM-specific commands:
4594 `set arm disassembler'
4595      This commands selects from a list of disassembly styles.  The
4596      `"std"' style is the standard style.
4598 `show arm disassembler'
4599      Show the current disassembly style.
4601 `set arm apcs32'
4602      This command toggles ARM operation mode between 32-bit and 26-bit.
4604 `show arm apcs32'
4605      Display the current usage of the ARM 32-bit mode.
4607 `set arm fpu FPUTYPE'
4608      This command sets the ARM floating-point unit (FPU) type.  The
4609      argument FPUTYPE can be one of these:
4611     `auto'
4612           Determine the FPU type by querying the OS ABI.
4614     `softfpa'
4615           Software FPU, with mixed-endian doubles on little-endian ARM
4616           processors.
4618     `fpa'
4619           GCC-compiled FPA co-processor.
4621     `softvfp'
4622           Software FPU with pure-endian doubles.
4624     `vfp'
4625           VFP co-processor.
4627 `show arm fpu'
4628      Show the current type of the FPU.
4630 `set arm abi'
4631      This command forces GDB to use the specified ABI.
4633 `show arm abi'
4634      Show the currently used ABI.
4636 `set debug arm'
4637      Toggle whether to display ARM-specific debugging messages from the
4638      ARM target support subsystem.
4640 `show debug arm'
4641      Show whether ARM-specific debugging messages are enabled.
4643    The following commands are available when an ARM target is debugged
4644 using the RDI interface:
4646 `rdilogfile [FILE]'
4647      Set the filename for the ADP (Angel Debugger Protocol) packet log.
4648      With an argument, sets the log file to the specified FILE.  With
4649      no argument, show the current log file name.  The default log file
4650      is `rdi.log'.
4652 `rdilogenable [ARG]'
4653      Control logging of ADP packets.  With an argument of 1 or `"yes"'
4654      enables logging, with an argument 0 or `"no"' disables it.  With
4655      no arguments displays the current setting.  When logging is
4656      enabled, ADP packets exchanged between GDB and the RDI target
4657      device are logged to a file.
4659 `set rdiromatzero'
4660      Tell GDB whether the target has ROM at address 0.  If on, vector
4661      catching is disabled, so that zero address can be used.  If off
4662      (the default), vector catching is enabled.  For this command to
4663      take effect, it needs to be invoked prior to the `target rdi'
4664      command.
4666 `show rdiromatzero'
4667      Show the current setting of ROM at zero address.
4669 `set rdiheartbeat'
4670      Enable or disable RDI heartbeat packets.  It is not recommended to
4671      turn on this option, since it confuses ARM and EPI JTAG interface,
4672      as well as the Angel monitor.
4674 `show rdiheartbeat'
4675      Show the setting of RDI heartbeat packets.
4677 \x1f
4678 File: gdb.info,  Node: H8/300,  Next: H8/500,  Prev: ARM,  Up: Embedded Processors
4680 18.3.2 Renesas H8/300
4681 ---------------------
4683 `target hms DEV'
4684      A Renesas SH, H8/300, or H8/500 board, attached via serial line to
4685      your host.  Use special commands `device' and `speed' to control
4686      the serial line and the communications speed used.
4688 `target e7000 DEV'
4689      E7000 emulator for Renesas H8 and SH.
4691 `target sh3 DEV'
4692 `target sh3e DEV'
4693      Renesas SH-3 and SH-3E target systems.
4696    When you select remote debugging to a Renesas SH, H8/300, or H8/500
4697 board, the `load' command downloads your program to the Renesas board
4698 and also opens it as the current executable target for GDB on your host
4699 (like the `file' command).
4701    GDB needs to know these things to talk to your Renesas SH, H8/300,
4702 or H8/500:
4704   1. that you want to use `target hms', the remote debugging interface
4705      for Renesas microprocessors, or `target e7000', the in-circuit
4706      emulator for the Renesas SH and the Renesas 300H.  (`target hms' is
4707      the default when GDB is configured specifically for the Renesas SH,
4708      H8/300, or H8/500.)
4710   2. what serial device connects your host to your Renesas board (the
4711      first serial device available on your host is the default).
4713   3. what speed to use over the serial device.
4715 * Menu:
4717 * Renesas Boards::      Connecting to Renesas boards.
4718 * Renesas ICE::         Using the E7000 In-Circuit Emulator.
4719 * Renesas Special::     Special GDB commands for Renesas micros.
4721 \x1f
4722 File: gdb.info,  Node: Renesas Boards,  Next: Renesas ICE,  Up: H8/300
4724 18.3.2.1 Connecting to Renesas boards
4725 .....................................
4727 Use the special `GDB' command `device PORT' if you need to explicitly
4728 set the serial device.  The default PORT is the first available port on
4729 your host.  This is only necessary on Unix hosts, where it is typically
4730 something like `/dev/ttya'.
4732    `GDB' has another special command to set the communications speed:
4733 `speed BPS'.  This command also is only used from Unix hosts; on DOS
4734 hosts, set the line speed as usual from outside GDB with the DOS `mode'
4735 command (for instance, `mode com2:9600,n,8,1,p' for a 9600bps
4736 connection).
4738    The `device' and `speed' commands are available only when you use a
4739 Unix host to debug your Renesas microprocessor programs.  If you use a
4740 DOS host, GDB depends on an auxiliary terminate-and-stay-resident
4741 program called `asynctsr' to communicate with the development board
4742 through a PC serial port.  You must also use the DOS `mode' command to
4743 set up the serial port on the DOS side.
4745    The following sample session illustrates the steps needed to start a
4746 program under GDB control on an H8/300.  The example uses a sample
4747 H8/300 program called `t.x'.  The procedure is the same for the Renesas
4748 SH and the H8/500.
4750    First hook up your development board.  In this example, we use a
4751 board attached to serial port `COM2'; if you use a different serial
4752 port, substitute its name in the argument of the `mode' command.  When
4753 you call `asynctsr', the auxiliary comms program used by the debugger,
4754 you give it just the numeric part of the serial port's name; for
4755 example, `asyncstr 2' below runs `asyncstr' on `COM2'.
4757      C:\H8300\TEST> asynctsr 2
4758      C:\H8300\TEST> mode com2:9600,n,8,1,p
4760      Resident portion of MODE loaded
4762      COM2: 9600, n, 8, 1, p
4764      _Warning:_ We have noticed a bug in PC-NFS that conflicts with
4765      `asynctsr'.  If you also run PC-NFS on your DOS host, you may need
4766      to disable it, or even boot without it, to use `asynctsr' to
4767      control your development board.
4769    Now that serial communications are set up, and the development board
4770 is connected, you can start up GDB.  Call `GDB' with the name of your
4771 program as the argument.  `GDB' prompts you, as usual, with the prompt
4772 `(gdb)'.  Use two special commands to begin your debugging session:
4773 `target hms' to specify cross-debugging to the Renesas board, and the
4774 `load' command to download your program to the board.  `load' displays
4775 the names of the program's sections, and a `*' for each 2K of data
4776 downloaded.  (If you want to refresh GDB data on symbols or on the
4777 executable file without downloading, use the GDB commands `file' or
4778 `symbol-file'.  These commands, and `load' itself, are described in
4779 *Note Commands to specify files: Files.)
4781      (eg-C:\H8300\TEST) gdb t.x
4782      GDB is free software and you are welcome to distribute copies
4783       of it under certain conditions; type "show copying" to see
4784       the conditions.
4785      There is absolutely no warranty for GDB; type "show warranty"
4786      for details.
4787      GDB 6.5, Copyright 1992 Free Software Foundation, Inc...
4788      (gdb) target hms
4789      Connected to remote H8/300 HMS system.
4790      (gdb) load t.x
4791      .text   : 0x8000 .. 0xabde ***********
4792      .data   : 0xabde .. 0xad30 *
4793      .stack  : 0xf000 .. 0xf014 *
4795    At this point, you're ready to run or debug your program.  From here
4796 on, you can use all the usual GDB commands.  The `break' command sets
4797 breakpoints; the `run' command starts your program; `print' or `x'
4798 display data; the `continue' command resumes execution after stopping
4799 at a breakpoint.  You can use the `help' command at any time to find
4800 out more about GDB commands.
4802    Remember, however, that _operating system_ facilities aren't
4803 available on your development board; for example, if your program hangs,
4804 you can't send an interrupt--but you can press the RESET switch!
4806    Use the RESET button on the development board
4807    * to interrupt your program (don't use `ctl-C' on the DOS host--it
4808      has no way to pass an interrupt signal to the development board);
4809      and
4811    * to return to the GDB command prompt after your program finishes
4812      normally.  The communications protocol provides no other way for
4813      GDB to detect program completion.
4815    In either case, GDB sees the effect of a RESET on the development
4816 board as a "normal exit" of your program.
4818 \x1f
4819 File: gdb.info,  Node: Renesas ICE,  Next: Renesas Special,  Prev: Renesas Boards,  Up: H8/300
4821 18.3.2.2 Using the E7000 in-circuit emulator
4822 ............................................
4824 You can use the E7000 in-circuit emulator to develop code for either the
4825 Renesas SH or the H8/300H.  Use one of these forms of the `target
4826 e7000' command to connect GDB to your E7000:
4828 `target e7000 PORT SPEED'
4829      Use this form if your E7000 is connected to a serial port.  The
4830      PORT argument identifies what serial port to use (for example,
4831      `com2').  The third argument is the line speed in bits per second
4832      (for example, `9600').
4834 `target e7000 HOSTNAME'
4835      If your E7000 is installed as a host on a TCP/IP network, you can
4836      just specify its hostname; GDB uses `telnet' to connect.
4838    The following special commands are available when debugging with the
4839 Renesas E7000 ICE:
4841 `e7000 COMMAND'
4842      This sends the specified COMMAND to the E7000 monitor.
4844 `ftplogin MACHINE USERNAME PASSWORD DIR'
4845      This command records information for subsequent interface with the
4846      E7000 monitor via the FTP protocol: GDB will log into the named
4847      MACHINE using specified USERNAME and PASSWORD, and then chdir to
4848      the named directory DIR.
4850 `ftpload FILE'
4851      This command uses credentials recorded by `ftplogin' to fetch and
4852      load the named FILE from the E7000 monitor.
4854 `drain'
4855      This command drains any pending text buffers stored on the E7000.
4857 `set usehardbreakpoints'
4858 `show usehardbreakpoints'
4859      These commands set and show the use of hardware breakpoints for all
4860      breakpoints.  *Note hardware-assisted breakpoint: Set Breaks, for
4861      more information about using hardware breakpoints selectively.
4863 \x1f
4864 File: gdb.info,  Node: Renesas Special,  Prev: Renesas ICE,  Up: H8/300
4866 18.3.2.3 Special GDB commands for Renesas micros
4867 ................................................
4869 Some GDB commands are available only for the H8/300:
4871 `set machine h8300'
4872 `set machine h8300h'
4873      Condition GDB for one of the two variants of the H8/300
4874      architecture with `set machine'.  You can use `show machine' to
4875      check which variant is currently in effect.
4878 \x1f
4879 File: gdb.info,  Node: H8/500,  Next: M32R/D,  Prev: H8/300,  Up: Embedded Processors
4881 18.3.3 H8/500
4882 -------------
4884 `set memory MOD'
4885 `show memory'
4886      Specify which H8/500 memory model (MOD) you are using with `set
4887      memory'; check which memory model is in effect with `show memory'.
4888      The accepted values for MOD are `small', `big', `medium', and
4889      `compact'.
4892 \x1f
4893 File: gdb.info,  Node: M32R/D,  Next: M68K,  Prev: H8/500,  Up: Embedded Processors
4895 18.3.4 Renesas M32R/D and M32R/SDI
4896 ----------------------------------
4898 `target m32r DEV'
4899      Renesas M32R/D ROM monitor.
4901 `target m32rsdi DEV'
4902      Renesas M32R SDI server, connected via parallel port to the board.
4904    The following GDB commands are specific to the M32R monitor:
4906 `set download-path PATH'
4907      Set the default path for finding donwloadable SREC files.
4909 `show download-path'
4910      Show the default path for downloadable SREC files.
4912 `set board-address ADDR'
4913      Set the IP address for the M32R-EVA target board.
4915 `show board-address'
4916      Show the current IP address of the target board.
4918 `set server-address ADDR'
4919      Set the IP address for the download server, which is the GDB's
4920      host machine.
4922 `show server-address'
4923      Display the IP address of the download server.
4925 `upload [FILE]'
4926      Upload the specified SREC FILE via the monitor's Ethernet upload
4927      capability.  If no FILE argument is given, the current executable
4928      file is uploaded.
4930 `tload [FILE]'
4931      Test the `upload' command.
4933    The following commands are available for M32R/SDI:
4935 `sdireset'
4936      This command resets the SDI connection.
4938 `sdistatus'
4939      This command shows the SDI connection status.
4941 `debug_chaos'
4942      Instructs the remote that M32R/Chaos debugging is to be used.
4944 `use_debug_dma'
4945      Instructs the remote to use the DEBUG_DMA method of accessing
4946      memory.
4948 `use_mon_code'
4949      Instructs the remote to use the MON_CODE method of accessing
4950      memory.
4952 `use_ib_break'
4953      Instructs the remote to set breakpoints by IB break.
4955 `use_dbt_break'
4956      Instructs the remote to set breakpoints by DBT.
4958 \x1f
4959 File: gdb.info,  Node: M68K,  Next: MIPS Embedded,  Prev: M32R/D,  Up: Embedded Processors
4961 18.3.5 M68k
4962 -----------
4964 The Motorola m68k configuration includes ColdFire support, and target
4965 command for the following ROM monitors.
4967 `target abug DEV'
4968      ABug ROM monitor for M68K.
4970 `target cpu32bug DEV'
4971      CPU32BUG monitor, running on a CPU32 (M68K) board.
4973 `target dbug DEV'
4974      dBUG ROM monitor for Motorola ColdFire.
4976 `target est DEV'
4977      EST-300 ICE monitor, running on a CPU32 (M68K) board.
4979 `target rom68k DEV'
4980      ROM 68K monitor, running on an M68K IDP board.
4983 `target rombug DEV'
4984      ROMBUG ROM monitor for OS/9000.
4987 \x1f
4988 File: gdb.info,  Node: MIPS Embedded,  Next: OpenRISC 1000,  Prev: M68K,  Up: Embedded Processors
4990 18.3.6 MIPS Embedded
4991 --------------------
4993 GDB can use the MIPS remote debugging protocol to talk to a MIPS board
4994 attached to a serial line.  This is available when you configure GDB
4995 with `--target=mips-idt-ecoff'.
4997    Use these GDB commands to specify the connection to your target
4998 board:
5000 `target mips PORT'
5001      To run a program on the board, start up `gdb' with the name of
5002      your program as the argument.  To connect to the board, use the
5003      command `target mips PORT', where PORT is the name of the serial
5004      port connected to the board.  If the program has not already been
5005      downloaded to the board, you may use the `load' command to
5006      download it.  You can then use all the usual GDB commands.
5008      For example, this sequence connects to the target board through a
5009      serial port, and loads and runs a program called PROG through the
5010      debugger:
5012           host$ gdb PROG
5013           GDB is free software and ...
5014           (gdb) target mips /dev/ttyb
5015           (gdb) load PROG
5016           (gdb) run
5018 `target mips HOSTNAME:PORTNUMBER'
5019      On some GDB host configurations, you can specify a TCP connection
5020      (for instance, to a serial line managed by a terminal
5021      concentrator) instead of a serial port, using the syntax
5022      `HOSTNAME:PORTNUMBER'.
5024 `target pmon PORT'
5025      PMON ROM monitor.
5027 `target ddb PORT'
5028      NEC's DDB variant of PMON for Vr4300.
5030 `target lsi PORT'
5031      LSI variant of PMON.
5033 `target r3900 DEV'
5034      Densan DVE-R3900 ROM monitor for Toshiba R3900 Mips.
5036 `target array DEV'
5037      Array Tech LSI33K RAID controller board.
5040 GDB also supports these special commands for MIPS targets:
5042 `set mipsfpu double'
5043 `set mipsfpu single'
5044 `set mipsfpu none'
5045 `set mipsfpu auto'
5046 `show mipsfpu'
5047      If your target board does not support the MIPS floating point
5048      coprocessor, you should use the command `set mipsfpu none' (if you
5049      need this, you may wish to put the command in your GDB init file).
5050      This tells GDB how to find the return value of functions which
5051      return floating point values.  It also allows GDB to avoid saving
5052      the floating point registers when calling functions on the board.
5053      If you are using a floating point coprocessor with only single
5054      precision floating point support, as on the R4650 processor, use
5055      the command `set mipsfpu single'.  The default double precision
5056      floating point coprocessor may be selected using `set mipsfpu
5057      double'.
5059      In previous versions the only choices were double precision or no
5060      floating point, so `set mipsfpu on' will select double precision
5061      and `set mipsfpu off' will select no floating point.
5063      As usual, you can inquire about the `mipsfpu' variable with `show
5064      mipsfpu'.
5066 `set timeout SECONDS'
5067 `set retransmit-timeout SECONDS'
5068 `show timeout'
5069 `show retransmit-timeout'
5070      You can control the timeout used while waiting for a packet, in
5071      the MIPS remote protocol, with the `set timeout SECONDS' command.
5072      The default is 5 seconds.  Similarly, you can control the timeout
5073      used while waiting for an acknowledgement of a packet with the `set
5074      retransmit-timeout SECONDS' command.  The default is 3 seconds.
5075      You can inspect both values with `show timeout' and `show
5076      retransmit-timeout'.  (These commands are _only_ available when
5077      GDB is configured for `--target=mips-idt-ecoff'.)
5079      The timeout set by `set timeout' does not apply when GDB is
5080      waiting for your program to stop.  In that case, GDB waits forever
5081      because it has no way of knowing how long the program is going to
5082      run before stopping.
5084 `set syn-garbage-limit NUM'
5085      Limit the maximum number of characters GDB should ignore when it
5086      tries to synchronize with the remote target.  The default is 10
5087      characters.  Setting the limit to -1 means there's no limit.
5089 `show syn-garbage-limit'
5090      Show the current limit on the number of characters to ignore when
5091      trying to synchronize with the remote system.
5093 `set monitor-prompt PROMPT'
5094      Tell GDB to expect the specified PROMPT string from the remote
5095      monitor.  The default depends on the target:
5096     pmon target
5097           `PMON'
5099     ddb target
5100           `NEC010'
5102     lsi target
5103           `PMON>'
5105 `show monitor-prompt'
5106      Show the current strings GDB expects as the prompt from the remote
5107      monitor.
5109 `set monitor-warnings'
5110      Enable or disable monitor warnings about hardware breakpoints.
5111      This has effect only for the `lsi' target.  When on, GDB will
5112      display warning messages whose codes are returned by the `lsi'
5113      PMON monitor for breakpoint commands.
5115 `show monitor-warnings'
5116      Show the current setting of printing monitor warnings.
5118 `pmon COMMAND'
5119      This command allows sending an arbitrary COMMAND string to the
5120      monitor.  The monitor must be in debug mode for this to work.
5122 \x1f
5123 File: gdb.info,  Node: OpenRISC 1000,  Next: PA,  Prev: MIPS Embedded,  Up: Embedded Processors
5125 18.3.7 OpenRISC 1000
5126 --------------------
5128 See OR1k Architecture document (`www.opencores.org') for more
5129 information about platform and commands.
5131 `target jtag jtag://HOST:PORT'
5132      Connects to remote JTAG server.  JTAG remote server can be either
5133      an or1ksim or JTAG server, connected via parallel port to the
5134      board.
5136      Example: `target jtag jtag://localhost:9999'
5138 `or1ksim COMMAND'
5139      If connected to `or1ksim' OpenRISC 1000 Architectural Simulator,
5140      proprietary commands can be executed.
5142 `info or1k spr'
5143      Displays spr groups.
5145 `info or1k spr GROUP'
5146 `info or1k spr GROUPNO'
5147      Displays register names in selected group.
5149 `info or1k spr GROUP REGISTER'
5150 `info or1k spr REGISTER'
5151 `info or1k spr GROUPNO REGISTERNO'
5152 `info or1k spr REGISTERNO'
5153      Shows information about specified spr register.
5155 `spr GROUP REGISTER VALUE'
5156 `spr REGISTER VALUE'
5157 `spr GROUPNO REGISTERNO VALUE'
5158 `spr REGISTERNO VALUE'
5159      Writes VALUE to specified spr register.
5161    Some implementations of OpenRISC 1000 Architecture also have
5162 hardware trace.  It is very similar to GDB trace, except it does not
5163 interfere with normal program execution and is thus much faster.
5164 Hardware breakpoints/watchpoint triggers can be set using:
5165 `$LEA/$LDATA'
5166      Load effective address/data
5168 `$SEA/$SDATA'
5169      Store effective address/data
5171 `$AEA/$ADATA'
5172      Access effective address ($SEA or $LEA) or data ($SDATA/$LDATA)
5174 `$FETCH'
5175      Fetch data
5177    When triggered, it can capture low level data, like: `PC', `LSEA',
5178 `LDATA', `SDATA', `READSPR', `WRITESPR', `INSTR'.
5180    `htrace' commands: 
5181 `hwatch CONDITIONAL'
5182      Set hardware watchpoint on combination of Load/Store Effecive
5183      Address(es) or Data.  For example:
5185      `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
5186      ($SDATA >= 50)'
5188      `hwatch ($LEA == my_var) && ($LDATA < 50) || ($SEA == my_var) &&
5189      ($SDATA >= 50)'
5191 `htrace info'
5192      Display information about current HW trace configuration.
5194 `htrace trigger CONDITIONAL'
5195      Set starting criteria for HW trace.
5197 `htrace qualifier CONDITIONAL'
5198      Set acquisition qualifier for HW trace.
5200 `htrace stop CONDITIONAL'
5201      Set HW trace stopping criteria.
5203 `htrace record [DATA]*'
5204      Selects the data to be recorded, when qualifier is met and HW
5205      trace was triggered.
5207 `htrace enable'
5208 `htrace disable'
5209      Enables/disables the HW trace.
5211 `htrace rewind [FILENAME]'
5212      Clears currently recorded trace data.
5214      If filename is specified, new trace file is made and any newly
5215      collected data will be written there.
5217 `htrace print [START [LEN]]'
5218      Prints trace buffer, using current record configuration.
5220 `htrace mode continuous'
5221      Set continuous trace mode.
5223 `htrace mode suspend'
5224      Set suspend trace mode.
5227 \x1f
5228 File: gdb.info,  Node: PowerPC,  Next: SH,  Prev: PA,  Up: Embedded Processors
5230 18.3.8 PowerPC
5231 --------------
5233 `target dink32 DEV'
5234      DINK32 ROM monitor.
5236 `target ppcbug DEV'
5238 `target ppcbug1 DEV'
5239      PPCBUG ROM monitor for PowerPC.
5241 `target sds DEV'
5242      SDS monitor, running on a PowerPC board (such as Motorola's ADS).
5244    The following commands specifi to the SDS protocol are supported
5245 byGDB:
5247 `set sdstimeout NSEC'
5248      Set the timeout for SDS protocol reads to be NSEC seconds.  The
5249      default is 2 seconds.
5251 `show sdstimeout'
5252      Show the current value of the SDS timeout.
5254 `sds COMMAND'
5255      Send the specified COMMAND string to the SDS monitor.
5257 \x1f
5258 File: gdb.info,  Node: PA,  Next: PowerPC,  Prev: OpenRISC 1000,  Up: Embedded Processors
5260 18.3.9 HP PA Embedded
5261 ---------------------
5263 `target op50n DEV'
5264      OP50N monitor, running on an OKI HPPA board.
5266 `target w89k DEV'
5267      W89K monitor, running on a Winbond HPPA board.
5270 \x1f
5271 File: gdb.info,  Node: SH,  Next: Sparclet,  Prev: PowerPC,  Up: Embedded Processors
5273 18.3.10 Renesas SH
5274 ------------------
5276 `target hms DEV'
5277      A Renesas SH board attached via serial line to your host.  Use
5278      special commands `device' and `speed' to control the serial line
5279      and the communications speed used.
5281 `target e7000 DEV'
5282      E7000 emulator for Renesas SH.
5284 `target sh3 DEV'
5286 `target sh3e DEV'
5287      Renesas SH-3 and SH-3E target systems.
5290 \x1f
5291 File: gdb.info,  Node: Sparclet,  Next: Sparclite,  Prev: SH,  Up: Embedded Processors
5293 18.3.11 Tsqware Sparclet
5294 ------------------------
5296 GDB enables developers to debug tasks running on Sparclet targets from
5297 a Unix host.  GDB uses code that runs on both the Unix host and on the
5298 Sparclet target.  The program `gdb' is installed and executed on the
5299 Unix host.
5301 `remotetimeout ARGS'
5302      GDB supports the option `remotetimeout'.  This option is set by
5303      the user, and  ARGS represents the number of seconds GDB waits for
5304      responses.
5306    When compiling for debugging, include the options `-g' to get debug
5307 information and `-Ttext' to relocate the program to where you wish to
5308 load it on the target.  You may also want to add the options `-n' or
5309 `-N' in order to reduce the size of the sections.  Example:
5311      sparclet-aout-gcc prog.c -Ttext 0x12010000 -g -o prog -N
5313    You can use `objdump' to verify that the addresses are what you
5314 intended:
5316      sparclet-aout-objdump --headers --syms prog
5318    Once you have set your Unix execution search path to find GDB, you
5319 are ready to run GDB.  From your Unix host, run `gdb' (or
5320 `sparclet-aout-gdb', depending on your installation).
5322    GDB comes up showing the prompt:
5324      (gdbslet)
5326 * Menu:
5328 * Sparclet File::                Setting the file to debug
5329 * Sparclet Connection::          Connecting to Sparclet
5330 * Sparclet Download::            Sparclet download
5331 * Sparclet Execution::           Running and debugging
5333 \x1f
5334 File: gdb.info,  Node: Sparclet File,  Next: Sparclet Connection,  Up: Sparclet
5336 18.3.11.1 Setting file to debug
5337 ...............................
5339 The GDB command `file' lets you choose with program to debug.
5341      (gdbslet) file prog
5343    GDB then attempts to read the symbol table of `prog'.  GDB locates
5344 the file by searching the directories listed in the command search path.
5345 If the file was compiled with debug information (option "-g"), source
5346 files will be searched as well.  GDB locates the source files by
5347 searching the directories listed in the directory search path (*note
5348 Your program's environment: Environment.).  If it fails to find a file,
5349 it displays a message such as:
5351      prog: No such file or directory.
5353    When this happens, add the appropriate directories to the search
5354 paths with the GDB commands `path' and `dir', and execute the `target'
5355 command again.
5357 \x1f
5358 File: gdb.info,  Node: Sparclet Connection,  Next: Sparclet Download,  Prev: Sparclet File,  Up: Sparclet
5360 18.3.11.2 Connecting to Sparclet
5361 ................................
5363 The GDB command `target' lets you connect to a Sparclet target.  To
5364 connect to a target on serial port "`ttya'", type:
5366      (gdbslet) target sparclet /dev/ttya
5367      Remote target sparclet connected to /dev/ttya
5368      main () at ../prog.c:3
5370    GDB displays messages like these:
5372      Connected to ttya.
5374 \x1f
5375 File: gdb.info,  Node: Sparclet Download,  Next: Sparclet Execution,  Prev: Sparclet Connection,  Up: Sparclet
5377 18.3.11.3 Sparclet download
5378 ...........................
5380 Once connected to the Sparclet target, you can use the GDB `load'
5381 command to download the file from the host to the target.  The file
5382 name and load offset should be given as arguments to the `load' command.
5383 Since the file format is aout, the program must be loaded to the
5384 starting address.  You can use `objdump' to find out what this value
5385 is.  The load offset is an offset which is added to the VMA (virtual
5386 memory address) of each of the file's sections.  For instance, if the
5387 program `prog' was linked to text address 0x1201000, with data at
5388 0x12010160 and bss at 0x12010170, in GDB, type:
5390      (gdbslet) load prog 0x12010000
5391      Loading section .text, size 0xdb0 vma 0x12010000
5393    If the code is loaded at a different address then what the program
5394 was linked to, you may need to use the `section' and `add-symbol-file'
5395 commands to tell GDB where to map the symbol table.
5397 \x1f
5398 File: gdb.info,  Node: Sparclet Execution,  Prev: Sparclet Download,  Up: Sparclet
5400 18.3.11.4 Running and debugging
5401 ...............................
5403 You can now begin debugging the task using GDB's execution control
5404 commands, `b', `step', `run', etc.  See the GDB manual for the list of
5405 commands.
5407      (gdbslet) b main
5408      Breakpoint 1 at 0x12010000: file prog.c, line 3.
5409      (gdbslet) run
5410      Starting program: prog
5411      Breakpoint 1, main (argc=1, argv=0xeffff21c) at prog.c:3
5412      3        char *symarg = 0;
5413      (gdbslet) step
5414      4        char *execarg = "hello!";
5415      (gdbslet)
5417 \x1f
5418 File: gdb.info,  Node: Sparclite,  Next: ST2000,  Prev: Sparclet,  Up: Embedded Processors
5420 18.3.12 Fujitsu Sparclite
5421 -------------------------
5423 `target sparclite DEV'
5424      Fujitsu sparclite boards, used only for the purpose of loading.
5425      You must use an additional command to debug the program.  For
5426      example: target remote DEV using GDB standard remote protocol.
5429 \x1f
5430 File: gdb.info,  Node: ST2000,  Next: Z8000,  Prev: Sparclite,  Up: Embedded Processors
5432 18.3.13 Tandem ST2000
5433 ---------------------
5435 GDB may be used with a Tandem ST2000 phone switch, running Tandem's
5436 STDBUG protocol.
5438    To connect your ST2000 to the host system, see the manufacturer's
5439 manual.  Once the ST2000 is physically attached, you can run:
5441      target st2000 DEV SPEED
5443 to establish it as your debugging environment.  DEV is normally the
5444 name of a serial device, such as `/dev/ttya', connected to the ST2000
5445 via a serial line.  You can instead specify DEV as a TCP connection
5446 (for example, to a serial line attached via a terminal concentrator)
5447 using the syntax `HOSTNAME:PORTNUMBER'.
5449    The `load' and `attach' commands are _not_ defined for this target;
5450 you must load your program into the ST2000 as you normally would for
5451 standalone operation.  GDB reads debugging information (such as
5452 symbols) from a separate, debugging version of the program available on
5453 your host computer.
5455    These auxiliary GDB commands are available to help you with the
5456 ST2000 environment:
5458 `st2000 COMMAND'
5459      Send a COMMAND to the STDBUG monitor.  See the manufacturer's
5460      manual for available commands.
5462 `connect'
5463      Connect the controlling terminal to the STDBUG command monitor.
5464      When you are done interacting with STDBUG, typing either of two
5465      character sequences gets you back to the GDB command prompt:
5466      `<RET>~.' (Return, followed by tilde and period) or `<RET>~<C-d>'
5467      (Return, followed by tilde and control-D).
5469 \x1f
5470 File: gdb.info,  Node: Z8000,  Next: AVR,  Prev: ST2000,  Up: Embedded Processors
5472 18.3.14 Zilog Z8000
5473 -------------------
5475 When configured for debugging Zilog Z8000 targets, GDB includes a Z8000
5476 simulator.
5478    For the Z8000 family, `target sim' simulates either the Z8002 (the
5479 unsegmented variant of the Z8000 architecture) or the Z8001 (the
5480 segmented variant).  The simulator recognizes which architecture is
5481 appropriate by inspecting the object code.
5483 `target sim ARGS'
5484      Debug programs on a simulated CPU.  If the simulator supports setup
5485      options, specify them via ARGS.
5487 After specifying this target, you can debug programs for the simulated
5488 CPU in the same style as programs for your host computer; use the
5489 `file' command to load a new program image, the `run' command to run
5490 your program, and so on.
5492    As well as making available all the usual machine registers (*note
5493 Registers: Registers.), the Z8000 simulator provides three additional
5494 items of information as specially named registers:
5496 `cycles'
5497      Counts clock-ticks in the simulator.
5499 `insts'
5500      Counts instructions run in the simulator.
5502 `time'
5503      Execution time in 60ths of a second.
5506    You can refer to these values in GDB expressions with the usual
5507 conventions; for example, `b fputc if $cycles>5000' sets a conditional
5508 breakpoint that suspends only after at least 5000 simulated clock ticks.
5510 \x1f
5511 File: gdb.info,  Node: AVR,  Next: CRIS,  Prev: Z8000,  Up: Embedded Processors
5513 18.3.15 Atmel AVR
5514 -----------------
5516 When configured for debugging the Atmel AVR, GDB supports the following
5517 AVR-specific commands:
5519 `info io_registers'
5520      This command displays information about the AVR I/O registers.  For
5521      each register, GDB prints its number and value.
5523 \x1f
5524 File: gdb.info,  Node: CRIS,  Next: Super-H,  Prev: AVR,  Up: Embedded Processors
5526 18.3.16 CRIS
5527 ------------
5529 When configured for debugging CRIS, GDB provides the following
5530 CRIS-specific commands:
5532 `set cris-version VER'
5533      Set the current CRIS version to VER, either `10' or `32'.  The
5534      CRIS version affects register names and sizes.  This command is
5535      useful in case autodetection of the CRIS version fails.
5537 `show cris-version'
5538      Show the current CRIS version.
5540 `set cris-dwarf2-cfi'
5541      Set the usage of DWARF-2 CFI for CRIS debugging.  The default is
5542      `on'.  Change to `off' when using `gcc-cris' whose version is below
5543      `R59'.
5545 `show cris-dwarf2-cfi'
5546      Show the current state of using DWARF-2 CFI.
5548 `set cris-mode MODE'
5549      Set the current CRIS mode to MODE.  It should only be changed when
5550      debugging in guru mode, in which case it should be set to `guru'
5551      (the default is `normal').
5553 `show cris-mode'
5554      Show the current CRIS mode.
5556 \x1f
5557 File: gdb.info,  Node: Super-H,  Next: WinCE,  Prev: CRIS,  Up: Embedded Processors
5559 18.3.17 Renesas Super-H
5560 -----------------------
5562 For the Renesas Super-H processor, GDB provides these commands:
5564 `regs'
5565      Show the values of all Super-H registers.
5567 \x1f
5568 File: gdb.info,  Node: WinCE,  Prev: Super-H,  Up: Embedded Processors
5570 18.3.18 Windows CE
5571 ------------------
5573 The following commands are available for Windows CE:
5575 `set remotedirectory DIR'
5576      Tell GDB to upload files from the named directory DIR.  The
5577      default is `/gdb', i.e. the root directory on the current drive.
5579 `show remotedirectory'
5580      Show the current value of the upload directory.
5582 `set remoteupload METHOD'
5583      Set the method used to upload files to remote device.  Valid values
5584      for METHOD are `always', `newer', and `never'.  The default is
5585      `newer'.
5587 `show remoteupload'
5588      Show the current setting of the upload method.
5590 `set remoteaddhost'
5591      Tell GDB whether to add this host to the remote stub's arguments
5592      when you debug over a network.
5594 `show remoteaddhost'
5595      Show whether to add this host to remote stub's arguments when
5596      debugging over a network.
5598 \x1f
5599 File: gdb.info,  Node: Architectures,  Prev: Embedded Processors,  Up: Configurations
5601 18.4 Architectures
5602 ==================
5604 This section describes characteristics of architectures that affect all
5605 uses of GDB with the architecture, both native and cross.
5607 * Menu:
5609 * i386::
5610 * A29K::
5611 * Alpha::
5612 * MIPS::
5613 * HPPA::               HP PA architecture
5615 \x1f
5616 File: gdb.info,  Node: i386,  Next: A29K,  Up: Architectures
5618 18.4.1 x86 Architecture-specific issues.
5619 ----------------------------------------
5621 `set struct-convention MODE'
5622      Set the convention used by the inferior to return `struct's and
5623      `union's from functions to MODE.  Possible values of MODE are
5624      `"pcc"', `"reg"', and `"default"' (the default).  `"default"' or
5625      `"pcc"' means that `struct's are returned on the stack, while
5626      `"reg"' means that a `struct' or a `union' whose size is 1, 2, 4,
5627      or 8 bytes will be returned in a register.
5629 `show struct-convention'
5630      Show the current setting of the convention to return `struct's
5631      from functions.
5633 \x1f
5634 File: gdb.info,  Node: A29K,  Next: Alpha,  Prev: i386,  Up: Architectures
5636 18.4.2 A29K
5637 -----------
5639 `set rstack_high_address ADDRESS'
5640      On AMD 29000 family processors, registers are saved in a separate
5641      "register stack".  There is no way for GDB to determine the extent
5642      of this stack.  Normally, GDB just assumes that the stack is
5643      "large enough".  This may result in GDB referencing memory
5644      locations that do not exist.  If necessary, you can get around
5645      this problem by specifying the ending address of the register
5646      stack with the `set rstack_high_address' command.  The argument
5647      should be an address, which you probably want to precede with `0x'
5648      to specify in hexadecimal.
5650 `show rstack_high_address'
5651      Display the current limit of the register stack, on AMD 29000
5652      family processors.
5655 \x1f
5656 File: gdb.info,  Node: Alpha,  Next: MIPS,  Prev: A29K,  Up: Architectures
5658 18.4.3 Alpha
5659 ------------
5661 See the following section.
5663 \x1f
5664 File: gdb.info,  Node: MIPS,  Next: HPPA,  Prev: Alpha,  Up: Architectures
5666 18.4.4 MIPS
5667 -----------
5669 Alpha- and MIPS-based computers use an unusual stack frame, which
5670 sometimes requires GDB to search backward in the object code to find
5671 the beginning of a function.
5673    To improve response time (especially for embedded applications, where
5674 GDB may be restricted to a slow serial line for this search) you may
5675 want to limit the size of this search, using one of these commands:
5677 `set heuristic-fence-post LIMIT'
5678      Restrict GDB to examining at most LIMIT bytes in its search for
5679      the beginning of a function.  A value of 0 (the default) means
5680      there is no limit.  However, except for 0, the larger the limit
5681      the more bytes `heuristic-fence-post' must search and therefore
5682      the longer it takes to run.  You should only need to use this
5683      command when debugging a stripped executable.
5685 `show heuristic-fence-post'
5686      Display the current limit.
5688 These commands are available _only_ when GDB is configured for
5689 debugging programs on Alpha or MIPS processors.
5691    Several MIPS-specific commands are available when debugging MIPS
5692 programs:
5694 `set mips saved-gpreg-size SIZE'
5695      Set the size of MIPS general-purpose registers saved on the stack.
5696      The argument SIZE can be one of the following:
5698     `32'
5699           32-bit GP registers
5701     `64'
5702           64-bit GP registers
5704     `auto'
5705           Use the target's default setting or autodetect the saved size
5706           from the information contained in the executable.  This is
5707           the default
5709 `show mips saved-gpreg-size'
5710      Show the current size of MIPS GP registers on the stack.
5712 `set mips stack-arg-size SIZE'
5713      Set the amount of stack space reserved for arguments to functions.
5714      The argument can be one of `"32"', `"64"' or `"auto"' (the
5715      default).
5717 `set mips abi ARG'
5718      Tell GDB which MIPS ABI is used by the inferior.  Possible values
5719      of ARG are:
5721     `auto'
5722           The default ABI associated with the current binary (this is
5723           the default).
5725     `o32'
5727     `o64'
5729     `n32'
5731     `n64'
5733     `eabi32'
5735     `eabi64'
5737     `auto'
5739 `show mips abi'
5740      Show the MIPS ABI used by GDB to debug the inferior.
5742 `set mipsfpu'
5743 `show mipsfpu'
5744      *Note set mipsfpu: MIPS Embedded.
5746 `set mips mask-address ARG'
5747      This command determines whether the most-significant 32 bits of
5748      64-bit MIPS addresses are masked off.  The argument ARG can be
5749      `on', `off', or `auto'.  The latter is the default setting, which
5750      lets GDB determine the correct value.
5752 `show mips mask-address'
5753      Show whether the upper 32 bits of MIPS addresses are masked off or
5754      not.
5756 `set remote-mips64-transfers-32bit-regs'
5757      This command controls compatibility with 64-bit MIPS targets that
5758      transfer data in 32-bit quantities.  If you have an old MIPS 64
5759      target that transfers 32 bits for some registers, like SR and FSR,
5760      and 64 bits for other registers, set this option to `on'.
5762 `show remote-mips64-transfers-32bit-regs'
5763      Show the current setting of compatibility with older MIPS 64
5764      targets.
5766 `set debug mips'
5767      This command turns on and off debugging messages for the
5768      MIPS-specific target code in GDB.
5770 `show debug mips'
5771      Show the current setting of MIPS debugging messages.
5773 \x1f
5774 File: gdb.info,  Node: HPPA,  Prev: MIPS,  Up: Architectures
5776 18.4.5 HPPA
5777 -----------
5779 When GDB is debugging te HP PA architecture, it provides the following
5780 special commands:
5782 `set debug hppa'
5783      THis command determines whether HPPA architecture specific
5784      debugging messages are to be displayed.
5786 `show debug hppa'
5787      Show whether HPPA debugging messages are displayed.
5789 `maint print unwind ADDRESS'
5790      This command displays the contents of the unwind table entry at the
5791      given ADDRESS.
5794 \x1f
5795 File: gdb.info,  Node: Controlling GDB,  Next: Sequences,  Prev: Configurations,  Up: Top
5797 19 Controlling GDB
5798 ******************
5800 You can alter the way GDB interacts with you by using the `set'
5801 command.  For commands controlling how GDB displays data, see *Note
5802 Print settings: Print Settings.  Other settings are described here.
5804 * Menu:
5806 * Prompt::                      Prompt
5807 * Editing::                     Command editing
5808 * Command History::             Command history
5809 * Screen Size::                 Screen size
5810 * Numbers::                     Numbers
5811 * ABI::                         Configuring the current ABI
5812 * Messages/Warnings::           Optional warnings and messages
5813 * Debugging Output::            Optional messages about internal happenings
5815 \x1f
5816 File: gdb.info,  Node: Prompt,  Next: Editing,  Up: Controlling GDB
5818 19.1 Prompt
5819 ===========
5821 GDB indicates its readiness to read a command by printing a string
5822 called the "prompt".  This string is normally `(gdb)'.  You can change
5823 the prompt string with the `set prompt' command.  For instance, when
5824 debugging GDB with GDB, it is useful to change the prompt in one of the
5825 GDB sessions so that you can always tell which one you are talking to.
5827    _Note:_  `set prompt' does not add a space for you after the prompt
5828 you set.  This allows you to set a prompt which ends in a space or a
5829 prompt that does not.
5831 `set prompt NEWPROMPT'
5832      Directs GDB to use NEWPROMPT as its prompt string henceforth.
5834 `show prompt'
5835      Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
5837 \x1f
5838 File: gdb.info,  Node: Editing,  Next: Command History,  Prev: Prompt,  Up: Controlling GDB
5840 19.2 Command editing
5841 ====================
5843 GDB reads its input commands via the "Readline" interface.  This GNU
5844 library provides consistent behavior for programs which provide a
5845 command line interface to the user.  Advantages are GNU Emacs-style or
5846 "vi"-style inline editing of commands, `csh'-like history substitution,
5847 and a storage and recall of command history across debugging sessions.
5849    You may control the behavior of command line editing in GDB with the
5850 command `set'.
5852 `set editing'
5853 `set editing on'
5854      Enable command line editing (enabled by default).
5856 `set editing off'
5857      Disable command line editing.
5859 `show editing'
5860      Show whether command line editing is enabled.
5862    *Note Command Line Editing::, for more details about the Readline
5863 interface.  Users unfamiliar with GNU Emacs or `vi' are encouraged to
5864 read that chapter.
5866 \x1f
5867 File: gdb.info,  Node: Command History,  Next: Screen Size,  Prev: Editing,  Up: Controlling GDB
5869 19.3 Command history
5870 ====================
5872 GDB can keep track of the commands you type during your debugging
5873 sessions, so that you can be certain of precisely what happened.  Use
5874 these commands to manage the GDB command history facility.
5876    GDB uses the GNU History library, a part of the Readline package, to
5877 provide the history facility.  *Note Using History Interactively::, for
5878 the detailed description of the History library.
5880    To issue a command to GDB without affecting certain aspects of the
5881 state which is seen by users, prefix it with `server '.  This means
5882 that this command will not affect the command history, nor will it
5883 affect GDB's notion of which command to repeat if <RET> is pressed on a
5884 line by itself.
5886    The server prefix does not affect the recording of values into the
5887 value history; to print a value without recording it into the value
5888 history, use the `output' command instead of the `print' command.
5890    Here is the description of GDB commands related to command history.
5892 `set history filename FNAME'
5893      Set the name of the GDB command history file to FNAME.  This is
5894      the file where GDB reads an initial command history list, and
5895      where it writes the command history from this session when it
5896      exits.  You can access this list through history expansion or
5897      through the history command editing characters listed below.  This
5898      file defaults to the value of the environment variable
5899      `GDBHISTFILE', or to `./.gdb_history' (`./_gdb_history' on MS-DOS)
5900      if this variable is not set.
5902 `set history save'
5903 `set history save on'
5904      Record command history in a file, whose name may be specified with
5905      the `set history filename' command.  By default, this option is
5906      disabled.
5908 `set history save off'
5909      Stop recording command history in a file.
5911 `set history size SIZE'
5912      Set the number of commands which GDB keeps in its history list.
5913      This defaults to the value of the environment variable `HISTSIZE',
5914      or to 256 if this variable is not set.
5916    History expansion assigns special meaning to the character `!'.
5917 *Note Event Designators::, for more details.
5919    Since `!' is also the logical not operator in C, history expansion
5920 is off by default. If you decide to enable history expansion with the
5921 `set history expansion on' command, you may sometimes need to follow
5922 `!' (when it is used as logical not, in an expression) with a space or
5923 a tab to prevent it from being expanded.  The readline history
5924 facilities do not attempt substitution on the strings `!=' and `!(',
5925 even when history expansion is enabled.
5927    The commands to control history expansion are:
5929 `set history expansion on'
5930 `set history expansion'
5931      Enable history expansion.  History expansion is off by default.
5933 `set history expansion off'
5934      Disable history expansion.
5936 `show history'
5937 `show history filename'
5938 `show history save'
5939 `show history size'
5940 `show history expansion'
5941      These commands display the state of the GDB history parameters.
5942      `show history' by itself displays all four states.
5944 `show commands'
5945      Display the last ten commands in the command history.
5947 `show commands N'
5948      Print ten commands centered on command number N.
5950 `show commands +'
5951      Print ten commands just after the commands last printed.
5953 \x1f
5954 File: gdb.info,  Node: Screen Size,  Next: Numbers,  Prev: Command History,  Up: Controlling GDB
5956 19.4 Screen size
5957 ================
5959 Certain commands to GDB may produce large amounts of information output
5960 to the screen.  To help you read all of it, GDB pauses and asks you for
5961 input at the end of each page of output.  Type <RET> when you want to
5962 continue the output, or `q' to discard the remaining output.  Also, the
5963 screen width setting determines when to wrap lines of output.
5964 Depending on what is being printed, GDB tries to break the line at a
5965 readable place, rather than simply letting it overflow onto the
5966 following line.
5968    Normally GDB knows the size of the screen from the terminal driver
5969 software.  For example, on Unix GDB uses the termcap data base together
5970 with the value of the `TERM' environment variable and the `stty rows'
5971 and `stty cols' settings.  If this is not correct, you can override it
5972 with the `set height' and `set width' commands:
5974 `set height LPP'
5975 `show height'
5976 `set width CPL'
5977 `show width'
5978      These `set' commands specify a screen height of LPP lines and a
5979      screen width of CPL characters.  The associated `show' commands
5980      display the current settings.
5982      If you specify a height of zero lines, GDB does not pause during
5983      output no matter how long the output is.  This is useful if output
5984      is to a file or to an editor buffer.
5986      Likewise, you can specify `set width 0' to prevent GDB from
5987      wrapping its output.
5989 `set pagination on'
5990 `set pagination off'
5991      Turn the output pagination on or off; the default is on.  Turning
5992      pagination off is the alternative to `set height 0'.
5994 `show pagination'
5995      Show the current pagination mode.
5997 \x1f
5998 File: gdb.info,  Node: Numbers,  Next: ABI,  Prev: Screen Size,  Up: Controlling GDB
6000 19.5 Numbers
6001 ============
6003 You can always enter numbers in octal, decimal, or hexadecimal in GDB
6004 by the usual conventions: octal numbers begin with `0', decimal numbers
6005 end with `.', and hexadecimal numbers begin with `0x'.  Numbers that
6006 neither begin with `0' or `0x', nor end with a `.' are, by default,
6007 entered in base 10; likewise, the default display for numbers--when no
6008 particular format is specified--is base 10.  You can change the default
6009 base for both input and output with the commands described below.
6011 `set input-radix BASE'
6012      Set the default base for numeric input.  Supported choices for
6013      BASE are decimal 8, 10, or 16.  BASE must itself be specified
6014      either unambiguously or using the current input radix; for
6015      example, any of
6017           set input-radix 012
6018           set input-radix 10.
6019           set input-radix 0xa
6021      sets the input base to decimal.  On the other hand, `set
6022      input-radix 10' leaves the input radix unchanged, no matter what
6023      it was, since `10', being without any leading or trailing signs of
6024      its base, is interpreted in the current radix.  Thus, if the
6025      current radix is 16, `10' is interpreted in hex, i.e. as 16
6026      decimal, which doesn't change the radix.
6028 `set output-radix BASE'
6029      Set the default base for numeric display.  Supported choices for
6030      BASE are decimal 8, 10, or 16.  BASE must itself be specified
6031      either unambiguously or using the current input radix.
6033 `show input-radix'
6034      Display the current default base for numeric input.
6036 `show output-radix'
6037      Display the current default base for numeric display.
6039 `set radix [BASE]'
6040 `show radix'
6041      These commands set and show the default base for both input and
6042      output of numbers.  `set radix' sets the radix of input and output
6043      to the same base; without an argument, it resets the radix back to
6044      its default value of 10.
6047 \x1f
6048 File: gdb.info,  Node: ABI,  Next: Messages/Warnings,  Prev: Numbers,  Up: Controlling GDB
6050 19.6 Configuring the current ABI
6051 ================================
6053 GDB can determine the "ABI" (Application Binary Interface) of your
6054 application automatically.  However, sometimes you need to override its
6055 conclusions.  Use these commands to manage GDB's view of the current
6056 ABI.
6058    One GDB configuration can debug binaries for multiple operating
6059 system targets, either via remote debugging or native emulation.  GDB
6060 will autodetect the "OS ABI" (Operating System ABI) in use, but you can
6061 override its conclusion using the `set osabi' command.  One example
6062 where this is useful is in debugging of binaries which use an alternate
6063 C library (e.g. UCLIBC for GNU/Linux) which does not have the same
6064 identifying marks that the standard C library for your platform
6065 provides.
6067 `show osabi'
6068      Show the OS ABI currently in use.
6070 `set osabi'
6071      With no argument, show the list of registered available OS ABI's.
6073 `set osabi ABI'
6074      Set the current OS ABI to ABI.
6076    Generally, the way that an argument of type `float' is passed to a
6077 function depends on whether the function is prototyped.  For a
6078 prototyped (i.e. ANSI/ISO style) function, `float' arguments are passed
6079 unchanged, according to the architecture's convention for `float'.  For
6080 unprototyped (i.e. K&R style) functions, `float' arguments are first
6081 promoted to type `double' and then passed.
6083    Unfortunately, some forms of debug information do not reliably
6084 indicate whether a function is prototyped.  If GDB calls a function
6085 that is not marked as prototyped, it consults `set
6086 coerce-float-to-double'.
6088 `set coerce-float-to-double'
6089 `set coerce-float-to-double on'
6090      Arguments of type `float' will be promoted to `double' when passed
6091      to an unprototyped function.  This is the default setting.
6093 `set coerce-float-to-double off'
6094      Arguments of type `float' will be passed directly to unprototyped
6095      functions.
6097 `show coerce-float-to-double'
6098      Show the current setting of promoting `float' to `double'.
6100    GDB needs to know the ABI used for your program's C++ objects.  The
6101 correct C++ ABI depends on which C++ compiler was used to build your
6102 application.  GDB only fully supports programs with a single C++ ABI;
6103 if your program contains code using multiple C++ ABI's or if GDB can
6104 not identify your program's ABI correctly, you can tell GDB which ABI
6105 to use.  Currently supported ABI's include "gnu-v2", for `g++' versions
6106 before 3.0, "gnu-v3", for `g++' versions 3.0 and later, and "hpaCC" for
6107 the HP ANSI C++ compiler.  Other C++ compilers may use the "gnu-v2" or
6108 "gnu-v3" ABI's as well.  The default setting is "auto".
6110 `show cp-abi'
6111      Show the C++ ABI currently in use.
6113 `set cp-abi'
6114      With no argument, show the list of supported C++ ABI's.
6116 `set cp-abi ABI'
6117 `set cp-abi auto'
6118      Set the current C++ ABI to ABI, or return to automatic detection.
6120 \x1f
6121 File: gdb.info,  Node: Messages/Warnings,  Next: Debugging Output,  Prev: ABI,  Up: Controlling GDB
6123 19.7 Optional warnings and messages
6124 ===================================
6126 By default, GDB is silent about its inner workings.  If you are running
6127 on a slow machine, you may want to use the `set verbose' command.  This
6128 makes GDB tell you when it does a lengthy internal operation, so you
6129 will not think it has crashed.
6131    Currently, the messages controlled by `set verbose' are those which
6132 announce that the symbol table for a source file is being read; see
6133 `symbol-file' in *Note Commands to specify files: Files.
6135 `set verbose on'
6136      Enables GDB output of certain informational messages.
6138 `set verbose off'
6139      Disables GDB output of certain informational messages.
6141 `show verbose'
6142      Displays whether `set verbose' is on or off.
6144    By default, if GDB encounters bugs in the symbol table of an object
6145 file, it is silent; but if you are debugging a compiler, you may find
6146 this information useful (*note Errors reading symbol files: Symbol
6147 Errors.).
6149 `set complaints LIMIT'
6150      Permits GDB to output LIMIT complaints about each type of unusual
6151      symbols before becoming silent about the problem.  Set LIMIT to
6152      zero to suppress all complaints; set it to a large number to
6153      prevent complaints from being suppressed.
6155 `show complaints'
6156      Displays how many symbol complaints GDB is permitted to produce.
6159    By default, GDB is cautious, and asks what sometimes seems to be a
6160 lot of stupid questions to confirm certain commands.  For example, if
6161 you try to run a program which is already running:
6163      (gdb) run
6164      The program being debugged has been started already.
6165      Start it from the beginning? (y or n)
6167    If you are willing to unflinchingly face the consequences of your own
6168 commands, you can disable this "feature":
6170 `set confirm off'
6171      Disables confirmation requests.
6173 `set confirm on'
6174      Enables confirmation requests (the default).
6176 `show confirm'
6177      Displays state of confirmation requests.
6180 \x1f
6181 File: gdb.info,  Node: Debugging Output,  Prev: Messages/Warnings,  Up: Controlling GDB
6183 19.8 Optional messages about internal happenings
6184 ================================================
6186 GDB has commands that enable optional debugging messages from various
6187 GDB subsystems; normally these commands are of interest to GDB
6188 maintainers, or when reporting a bug.  This section documents those
6189 commands.
6191 `set exec-done-display'
6192      Turns on or off the notification of asynchronous commands'
6193      completion.  When on, GDB will print a message when an
6194      asynchronous command finishes its execution.  The default is off.  
6196 `show exec-done-display'
6197      Displays the current setting of asynchronous command completion
6198      notification.  
6200 `set debug arch'
6201      Turns on or off display of gdbarch debugging info.  The default is
6202      off 
6204 `show debug arch'
6205      Displays the current state of displaying gdbarch debugging info.
6207 `set debug aix-thread'
6208      Display debugging messages about inner workings of the AIX thread
6209      module.
6211 `show debug aix-thread'
6212      Show the current state of AIX thread debugging info display.
6214 `set debug event'
6215      Turns on or off display of GDB event debugging info.  The default
6216      is off.
6218 `show debug event'
6219      Displays the current state of displaying GDB event debugging info.
6221 `set debug expression'
6222      Turns on or off display of debugging info about GDB expression
6223      parsing.  The default is off.
6225 `show debug expression'
6226      Displays the current state of displaying debugging info about GDB
6227      expression parsing.
6229 `set debug frame'
6230      Turns on or off display of GDB frame debugging info.  The default
6231      is off.
6233 `show debug frame'
6234      Displays the current state of displaying GDB frame debugging info.
6236 `set debug infrun'
6237      Turns on or off display of GDB debugging info for running the
6238      inferior.  The default is off.  `infrun.c' contains GDB's runtime
6239      state machine used for implementing operations such as
6240      single-stepping the inferior.
6242 `show debug infrun'
6243      Displays the current state of GDB inferior debugging.
6245 `set debug lin-lwp'
6246      Turns on or off debugging messages from the Linux LWP debug
6247      support.
6249 `show debug lin-lwp'
6250      Show the current state of Linux LWP debugging messages.
6252 `set debug observer'
6253      Turns on or off display of GDB observer debugging.  This includes
6254      info such as the notification of observable events.
6256 `show debug observer'
6257      Displays the current state of observer debugging.
6259 `set debug overload'
6260      Turns on or off display of GDB C++ overload debugging info. This
6261      includes info such as ranking of functions, etc.  The default is
6262      off.
6264 `show debug overload'
6265      Displays the current state of displaying GDB C++ overload
6266      debugging info.  
6268 `set debug remote'
6269      Turns on or off display of reports on all packets sent back and
6270      forth across the serial line to the remote machine.  The info is
6271      printed on the GDB standard output stream. The default is off.
6273 `show debug remote'
6274      Displays the state of display of remote packets.
6276 `set debug serial'
6277      Turns on or off display of GDB serial debugging info. The default
6278      is off.
6280 `show debug serial'
6281      Displays the current state of displaying GDB serial debugging info.
6283 `set debug solib-frv'
6284      Turns on or off debugging messages for FR-V shared-library code.
6286 `show debug solib-frv'
6287      Display the current state of FR-V shared-library code debugging
6288      messages.
6290 `set debug target'
6291      Turns on or off display of GDB target debugging info. This info
6292      includes what is going on at the target level of GDB, as it
6293      happens. The default is 0.  Set it to 1 to track events, and to 2
6294      to also track the value of large memory transfers.  Changes to
6295      this flag do not take effect until the next time you connect to a
6296      target or use the `run' command.
6298 `show debug target'
6299      Displays the current state of displaying GDB target debugging info.
6301 `set debugvarobj'
6302      Turns on or off display of GDB variable object debugging info. The
6303      default is off.
6305 `show debugvarobj'
6306      Displays the current state of displaying GDB variable object
6307      debugging info.
6309 \x1f
6310 File: gdb.info,  Node: Sequences,  Next: TUI,  Prev: Controlling GDB,  Up: Top
6312 20 Canned Sequences of Commands
6313 *******************************
6315 Aside from breakpoint commands (*note Breakpoint command lists: Break
6316 Commands.), GDB provides two ways to store sequences of commands for
6317 execution as a unit: user-defined commands and command files.
6319 * Menu:
6321 * Define::             How to define your own commands
6322 * Hooks::              Hooks for user-defined commands
6323 * Command Files::      How to write scripts of commands to be stored in a file
6324 * Output::             Commands for controlled output
6326 \x1f
6327 File: gdb.info,  Node: Define,  Next: Hooks,  Up: Sequences
6329 20.1 User-defined commands
6330 ==========================
6332 A "user-defined command" is a sequence of GDB commands to which you
6333 assign a new name as a command.  This is done with the `define'
6334 command.  User commands may accept up to 10 arguments separated by
6335 whitespace.  Arguments are accessed within the user command via
6336 `$arg0...$arg9'.  A trivial example:
6338      define adder
6339        print $arg0 + $arg1 + $arg2
6340      end
6342 To execute the command use:
6344      adder 1 2 3
6346 This defines the command `adder', which prints the sum of its three
6347 arguments.  Note the arguments are text substitutions, so they may
6348 reference variables, use complex expressions, or even perform inferior
6349 functions calls.
6351    In addition, `$argc' may be used to find out how many arguments have
6352 been passed.  This expands to a number in the range 0...10.
6354      define adder
6355        if $argc == 2
6356          print $arg0 + $arg1
6357        end
6358        if $argc == 3
6359          print $arg0 + $arg1 + $arg2
6360        end
6361      end
6363 `define COMMANDNAME'
6364      Define a command named COMMANDNAME.  If there is already a command
6365      by that name, you are asked to confirm that you want to redefine
6366      it.
6368      The definition of the command is made up of other GDB command
6369      lines, which are given following the `define' command.  The end of
6370      these commands is marked by a line containing `end'.
6372 `document COMMANDNAME'
6373      Document the user-defined command COMMANDNAME, so that it can be
6374      accessed by `help'.  The command COMMANDNAME must already be
6375      defined.  This command reads lines of documentation just as
6376      `define' reads the lines of the command definition, ending with
6377      `end'.  After the `document' command is finished, `help' on command
6378      COMMANDNAME displays the documentation you have written.
6380      You may use the `document' command again to change the
6381      documentation of a command.  Redefining the command with `define'
6382      does not change the documentation.
6384 `dont-repeat'
6385      Used inside a user-defined command, this tells GDB that this
6386      command should not be repeated when the user hits <RET> (*note
6387      repeat last command: Command Syntax.).
6389 `help user-defined'
6390      List all user-defined commands, with the first line of the
6391      documentation (if any) for each.
6393 `show user'
6394 `show user COMMANDNAME'
6395      Display the GDB commands used to define COMMANDNAME (but not its
6396      documentation).  If no COMMANDNAME is given, display the
6397      definitions for all user-defined commands.
6399 `show max-user-call-depth'
6400 `set max-user-call-depth'
6401      The value of `max-user-call-depth' controls how many recursion
6402      levels are allowed in user-defined commands before GDB suspects an
6403      infinite recursion and aborts the command.
6405    In addition to the above commands, user-defined commands frequently
6406 use control flow commands, described in *Note Command Files::.
6408    When user-defined commands are executed, the commands of the
6409 definition are not printed.  An error in any command stops execution of
6410 the user-defined command.
6412    If used interactively, commands that would ask for confirmation
6413 proceed without asking when used inside a user-defined command.  Many
6414 GDB commands that normally print messages to say what they are doing
6415 omit the messages when used in a user-defined command.
6417 \x1f
6418 File: gdb.info,  Node: Hooks,  Next: Command Files,  Prev: Define,  Up: Sequences
6420 20.2 User-defined command hooks
6421 ===============================
6423 You may define "hooks", which are a special kind of user-defined
6424 command.  Whenever you run the command `foo', if the user-defined
6425 command `hook-foo' exists, it is executed (with no arguments) before
6426 that command.
6428    A hook may also be defined which is run after the command you
6429 executed.  Whenever you run the command `foo', if the user-defined
6430 command `hookpost-foo' exists, it is executed (with no arguments) after
6431 that command.  Post-execution hooks may exist simultaneously with
6432 pre-execution hooks, for the same command.
6434    It is valid for a hook to call the command which it hooks.  If this
6435 occurs, the hook is not re-executed, thereby avoiding infinite
6436 recursion.
6438    In addition, a pseudo-command, `stop' exists.  Defining
6439 (`hook-stop') makes the associated commands execute every time
6440 execution stops in your program: before breakpoint commands are run,
6441 displays are printed, or the stack frame is printed.
6443    For example, to ignore `SIGALRM' signals while single-stepping, but
6444 treat them normally during normal execution, you could define:
6446      define hook-stop
6447      handle SIGALRM nopass
6448      end
6450      define hook-run
6451      handle SIGALRM pass
6452      end
6454      define hook-continue
6455      handle SIGLARM pass
6456      end
6458    As a further example, to hook at the begining and end of the `echo'
6459 command, and to add extra text to the beginning and end of the message,
6460 you could define:
6462      define hook-echo
6463      echo <<<---
6464      end
6466      define hookpost-echo
6467      echo --->>>\n
6468      end
6470      (gdb) echo Hello World
6471      <<<---Hello World--->>>
6472      (gdb)
6474    You can define a hook for any single-word command in GDB, but not
6475 for command aliases; you should define a hook for the basic command
6476 name, e.g.  `backtrace' rather than `bt'.  If an error occurs during
6477 the execution of your hook, execution of GDB commands stops and GDB
6478 issues a prompt (before the command that you actually typed had a
6479 chance to run).
6481    If you try to define a hook which does not match any known command,
6482 you get a warning from the `define' command.
6484 \x1f
6485 File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Hooks,  Up: Sequences
6487 20.3 Command files
6488 ==================
6490 A command file for GDB is a text file made of lines that are GDB
6491 commands.  Comments (lines starting with `#') may also be included.  An
6492 empty line in a command file does nothing; it does not mean to repeat
6493 the last command, as it would from the terminal.
6495    You can request the execution of a command file with the `source'
6496 command:
6498 `source FILENAME'
6499      Execute the command file FILENAME.
6501    The lines in a command file are generally executed sequentially,
6502 unless the order of execution is changed by one of the _flow-control
6503 commands_ described below.  The commands are not printed as they are
6504 executed.  An error in any command terminates execution of the command
6505 file and control is returned to the console.
6507    GDB searches for FILENAME in the current directory and then on the
6508 search path (specified with the `directory' command).
6510    Commands that would ask for confirmation if used interactively
6511 proceed without asking when used in a command file.  Many GDB commands
6512 that normally print messages to say what they are doing omit the
6513 messages when called from command files.
6515    GDB also accepts command input from standard input.  In this mode,
6516 normal output goes to standard output and error output goes to standard
6517 error.  Errors in a command file supplied on standard input do not
6518 terminate execution of the command file--execution continues with the
6519 next command.
6521      gdb < cmds > log 2>&1
6523    (The syntax above will vary depending on the shell used.) This
6524 example will execute commands from the file `cmds'. All output and
6525 errors would be directed to `log'.
6527    Since commands stored on command files tend to be more general than
6528 commands typed interactively, they frequently need to deal with
6529 complicated situations, such as different or unexpected values of
6530 variables and symbols, changes in how the program being debugged is
6531 built, etc.  GDB provides a set of flow-control commands to deal with
6532 these complexities.  Using these commands, you can write complex
6533 scripts that loop over data structures, execute commands conditionally,
6534 etc.
6536 `if'
6537 `else'
6538      This command allows to include in your script conditionally
6539      executed commands. The `if' command takes a single argument, which
6540      is an expression to evaluate.  It is followed by a series of
6541      commands that are executed only if the expression is true (its
6542      value is nonzero).  There can then optionally be an `else' line,
6543      followed by a series of commands that are only executed if the
6544      expression was false.  The end of the list is marked by a line
6545      containing `end'.
6547 `while'
6548      This command allows to write loops.  Its syntax is similar to
6549      `if': the command takes a single argument, which is an expression
6550      to evaluate, and must be followed by the commands to execute, one
6551      per line, terminated by an `end'.  These commands are called the
6552      "body" of the loop.  The commands in the body of `while' are
6553      executed repeatedly as long as the expression evaluates to true.
6555 `loop_break'
6556      This command exits the `while' loop in whose body it is included.
6557      Execution of the script continues after that `while's `end' line.
6559 `loop_continue'
6560      This command skips the execution of the rest of the body of
6561      commands in the `while' loop in whose body it is included.
6562      Execution branches to the beginning of the `while' loop, where it
6563      evaluates the controlling expression.
6565 `end'
6566      Terminate the block of commands that are the body of `if', `else',
6567      or `while' flow-control commands.
6569 \x1f
6570 File: gdb.info,  Node: Output,  Prev: Command Files,  Up: Sequences
6572 20.4 Commands for controlled output
6573 ===================================
6575 During the execution of a command file or a user-defined command, normal
6576 GDB output is suppressed; the only output that appears is what is
6577 explicitly printed by the commands in the definition.  This section
6578 describes three commands useful for generating exactly the output you
6579 want.
6581 `echo TEXT'
6582      Print TEXT.  Nonprinting characters can be included in TEXT using
6583      C escape sequences, such as `\n' to print a newline.  *No newline
6584      is printed unless you specify one.* In addition to the standard C
6585      escape sequences, a backslash followed by a space stands for a
6586      space.  This is useful for displaying a string with spaces at the
6587      beginning or the end, since leading and trailing spaces are
6588      otherwise trimmed from all arguments.  To print ` and foo = ', use
6589      the command `echo \ and foo = \ '.
6591      A backslash at the end of TEXT can be used, as in C, to continue
6592      the command onto subsequent lines.  For example,
6594           echo This is some text\n\
6595           which is continued\n\
6596           onto several lines.\n
6598      produces the same output as
6600           echo This is some text\n
6601           echo which is continued\n
6602           echo onto several lines.\n
6604 `output EXPRESSION'
6605      Print the value of EXPRESSION and nothing but that value: no
6606      newlines, no `$NN = '.  The value is not entered in the value
6607      history either.  *Note Expressions: Expressions, for more
6608      information on expressions.
6610 `output/FMT EXPRESSION'
6611      Print the value of EXPRESSION in format FMT.  You can use the same
6612      formats as for `print'.  *Note Output formats: Output Formats, for
6613      more information.
6615 `printf STRING, EXPRESSIONS...'
6616      Print the values of the EXPRESSIONS under the control of STRING.
6617      The EXPRESSIONS are separated by commas and may be either numbers
6618      or pointers.  Their values are printed as specified by STRING,
6619      exactly as if your program were to execute the C subroutine
6621           printf (STRING, EXPRESSIONS...);
6623      For example, you can print two values in hex like this:
6625           printf "foo, bar-foo = 0x%x, 0x%x\n", foo, bar-foo
6627      The only backslash-escape sequences that you can use in the format
6628      string are the simple ones that consist of backslash followed by a
6629      letter.
6631 \x1f
6632 File: gdb.info,  Node: Interpreters,  Next: Emacs,  Prev: TUI,  Up: Top
6634 21 Command Interpreters
6635 ***********************
6637 GDB supports multiple command interpreters, and some command
6638 infrastructure to allow users or user interface writers to switch
6639 between interpreters or run commands in other interpreters.
6641    GDB currently supports two command interpreters, the console
6642 interpreter (sometimes called the command-line interpreter or CLI) and
6643 the machine interface interpreter (or GDB/MI).  This manual describes
6644 both of these interfaces in great detail.
6646    By default, GDB will start with the console interpreter.  However,
6647 the user may choose to start GDB with another interpreter by specifying
6648 the `-i' or `--interpreter' startup options.  Defined interpreters
6649 include:
6651 `console'
6652      The traditional console or command-line interpreter.  This is the
6653      most often used interpreter with GDB. With no interpreter
6654      specified at runtime, GDB will use this interpreter.
6656 `mi'
6657      The newest GDB/MI interface (currently `mi2').  Used primarily by
6658      programs wishing to use GDB as a backend for a debugger GUI or an
6659      IDE.  For more information, see *Note The GDB/MI Interface: GDB/MI.
6661 `mi2'
6662      The current GDB/MI interface.
6664 `mi1'
6665      The GDB/MI interface included in GDB 5.1, 5.2, and 5.3.
6668    The interpreter being used by GDB may not be dynamically switched at
6669 runtime.  Although possible, this could lead to a very precarious
6670 situation.  Consider an IDE using GDB/MI.  If a user enters the command
6671 "interpreter-set console" in a console view, GDB would switch to using
6672 the console interpreter, rendering the IDE inoperable!
6674    Although you may only choose a single interpreter at startup, you
6675 may execute commands in any interpreter from the current interpreter
6676 using the appropriate command.  If you are running the console
6677 interpreter, simply use the `interpreter-exec' command:
6679      interpreter-exec mi "-data-list-register-names"
6681    GDB/MI has a similar command, although it is only available in
6682 versions of GDB which support GDB/MI version 2 (or greater).
6684 \x1f
6685 File: gdb.info,  Node: TUI,  Next: Interpreters,  Prev: Sequences,  Up: Top
6687 22 GDB Text User Interface
6688 **************************
6690 * Menu:
6692 * TUI Overview::                TUI overview
6693 * TUI Keys::                    TUI key bindings
6694 * TUI Single Key Mode::         TUI single key mode
6695 * TUI Commands::                TUI specific commands
6696 * TUI Configuration::           TUI configuration variables
6698    The GDB Text User Interface, TUI in short, is a terminal interface
6699 which uses the `curses' library to show the source file, the assembly
6700 output, the program registers and GDB commands in separate text windows.
6702    The TUI is enabled by invoking GDB using either `gdbtui' or `gdb
6703 -tui'.
6705 \x1f
6706 File: gdb.info,  Node: TUI Overview,  Next: TUI Keys,  Up: TUI
6708 22.1 TUI overview
6709 =================
6711 The TUI has two display modes that can be switched while GDB runs:
6713    * A curses (or TUI) mode in which it displays several text windows
6714      on the terminal.
6716    * A standard mode which corresponds to the GDB configured without
6717      the TUI.
6719    In the TUI mode, GDB can display several text window on the terminal:
6721 _command_
6722      This window is the GDB command window with the GDB prompt and the
6723      GDB outputs.  The GDB input is still managed using readline but
6724      through the TUI.  The _command_ window is always visible.
6726 _source_
6727      The source window shows the source file of the program.  The
6728      current line as well as active breakpoints are displayed in this
6729      window.
6731 _assembly_
6732      The assembly window shows the disassembly output of the program.
6734 _register_
6735      This window shows the processor registers.  It detects when a
6736      register is changed and when this is the case, registers that have
6737      changed are highlighted.
6740    The source and assembly windows show the current program position by
6741 highlighting the current line and marking them with the `>' marker.
6742 Breakpoints are also indicated with two markers.  A first one indicates
6743 the breakpoint type:
6746      Breakpoint which was hit at least once.
6749      Breakpoint which was never hit.
6752      Hardware breakpoint which was hit at least once.
6755      Hardware breakpoint which was never hit.
6758    The second marker indicates whether the breakpoint is enabled or not:
6761      Breakpoint is enabled.
6764      Breakpoint is disabled.
6767    The source, assembly and register windows are attached to the thread
6768 and the frame position.  They are updated when the current thread
6769 changes, when the frame changes or when the program counter changes.
6770 These three windows are arranged by the TUI according to several
6771 layouts.  The layout defines which of these three windows are visible.
6772 The following layouts are available:
6774    * source
6776    * assembly
6778    * source and assembly
6780    * source and registers
6782    * assembly and registers
6785    On top of the command window a status line gives various information
6786 concerning the current process begin debugged.  The status line is
6787 updated when the information it shows changes.  The following fields
6788 are displayed:
6790 _target_
6791      Indicates the current gdb target (*note Specifying a Debugging
6792      Target: Targets.).
6794 _process_
6795      Gives information about the current process or thread number.
6796      When no process is being debugged, this field is set to `No
6797      process'.
6799 _function_
6800      Gives the current function name for the selected frame.  The name
6801      is demangled if demangling is turned on (*note Print Settings::).
6802      When there is no symbol corresponding to the current program
6803      counter the string `??' is displayed.
6805 _line_
6806      Indicates the current line number for the selected frame.  When
6807      the current line number is not known the string `??' is displayed.
6809 _pc_
6810      Indicates the current program counter address.
6813 \x1f
6814 File: gdb.info,  Node: TUI Keys,  Next: TUI Single Key Mode,  Prev: TUI Overview,  Up: TUI
6816 22.2 TUI Key Bindings
6817 =====================
6819 The TUI installs several key bindings in the readline keymaps (*note
6820 Command Line Editing::).  They allow to leave or enter in the TUI mode
6821 or they operate directly on the TUI layout and windows.  The TUI also
6822 provides a _SingleKey_ keymap which binds several keys directly to GDB
6823 commands.  The following key bindings are installed for both TUI mode
6824 and the GDB standard mode.
6826 `C-x C-a'
6827 `C-x a'
6828 `C-x A'
6829      Enter or leave the TUI mode.  When the TUI mode is left, the
6830      curses window management is left and GDB operates using its
6831      standard mode writing on the terminal directly.  When the TUI mode
6832      is entered, the control is given back to the curses windows.  The
6833      screen is then refreshed.
6835 `C-x 1'
6836      Use a TUI layout with only one window.  The layout will either be
6837      `source' or `assembly'.  When the TUI mode is not active, it will
6838      switch to the TUI mode.
6840      Think of this key binding as the Emacs `C-x 1' binding.
6842 `C-x 2'
6843      Use a TUI layout with at least two windows.  When the current
6844      layout shows already two windows, a next layout with two windows
6845      is used.  When a new layout is chosen, one window will always be
6846      common to the previous layout and the new one.
6848      Think of it as the Emacs `C-x 2' binding.
6850 `C-x o'
6851      Change the active window.  The TUI associates several key bindings
6852      (like scrolling and arrow keys) to the active window. This command
6853      gives the focus to the next TUI window.
6855      Think of it as the Emacs `C-x o' binding.
6857 `C-x s'
6858      Use the TUI _SingleKey_ keymap that binds single key to gdb
6859      commands (*note TUI Single Key Mode::).
6862    The following key bindings are handled only by the TUI mode:
6864 <PgUp>
6865      Scroll the active window one page up.
6867 <PgDn>
6868      Scroll the active window one page down.
6870 <Up>
6871      Scroll the active window one line up.
6873 <Down>
6874      Scroll the active window one line down.
6876 <Left>
6877      Scroll the active window one column left.
6879 <Right>
6880      Scroll the active window one column right.
6882 <C-L>
6883      Refresh the screen.
6886    In the TUI mode, the arrow keys are used by the active window for
6887 scrolling.  This means they are available for readline when the active
6888 window is the command window.  When the command window does not have
6889 the focus, it is necessary to use other readline key bindings such as
6890 <C-p>, <C-n>, <C-b> and <C-f>.
6892 \x1f
6893 File: gdb.info,  Node: TUI Single Key Mode,  Next: TUI Commands,  Prev: TUI Keys,  Up: TUI
6895 22.3 TUI Single Key Mode
6896 ========================
6898 The TUI provides a _SingleKey_ mode in which it installs a particular
6899 key binding in the readline keymaps to connect single keys to some gdb
6900 commands.
6903      continue
6906      down
6909      finish
6912      next
6915      exit the _SingleKey_ mode.
6918      run
6921      step
6924      up
6927      info locals
6930      where
6933    Other keys temporarily switch to the GDB command prompt.  The key
6934 that was pressed is inserted in the editing buffer so that it is
6935 possible to type most GDB commands without interaction with the TUI
6936 _SingleKey_ mode.  Once the command is entered the TUI _SingleKey_ mode
6937 is restored.  The only way to permanently leave this mode is by hitting
6938 <q> or `<C-x> <s>'.
6940 \x1f
6941 File: gdb.info,  Node: TUI Commands,  Next: TUI Configuration,  Prev: TUI Single Key Mode,  Up: TUI
6943 22.4 TUI specific commands
6944 ==========================
6946 The TUI has specific commands to control the text windows.  These
6947 commands are always available, that is they do not depend on the
6948 current terminal mode in which GDB runs.  When GDB is in the standard
6949 mode, using these commands will automatically switch in the TUI mode.
6951 `info win'
6952      List and give the size of all displayed windows.
6954 `layout next'
6955      Display the next layout.
6957 `layout prev'
6958      Display the previous layout.
6960 `layout src'
6961      Display the source window only.
6963 `layout asm'
6964      Display the assembly window only.
6966 `layout split'
6967      Display the source and assembly window.
6969 `layout regs'
6970      Display the register window together with the source or assembly
6971      window.
6973 `focus next | prev | src | asm | regs | split'
6974      Set the focus to the named window.  This command allows to change
6975      the active window so that scrolling keys can be affected to
6976      another window.
6978 `refresh'
6979      Refresh the screen.  This is similar to using <C-L> key.
6981 `tui reg float'
6982      Show the floating point registers in the register window.
6984 `tui reg general'
6985      Show the general registers in the register window.
6987 `tui reg next'
6988      Show the next register group.  The list of register groups as well
6989      as their order is target specific.  The predefined register groups
6990      are the following: `general', `float', `system', `vector', `all',
6991      `save', `restore'.
6993 `tui reg system'
6994      Show the system registers in the register window.
6996 `update'
6997      Update the source window and the current execution point.
6999 `winheight NAME +COUNT'
7000 `winheight NAME -COUNT'
7001      Change the height of the window NAME by COUNT lines.  Positive
7002      counts increase the height, while negative counts decrease it.
7004 `tabset'
7005      Set the width of tab stops to be NCHARS characters.
7008 \x1f
7009 File: gdb.info,  Node: TUI Configuration,  Prev: TUI Commands,  Up: TUI
7011 22.5 TUI configuration variables
7012 ================================
7014 The TUI has several configuration variables that control the appearance
7015 of windows on the terminal.
7017 `set tui border-kind KIND'
7018      Select the border appearance for the source, assembly and register
7019      windows.  The possible values are the following:
7020     `space'
7021           Use a space character to draw the border.
7023     `ascii'
7024           Use ascii characters + - and | to draw the border.
7026     `acs'
7027           Use the Alternate Character Set to draw the border.  The
7028           border is drawn using character line graphics if the terminal
7029           supports them.
7032 `set tui active-border-mode MODE'
7033      Select the attributes to display the border of the active window.
7034      The possible values are `normal', `standout', `reverse', `half',
7035      `half-standout', `bold' and `bold-standout'.
7037 `set tui border-mode MODE'
7038      Select the attributes to display the border of other windows.  The
7039      MODE can be one of the following:
7040     `normal'
7041           Use normal attributes to display the border.
7043     `standout'
7044           Use standout mode.
7046     `reverse'
7047           Use reverse video mode.
7049     `half'
7050           Use half bright mode.
7052     `half-standout'
7053           Use half bright and standout mode.
7055     `bold'
7056           Use extra bright or bold mode.
7058     `bold-standout'
7059           Use extra bright or bold and standout mode.
7063 \x1f
7064 File: gdb.info,  Node: Emacs,  Next: Annotations,  Prev: Interpreters,  Up: Top
7066 23 Using GDB under GNU Emacs
7067 ****************************
7069 A special interface allows you to use GNU Emacs to view (and edit) the
7070 source files for the program you are debugging with GDB.
7072    To use this interface, use the command `M-x gdb' in Emacs.  Give the
7073 executable file you want to debug as an argument.  This command starts
7074 GDB as a subprocess of Emacs, with input and output through a newly
7075 created Emacs buffer.
7077    Using GDB under Emacs is just like using GDB normally except for two
7078 things:
7080    * All "terminal" input and output goes through the Emacs buffer.
7082    This applies both to GDB commands and their output, and to the input
7083 and output done by the program you are debugging.
7085    This is useful because it means that you can copy the text of
7086 previous commands and input them again; you can even use parts of the
7087 output in this way.
7089    All the facilities of Emacs' Shell mode are available for interacting
7090 with your program.  In particular, you can send signals the usual
7091 way--for example, `C-c C-c' for an interrupt, `C-c C-z' for a stop.
7093    * GDB displays source code through Emacs.
7095    Each time GDB displays a stack frame, Emacs automatically finds the
7096 source file for that frame and puts an arrow (`=>') at the left margin
7097 of the current line.  Emacs uses a separate buffer for source display,
7098 and splits the screen to show both your GDB session and the source.
7100    Explicit GDB `list' or search commands still produce output as
7101 usual, but you probably have no reason to use them from Emacs.
7103    If you specify an absolute file name when prompted for the `M-x gdb'
7104 argument, then Emacs sets your current working directory to where your
7105 program resides.  If you only specify the file name, then Emacs sets
7106 your current working directory to to the directory associated with the
7107 previous buffer.  In this case, GDB may find your program by searching
7108 your environment's `PATH' variable, but on some operating systems it
7109 might not find the source.  So, although the GDB input and output
7110 session proceeds normally, the auxiliary buffer does not display the
7111 current source and line of execution.
7113    The initial working directory of GDB is printed on the top line of
7114 the GDB I/O buffer and this serves as a default for the commands that
7115 specify files for GDB to operate on.  *Note Commands to specify files:
7116 Files.
7118    By default, `M-x gdb' calls the program called `gdb'.  If you need
7119 to call GDB by a different name (for example, if you keep several
7120 configurations around, with different names) you can customize the
7121 Emacs variable `gud-gdb-command-name' to run the one you want.
7123    In the GDB I/O buffer, you can use these special Emacs commands in
7124 addition to the standard Shell mode commands:
7126 `C-h m'
7127      Describe the features of Emacs' GDB Mode.
7129 `C-c C-s'
7130      Execute to another source line, like the GDB `step' command; also
7131      update the display window to show the current file and location.
7133 `C-c C-n'
7134      Execute to next source line in this function, skipping all function
7135      calls, like the GDB `next' command.  Then update the display window
7136      to show the current file and location.
7138 `C-c C-i'
7139      Execute one instruction, like the GDB `stepi' command; update
7140      display window accordingly.
7142 `C-c C-f'
7143      Execute until exit from the selected stack frame, like the GDB
7144      `finish' command.
7146 `C-c C-r'
7147      Continue execution of your program, like the GDB `continue'
7148      command.
7150 `C-c <'
7151      Go up the number of frames indicated by the numeric argument
7152      (*note Numeric Arguments: (Emacs)Arguments.), like the GDB `up'
7153      command.
7155 `C-c >'
7156      Go down the number of frames indicated by the numeric argument,
7157      like the GDB `down' command.
7159    In any source file, the Emacs command `C-x SPC' (`gud-break') tells
7160 GDB to set a breakpoint on the source line point is on.
7162    If you type `M-x speedbar', then Emacs displays a separate frame
7163 which shows a backtrace when the GDB I/O buffer is current.  Move point
7164 to any frame in the stack and type <RET> to make it become the current
7165 frame and display the associated source in the source buffer.
7166 Alternatively, click `Mouse-2' to make the selected frame become the
7167 current one.
7169    If you accidentally delete the source-display buffer, an easy way to
7170 get it back is to type the command `f' in the GDB buffer, to request a
7171 frame display; when you run under Emacs, this recreates the source
7172 buffer if necessary to show you the context of the current frame.
7174    The source files displayed in Emacs are in ordinary Emacs buffers
7175 which are visiting the source files in the usual way.  You can edit the
7176 files with these buffers if you wish; but keep in mind that GDB
7177 communicates with Emacs in terms of line numbers.  If you add or delete
7178 lines from the text, the line numbers that GDB knows cease to
7179 correspond properly with the code.
7181    The description given here is for GNU Emacs version 21.3 and a more
7182 detailed description of its interaction with GDB is given in the Emacs
7183 manual (*note Debuggers: (Emacs)Debuggers.).
7185 \x1f
7186 File: gdb.info,  Node: GDB/MI,  Next: GDB Bugs,  Prev: Annotations,  Up: Top
7188 24 The GDB/MI Interface
7189 ***********************
7191 Function and Purpose
7192 ====================
7194 GDB/MI is a line based machine oriented text interface to GDB and is
7195 activated by specifying using the `--interpreter' command line option
7196 (*note Mode Options::).  It is specifically intended to support the
7197 development of systems which use the debugger as just one small
7198 component of a larger system.
7200    This chapter is a specification of the GDB/MI interface.  It is
7201 written in the form of a reference manual.
7203    Note that GDB/MI is still under construction, so some of the
7204 features described below are incomplete and subject to change.
7206 Notation and Terminology
7207 ========================
7209 This chapter uses the following notation:
7211    * `|' separates two alternatives.
7213    * `[ SOMETHING ]' indicates that SOMETHING is optional: it may or
7214      may not be given.
7216    * `( GROUP )*' means that GROUP inside the parentheses may repeat
7217      zero or more times.
7219    * `( GROUP )+' means that GROUP inside the parentheses may repeat
7220      one or more times.
7222    * `"STRING"' means a literal STRING.
7224 Acknowledgments
7225 ===============
7227 In alphabetic order: Andrew Cagney, Fernando Nasser, Stan Shebs and
7228 Elena Zannoni.
7230 * Menu:
7232 * GDB/MI Command Syntax::
7233 * GDB/MI Compatibility with CLI::
7234 * GDB/MI Output Records::
7235 * GDB/MI Command Description Format::
7236 * GDB/MI Breakpoint Table Commands::
7237 * GDB/MI Data Manipulation::
7238 * GDB/MI Program Control::
7239 * GDB/MI Miscellaneous Commands::
7240 * GDB/MI Stack Manipulation::
7241 * GDB/MI Symbol Query::
7242 * GDB/MI Target Manipulation::
7243 * GDB/MI Thread Commands::
7244 * GDB/MI Tracepoint Commands::
7245 * GDB/MI Variable Objects::
7247 \x1f
7248 File: gdb.info,  Node: GDB/MI Command Syntax,  Next: GDB/MI Compatibility with CLI,  Up: GDB/MI
7250 24.1 GDB/MI Command Syntax
7251 ==========================
7253 * Menu:
7255 * GDB/MI Input Syntax::
7256 * GDB/MI Output Syntax::
7257 * GDB/MI Simple Examples::
7259 \x1f
7260 File: gdb.info,  Node: GDB/MI Input Syntax,  Next: GDB/MI Output Syntax,  Up: GDB/MI Command Syntax
7262 24.1.1 GDB/MI Input Syntax
7263 --------------------------
7265 `COMMAND ==>'
7266      `CLI-COMMAND | MI-COMMAND'
7268 `CLI-COMMAND ==>'
7269      `[ TOKEN ] CLI-COMMAND NL', where CLI-COMMAND is any existing GDB
7270      CLI command.
7272 `MI-COMMAND ==>'
7273      `[ TOKEN ] "-" OPERATION ( " " OPTION )* `[' " --" `]' ( " "
7274      PARAMETER )* NL'
7276 `TOKEN ==>'
7277      "any sequence of digits"
7279 `OPTION ==>'
7280      `"-" PARAMETER [ " " PARAMETER ]'
7282 `PARAMETER ==>'
7283      `NON-BLANK-SEQUENCE | C-STRING'
7285 `OPERATION ==>'
7286      _any of the operations described in this chapter_
7288 `NON-BLANK-SEQUENCE ==>'
7289      _anything, provided it doesn't contain special characters such as
7290      "-", NL, """ and of course " "_
7292 `C-STRING ==>'
7293      `""" SEVEN-BIT-ISO-C-STRING-CONTENT """'
7295 `NL ==>'
7296      `CR | CR-LF'
7298 Notes:
7300    * The CLI commands are still handled by the MI interpreter; their
7301      output is described below.
7303    * The `TOKEN', when present, is passed back when the command
7304      finishes.
7306    * Some MI commands accept optional arguments as part of the parameter
7307      list.  Each option is identified by a leading `-' (dash) and may be
7308      followed by an optional argument parameter.  Options occur first
7309      in the parameter list and can be delimited from normal parameters
7310      using `--' (this is useful when some parameters begin with a dash).
7312    Pragmatics:
7314    * We want easy access to the existing CLI syntax (for debugging).
7316    * We want it to be easy to spot a MI operation.
7318 \x1f
7319 File: gdb.info,  Node: GDB/MI Output Syntax,  Next: GDB/MI Simple Examples,  Prev: GDB/MI Input Syntax,  Up: GDB/MI Command Syntax
7321 24.1.2 GDB/MI Output Syntax
7322 ---------------------------
7324 The output from GDB/MI consists of zero or more out-of-band records
7325 followed, optionally, by a single result record.  This result record is
7326 for the most recent command.  The sequence of output records is
7327 terminated by `(gdb)'.
7329    If an input command was prefixed with a `TOKEN' then the
7330 corresponding output for that command will also be prefixed by that same
7331 TOKEN.
7333 `OUTPUT ==>'
7334      `( OUT-OF-BAND-RECORD )* [ RESULT-RECORD ] "(gdb)" NL'
7336 `RESULT-RECORD ==>'
7337      ` [ TOKEN ] "^" RESULT-CLASS ( "," RESULT )* NL'
7339 `OUT-OF-BAND-RECORD ==>'
7340      `ASYNC-RECORD | STREAM-RECORD'
7342 `ASYNC-RECORD ==>'
7343      `EXEC-ASYNC-OUTPUT | STATUS-ASYNC-OUTPUT | NOTIFY-ASYNC-OUTPUT'
7345 `EXEC-ASYNC-OUTPUT ==>'
7346      `[ TOKEN ] "*" ASYNC-OUTPUT'
7348 `STATUS-ASYNC-OUTPUT ==>'
7349      `[ TOKEN ] "+" ASYNC-OUTPUT'
7351 `NOTIFY-ASYNC-OUTPUT ==>'
7352      `[ TOKEN ] "=" ASYNC-OUTPUT'
7354 `ASYNC-OUTPUT ==>'
7355      `ASYNC-CLASS ( "," RESULT )* NL'
7357 `RESULT-CLASS ==>'
7358      `"done" | "running" | "connected" | "error" | "exit"'
7360 `ASYNC-CLASS ==>'
7361      `"stopped" | OTHERS' (where OTHERS will be added depending on the
7362      needs--this is still in development).
7364 `RESULT ==>'
7365      ` VARIABLE "=" VALUE'
7367 `VARIABLE ==>'
7368      ` STRING '
7370 `VALUE ==>'
7371      ` CONST | TUPLE | LIST '
7373 `CONST ==>'
7374      `C-STRING'
7376 `TUPLE ==>'
7377      ` "{}" | "{" RESULT ( "," RESULT )* "}" '
7379 `LIST ==>'
7380      ` "[]" | "[" VALUE ( "," VALUE )* "]" | "[" RESULT ( "," RESULT )*
7381      "]" '
7383 `STREAM-RECORD ==>'
7384      `CONSOLE-STREAM-OUTPUT | TARGET-STREAM-OUTPUT | LOG-STREAM-OUTPUT'
7386 `CONSOLE-STREAM-OUTPUT ==>'
7387      `"~" C-STRING'
7389 `TARGET-STREAM-OUTPUT ==>'
7390      `"@" C-STRING'
7392 `LOG-STREAM-OUTPUT ==>'
7393      `"&" C-STRING'
7395 `NL ==>'
7396      `CR | CR-LF'
7398 `TOKEN ==>'
7399      _any sequence of digits_.
7401 Notes:
7403    * All output sequences end in a single line containing a period.
7405    * The `TOKEN' is from the corresponding request.  If an execution
7406      command is interrupted by the `-exec-interrupt' command, the TOKEN
7407      associated with the `*stopped' message is the one of the original
7408      execution command, not the one of the interrupt command.
7410    * STATUS-ASYNC-OUTPUT contains on-going status information about the
7411      progress of a slow operation.  It can be discarded.  All status
7412      output is prefixed by `+'.
7414    * EXEC-ASYNC-OUTPUT contains asynchronous state change on the target
7415      (stopped, started, disappeared).  All async output is prefixed by
7416      `*'.
7418    * NOTIFY-ASYNC-OUTPUT contains supplementary information that the
7419      client should handle (e.g., a new breakpoint information).  All
7420      notify output is prefixed by `='.
7422    * CONSOLE-STREAM-OUTPUT is output that should be displayed as is in
7423      the console.  It is the textual response to a CLI command.  All
7424      the console output is prefixed by `~'.
7426    * TARGET-STREAM-OUTPUT is the output produced by the target program.
7427      All the target output is prefixed by `@'.
7429    * LOG-STREAM-OUTPUT is output text coming from GDB's internals, for
7430      instance messages that should be displayed as part of an error
7431      log.  All the log output is prefixed by `&'.
7433    * New GDB/MI commands should only output LISTS containing VALUES.
7436    *Note GDB/MI Stream Records: GDB/MI Stream Records, for more details
7437 about the various output records.
7439 \x1f
7440 File: gdb.info,  Node: GDB/MI Simple Examples,  Prev: GDB/MI Output Syntax,  Up: GDB/MI Command Syntax
7442 24.1.3 Simple Examples of GDB/MI Interaction
7443 --------------------------------------------
7445 This subsection presents several simple examples of interaction using
7446 the GDB/MI interface.  In these examples, `->' means that the following
7447 line is passed to GDB/MI as input, while `<-' means the output received
7448 from GDB/MI.
7450 Target Stop
7451 ...........
7453 Here's an example of stopping the inferior process:
7455      -> -stop
7456      <- (gdb)
7458 and later:
7460      <- *stop,reason="stop",address="0x123",source="a.c:123"
7461      <- (gdb)
7463 Simple CLI Command
7464 ..................
7466 Here's an example of a simple CLI command being passed through GDB/MI
7467 and on to the CLI.
7469      -> print 1+2
7470      <- &"print 1+2\n"
7471      <- ~"$1 = 3\n"
7472      <- ^done
7473      <- (gdb)
7475 Command With Side Effects
7476 .........................
7478      -> -symbol-file xyz.exe
7479      <- *breakpoint,nr="3",address="0x123",source="a.c:123"
7480      <- (gdb)
7482 A Bad Command
7483 .............
7485 Here's what happens if you pass a non-existent command:
7487      -> -rubbish
7488      <- ^error,msg="Undefined MI command: rubbish"
7489      <- (gdb)
7491 \x1f
7492 File: gdb.info,  Node: GDB/MI Compatibility with CLI,  Next: GDB/MI Output Records,  Prev: GDB/MI Command Syntax,  Up: GDB/MI
7494 24.2 GDB/MI Compatibility with CLI
7495 ==================================
7497 To help users familiar with GDB's existing CLI interface, GDB/MI
7498 accepts existing CLI commands.  As specified by the syntax, such
7499 commands can be directly entered into the GDB/MI interface and GDB will
7500 respond.
7502    This mechanism is provided as an aid to developers of GDB/MI clients
7503 and not as a reliable interface into the CLI.  Since the command is
7504 being interpreteted in an environment that assumes GDB/MI behaviour,
7505 the exact output of such commands is likely to end up being an
7506 un-supported hybrid of GDB/MI and CLI output.
7508 \x1f
7509 File: gdb.info,  Node: GDB/MI Output Records,  Next: GDB/MI Command Description Format,  Prev: GDB/MI Compatibility with CLI,  Up: GDB/MI
7511 24.3 GDB/MI Output Records
7512 ==========================
7514 * Menu:
7516 * GDB/MI Result Records::
7517 * GDB/MI Stream Records::
7518 * GDB/MI Out-of-band Records::
7520 \x1f
7521 File: gdb.info,  Node: GDB/MI Result Records,  Next: GDB/MI Stream Records,  Up: GDB/MI Output Records
7523 24.3.1 GDB/MI Result Records
7524 ----------------------------
7526 In addition to a number of out-of-band notifications, the response to a
7527 GDB/MI command includes one of the following result indications:
7529 `"^done" [ "," RESULTS ]'
7530      The synchronous operation was successful, `RESULTS' are the return
7531      values.
7533 `"^running"'
7534      The asynchronous operation was successfully started.  The target is
7535      running.
7537 `"^error" "," C-STRING'
7538      The operation failed.  The `C-STRING' contains the corresponding
7539      error message.
7541 \x1f
7542 File: gdb.info,  Node: GDB/MI Stream Records,  Next: GDB/MI Out-of-band Records,  Prev: GDB/MI Result Records,  Up: GDB/MI Output Records
7544 24.3.2 GDB/MI Stream Records
7545 ----------------------------
7547 GDB internally maintains a number of output streams: the console, the
7548 target, and the log.  The output intended for each of these streams is
7549 funneled through the GDB/MI interface using "stream records".
7551    Each stream record begins with a unique "prefix character" which
7552 identifies its stream (*note GDB/MI Output Syntax: GDB/MI Output
7553 Syntax.).  In addition to the prefix, each stream record contains a
7554 `STRING-OUTPUT'.  This is either raw text (with an implicit new line)
7555 or a quoted C string (which does not contain an implicit newline).
7557 `"~" STRING-OUTPUT'
7558      The console output stream contains text that should be displayed
7559      in the CLI console window.  It contains the textual responses to
7560      CLI commands.
7562 `"@" STRING-OUTPUT'
7563      The target output stream contains any textual output from the
7564      running target.
7566 `"&" STRING-OUTPUT'
7567      The log stream contains debugging messages being produced by GDB's
7568      internals.
7570 \x1f
7571 File: gdb.info,  Node: GDB/MI Out-of-band Records,  Prev: GDB/MI Stream Records,  Up: GDB/MI Output Records
7573 24.3.3 GDB/MI Out-of-band Records
7574 ---------------------------------
7576 "Out-of-band" records are used to notify the GDB/MI client of
7577 additional changes that have occurred.  Those changes can either be a
7578 consequence of GDB/MI (e.g., a breakpoint modified) or a result of
7579 target activity (e.g., target stopped).
7581    The following is a preliminary list of possible out-of-band records.
7582 In particular, the EXEC-ASYNC-OUTPUT records.
7584 `*stopped,reason="REASON"'
7586    REASON can be one of the following:
7588 `breakpoint-hit'
7589      A breakpoint was reached.
7591 `watchpoint-trigger'
7592      A watchpoint was triggered.
7594 `read-watchpoint-trigger'
7595      A read watchpoint was triggered.
7597 `access-watchpoint-trigger'
7598      An access watchpoint was triggered.
7600 `function-finished'
7601      An -exec-finish or similar CLI command was accomplished.
7603 `location-reached'
7604      An -exec-until or similar CLI command was accomplished.
7606 `watchpoint-scope'
7607      A watchpoint has gone out of scope.
7609 `end-stepping-range'
7610      An -exec-next, -exec-next-instruction, -exec-step,
7611      -exec-step-instruction or similar CLI command was accomplished.
7613 `exited-signalled'
7614      The inferior exited because of a signal.
7616 `exited'
7617      The inferior exited.
7619 `exited-normally'
7620      The inferior exited normally.
7622 `signal-received'
7623      A signal was received by the inferior.
7625 \x1f
7626 File: gdb.info,  Node: GDB/MI Command Description Format,  Next: GDB/MI Breakpoint Table Commands,  Prev: GDB/MI Output Records,  Up: GDB/MI
7628 24.4 GDB/MI Command Description Format
7629 ======================================
7631 The remaining sections describe blocks of commands.  Each block of
7632 commands is laid out in a fashion similar to this section.
7634    Note the the line breaks shown in the examples are here only for
7635 readability.  They don't appear in the real output.  Also note that the
7636 commands with a non-available example (N.A.) are not yet implemented.
7638 Motivation
7639 ----------
7641 The motivation for this collection of commands.
7643 Introduction
7644 ------------
7646 A brief introduction to this collection of commands as a whole.
7648 Commands
7649 --------
7651 For each command in the block, the following is described:
7653 Synopsis
7654 ........
7656       -command ARGS...
7658 Result
7659 ......
7661 GDB Command
7662 ...........
7664 The corresponding GDB CLI command(s), if any.
7666 Example
7667 .......
7669 \x1f
7670 File: gdb.info,  Node: GDB/MI Breakpoint Table Commands,  Next: GDB/MI Data Manipulation,  Prev: GDB/MI Command Description Format,  Up: GDB/MI
7672 24.5 GDB/MI Breakpoint table commands
7673 =====================================
7675 This section documents GDB/MI commands for manipulating breakpoints.
7677 The `-break-after' Command
7678 --------------------------
7680 Synopsis
7681 ........
7683       -break-after NUMBER COUNT
7685    The breakpoint number NUMBER is not in effect until it has been hit
7686 COUNT times.  To see how this is reflected in the output of the
7687 `-break-list' command, see the description of the `-break-list' command
7688 below.
7690 GDB Command
7691 ...........
7693 The corresponding GDB command is `ignore'.
7695 Example
7696 .......
7698      (gdb)
7699      -break-insert main
7700      ^done,bkpt={number="1",addr="0x000100d0",file="hello.c",
7701      fullname="/home/foo/hello.c",line="5",times="0"}
7702      (gdb)
7703      -break-after 1 3
7704      ~
7705      ^done
7706      (gdb)
7707      -break-list
7708      ^done,BreakpointTable={nr_rows="1",nr_cols="6",
7709      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
7710      {width="14",alignment="-1",col_name="type",colhdr="Type"},
7711      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
7712      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
7713      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
7714      {width="40",alignment="2",col_name="what",colhdr="What"}],
7715      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
7716      addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
7717      line="5",times="0",ignore="3"}]}
7718      (gdb)
7720 The `-break-condition' Command
7721 ------------------------------
7723 Synopsis
7724 ........
7726       -break-condition NUMBER EXPR
7728    Breakpoint NUMBER will stop the program only if the condition in
7729 EXPR is true.  The condition becomes part of the `-break-list' output
7730 (see the description of the `-break-list' command below).
7732 GDB Command
7733 ...........
7735 The corresponding GDB command is `condition'.
7737 Example
7738 .......
7740      (gdb)
7741      -break-condition 1 1
7742      ^done
7743      (gdb)
7744      -break-list
7745      ^done,BreakpointTable={nr_rows="1",nr_cols="6",
7746      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
7747      {width="14",alignment="-1",col_name="type",colhdr="Type"},
7748      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
7749      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
7750      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
7751      {width="40",alignment="2",col_name="what",colhdr="What"}],
7752      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
7753      addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
7754      line="5",cond="1",times="0",ignore="3"}]}
7755      (gdb)
7757 The `-break-delete' Command
7758 ---------------------------
7760 Synopsis
7761 ........
7763       -break-delete ( BREAKPOINT )+
7765    Delete the breakpoint(s) whose number(s) are specified in the
7766 argument list.  This is obviously reflected in the breakpoint list.
7768 GDB command
7769 ...........
7771 The corresponding GDB command is `delete'.
7773 Example
7774 .......
7776      (gdb)
7777      -break-delete 1
7778      ^done
7779      (gdb)
7780      -break-list
7781      ^done,BreakpointTable={nr_rows="0",nr_cols="6",
7782      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
7783      {width="14",alignment="-1",col_name="type",colhdr="Type"},
7784      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
7785      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
7786      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
7787      {width="40",alignment="2",col_name="what",colhdr="What"}],
7788      body=[]}
7789      (gdb)
7791 The `-break-disable' Command
7792 ----------------------------
7794 Synopsis
7795 ........
7797       -break-disable ( BREAKPOINT )+
7799    Disable the named BREAKPOINT(s).  The field `enabled' in the break
7800 list is now set to `n' for the named BREAKPOINT(s).
7802 GDB Command
7803 ...........
7805 The corresponding GDB command is `disable'.
7807 Example
7808 .......
7810      (gdb)
7811      -break-disable 2
7812      ^done
7813      (gdb)
7814      -break-list
7815      ^done,BreakpointTable={nr_rows="1",nr_cols="6",
7816      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
7817      {width="14",alignment="-1",col_name="type",colhdr="Type"},
7818      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
7819      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
7820      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
7821      {width="40",alignment="2",col_name="what",colhdr="What"}],
7822      body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="n",
7823      addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
7824      line="5",times="0"}]}
7825      (gdb)
7827 The `-break-enable' Command
7828 ---------------------------
7830 Synopsis
7831 ........
7833       -break-enable ( BREAKPOINT )+
7835    Enable (previously disabled) BREAKPOINT(s).
7837 GDB Command
7838 ...........
7840 The corresponding GDB command is `enable'.
7842 Example
7843 .......
7845      (gdb)
7846      -break-enable 2
7847      ^done
7848      (gdb)
7849      -break-list
7850      ^done,BreakpointTable={nr_rows="1",nr_cols="6",
7851      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
7852      {width="14",alignment="-1",col_name="type",colhdr="Type"},
7853      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
7854      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
7855      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
7856      {width="40",alignment="2",col_name="what",colhdr="What"}],
7857      body=[bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
7858      addr="0x000100d0",func="main",file="hello.c",fullname="/home/foo/hello.c",
7859      line="5",times="0"}]}
7860      (gdb)
7862 The `-break-info' Command
7863 -------------------------
7865 Synopsis
7866 ........
7868       -break-info BREAKPOINT
7870    Get information about a single breakpoint.
7872 GDB command
7873 ...........
7875 The corresponding GDB command is `info break BREAKPOINT'.
7877 Example
7878 .......
7880 N.A.
7882 The `-break-insert' Command
7883 ---------------------------
7885 Synopsis
7886 ........
7888       -break-insert [ -t ] [ -h ] [ -r ]
7889          [ -c CONDITION ] [ -i IGNORE-COUNT ]
7890          [ -p THREAD ] [ LINE | ADDR ]
7892 If specified, LINE, can be one of:
7894    * function
7896    * filename:linenum
7898    * filename:function
7900    * *address
7902    The possible optional parameters of this command are:
7904 `-t'
7905      Insert a temporary breakpoint.
7907 `-h'
7908      Insert a hardware breakpoint.
7910 `-c CONDITION'
7911      Make the breakpoint conditional on CONDITION.
7913 `-i IGNORE-COUNT'
7914      Initialize the IGNORE-COUNT.
7916 `-r'
7917      Insert a regular breakpoint in all the functions whose names match
7918      the given regular expression.  Other flags are not applicable to
7919      regular expresson.
7921 Result
7922 ......
7924 The result is in the form:
7926      ^done,bkpt={number="NUMBER",type="TYPE",disp="del"|"keep",
7927      enabled="y"|"n",addr="HEX",func="FUNCNAME",file="FILENAME",
7928      fullname="FULL_FILENAME",line="LINENO",times="TIMES"}
7930 where NUMBER is the GDB number for this breakpoint, FUNCNAME is the
7931 name of the function where the breakpoint was inserted, FILENAME is the
7932 name of the source file which contains this function, LINENO is the
7933 source line number within that file and TIMES the number of times that
7934 the breakpoint has been hit (always 0 for -break-insert but may be
7935 greater for -break-info or -break-list which use the same output).
7937    Note: this format is open to change.
7939 GDB Command
7940 ...........
7942 The corresponding GDB commands are `break', `tbreak', `hbreak',
7943 `thbreak', and `rbreak'.
7945 Example
7946 .......
7948      (gdb)
7949      -break-insert main
7950      ^done,bkpt={number="1",addr="0x0001072c",file="recursive2.c",
7951      fullname="/home/foo/recursive2.c,line="4",times="0"}
7952      (gdb)
7953      -break-insert -t foo
7954      ^done,bkpt={number="2",addr="0x00010774",file="recursive2.c",
7955      fullname="/home/foo/recursive2.c,line="11",times="0"}
7956      (gdb)
7957      -break-list
7958      ^done,BreakpointTable={nr_rows="2",nr_cols="6",
7959      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
7960      {width="14",alignment="-1",col_name="type",colhdr="Type"},
7961      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
7962      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
7963      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
7964      {width="40",alignment="2",col_name="what",colhdr="What"}],
7965      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
7966      addr="0x0001072c", func="main",file="recursive2.c",
7967      fullname="/home/foo/recursive2.c,"line="4",times="0"},
7968      bkpt={number="2",type="breakpoint",disp="del",enabled="y",
7969      addr="0x00010774",func="foo",file="recursive2.c",
7970      fullname="/home/foo/recursive2.c",line="11",times="0"}]}
7971      (gdb)
7972      -break-insert -r foo.*
7973      ~int foo(int, int);
7974      ^done,bkpt={number="3",addr="0x00010774",file="recursive2.c,
7975      "fullname="/home/foo/recursive2.c",line="11",times="0"}
7976      (gdb)
7978 The `-break-list' Command
7979 -------------------------
7981 Synopsis
7982 ........
7984       -break-list
7986    Displays the list of inserted breakpoints, showing the following
7987 fields:
7989 `Number'
7990      number of the breakpoint
7992 `Type'
7993      type of the breakpoint: `breakpoint' or `watchpoint'
7995 `Disposition'
7996      should the breakpoint be deleted or disabled when it is hit: `keep'
7997      or `nokeep'
7999 `Enabled'
8000      is the breakpoint enabled or no: `y' or `n'
8002 `Address'
8003      memory location at which the breakpoint is set
8005 `What'
8006      logical location of the breakpoint, expressed by function name,
8007      file name, line number
8009 `Times'
8010      number of times the breakpoint has been hit
8012    If there are no breakpoints or watchpoints, the `BreakpointTable'
8013 `body' field is an empty list.
8015 GDB Command
8016 ...........
8018 The corresponding GDB command is `info break'.
8020 Example
8021 .......
8023      (gdb)
8024      -break-list
8025      ^done,BreakpointTable={nr_rows="2",nr_cols="6",
8026      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
8027      {width="14",alignment="-1",col_name="type",colhdr="Type"},
8028      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
8029      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
8030      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
8031      {width="40",alignment="2",col_name="what",colhdr="What"}],
8032      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
8033      addr="0x000100d0",func="main",file="hello.c",line="5",times="0"},
8034      bkpt={number="2",type="breakpoint",disp="keep",enabled="y",
8035      addr="0x00010114",func="foo",file="hello.c",fullname="/home/foo/hello.c",
8036      line="13",times="0"}]}
8037      (gdb)
8039    Here's an example of the result when there are no breakpoints:
8041      (gdb)
8042      -break-list
8043      ^done,BreakpointTable={nr_rows="0",nr_cols="6",
8044      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
8045      {width="14",alignment="-1",col_name="type",colhdr="Type"},
8046      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
8047      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
8048      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
8049      {width="40",alignment="2",col_name="what",colhdr="What"}],
8050      body=[]}
8051      (gdb)
8053 The `-break-watch' Command
8054 --------------------------
8056 Synopsis
8057 ........
8059       -break-watch [ -a | -r ]
8061    Create a watchpoint.  With the `-a' option it will create an
8062 "access" watchpoint, i.e. a watchpoint that triggers either on a read
8063 from or on a write to the memory location.  With the `-r' option, the
8064 watchpoint created is a "read" watchpoint, i.e. it will trigger only
8065 when the memory location is accessed for reading.  Without either of
8066 the options, the watchpoint created is a regular watchpoint, i.e. it
8067 will trigger when the memory location is accessed for writing.  *Note
8068 Setting watchpoints: Set Watchpoints.
8070    Note that `-break-list' will report a single list of watchpoints and
8071 breakpoints inserted.
8073 GDB Command
8074 ...........
8076 The corresponding GDB commands are `watch', `awatch', and `rwatch'.
8078 Example
8079 .......
8081 Setting a watchpoint on a variable in the `main' function:
8083      (gdb)
8084      -break-watch x
8085      ^done,wpt={number="2",exp="x"}
8086      (gdb)
8087      -exec-continue
8088      ^running
8089      ^done,reason="watchpoint-trigger",wpt={number="2",exp="x"},
8090      value={old="-268439212",new="55"},
8091      frame={func="main",args=[],file="recursive2.c",
8092      fullname="/home/foo/bar/recursive2.c",line="5"}
8093      (gdb)
8095    Setting a watchpoint on a variable local to a function.  GDB will
8096 stop the program execution twice: first for the variable changing
8097 value, then for the watchpoint going out of scope.
8099      (gdb)
8100      -break-watch C
8101      ^done,wpt={number="5",exp="C"}
8102      (gdb)
8103      -exec-continue
8104      ^running
8105      ^done,reason="watchpoint-trigger",
8106      wpt={number="5",exp="C"},value={old="-276895068",new="3"},
8107      frame={func="callee4",args=[],
8108      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8109      fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
8110      (gdb)
8111      -exec-continue
8112      ^running
8113      ^done,reason="watchpoint-scope",wpnum="5",
8114      frame={func="callee3",args=[{name="strarg",
8115      value="0x11940 \"A string argument.\""}],
8116      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8117      fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
8118      (gdb)
8120    Listing breakpoints and watchpoints, at different points in the
8121 program execution.  Note that once the watchpoint goes out of scope, it
8122 is deleted.
8124      (gdb)
8125      -break-watch C
8126      ^done,wpt={number="2",exp="C"}
8127      (gdb)
8128      -break-list
8129      ^done,BreakpointTable={nr_rows="2",nr_cols="6",
8130      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
8131      {width="14",alignment="-1",col_name="type",colhdr="Type"},
8132      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
8133      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
8134      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
8135      {width="40",alignment="2",col_name="what",colhdr="What"}],
8136      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
8137      addr="0x00010734",func="callee4",
8138      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8139      fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c"line="8",times="1"},
8140      bkpt={number="2",type="watchpoint",disp="keep",
8141      enabled="y",addr="",what="C",times="0"}]}
8142      (gdb)
8143      -exec-continue
8144      ^running
8145      ^done,reason="watchpoint-trigger",wpt={number="2",exp="C"},
8146      value={old="-276895068",new="3"},
8147      frame={func="callee4",args=[],
8148      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8149      fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="13"}
8150      (gdb)
8151      -break-list
8152      ^done,BreakpointTable={nr_rows="2",nr_cols="6",
8153      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
8154      {width="14",alignment="-1",col_name="type",colhdr="Type"},
8155      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
8156      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
8157      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
8158      {width="40",alignment="2",col_name="what",colhdr="What"}],
8159      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
8160      addr="0x00010734",func="callee4",
8161      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8162      fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",times="1"},
8163      bkpt={number="2",type="watchpoint",disp="keep",
8164      enabled="y",addr="",what="C",times="-5"}]}
8165      (gdb)
8166      -exec-continue
8167      ^running
8168      ^done,reason="watchpoint-scope",wpnum="2",
8169      frame={func="callee3",args=[{name="strarg",
8170      value="0x11940 \"A string argument.\""}],
8171      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8172      fullname="/home/foo/bar/devo/gdb/testsuite/gdb.mi/basics.c",line="18"}
8173      (gdb)
8174      -break-list
8175      ^done,BreakpointTable={nr_rows="1",nr_cols="6",
8176      hdr=[{width="3",alignment="-1",col_name="number",colhdr="Num"},
8177      {width="14",alignment="-1",col_name="type",colhdr="Type"},
8178      {width="4",alignment="-1",col_name="disp",colhdr="Disp"},
8179      {width="3",alignment="-1",col_name="enabled",colhdr="Enb"},
8180      {width="10",alignment="-1",col_name="addr",colhdr="Address"},
8181      {width="40",alignment="2",col_name="what",colhdr="What"}],
8182      body=[bkpt={number="1",type="breakpoint",disp="keep",enabled="y",
8183      addr="0x00010734",func="callee4",
8184      file="../../../devo/gdb/testsuite/gdb.mi/basics.c",
8185      fullname="/home/foo/devo/gdb/testsuite/gdb.mi/basics.c",line="8",
8186      times="1"}]}
8187      (gdb)