854e34f209c7710b906f5c48c57ad53eb416d0ac
[external/binutils.git] / gdb / doc / gdb.info-5
1 This is Info file ./gdb.info, produced by Makeinfo version 1.68 from
2 the input file gdb.texinfo.
3
4 START-INFO-DIR-ENTRY
5 * Gdb: (gdb).                     The GNU debugger.
6 END-INFO-DIR-ENTRY
7    This file documents the GNU debugger GDB.
8
9    This is the Seventh Edition, February 1999, of `Debugging with GDB:
10 the GNU Source-Level Debugger' for GDB Version 4.18.
11
12    Copyright (C) 1988-1999 Free Software Foundation, Inc.
13
14    Permission is granted to make and distribute verbatim copies of this
15 manual provided the copyright notice and this permission notice are
16 preserved on all copies.
17
18    Permission is granted to copy and distribute modified versions of
19 this manual under the conditions for verbatim copying, provided also
20 that the entire resulting derived work is distributed under the terms
21 of a permission notice identical to this one.
22
23    Permission is granted to copy and distribute translations of this
24 manual into another language, under the above conditions for modified
25 versions.
26
27 \1f
28 File: gdb.info,  Node: C Operators,  Next: C Constants,  Up: C
29
30 C and C++ operators
31 ...................
32
33    Operators must be defined on values of specific types.  For instance,
34 `+' is defined on numbers, but not on structures.  Operators are often
35 defined on groups of types.
36
37    For the purposes of C and C++, the following definitions hold:
38
39    * *Integral types* include `int' with any of its storage-class
40      specifiers; `char'; and `enum'.
41
42    * *Floating-point types* include `float' and `double'.
43
44    * *Pointer types* include all types defined as `(TYPE *)'.
45
46    * *Scalar types* include all of the above.
47
48 The following operators are supported.  They are listed here in order
49 of increasing precedence:
50
51 `,'
52      The comma or sequencing operator.  Expressions in a
53      comma-separated list are evaluated from left to right, with the
54      result of the entire expression being the last expression
55      evaluated.
56
57 `='
58      Assignment.  The value of an assignment expression is the value
59      assigned.  Defined on scalar types.
60
61 `OP='
62      Used in an expression of the form `A OP= B', and translated to
63      `A = A OP B'.  `OP=' and `=' have the same precendence.  OP is any
64      one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
65      `/', `%'.
66
67 `?:'
68      The ternary operator.  `A ? B : C' can be thought of as:  if A
69      then B else C.  A should be of an integral type.
70
71 `||'
72      Logical OR.  Defined on integral types.
73
74 `&&'
75      Logical AND.  Defined on integral types.
76
77 `|'
78      Bitwise OR.  Defined on integral types.
79
80 `^'
81      Bitwise exclusive-OR.  Defined on integral types.
82
83 `&'
84      Bitwise AND.  Defined on integral types.
85
86 `==, !='
87      Equality and inequality.  Defined on scalar types.  The value of
88      these expressions is 0 for false and non-zero for true.
89
90 `<, >, <=, >='
91      Less than, greater than, less than or equal, greater than or equal.
92      Defined on scalar types.  The value of these expressions is 0 for
93      false and non-zero for true.
94
95 `<<, >>'
96      left shift, and right shift.  Defined on integral types.
97
98 `@'
99      The GDB "artificial array" operator (*note Expressions:
100      Expressions.).
101
102 `+, -'
103      Addition and subtraction.  Defined on integral types,
104      floating-point types and pointer types.
105
106 `*, /, %'
107      Multiplication, division, and modulus.  Multiplication and
108      division are defined on integral and floating-point types.
109      Modulus is defined on integral types.
110
111 `++, --'
112      Increment and decrement.  When appearing before a variable, the
113      operation is performed before the variable is used in an
114      expression; when appearing after it, the variable's value is used
115      before the operation takes place.
116
117 `*'
118      Pointer dereferencing.  Defined on pointer types.  Same precedence
119      as `++'.
120
121 `&'
122      Address operator.  Defined on variables.  Same precedence as `++'.
123
124      For debugging C++, GDB implements a use of `&' beyond what is
125      allowed in the C++ language itself: you can use `&(&REF)' (or, if
126      you prefer, simply `&&REF') to examine the address where a C++
127      reference variable (declared with `&REF') is stored.
128
129 `-'
130      Negative.  Defined on integral and floating-point types.  Same
131      precedence as `++'.
132
133 `!'
134      Logical negation.  Defined on integral types.  Same precedence as
135      `++'.
136
137 `~'
138      Bitwise complement operator.  Defined on integral types.  Same
139      precedence as `++'.
140
141 `., ->'
142      Structure member, and pointer-to-structure member.  For
143      convenience, GDB regards the two as equivalent, choosing whether
144      to dereference a pointer based on the stored type information.
145      Defined on `struct' and `union' data.
146
147 `[]'
148      Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
149      as `->'.
150
151 `()'
152      Function parameter list.  Same precedence as `->'.
153
154 `::'
155      C++ scope resolution operator.  Defined on `struct', `union', and
156      `class' types.
157
158 `::'
159      Doubled colons also represent the GDB scope operator (*note
160      Expressions: Expressions.).  Same precedence as `::', above.
161
162 * Menu:
163
164 * C Constants::
165
166 \1f
167 File: gdb.info,  Node: C Constants,  Next: Cplus expressions,  Prev: C Operators,  Up: C
168
169 C and C++ constants
170 ...................
171
172    GDB allows you to express the constants of C and C++ in the
173 following ways:
174
175    * Integer constants are a sequence of digits.  Octal constants are
176      specified by a leading `0' (i.e. zero), and hexadecimal constants
177      by a leading `0x' or `0X'.  Constants may also end with a letter
178      `l', specifying that the constant should be treated as a `long'
179      value.
180
181    * Floating point constants are a sequence of digits, followed by a
182      decimal point, followed by a sequence of digits, and optionally
183      followed by an exponent.  An exponent is of the form:
184      `e[[+]|-]NNN', where NNN is another sequence of digits.  The `+'
185      is optional for positive exponents.
186
187    * Enumerated constants consist of enumerated identifiers, or their
188      integral equivalents.
189
190    * Character constants are a single character surrounded by single
191      quotes (`''), or a number--the ordinal value of the corresponding
192      character (usually its ASCII value).  Within quotes, the single
193      character may be represented by a letter or by "escape sequences",
194      which are of the form `\NNN', where NNN is the octal representation
195      of the character's ordinal value; or of the form `\X', where `X'
196      is a predefined special character--for example, `\n' for newline.
197
198    * String constants are a sequence of character constants surrounded
199      by double quotes (`"').
200
201    * Pointer constants are an integral value.  You can also write
202      pointers to constants using the C operator `&'.
203
204    * Array constants are comma-separated lists surrounded by braces `{'
205      and `}'; for example, `{1,2,3}' is a three-element array of
206      integers, `{{1,2}, {3,4}, {5,6}}' is a three-by-two array, and
207      `{&"hi", &"there", &"fred"}' is a three-element array of pointers.
208
209 * Menu:
210
211 * Cplus expressions::
212 * C Defaults::
213
214 * C Checks::
215
216 * Debugging C::
217
218 \1f
219 File: gdb.info,  Node: Cplus expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
220
221 C++ expressions
222 ...............
223
224    GDB expression handling can interpret most C++ expressions.
225
226      *Warning:* GDB can only debug C++ code if you use the proper
227      compiler.  Typically, C++ debugging depends on the use of
228      additional debugging information in the symbol table, and thus
229      requires special support.  In particular, if your compiler
230      generates a.out, MIPS ECOFF, RS/6000 XCOFF, or ELF with stabs
231      extensions to the symbol table, these facilities are all
232      available.  (With GNU CC, you can use the `-gstabs' option to
233      request stabs debugging extensions explicitly.)  Where the object
234      code format is standard COFF or DWARF in ELF, on the other hand,
235      most of the C++ support in GDB does *not* work.
236
237   1. Member function calls are allowed; you can use expressions like
238
239           count = aml->GetOriginal(x, y)
240
241   2. While a member function is active (in the selected stack frame),
242      your expressions have the same namespace available as the member
243      function; that is, GDB allows implicit references to the class
244      instance pointer `this' following the same rules as C++.
245
246   3. You can call overloaded functions; GDB resolves the function call
247      to the right definition, with one restriction--you must use
248      arguments of the type required by the function that you want to
249      call.  GDB does not perform conversions requiring constructors or
250      user-defined type operators.
251
252   4. GDB understands variables declared as C++ references; you can use
253      them in expressions just as you do in C++ source--they are
254      automatically dereferenced.
255
256      In the parameter list shown when GDB displays a frame, the values
257      of reference variables are not displayed (unlike other variables);
258      this avoids clutter, since references are often used for large
259      structures.  The *address* of a reference variable is always
260      shown, unless you have specified `set print address off'.
261
262   5. GDB supports the C++ name resolution operator `::'--your
263      expressions can use it just as expressions in your program do.
264      Since one scope may be defined in another, you can use `::'
265      repeatedly if necessary, for example in an expression like
266      `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope by
267      reference to source files, in both C and C++ debugging (*note
268      Program variables: Variables.).
269
270 \1f
271 File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: Cplus expressions,  Up: C
272
273 C and C++ defaults
274 ..................
275
276    If you allow GDB to set type and range checking automatically, they
277 both default to `off' whenever the working language changes to C or
278 C++.  This happens regardless of whether you or GDB selects the working
279 language.
280
281    If you allow GDB to set the language automatically, it recognizes
282 source files whose names end with `.c', `.C', or `.cc', etc, and when
283 GDB enters code compiled from one of these files, it sets the working
284 language to C or C++.  *Note Having GDB infer the source language:
285 Automatically, for further details.
286
287 \1f
288 File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C Constants
289
290 C and C++ type and range checks
291 ...............................
292
293    By default, when GDB parses C or C++ expressions, type checking is
294 not used.  However, if you turn type checking on, GDB considers two
295 variables type equivalent if:
296
297    * The two variables are structured and have the same structure,
298      union, or enumerated tag.
299
300    * The two variables have the same type name, or types that have been
301      declared equivalent through `typedef'.
302
303    Range checking, if turned on, is done on mathematical operations.
304 Array indices are not checked, since they are often used to index a
305 pointer that is not itself an array.
306
307 \1f
308 File: gdb.info,  Node: Debugging C,  Next: Debugging C plus plus,  Prev: C Checks,  Up: C
309
310 GDB and C
311 .........
312
313    The `set print union' and `show print union' commands apply to the
314 `union' type.  When set to `on', any `union' that is inside a `struct'
315 or `class' is also printed.  Otherwise, it appears as `{...}'.
316
317    The `@' operator aids in the debugging of dynamic arrays, formed
318 with pointers and a memory allocation function.  *Note Expressions:
319 Expressions.
320
321 * Menu:
322
323 * Debugging C plus plus::
324
325 \1f
326 File: gdb.info,  Node: Debugging C plus plus,  Prev: Debugging C,  Up: C
327
328 GDB features for C++
329 ....................
330
331    Some GDB commands are particularly useful with C++, and some are
332 designed specifically for use with C++.  Here is a summary:
333
334 `breakpoint menus'
335      When you want a breakpoint in a function whose name is overloaded,
336      GDB breakpoint menus help you specify which function definition
337      you want.  *Note Breakpoint menus: Breakpoint Menus.
338
339 `rbreak REGEX'
340      Setting breakpoints using regular expressions is helpful for
341      setting breakpoints on overloaded functions that are not members
342      of any special classes.  *Note Setting breakpoints: Set Breaks.
343
344 `catch throw'
345 `catch catch'
346      Debug C++ exception handling using these commands.  *Note Setting
347      catchpoints: Set Catchpoints.
348
349 `ptype TYPENAME'
350      Print inheritance relationships as well as other information for
351      type TYPENAME.  *Note Examining the Symbol Table: Symbols.
352
353 `set print demangle'
354 `show print demangle'
355 `set print asm-demangle'
356 `show print asm-demangle'
357      Control whether C++ symbols display in their source form, both when
358      displaying code as C++ source and when displaying disassemblies.
359      *Note Print settings: Print Settings.
360
361 `set print object'
362 `show print object'
363      Choose whether to print derived (actual) or declared types of
364      objects.  *Note Print settings: Print Settings.
365
366 `set print vtbl'
367 `show print vtbl'
368      Control the format for printing virtual function tables.  *Note
369      Print settings: Print Settings.
370
371 `Overloaded symbol names'
372      You can specify a particular definition of an overloaded symbol,
373      using the same notation that is used to declare such symbols in
374      C++: type `SYMBOL(TYPES)' rather than just SYMBOL.  You can also
375      use the GDB command-line word completion facilities to list the
376      available choices, or to finish the type list for you.  *Note
377      Command completion: Completion, for details on how to do this.
378
379 \1f
380 File: gdb.info,  Node: Modula-2,  Prev: C,  Up: Support
381
382 Modula-2
383 --------
384
385    The extensions made to GDB to support Modula-2 only support output
386 from the GNU Modula-2 compiler (which is currently being developed).
387 Other Modula-2 compilers are not currently supported, and attempting to
388 debug executables produced by them is most likely to give an error as
389 GDB reads in the executable's symbol table.
390
391 * Menu:
392
393 * M2 Operators::                Built-in operators
394 * Built-In Func/Proc::          Built-in functions and procedures
395 * M2 Constants::                Modula-2 constants
396 * M2 Defaults::                 Default settings for Modula-2
397 * Deviations::                  Deviations from standard Modula-2
398 * M2 Checks::                   Modula-2 type and range checks
399 * M2 Scope::                    The scope operators `::' and `.'
400 * GDB/M2::                      GDB and Modula-2
401
402 \1f
403 File: gdb.info,  Node: M2 Operators,  Next: Built-In Func/Proc,  Prev: Modula-2,  Up: Modula-2
404
405 Operators
406 .........
407
408    Operators must be defined on values of specific types.  For instance,
409 `+' is defined on numbers, but not on structures.  Operators are often
410 defined on groups of types.  For the purposes of Modula-2, the
411 following definitions hold:
412
413    * *Integral types* consist of `INTEGER', `CARDINAL', and their
414      subranges.
415
416    * *Character types* consist of `CHAR' and its subranges.
417
418    * *Floating-point types* consist of `REAL'.
419
420    * *Pointer types* consist of anything declared as `POINTER TO TYPE'.
421
422    * *Scalar types* consist of all of the above.
423
424    * *Set types* consist of `SET' and `BITSET' types.
425
426    * *Boolean types* consist of `BOOLEAN'.
427
428 The following operators are supported, and appear in order of
429 increasing precedence:
430
431 `,'
432      Function argument or array index separator.
433
434 `:='
435      Assignment.  The value of VAR `:=' VALUE is VALUE.
436
437 `<, >'
438      Less than, greater than on integral, floating-point, or enumerated
439      types.
440
441 `<=, >='
442      Less than, greater than, less than or equal to, greater than or
443      equal to on integral, floating-point and enumerated types, or set
444      inclusion on set types.  Same precedence as `<'.
445
446 `=, <>, #'
447      Equality and two ways of expressing inequality, valid on scalar
448      types.  Same precedence as `<'.  In GDB scripts, only `<>' is
449      available for inequality, since `#' conflicts with the script
450      comment character.
451
452 `IN'
453      Set membership.  Defined on set types and the types of their
454      members.  Same precedence as `<'.
455
456 `OR'
457      Boolean disjunction.  Defined on boolean types.
458
459 `AND, &'
460      Boolean conjuction.  Defined on boolean types.
461
462 `@'
463      The GDB "artificial array" operator (*note Expressions:
464      Expressions.).
465
466 `+, -'
467      Addition and subtraction on integral and floating-point types, or
468      union and difference on set types.
469
470 `*'
471      Multiplication on integral and floating-point types, or set
472      intersection on set types.
473
474 `/'
475      Division on floating-point types, or symmetric set difference on
476      set types.  Same precedence as `*'.
477
478 `DIV, MOD'
479      Integer division and remainder.  Defined on integral types.  Same
480      precedence as `*'.
481
482 `-'
483      Negative. Defined on `INTEGER' and `REAL' data.
484
485 `^'
486      Pointer dereferencing.  Defined on pointer types.
487
488 `NOT'
489      Boolean negation.  Defined on boolean types.  Same precedence as
490      `^'.
491
492 `.'
493      `RECORD' field selector.  Defined on `RECORD' data.  Same
494      precedence as `^'.
495
496 `[]'
497      Array indexing.  Defined on `ARRAY' data.  Same precedence as `^'.
498
499 `()'
500      Procedure argument list.  Defined on `PROCEDURE' objects.  Same
501      precedence as `^'.
502
503 `::, .'
504      GDB and Modula-2 scope operators.
505
506      *Warning:* Sets and their operations are not yet supported, so GDB
507      treats the use of the operator `IN', or the use of operators `+',
508      `-', `*', `/', `=', , `<>', `#', `<=', and `>=' on sets as an
509      error.
510
511 \1f
512 File: gdb.info,  Node: Built-In Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
513
514 Built-in functions and procedures
515 .................................
516
517    Modula-2 also makes available several built-in procedures and
518 functions.  In describing these, the following metavariables are used:
519
520 A
521      represents an `ARRAY' variable.
522
523 C
524      represents a `CHAR' constant or variable.
525
526 I
527      represents a variable or constant of integral type.
528
529 M
530      represents an identifier that belongs to a set.  Generally used in
531      the same function with the metavariable S.  The type of S should
532      be `SET OF MTYPE' (where MTYPE is the type of M).
533
534 N
535      represents a variable or constant of integral or floating-point
536      type.
537
538 R
539      represents a variable or constant of floating-point type.
540
541 T
542      represents a type.
543
544 V
545      represents a variable.
546
547 X
548      represents a variable or constant of one of many types.  See the
549      explanation of the function for details.
550
551    All Modula-2 built-in procedures also return a result, described
552 below.
553
554 `ABS(N)'
555      Returns the absolute value of N.
556
557 `CAP(C)'
558      If C is a lower case letter, it returns its upper case equivalent,
559      otherwise it returns its argument
560
561 `CHR(I)'
562      Returns the character whose ordinal value is I.
563
564 `DEC(V)'
565      Decrements the value in the variable V.  Returns the new value.
566
567 `DEC(V,I)'
568      Decrements the value in the variable V by I.  Returns the new
569      value.
570
571 `EXCL(M,S)'
572      Removes the element M from the set S.  Returns the new set.
573
574 `FLOAT(I)'
575      Returns the floating point equivalent of the integer I.
576
577 `HIGH(A)'
578      Returns the index of the last member of A.
579
580 `INC(V)'
581      Increments the value in the variable V.  Returns the new value.
582
583 `INC(V,I)'
584      Increments the value in the variable V by I.  Returns the new
585      value.
586
587 `INCL(M,S)'
588      Adds the element M to the set S if it is not already there.
589      Returns the new set.
590
591 `MAX(T)'
592      Returns the maximum value of the type T.
593
594 `MIN(T)'
595      Returns the minimum value of the type T.
596
597 `ODD(I)'
598      Returns boolean TRUE if I is an odd number.
599
600 `ORD(X)'
601      Returns the ordinal value of its argument.  For example, the
602      ordinal value of a character is its ASCII value (on machines
603      supporting the ASCII character set).  X must be of an ordered
604      type, which include integral, character and enumerated types.
605
606 `SIZE(X)'
607      Returns the size of its argument.  X can be a variable or a type.
608
609 `TRUNC(R)'
610      Returns the integral part of R.
611
612 `VAL(T,I)'
613      Returns the member of the type T whose ordinal value is I.
614
615      *Warning:*  Sets and their operations are not yet supported, so
616      GDB treats the use of procedures `INCL' and `EXCL' as an error.
617
618 \1f
619 File: gdb.info,  Node: M2 Constants,  Next: M2 Defaults,  Prev: Built-In Func/Proc,  Up: Modula-2
620
621 Constants
622 .........
623
624    GDB allows you to express the constants of Modula-2 in the following
625 ways:
626
627    * Integer constants are simply a sequence of digits.  When used in an
628      expression, a constant is interpreted to be type-compatible with
629      the rest of the expression.  Hexadecimal integers are specified by
630      a trailing `H', and octal integers by a trailing `B'.
631
632    * Floating point constants appear as a sequence of digits, followed
633      by a decimal point and another sequence of digits.  An optional
634      exponent can then be specified, in the form `E[+|-]NNN', where
635      `[+|-]NNN' is the desired exponent.  All of the digits of the
636      floating point constant must be valid decimal (base 10) digits.
637
638    * Character constants consist of a single character enclosed by a
639      pair of like quotes, either single (`'') or double (`"').  They may
640      also be expressed by their ordinal value (their ASCII value,
641      usually) followed by a `C'.
642
643    * String constants consist of a sequence of characters enclosed by a
644      pair of like quotes, either single (`'') or double (`"').  Escape
645      sequences in the style of C are also allowed.  *Note C and C++
646      constants: C Constants, for a brief explanation of escape
647      sequences.
648
649    * Enumerated constants consist of an enumerated identifier.
650
651    * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
652
653    * Pointer constants consist of integral values only.
654
655    * Set constants are not yet supported.
656
657 \1f
658 File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Constants,  Up: Modula-2
659
660 Modula-2 defaults
661 .................
662
663    If type and range checking are set automatically by GDB, they both
664 default to `on' whenever the working language changes to Modula-2.
665 This happens regardless of whether you, or GDB, selected the working
666 language.
667
668    If you allow GDB to set the language automatically, then entering
669 code compiled from a file whose name ends with `.mod' sets the working
670 language to Modula-2. *Note Having GDB set the language automatically:
671 Automatically, for further details.
672
673 \1f
674 File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
675
676 Deviations from standard Modula-2
677 .................................
678
679    A few changes have been made to make Modula-2 programs easier to
680 debug.  This is done primarily via loosening its type strictness:
681
682    * Unlike in standard Modula-2, pointer constants can be formed by
683      integers.  This allows you to modify pointer variables during
684      debugging.  (In standard Modula-2, the actual address contained in
685      a pointer variable is hidden from you; it can only be modified
686      through direct assignment to another pointer variable or
687      expression that returned a pointer.)
688
689    * C escape sequences can be used in strings and characters to
690      represent non-printable characters.  GDB prints out strings with
691      these escape sequences embedded.  Single non-printable characters
692      are printed using the `CHR(NNN)' format.
693
694    * The assignment operator (`:=') returns the value of its right-hand
695      argument.
696
697    * All built-in procedures both modify *and* return their argument.
698
699 \1f
700 File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
701
702 Modula-2 type and range checks
703 ..............................
704
705      *Warning:* in this release, GDB does not yet perform type or range
706      checking.
707
708    GDB considers two Modula-2 variables type equivalent if:
709
710    * They are of types that have been declared equivalent via a `TYPE
711      T1 = T2' statement
712
713    * They have been declared on the same line.  (Note:  This is true of
714      the GNU Modula-2 compiler, but it may not be true of other
715      compilers.)
716
717    As long as type checking is enabled, any attempt to combine variables
718 whose types are not equivalent is an error.
719
720    Range checking is done on all mathematical operations, assignment,
721 array index bounds, and all built-in functions and procedures.
722
723 \1f
724 File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
725
726 The scope operators `::' and `.'
727 ................................
728
729    There are a few subtle differences between the Modula-2 scope
730 operator (`.') and the GDB scope operator (`::').  The two have similar
731 syntax:
732
733
734      MODULE . ID
735      SCOPE :: ID
736
737 where SCOPE is the name of a module or a procedure, MODULE the name of
738 a module, and ID is any declared identifier within your program, except
739 another module.
740
741    Using the `::' operator makes GDB search the scope specified by
742 SCOPE for the identifier ID.  If it is not found in the specified
743 scope, then GDB searches all scopes enclosing the one specified by
744 SCOPE.
745
746    Using the `.' operator makes GDB search the current scope for the
747 identifier specified by ID that was imported from the definition module
748 specified by MODULE.  With this operator, it is an error if the
749 identifier ID was not imported from definition module MODULE, or if ID
750 is not an identifier in MODULE.
751
752 \1f
753 File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
754
755 GDB and Modula-2
756 ................
757
758    Some GDB commands have little use when debugging Modula-2 programs.
759 Five subcommands of `set print' and `show print' apply specifically to
760 C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'.
761 The first four apply to C++, and the last to the C `union' type, which
762 has no direct analogue in Modula-2.
763
764    The `@' operator (*note Expressions: Expressions.), while available
765 while using any language, is not useful with Modula-2.  Its intent is
766 to aid the debugging of "dynamic arrays", which cannot be created in
767 Modula-2 as they can in C or C++.  However, because an address can be
768 specified by an integral constant, the construct `{TYPE}ADREXP' is
769 still useful.  (*note Expressions: Expressions.)
770
771    In GDB scripts, the Modula-2 inequality operator `#' is interpreted
772 as the beginning of a comment.  Use `<>' instead.
773
774 \1f
775 File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Languages,  Up: Top
776
777 Examining the Symbol Table
778 **************************
779
780    The commands described in this section allow you to inquire about the
781 symbols (names of variables, functions and types) defined in your
782 program.  This information is inherent in the text of your program and
783 does not change as your program executes.  GDB finds it in your
784 program's symbol table, in the file indicated when you started GDB
785 (*note Choosing files: File Options.), or by one of the file-management
786 commands (*note Commands to specify files: Files.).
787
788    Occasionally, you may need to refer to symbols that contain unusual
789 characters, which GDB ordinarily treats as word delimiters.  The most
790 frequent case is in referring to static variables in other source files
791 (*note Program variables: Variables.).  File names are recorded in
792 object files as debugging symbols, but GDB would ordinarily parse a
793 typical file name, like `foo.c', as the three words `foo' `.' `c'.  To
794 allow GDB to recognize `foo.c' as a single symbol, enclose it in single
795 quotes; for example,
796
797      p 'foo.c'::x
798
799 looks up the value of `x' in the scope of the file `foo.c'.
800
801 `info address SYMBOL'
802      Describe where the data for SYMBOL is stored.  For a register
803      variable, this says which register it is kept in.  For a
804      non-register local variable, this prints the stack-frame offset at
805      which the variable is always stored.
806
807      Note the contrast with `print &SYMBOL', which does not work at all
808      for a register variable, and for a stack local variable prints the
809      exact address of the current instantiation of the variable.
810
811 `whatis EXP'
812      Print the data type of expression EXP.  EXP is not actually
813      evaluated, and any side-effecting operations (such as assignments
814      or function calls) inside it do not take place.  *Note
815      Expressions: Expressions.
816
817 `whatis'
818      Print the data type of `$', the last value in the value history.
819
820 `ptype TYPENAME'
821      Print a description of data type TYPENAME.  TYPENAME may be the
822      name of a type, or for C code it may have the form `class
823      CLASS-NAME', `struct STRUCT-TAG', `union UNION-TAG' or `enum
824      ENUM-TAG'.
825
826 `ptype EXP'
827 `ptype'
828      Print a description of the type of expression EXP.  `ptype'
829      differs from `whatis' by printing a detailed description, instead
830      of just the name of the type.
831
832      For example, for this variable declaration:
833
834           struct complex {double real; double imag;} v;
835
836      the two commands give this output:
837
838           (gdb) whatis v
839           type = struct complex
840           (gdb) ptype v
841           type = struct complex {
842               double real;
843               double imag;
844           }
845
846      As with `whatis', using `ptype' without an argument refers to the
847      type of `$', the last value in the value history.
848
849 `info types REGEXP'
850 `info types'
851      Print a brief description of all types whose name matches REGEXP
852      (or all types in your program, if you supply no argument).  Each
853      complete typename is matched as though it were a complete line;
854      thus, `i type value' gives information on all types in your
855      program whose name includes the string `value', but `i type
856      ^value$' gives information only on types whose complete name is
857      `value'.
858
859      This command differs from `ptype' in two ways: first, like
860      `whatis', it does not print a detailed description; second, it
861      lists all source files where a type is defined.
862
863 `info source'
864      Show the name of the current source file--that is, the source file
865      for the function containing the current point of execution--and
866      the language it was written in.
867
868 `info sources'
869      Print the names of all source files in your program for which
870      there is debugging information, organized into two lists: files
871      whose symbols have already been read, and files whose symbols will
872      be read when needed.
873
874 `info functions'
875      Print the names and data types of all defined functions.
876
877 `info functions REGEXP'
878      Print the names and data types of all defined functions whose
879      names contain a match for regular expression REGEXP.  Thus, `info
880      fun step' finds all functions whose names include `step'; `info
881      fun ^step' finds those whose names start with `step'.
882
883 `info variables'
884      Print the names and data types of all variables that are declared
885      outside of functions (i.e., excluding local variables).
886
887 `info variables REGEXP'
888      Print the names and data types of all variables (except for local
889      variables) whose names contain a match for regular expression
890      REGEXP.
891
892      Some systems allow individual object files that make up your
893      program to be replaced without stopping and restarting your
894      program.  For example, in VxWorks you can simply recompile a
895      defective object file and keep on running.  If you are running on
896      one of these systems, you can allow GDB to reload the symbols for
897      automatically relinked modules:
898
899     `set symbol-reloading on'
900           Replace symbol definitions for the corresponding source file
901           when an object file with a particular name is seen again.
902
903     `set symbol-reloading off'
904           Do not replace symbol definitions when re-encountering object
905           files of the same name.  This is the default state; if you
906           are not running on a system that permits automatically
907           relinking modules, you should leave `symbol-reloading' off,
908           since otherwise GDB may discard symbols when linking large
909           programs, that may contain several modules (from different
910           directories or libraries) with the same name.
911
912     `show symbol-reloading'
913           Show the current `on' or `off' setting.
914
915 `maint print symbols FILENAME'
916 `maint print psymbols FILENAME'
917 `maint print msymbols FILENAME'
918      Write a dump of debugging symbol data into the file FILENAME.
919      These commands are used to debug the GDB symbol-reading code.  Only
920      symbols with debugging data are included.  If you use `maint print
921      symbols', GDB includes all the symbols for which it has already
922      collected full details: that is, FILENAME reflects symbols for
923      only those files whose symbols GDB has read.  You can use the
924      command `info sources' to find out which files these are.  If you
925      use `maint print psymbols' instead, the dump shows information
926      about symbols that GDB only knows partially--that is, symbols
927      defined in files that GDB has skimmed, but not yet read
928      completely.  Finally, `maint print msymbols' dumps just the
929      minimal symbol information required for each object file from
930      which GDB has read some symbols.  *Note Commands to specify files:
931      Files, for a discussion of how GDB reads symbols (in the
932      description of `symbol-file').
933
934 \1f
935 File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
936
937 Altering Execution
938 ******************
939
940    Once you think you have found an error in your program, you might
941 want to find out for certain whether correcting the apparent error
942 would lead to correct results in the rest of the run.  You can find the
943 answer by experiment, using the GDB features for altering execution of
944 the program.
945
946    For example, you can store new values into variables or memory
947 locations, give your program a signal, restart it at a different
948 address, or even return prematurely from a function.
949
950 * Menu:
951
952 * Assignment::                  Assignment to variables
953 * Jumping::                     Continuing at a different address
954
955 * Signaling::                   Giving your program a signal
956
957 * Returning::                   Returning from a function
958 * Calling::                     Calling your program's functions
959 * Patching::                    Patching your program
960
961 \1f
962 File: gdb.info,  Node: Assignment,  Next: Jumping,  Prev: Altering,  Up: Altering
963
964 Assignment to variables
965 =======================
966
967    To alter the value of a variable, evaluate an assignment expression.
968 *Note Expressions: Expressions.  For example,
969
970      print x=4
971
972 stores the value 4 into the variable `x', and then prints the value of
973 the assignment expression (which is 4).  *Note Using GDB with Different
974 Languages: Languages, for more information on operators in supported
975 languages.
976
977    If you are not interested in seeing the value of the assignment, use
978 the `set' command instead of the `print' command.  `set' is really the
979 same as `print' except that the expression's value is not printed and
980 is not put in the value history (*note Value history: Value History.).
981 The expression is evaluated only for its effects.
982
983    If the beginning of the argument string of the `set' command appears
984 identical to a `set' subcommand, use the `set variable' command instead
985 of just `set'.  This command is identical to `set' except for its lack
986 of subcommands.  For example, if your program has a variable `width',
987 you get an error if you try to set a new value with just `set
988 width=13', because GDB has the command `set width':
989
990      (gdb) whatis width
991      type = double
992      (gdb) p width
993      $4 = 13
994      (gdb) set width=47
995      Invalid syntax in expression.
996
997 The invalid expression, of course, is `=47'.  In order to actually set
998 the program's variable `width', use
999
1000      (gdb) set var width=47
1001
1002    GDB allows more implicit conversions in assignments than C; you can
1003 freely store an integer value into a pointer variable or vice versa,
1004 and you can convert any structure to any other structure that is the
1005 same length or shorter.
1006
1007    To store values into arbitrary places in memory, use the `{...}'
1008 construct to generate a value of specified type at a specified address
1009 (*note Expressions: Expressions.).  For example, `{int}0x83040' refers
1010 to memory location `0x83040' as an integer (which implies a certain size
1011 and representation in memory), and
1012
1013      set {int}0x83040 = 4
1014
1015 stores the value 4 into that memory location.
1016
1017 \1f
1018 File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
1019
1020 Continuing at a different address
1021 =================================
1022
1023    Ordinarily, when you continue your program, you do so at the place
1024 where it stopped, with the `continue' command.  You can instead
1025 continue at an address of your own choosing, with the following
1026 commands:
1027
1028 `jump LINESPEC'
1029      Resume execution at line LINESPEC.  Execution stops again
1030      immediately if there is a breakpoint there.  *Note Printing source
1031      lines: List, for a description of the different forms of LINESPEC.
1032      It is common practice to use the `tbreak' command in conjunction
1033      with `jump'.  *Note Setting breakpoints: Set Breaks.
1034
1035      The `jump' command does not change the current stack frame, or the
1036      stack pointer, or the contents of any memory location or any
1037      register other than the program counter.  If line LINESPEC is in a
1038      different function from the one currently executing, the results
1039      may be bizarre if the two functions expect different patterns of
1040      arguments or of local variables.  For this reason, the `jump'
1041      command requests confirmation if the specified line is not in the
1042      function currently executing.  However, even bizarre results are
1043      predictable if you are well acquainted with the machine-language
1044      code of your program.
1045
1046 `jump *ADDRESS'
1047      Resume execution at the instruction at address ADDRESS.
1048
1049    You can get much the same effect as the `jump' command by storing a
1050 new value into the register `$pc'.  The difference is that this does
1051 not start your program running; it only changes the address of where it
1052 *will* run when you continue.  For example,
1053
1054      set $pc = 0x485
1055
1056 makes the next `continue' command or stepping command execute at
1057 address `0x485', rather than at the address where your program stopped.
1058 *Note Continuing and stepping: Continuing and Stepping.
1059
1060    The most common occasion to use the `jump' command is to back
1061 up--perhaps with more breakpoints set--over a portion of a program that
1062 has already executed, in order to examine its execution in more detail.
1063
1064 \1f
1065 File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
1066
1067 Giving your program a signal
1068 ============================
1069
1070 `signal SIGNAL'
1071      Resume execution where your program stopped, but immediately give
1072      it the signal SIGNAL.  SIGNAL can be the name or the number of a
1073      signal.  For example, on many systems `signal 2' and `signal
1074      SIGINT' are both ways of sending an interrupt signal.
1075
1076      Alternatively, if SIGNAL is zero, continue execution without
1077      giving a signal.  This is useful when your program stopped on
1078      account of a signal and would ordinary see the signal when resumed
1079      with the `continue' command; `signal 0' causes it to resume
1080      without a signal.
1081
1082      `signal' does not repeat when you press <RET> a second time after
1083      executing the command.
1084
1085    Invoking the `signal' command is not the same as invoking the `kill'
1086 utility from the shell.  Sending a signal with `kill' causes GDB to
1087 decide what to do with the signal depending on the signal handling
1088 tables (*note Signals::.).  The `signal' command passes the signal
1089 directly to your program.
1090
1091 \1f
1092 File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
1093
1094 Returning from a function
1095 =========================
1096
1097 `return'
1098 `return EXPRESSION'
1099      You can cancel execution of a function call with the `return'
1100      command.  If you give an EXPRESSION argument, its value is used as
1101      the function's return value.
1102
1103    When you use `return', GDB discards the selected stack frame (and
1104 all frames within it).  You can think of this as making the discarded
1105 frame return prematurely.  If you wish to specify a value to be
1106 returned, give that value as the argument to `return'.
1107
1108    This pops the selected stack frame (*note Selecting a frame:
1109 Selection.), and any other frames inside of it, leaving its caller as
1110 the innermost remaining frame.  That frame becomes selected.  The
1111 specified value is stored in the registers used for returning values of
1112 functions.
1113
1114    The `return' command does not resume execution; it leaves the
1115 program stopped in the state that would exist if the function had just
1116 returned.  In contrast, the `finish' command (*note Continuing and
1117 stepping: Continuing and Stepping.) resumes execution until the
1118 selected stack frame returns naturally.
1119
1120 \1f
1121 File: gdb.info,  Node: Calling,  Next: Patching,  Prev: Returning,  Up: Altering
1122
1123 Calling program functions
1124 =========================
1125
1126 `call EXPR'
1127      Evaluate the expression EXPR without displaying `void' returned
1128      values.
1129
1130    You can use this variant of the `print' command if you want to
1131 execute a function from your program, but without cluttering the output
1132 with `void' returned values.  If the result is not void, it is printed
1133 and saved in the value history.
1134
1135    For the A29K, a user-controlled variable `call_scratch_address',
1136 specifies the location of a scratch area to be used when GDB calls a
1137 function in the target.  This is necessary because the usual method of
1138 putting the scratch area on the stack does not work in systems that
1139 have separate instruction and data spaces.
1140
1141 \1f
1142 File: gdb.info,  Node: Patching,  Prev: Calling,  Up: Altering
1143
1144 Patching programs
1145 =================
1146
1147    By default, GDB opens the file containing your program's executable
1148 code (or the corefile) read-only.  This prevents accidental alterations
1149 to machine code; but it also prevents you from intentionally patching
1150 your program's binary.
1151
1152    If you'd like to be able to patch the binary, you can specify that
1153 explicitly with the `set write' command.  For example, you might want
1154 to turn on internal debugging flags, or even to make emergency repairs.
1155
1156 `set write on'
1157 `set write off'
1158      If you specify `set write on', GDB opens executable and core files
1159      for both reading and writing; if you specify `set write off' (the
1160      default), GDB opens them read-only.
1161
1162      If you have already loaded a file, you must load it again (using
1163      the `exec-file' or `core-file' command) after changing `set
1164      write', for your new setting to take effect.
1165
1166 `show write'
1167      Display whether executable files and core files are opened for
1168      writing as well as reading.
1169
1170 \1f
1171 File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
1172
1173 GDB Files
1174 *********
1175
1176    GDB needs to know the file name of the program to be debugged, both
1177 in order to read its symbol table and in order to start your program.
1178 To debug a core dump of a previous run, you must also tell GDB the name
1179 of the core dump file.
1180
1181 * Menu:
1182
1183 * Files::                       Commands to specify files
1184 * Symbol Errors::               Errors reading symbol files
1185