home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Professional / OS2PRO194.ISO / os2 / prgramer / unix / info / gdb.i04 < prev    next >
Encoding:
GNU Info File  |  1993-06-12  |  50.9 KB  |  1,374 lines

  1. This is Info file gdb.info, produced by Makeinfo-1.47 from the input
  2. file gdb-all.tex.
  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 Edition 4.06, October 1992, of `Debugging with GDB: the GNU
  10. Source-Level Debugger' for GDB Version 4.7.
  11.  
  12.    Copyright (C) 1988, 1989, 1990, 1991, 1992 Free Software Foundation,
  13. Inc.
  14.  
  15.    Permission is granted to make and distribute verbatim copies of this
  16. manual provided the copyright notice and this permission notice are
  17. preserved on all copies.
  18.  
  19.    Permission is granted to copy and distribute modified versions of
  20. this manual under the conditions for verbatim copying, provided also
  21. that the section entitled "GNU General Public License" is included
  22. exactly as in the original, and provided that the entire resulting
  23. derived work is distributed under the terms of a permission notice
  24. identical to this one.
  25.  
  26.    Permission is granted to copy and distribute translations of this
  27. manual into another language, under the above conditions for modified
  28. versions, except that the section entitled "GNU General Public License"
  29. may be included in a translation approved by the Free Software
  30. Foundation instead of in the original English.
  31.  
  32. 
  33. File: gdb.info,  Node: Languages,  Next: Symbols,  Prev: Data,  Up: Top
  34.  
  35. Using GDB with Different Languages
  36. **********************************
  37.  
  38.    Although programming languages generally have common aspects, they
  39. are rarely expressed in the same manner.  For instance, in ANSI C,
  40. dereferencing a pointer `p' is accomplished by `*p', but in Modula-2,
  41. it is accomplished by `p^'.  Values can also be represented (and
  42. displayed) differently.  Hex numbers in C are written like `0x1ae',
  43. while in Modula-2 they appear as `1AEH'.
  44.  
  45.    Language-specific information is built into GDB for some languages,
  46. allowing you to express operations like the above in your program's
  47. native language, and allowing GDB to output values in a manner
  48. consistent with the syntax of your program's native language.  The
  49. language you use to build expressions, called the "working language",
  50. can be selected manually, or GDB can set it automatically.
  51.  
  52. * Menu:
  53.  
  54. * Setting::                     Switching between source languages
  55. * Show::                        Displaying the language
  56. * Checks::                      Type and Range checks
  57. * Support::                     Supported languages
  58.  
  59. 
  60. File: gdb.info,  Node: Setting,  Next: Show,  Up: Languages
  61.  
  62. Switching between source languages
  63. ==================================
  64.  
  65.    There are two ways to control the working language--either have GDB
  66. set it automatically, or select it manually yourself.  You can use the
  67. `set language' command for either purpose.  On startup, GDB defaults to
  68. setting the language automatically.
  69.  
  70. * Menu:
  71.  
  72. * Manually::                    Setting the working language manually
  73. * Automatically::               Having GDB infer the source language
  74.  
  75. 
  76. File: gdb.info,  Node: Manually,  Next: Automatically,  Up: Setting
  77.  
  78. Setting the working language
  79. ----------------------------
  80.  
  81.    To set the language, issue the command `set language LANG', where
  82. LANG is the name of a language: `c' or `modula-2'. For a list of the
  83. supported languages, type `set language'.
  84.  
  85.    Setting the language manually prevents GDB from updating the working
  86. language automatically.  This can lead to confusion if you try to debug
  87. a program when the working language is not the same as the source
  88. language, when an expression is acceptable to both languages--but means
  89. different things.  For instance, if the current source file were
  90. written in C, and GDB was parsing Modula-2, a command such as:
  91.  
  92.      print a = b + c
  93.  
  94. might not have the effect you intended.  In C, this means to add `b'
  95. and `c' and place the result in `a'.  The result printed would be the
  96. value of `a'.  In Modula-2, this means to compare `a' to the result of
  97. `b+c', yielding a `BOOLEAN' value.
  98.  
  99.    If you allow GDB to set the language automatically, then you can
  100. count on expressions evaluating the same way in your debugging session
  101. and in your program.
  102.  
  103. 
  104. File: gdb.info,  Node: Automatically,  Prev: Manually,  Up: Setting
  105.  
  106. Having GDB infer the source language
  107. ------------------------------------
  108.  
  109.    To have GDB set the working language automatically, use `set
  110. language local' or `set language auto'.  GDB then infers the language
  111. that a program was written in by looking at the name of its source
  112. files, and examining their extensions:
  113.  
  114. `*.mod'
  115.      Modula-2 source file
  116.  
  117. `*.c'
  118.      C source file
  119.  
  120. `*.C'
  121. `*.cc'
  122.      C++ source file
  123.  
  124.    This information is recorded for each function or procedure in a
  125. source file.  When your program stops in a frame (usually by
  126. encountering a breakpoint), GDB sets the working language to the
  127. language recorded for the function in that frame.  If the language for
  128. a frame is unknown (that is, if the function or block corresponding to
  129. the frame was defined in a source file that does not have a recognized
  130. extension), the current working language is not changed, and GDB issues
  131. a warning.
  132.  
  133.    This may not seem necessary for most programs, which are written
  134. entirely in one source language.  However, program modules and libraries
  135. written in one source language can be used by a main program written in
  136. a different source language.  Using `set language auto' in this case
  137. frees you from having to set the working language manually.
  138.  
  139. 
  140. File: gdb.info,  Node: Show,  Next: Checks,  Prev: Setting,  Up: Languages
  141.  
  142. Displaying the language
  143. =======================
  144.  
  145.    The following commands will help you find out which language is the
  146. working language, and also what language source files were written in.
  147.  
  148. `show language'
  149.      Display the current working language.  This is the language you
  150.      can use with commands such as `print' to build and compute
  151.      expressions that may involve variables in your program.
  152.  
  153. `info frame'
  154.      Among the other information listed here (*note Information about a
  155.      Frame: Frame Info.) is the source language for this frame.  This
  156.      is the language that will become the working language if you ever
  157.      use an identifier that is in this frame.
  158.  
  159. `info source'
  160.      Among the other information listed here (*note Examining the
  161.      Symbol Table: Symbols.) is the source language of this source file.
  162.  
  163. 
  164. File: gdb.info,  Node: Checks,  Next: Support,  Prev: Show,  Up: Languages
  165.  
  166. Type and range Checking
  167. =======================
  168.  
  169.      *Warning:* In this release, the GDB commands for type and range
  170.      checking are included, but they do not yet have any effect.  This
  171.      section documents the intended facilities.
  172.  
  173.    Some languages are designed to guard you against making seemingly
  174. common errors through a series of compile- and run-time checks.  These
  175. include checking the type of arguments to functions and operators, and
  176. making sure mathematical overflows are caught at run time.  Checks such
  177. as these help to ensure a program's correctness once it has been
  178. compiled by eliminating type mismatches, and providing active checks
  179. for range errors when your program is running.
  180.  
  181.    GDB can check for conditions like the above if you wish. Although
  182. GDB will not check the statements in your program, it can check
  183. expressions entered directly into GDB for evaluation via the `print'
  184. command, for example.  As with the working language, GDB can also
  185. decide whether or not to check automatically based on your program's
  186. source language.  *Note Supported Languages: Support, for the default
  187. settings of supported languages.
  188.  
  189. * Menu:
  190.  
  191. * Type Checking::               An overview of type checking
  192. * Range Checking::              An overview of range checking
  193.  
  194. 
  195. File: gdb.info,  Node: Type Checking,  Next: Range Checking,  Up: Checks
  196.  
  197. An overview of type checking
  198. ----------------------------
  199.  
  200.    Some languages, such as Modula-2, are strongly typed, meaning that
  201. the arguments to operators and functions have to be of the correct type,
  202. otherwise an error occurs.  These checks prevent type mismatch errors
  203. from ever causing any run-time problems.  For example,
  204.  
  205.      1 + 2 => 3
  206. but
  207.      error--> 1 + 2.3
  208.  
  209.    The second example fails because the `CARDINAL' 1 is not
  210. type-compatible with the `REAL' 2.3.
  211.  
  212.    For expressions you use in GDB commands, you can tell the GDB type
  213. checker to skip checking; to treat any mismatches as errors and abandon
  214. the expression; or only issue warnings when type mismatches occur, but
  215. evaluate the expression anyway.  When you choose the last of these, GDB
  216. evaluates expressions like the second example above, but also issues a
  217. warning.
  218.  
  219.    Even though you may turn type checking off, other type-based reasons
  220. may prevent GDB from evaluating an expression.  For instance, GDB does
  221. not know how to add an `int' and a `struct foo'.  These particular type
  222. errors have nothing to do with the language in use, and usually arise
  223. from expressions, such as the one described above, which make little
  224. sense to evaluate anyway.
  225.  
  226.    Each language defines to what degree it is strict about type.  For
  227. instance, both Modula-2 and C require the arguments to arithmetical
  228. operators to be numbers.  In C, enumerated types and pointers can be
  229. represented as numbers, so that they are valid arguments to mathematical
  230. operators.  *Note Supported Languages: Support, for further details on
  231. specific languages.
  232.  
  233.    GDB provides some additional commands for controlling the type
  234. checker:
  235.  
  236. `set check type auto'
  237.      Set type checking on or off based on the current working language.
  238.      *Note Supported Languages: Support, for the default settings for
  239.      each language.
  240.  
  241. `set check type on'
  242. `set check type off'
  243.      Set type checking on or off, overriding the default setting for the
  244.      current working language.  Issue a warning if the setting does not
  245.      match the language's default.  If any type mismatches occur in
  246.      evaluating an expression while typechecking is on, GDB prints a
  247.      message and aborts evaluation of the expression.
  248.  
  249. `set check type warn'
  250.      Cause the type checker to issue warnings, but to always attempt to
  251.      evaluate the expression.  Evaluating the expression may still be
  252.      impossible for other reasons.  For example, GDB cannot add numbers
  253.      and structures.
  254.  
  255. `show type'
  256.      Show the current setting of the type checker, and whether or not
  257.      GDB is setting it automatically.
  258.  
  259. 
  260. File: gdb.info,  Node: Range Checking,  Prev: Type Checking,  Up: Checks
  261.  
  262. An overview of Range Checking
  263. -----------------------------
  264.  
  265.    In some languages (such as Modula-2), it is an error to exceed the
  266. bounds of a type; this is enforced with run-time checks.  Such range
  267. checking is meant to ensure program correctness by making sure
  268. computations do not overflow, or indices on an array element access do
  269. not exceed the bounds of the array.
  270.  
  271.    For expressions you use in GDB commands, you can tell GDB to ignore
  272. range errors; to always treat them as errors and abandon the
  273. expression; or to issue warnings when a range error occurs but evaluate
  274. the expression anyway.
  275.  
  276.    A range error can result from numerical overflow, from exceeding an
  277. array index bound, or when you type in a constant that is not a member
  278. of any type.  Some languages, however, do not treat overflows as an
  279. error.  In many implementations of C, mathematical overflow causes the
  280. result to "wrap around" to lower values--for example, if M is the
  281. largest integer value, and S is the smallest, then
  282.  
  283.      M + 1 => S
  284.  
  285.    This, too, is specific to individual languages, and in some cases
  286. specific to individual compilers or machines.  *Note  Supported
  287. Languages: Support, for further details on specific languages.
  288.  
  289.    GDB provides some additional commands for controlling the range
  290. checker:
  291.  
  292. `set check range auto'
  293.      Set range checking on or off based on the current working language.
  294.      *Note Supported Languages: Support, for the default settings for
  295.      each language.
  296.  
  297. `set check range on'
  298. `set check range off'
  299.      Set range checking on or off, overriding the default setting for
  300.      the current working language.  A warning is issued if the setting
  301.      does not match the language's default.  If a range error occurs,
  302.      then a message is printed and evaluation of the expression is
  303.      aborted.
  304.  
  305. `set check range warn'
  306.      Output messages when the GDB range checker detects a range error,
  307.      but attempt to evaluate the expression anyway.  Evaluating the
  308.      expression may still be impossible for other reasons, such as
  309.      accessing memory that the process does not own (a typical example
  310.      from many UNIX systems).
  311.  
  312. `show range'
  313.      Show the current setting of the range checker, and whether or not
  314.      it is being set automatically by GDB.
  315.  
  316. 
  317. File: gdb.info,  Node: Support,  Prev: Checks,  Up: Languages
  318.  
  319. Supported Languages
  320. ===================
  321.  
  322.    GDB 4 supports C, C++, and Modula-2.  Some GDB features may be used
  323. in expressions regardless of the language you use: the GDB `@' and `::'
  324. operators, and the `{type}addr' construct (*note Expressions:
  325. Expressions.) can be used with the constructs of any of the supported
  326. languages.
  327.  
  328.    The following sections detail to what degree each of these source
  329. languages is supported by GDB.  These sections are not meant to be
  330. language tutorials or references, but serve only as a reference guide
  331. to what the GDB expression parser will accept, and what input and
  332. output formats should look like for different languages. There are many
  333. good books written on each of these languages; please look to these for
  334. a language reference or tutorial.
  335.  
  336. * Menu:
  337.  
  338. * C::                           C and C++
  339. * Modula-2::                    Modula-2
  340.  
  341. 
  342. File: gdb.info,  Node: C,  Next: Modula-2,  Up: Support
  343.  
  344. C and C++
  345. ---------
  346.  
  347.    Since C and C++ are so closely related, many features of GDB apply
  348. to both languages.  Whenever this is the case, we discuss both languages
  349. together.
  350.  
  351.    The C++ debugging facilities are jointly implemented by the GNU C++
  352. compiler and GDB.  Therefore, to debug your C++ code effectively, you
  353. must compile your C++ programs with the GNU C++ compiler, `g++'.
  354.  
  355. * Menu:
  356.  
  357. * C Operators::                 C and C++ Operators
  358. * C Constants::                 C and C++ Constants
  359. * Cplusplus expressions::       C++ Expressions
  360. * C Defaults::                  Default settings for C and C++
  361. * C Checks::                    C and C++ Type and Range Checks
  362. * Debugging C::                 GDB and C
  363. * Debugging C plus plus::       Special features for C++
  364.  
  365. 
  366. File: gdb.info,  Node: C Operators,  Next: C Constants,  Up: C
  367.  
  368. C and C++ Operators
  369. ...................
  370.  
  371.    Operators must be defined on values of specific types.  For instance,
  372. `+' is defined on numbers, but not on structures.  Operators are often
  373. defined on groups of types.
  374.  
  375.    For the purposes of C and C++, the following definitions hold:
  376.  
  377.    * *Integral types* include `int' with any of its storage-class
  378.      specifiers, `char', and `enum's.
  379.  
  380.    * *Floating-point types* include `float' and `double'.
  381.  
  382.    * *Pointer types* include all types defined as `(TYPE *)'.
  383.  
  384.    * *Scalar types* include all of the above.
  385.  
  386. The following operators are supported.  They are listed here in order
  387. of increasing precedence:
  388.  
  389. `,'
  390.      The comma or sequencing operator.  Expressions in a
  391.      comma-separated list are evaluated from left to right, with the
  392.      result of the entire expression being the last expression
  393.      evaluated.
  394.  
  395. `='
  396.      Assignment.  The value of an assignment expression is the value
  397.      assigned.  Defined on scalar types.
  398.  
  399. `OP='
  400.      Used in an expression of the form `A OP= B', and translated to
  401.      `A = A OP B'. `OP=' and `=' have the same precendence. OP is any
  402.      one of the operators `|', `^', `&', `<<', `>>', `+', `-', `*',
  403.      `/', `%'.
  404.  
  405. `?:'
  406.      The ternary operator.  `A ? B : C' can be thought of as:  if A
  407.      then B else C.  A should be of an integral type.
  408.  
  409. `||'
  410.      Logical OR.  Defined on integral types.
  411.  
  412. `&&'
  413.      Logical AND.  Defined on integral types.
  414.  
  415. `|'
  416.      Bitwise OR.  Defined on integral types.
  417.  
  418. `^'
  419.      Bitwise exclusive-OR.  Defined on integral types.
  420.  
  421. `&'
  422.      Bitwise AND.  Defined on integral types.
  423.  
  424. `==, !='
  425.      Equality and inequality.  Defined on scalar types.  The value of
  426.      these expressions is 0 for false and non-zero for true.
  427.  
  428. `<, >, <=, >='
  429.      Less than, greater than, less than or equal, greater than or equal.
  430.      Defined on scalar types.  The value of these expressions is 0 for
  431.      false and non-zero for true.
  432.  
  433. `<<, >>'
  434.      left shift, and right shift.  Defined on integral types.
  435.  
  436. `@'
  437.      The GDB "artificial array" operator (*note Expressions:
  438.      Expressions.).
  439.  
  440. `+, -'
  441.      Addition and subtraction.  Defined on integral types,
  442.      floating-point types and pointer types.
  443.  
  444. `*, /, %'
  445.      Multiplication, division, and modulus.  Multiplication and
  446.      division are defined on integral and floating-point types. 
  447.      Modulus is defined on integral types.
  448.  
  449. `++, --'
  450.      Increment and decrement.  When appearing before a variable, the
  451.      operation is performed before the variable is used in an
  452.      expression; when appearing after it, the variable's value is used
  453.      before the operation takes place.
  454.  
  455. `*'
  456.      Pointer dereferencing.  Defined on pointer types.  Same precedence
  457.      as `++'.
  458.  
  459. `&'
  460.      Address operator.  Defined on variables.  Same precedence as `++'.
  461.  
  462.      For debugging C++, GDB implements a use of `&' beyond what's
  463.      allowed in the C++ language itself: you can use `&(&REF)' (or, if
  464.      you prefer, simply `&&REF' to examine the address where a C++
  465.      reference variable (declared with `&REF') is stored.
  466.  
  467. `-'
  468.      Negative.  Defined on integral and floating-point types.  Same
  469.      precedence as `++'.
  470.  
  471. `!'
  472.      Logical negation.  Defined on integral types.  Same precedence as
  473.      `++'.
  474.  
  475. `~'
  476.      Bitwise complement operator.  Defined on integral types.  Same
  477.      precedence as `++'.
  478.  
  479. `., ->'
  480.      Structure member, and pointer-to-structure member.  For
  481.      convenience, GDB regards the two as equivalent, choosing whether
  482.      to dereference a pointer based on the stored type information.
  483.      Defined on `struct's and `union's.
  484.  
  485. `[]'
  486.      Array indexing.  `A[I]' is defined as `*(A+I)'.  Same precedence
  487.      as `->'.
  488.  
  489. `()'
  490.      Function parameter list.  Same precedence as `->'.
  491.  
  492. `::'
  493.      C++ scope resolution operator.  Defined on `struct', `union', and
  494.      `class' types.
  495.  
  496. `::'
  497.      The GDB scope operator (*note Expressions: Expressions.). Same
  498.      precedence as `::', above.
  499.  
  500. 
  501. File: gdb.info,  Node: C Constants,  Next: Cplusplus expressions,  Prev: C Operators,  Up: C
  502.  
  503. C and C++ Constants
  504. ...................
  505.  
  506.    GDB allows you to express the constants of C and C++ in the
  507. following ways:
  508.  
  509.    * Integer constants are a sequence of digits.  Octal constants are
  510.      specified by a leading `0' (ie. zero), and hexadecimal constants by
  511.      a leading `0x' or `0X'.  Constants may also end with a letter `l',
  512.      specifying that the constant should be treated as a `long' value.
  513.  
  514.    * Floating point constants are a sequence of digits, followed by a
  515.      decimal point, followed by a sequence of digits, and optionally
  516.      followed by an exponent.  An exponent is of the form:
  517.      `e[[+]|-]NNN', where NNN is another sequence of digits.  The `+'
  518.      is optional for positive exponents.
  519.  
  520.    * Enumerated constants consist of enumerated identifiers, or their
  521.      integral equivalents.
  522.  
  523.    * Character constants are a single character surrounded by single
  524.      quotes (`''), or a number--the ordinal value of the corresponding
  525.      character (usually its ASCII value).  Within quotes, the single
  526.      character may be represented by a letter or by "escape sequences",
  527.      which are of the form `\NNN', where NNN is the octal representation
  528.      of the character's ordinal value; or of the form `\X', where `X'
  529.      is a predefined special character--for example, `\n' for newline.
  530.  
  531.    * String constants are a sequence of character constants surrounded
  532.      by double quotes (`"').
  533.  
  534.    * Pointer constants are an integral value.
  535.  
  536. 
  537. File: gdb.info,  Node: Cplusplus expressions,  Next: C Defaults,  Prev: C Constants,  Up: C
  538.  
  539. C++ Expressions
  540. ...............
  541.  
  542.    GDB's expression handling has a number of extensions to interpret a
  543. significant subset of C++ expressions.
  544.  
  545.      *Warning:* Most of these extensions depend on the use of additional
  546.      debugging information in the symbol table, and thus require a rich,
  547.      extendable object code format.  In particular, if your system uses
  548.      a.out, MIPS ECOFF, RS/6000 XCOFF, or Sun ELF with stabs extensions
  549.      to the symbol table, these facilities are all available. Where the
  550.      object code format is standard COFF, on the other hand, most of
  551.      the C++ support in GDB will *not* work, nor can it. For the
  552.      standard SVr4 debugging format, DWARF in ELF, the standard is
  553.      still evolving, so the C++ support in GDB is still fragile; when
  554.      this debugging format stabilizes, however, C++ support will also
  555.      be available on systems that use it.
  556.  
  557.   1. Member function calls are allowed; you can use expressions like
  558.  
  559.           count = aml->GetOriginal(x, y)
  560.  
  561.   2. While a member function is active (in the selected stack frame),
  562.      your expressions have the same namespace available as the member
  563.      function; that is, GDB allows implicit references to the class
  564.      instance pointer `this' following the same rules as C++.
  565.  
  566.   3. You can call overloaded functions; GDB will resolve the function
  567.      call to the right definition, with one restriction--you must use
  568.      arguments of the type required by the function that you want to
  569.      call. GDB will not perform conversions requiring constructors or
  570.      user-defined type operators.
  571.  
  572.   4. GDB understands variables declared as C++ references; you can use
  573.      them in expressions just as you do in C++ source--they are
  574.      automatically dereferenced.
  575.  
  576.      In the parameter list shown when GDB displays a frame, the values
  577.      of reference variables are not displayed (unlike other variables);
  578.      this avoids clutter, since references are often used for large
  579.      structures. The *address* of a reference variable is always shown,
  580.      unless you have specified `set print address off'.
  581.  
  582.   5. GDB supports the C++ name resolution operator `::'--your
  583.      expressions can use it just as expressions in your program do. 
  584.      Since one scope may be defined in another, you can use `::'
  585.      repeatedly if necessary, for example in an expression like
  586.      `SCOPE1::SCOPE2::NAME'.  GDB also allows resolving name scope by
  587.      reference to source files, in both C and C++ debugging (*note
  588.      Program Variables: Variables.).
  589.  
  590. 
  591. File: gdb.info,  Node: C Defaults,  Next: C Checks,  Prev: Cplusplus expressions,  Up: C
  592.  
  593. C and C++ Defaults
  594. ..................
  595.  
  596.    If you allow GDB to set type and range checking automatically, they
  597. both default to `off' whenever the working language changes to C or
  598. C++.  This happens regardless of whether you, or GDB, selected the
  599. working language.
  600.  
  601.    If you allow GDB to set the language automatically, it sets the
  602. working language to C or C++ on entering code compiled from a source
  603. file whose name ends with `.c', `.C', or `.cc'. *Note Having GDB infer
  604. the source language: Automatically, for further details.
  605.  
  606. 
  607. File: gdb.info,  Node: C Checks,  Next: Debugging C,  Prev: C Defaults,  Up: C
  608.  
  609. C and C++ Type and Range Checks
  610. ...............................
  611.  
  612.      *Warning:* in this release, GDB does not yet perform type or range
  613.      checking.
  614.  
  615.    By default, when GDB parses C or C++ expressions, type checking is
  616. not used.  However, if you turn type checking on, GDB will consider two
  617. variables type equivalent if:
  618.  
  619.    * The two variables are structured and have the same structure,
  620.      union, or enumerated tag.
  621.  
  622.    * Two two variables have the same type name, or types that have been
  623.      declared equivalent through `typedef'.
  624.  
  625.    Range checking, if turned on, is done on mathematical operations. 
  626. Array indices are not checked, since they are often used to index a
  627. pointer that is not itself an array.
  628.  
  629. 
  630. File: gdb.info,  Node: Debugging C,  Next: Debugging C plus plus,  Prev: C Checks,  Up: C
  631.  
  632. GDB and C
  633. .........
  634.  
  635.    The `set print union' and `show print union' commands apply to the
  636. `union' type.  When set to `on', any `union' that is inside a `struct'
  637. or `class' will also be printed. Otherwise, it will appear as `{...}'.
  638.  
  639.    The `@' operator aids in the debugging of dynamic arrays, formed
  640. with pointers and a memory allocation function.  (*note Expressions:
  641. Expressions.)
  642.  
  643. 
  644. File: gdb.info,  Node: Debugging C plus plus,  Prev: Debugging C,  Up: C
  645.  
  646. GDB Features for C++
  647. ....................
  648.  
  649.    Some GDB commands are particularly useful with C++, and some are
  650. designed specifically for use with C++.  Here is a summary:
  651.  
  652. `breakpoint menus'
  653.      When you want a breakpoint in a function whose name is overloaded,
  654.      GDB's breakpoint menus help you specify which function definition
  655.      you want.  *Note Breakpoint Menus::.
  656.  
  657. `rbreak REGEX'
  658.      Setting breakpoints using regular expressions is helpful for
  659.      setting breakpoints on overloaded functions that are not members
  660.      of any special classes. *Note Setting Breakpoints: Set Breaks.
  661.  
  662. `catch EXCEPTIONS'
  663. `info catch'
  664.      Debug C++ exception handling using these commands.  *Note
  665.      Breakpoints and Exceptions: Exception Handling.
  666.  
  667. `ptype TYPENAME'
  668.      Print inheritance relationships as well as other information for
  669.      type TYPENAME. *Note Examining the Symbol Table: Symbols.
  670.  
  671. `set print demangle'
  672. `show print demangle'
  673. `set print asm-demangle'
  674. `show print asm-demangle'
  675.      Control whether C++ symbols display in their source form, both when
  676.      displaying code as C++ source and when displaying disassemblies.
  677.      *Note Print Settings: Print Settings.
  678.  
  679. `set print object'
  680. `show print object'
  681.      Choose whether to print derived (actual) or declared types of
  682.      objects. *Note Print Settings: Print Settings.
  683.  
  684. `set print vtbl'
  685. `show print vtbl'
  686.      Control the format for printing virtual function tables. *Note
  687.      Print Settings: Print Settings.
  688.  
  689. `Overloaded symbol names'
  690.      You can specify a particular definition of an overloaded symbol,
  691.      using the same notation that's used to declare such symbols in
  692.      C++: type `SYMBOL(TYPES)' rather than just SYMBOL.  You can also
  693.      use GDB's command-line word completion facilities to list the
  694.      available choices, or to finish the type list for you. *Note
  695.      Command Completion: Completion, for details on how to do this.
  696.  
  697. 
  698. File: gdb.info,  Node: Modula-2,  Prev: C,  Up: Support
  699.  
  700. Modula-2
  701. --------
  702.  
  703.    The extensions made to GDB to support Modula-2 support output from
  704. the GNU Modula-2 compiler (which is currently being developed). Other
  705. Modula-2 compilers are not currently supported, and attempting to debug
  706. executables produced by them will most likely result in an error as GDB
  707. reads in the executable's symbol table.
  708.  
  709. * Menu:
  710.  
  711. * M2 Operators::                Built-in operators
  712. * Built-In Func/Proc::           Built-in Functions and Procedures
  713. * M2 Constants::                Modula-2 Constants
  714. * M2 Defaults::                 Default settings for Modula-2
  715. * Deviations::                  Deviations from standard Modula-2
  716. * M2 Checks::                   Modula-2 Type and Range Checks
  717. * M2 Scope::                    The scope operators `::' and `.'
  718. * GDB/M2::                      GDB and Modula-2
  719.  
  720. 
  721. File: gdb.info,  Node: M2 Operators,  Next: Built-In Func/Proc,  Up: Modula-2
  722.  
  723. Operators
  724. .........
  725.  
  726.    Operators must be defined on values of specific types.  For instance,
  727. `+' is defined on numbers, but not on structures.  Operators are often
  728. defined on groups of types.  For the purposes of Modula-2, the
  729. following definitions hold:
  730.  
  731.    * *Integral types* consist of `INTEGER', `CARDINAL', and their
  732.      subranges.
  733.  
  734.    * *Character types* consist of `CHAR' and its subranges.
  735.  
  736.    * *Floating-point types* consist of `REAL'.
  737.  
  738.    * *Pointer types* consist of anything declared as `POINTER TO TYPE'.
  739.  
  740.    * *Scalar types* consist of all of the above.
  741.  
  742.    * *Set types* consist of `SET's and `BITSET's.
  743.  
  744.    * *Boolean types* consist of `BOOLEAN'.
  745.  
  746. The following operators are supported, and appear in order of
  747. increasing precedence:
  748.  
  749. `,'
  750.      Function argument or array index separator.
  751.  
  752. `:='
  753.      Assignment.  The value of VAR `:=' VALUE is VALUE.
  754.  
  755. `<, >'
  756.      Less than, greater than on integral, floating-point, or enumerated
  757.      types.
  758.  
  759. `<=, >='
  760.      Less than, greater than, less than or equal to, greater than or
  761.      equal to on integral, floating-point and enumerated types, or set
  762.      inclusion on set types.  Same precedence as `<'.
  763.  
  764. `=, <>, #'
  765.      Equality and two ways of expressing inequality, valid on scalar
  766.      types. Same precedence as `<'.  In GDB scripts, only `<>' is
  767.      available for inequality, since `#' conflicts with the script
  768.      comment character.
  769.  
  770. `IN'
  771.      Set membership.  Defined on set types and the types of their
  772.      members. Same precedence as `<'.
  773.  
  774. `OR'
  775.      Boolean disjunction.  Defined on boolean types.
  776.  
  777. `AND, &'
  778.      Boolean conjuction.  Defined on boolean types.
  779.  
  780. `@'
  781.      The GDB "artificial array" operator (*note Expressions:
  782.      Expressions.).
  783.  
  784. `+, -'
  785.      Addition and subtraction on integral and floating-point types, or
  786.      union and difference on set types.
  787.  
  788. `*'
  789.      Multiplication on integral and floating-point types, or set
  790.      intersection on set types.
  791.  
  792. `/'
  793.      Division on floating-point types, or symmetric set difference on
  794.      set types.  Same precedence as `*'.
  795.  
  796. `DIV, MOD'
  797.      Integer division and remainder.  Defined on integral types.  Same
  798.      precedence as `*'.
  799.  
  800. `-'
  801.      Negative. Defined on `INTEGER's and `REAL's.
  802.  
  803. `^'
  804.      Pointer dereferencing.  Defined on pointer types.
  805.  
  806. `NOT'
  807.      Boolean negation.  Defined on boolean types.  Same precedence as
  808.      `^'.
  809.  
  810. `.'
  811.      `RECORD' field selector.  Defined on `RECORD's.  Same precedence
  812.      as `^'.
  813.  
  814. `[]'
  815.      Array indexing.  Defined on `ARRAY's.  Same precedence as `^'.
  816.  
  817. `()'
  818.      Procedure argument list.  Defined on `PROCEDURE's.  Same precedence
  819.      as `^'.
  820.  
  821. `::, .'
  822.      GDB and Modula-2 scope operators.
  823.  
  824.      *Warning:* Sets and their operations are not yet supported, so GDB
  825.      will treat the use of the operator `IN', or the use of operators
  826.      `+', `-', `*', `/', `=', , `<>', `#', `<=', and `>=' on sets as an
  827.      error.
  828.  
  829. 
  830. File: gdb.info,  Node: Built-In Func/Proc,  Next: M2 Constants,  Prev: M2 Operators,  Up: Modula-2
  831.  
  832. Built-in Functions and Procedures
  833. .................................
  834.  
  835.    Modula-2 also makes available several built-in procedures and
  836. functions. In describing these, the following metavariables are used:
  837.  
  838. A
  839.      represents an `ARRAY' variable.
  840.  
  841. C
  842.      represents a `CHAR' constant or variable.
  843.  
  844. I
  845.      represents a variable or constant of integral type.
  846.  
  847. M
  848.      represents an identifier that belongs to a set.  Generally used in
  849.      the same function with the metavariable S.  The type of S should
  850.      be `SET OF MTYPE' (where MTYPE is the type of M.
  851.  
  852. N
  853.      represents a variable or constant of integral or floating-point
  854.      type.
  855.  
  856. R
  857.      represents a variable or constant of floating-point type.
  858.  
  859. T
  860.      represents a type.
  861.  
  862. V
  863.      represents a variable.
  864.  
  865. X
  866.      represents a variable or constant of one of many types.  See the
  867.      explanation of the function for details.
  868.  
  869.    All Modula-2 built-in procedures also return a result, described
  870. below.
  871.  
  872. `ABS(N)'
  873.      Returns the absolute value of N.
  874.  
  875. `CAP(C)'
  876.      If C is a lower case letter, it returns its upper case equivalent,
  877.      otherwise it returns its argument
  878.  
  879. `CHR(I)'
  880.      Returns the character whose ordinal value is I.
  881.  
  882. `DEC(V)'
  883.      Decrements the value in the variable V.  Returns the new value.
  884.  
  885. `DEC(V,I)'
  886.      Decrements the value in the variable V by I.  Returns the new
  887.      value.
  888.  
  889. `EXCL(M,S)'
  890.      Removes the element M from the set S.  Returns the new set.
  891.  
  892. `FLOAT(I)'
  893.      Returns the floating point equivalent of the integer I.
  894.  
  895. `HIGH(A)'
  896.      Returns the index of the last member of A.
  897.  
  898. `INC(V)'
  899.      Increments the value in the variable V.  Returns the new value.
  900.  
  901. `INC(V,I)'
  902.      Increments the value in the variable V by I.  Returns the new
  903.      value.
  904.  
  905. `INCL(M,S)'
  906.      Adds the element M to the set S if it is not already there. 
  907.      Returns the new set.
  908.  
  909. `MAX(T)'
  910.      Returns the maximum value of the type T.
  911.  
  912. `MIN(T)'
  913.      Returns the minimum value of the type T.
  914.  
  915. `ODD(I)'
  916.      Returns boolean TRUE if I is an odd number.
  917.  
  918. `ORD(X)'
  919.      Returns the ordinal value of its argument.  For example, the
  920.      ordinal value of a character is its ASCII value (on machines
  921.      supporting the ASCII character set).  X must be of an ordered
  922.      type, which include integral, character and enumerated types.
  923.  
  924. `SIZE(X)'
  925.      Returns the size of its argument.  X can be a variable or a type.
  926.  
  927. `TRUNC(R)'
  928.      Returns the integral part of R.
  929.  
  930. `VAL(T,I)'
  931.      Returns the member of the type T whose ordinal value is I.
  932.  
  933.      *Warning:*  Sets and their operations are not yet supported, so
  934.      GDB will treat the use of procedures `INCL' and `EXCL' as an error.
  935.  
  936. 
  937. File: gdb.info,  Node: M2 Constants,  Next: M2 Defaults,  Prev: Built-In Func/Proc,  Up: Modula-2
  938.  
  939. Constants
  940. .........
  941.  
  942.    GDB allows you to express the constants of Modula-2 in the following
  943. ways:
  944.  
  945.    * Integer constants are simply a sequence of digits.  When used in an
  946.      expression, a constant is interpreted to be type-compatible with
  947.      the rest of the expression.  Hexadecimal integers are specified by
  948.      a trailing `H', and octal integers by a trailing `B'.
  949.  
  950.    * Floating point constants appear as a sequence of digits, followed
  951.      by a decimal point and another sequence of digits.  An optional
  952.      exponent can then be specified, in the form `E[+|-]NNN', where
  953.      `[+|-]NNN' is the desired exponent.  All of the digits of the
  954.      floating point constant must be valid decimal (base 10) digits.
  955.  
  956.    * Character constants consist of a single character enclosed by a
  957.      pair of like quotes, either single (`'') or double (`"').  They may
  958.      also be expressed by their ordinal value (their ASCII value,
  959.      usually) followed by a `C'.
  960.  
  961.    * String constants consist of a sequence of characters enclosed by a
  962.      pair of like quotes, either single (`'') or double (`"'). Escape
  963.      sequences in the style of C are also allowed.  *Note C and C++
  964.      Constants: C Constants, for a brief explanation of escape
  965.      sequences.
  966.  
  967.    * Enumerated constants consist of an enumerated identifier.
  968.  
  969.    * Boolean constants consist of the identifiers `TRUE' and `FALSE'.
  970.  
  971.    * Pointer constants consist of integral values only.
  972.  
  973.    * Set constants are not yet supported.
  974.  
  975. 
  976. File: gdb.info,  Node: M2 Defaults,  Next: Deviations,  Prev: M2 Constants,  Up: Modula-2
  977.  
  978. Modula-2 Defaults
  979. .................
  980.  
  981.    If type and range checking are set automatically by GDB, they both
  982. default to `on' whenever the working language changes to Modula-2. 
  983. This happens regardless of whether you, or GDB, selected the working
  984. language.
  985.  
  986.    If you allow GDB to set the language automatically, then entering
  987. code compiled from a file whose name ends with `.mod' will set the
  988. working language to Modula-2. *Note Having GDB set the language
  989. automatically: Automatically, for further details.
  990.  
  991. 
  992. File: gdb.info,  Node: Deviations,  Next: M2 Checks,  Prev: M2 Defaults,  Up: Modula-2
  993.  
  994. Deviations from Standard Modula-2
  995. .................................
  996.  
  997.    A few changes have been made to make Modula-2 programs easier to
  998. debug. This is done primarily via loosening its type strictness:
  999.  
  1000.    * Unlike in standard Modula-2, pointer constants can be formed by
  1001.      integers.  This allows you to modify pointer variables during
  1002.      debugging.  (In standard Modula-2, the actual address contained in
  1003.      a pointer variable is hidden from you; it can only be modified
  1004.      through direct assignment to another pointer variable or
  1005.      expression that returned a pointer.)
  1006.  
  1007.    * C escape sequences can be used in strings and characters to
  1008.      represent non-printable characters.  GDB will print out strings
  1009.      with these escape sequences embedded.  Single non-printable
  1010.      characters are printed using the `CHR(NNN)' format.
  1011.  
  1012.    * The assignment operator (`:=') returns the value of its right-hand
  1013.      argument.
  1014.  
  1015.    * All built-in procedures both modify *and* return their argument.
  1016.  
  1017. 
  1018. File: gdb.info,  Node: M2 Checks,  Next: M2 Scope,  Prev: Deviations,  Up: Modula-2
  1019.  
  1020. Modula-2 Type and Range Checks
  1021. ..............................
  1022.  
  1023.      *Warning:* in this release, GDB does not yet perform type or range
  1024.      checking.
  1025.  
  1026.    GDB considers two Modula-2 variables type equivalent if:
  1027.  
  1028.    * They are of types that have been declared equivalent via a `TYPE
  1029.      T1 = T2' statement
  1030.  
  1031.    * They have been declared on the same line.  (Note:  This is true of
  1032.      the GNU Modula-2 compiler, but it may not be true of other
  1033.      compilers.)
  1034.  
  1035.    As long as type checking is enabled, any attempt to combine variables
  1036. whose types are not equivalent is an error.
  1037.  
  1038.    Range checking is done on all mathematical operations, assignment,
  1039. array index bounds, and all built-in functions and procedures.
  1040.  
  1041. 
  1042. File: gdb.info,  Node: M2 Scope,  Next: GDB/M2,  Prev: M2 Checks,  Up: Modula-2
  1043.  
  1044. The scope operators `::' and `.'
  1045. ................................
  1046.  
  1047.    There are a few subtle differences between the Modula-2 scope
  1048. operator (`.') and the GDB scope operator (`::').  The two have similar
  1049. syntax:
  1050.  
  1051.  
  1052.      MODULE . ID
  1053.      SCOPE :: ID
  1054.  
  1055. where SCOPE is the name of a module or a procedure, MODULE the name of
  1056. a module, and ID is any declared identifier within your program, except
  1057. another module.
  1058.  
  1059.    Using the `::' operator makes GDB search the scope specified by
  1060. SCOPE for the identifier ID.  If it is not found in the specified
  1061. scope, then GDB will search all scopes enclosing the one specified by
  1062. SCOPE.
  1063.  
  1064.    Using the `.' operator makes GDB search the current scope for the
  1065. identifier specified by ID that was imported from the definition module
  1066. specified by MODULE.  With this operator, it is an error if the
  1067. identifier ID was not imported from definition module MODULE, or if ID
  1068. is not an identifier in MODULE.
  1069.  
  1070. 
  1071. File: gdb.info,  Node: GDB/M2,  Prev: M2 Scope,  Up: Modula-2
  1072.  
  1073. GDB and Modula-2
  1074. ................
  1075.  
  1076.    Some GDB commands have little use when debugging Modula-2 programs.
  1077. Five subcommands of `set print' and `show print' apply specifically to
  1078. C and C++: `vtbl', `demangle', `asm-demangle', `object', and `union'. 
  1079. The first four apply to C++, and the last to C's `union' type, which
  1080. has no direct analogue in Modula-2.
  1081.  
  1082.    The `@' operator (*note Expressions: Expressions.), while available
  1083. while using any language, is not useful with Modula-2.  Its intent is
  1084. to aid the debugging of "dynamic arrays", which cannot be created in
  1085. Modula-2 as they can in C or C++.  However, because an address can be
  1086. specified by an integral constant, the construct `{TYPE}ADREXP' is
  1087. still useful.  (*note Expressions: Expressions.)
  1088.  
  1089.    In GDB scripts, the Modula-2 inequality operator `#' is interpreted
  1090. as the beginning of a comment.  Use `<>' instead.
  1091.  
  1092. 
  1093. File: gdb.info,  Node: Symbols,  Next: Altering,  Prev: Languages,  Up: Top
  1094.  
  1095. Examining the Symbol Table
  1096. **************************
  1097.  
  1098.    The commands described in this section allow you to inquire about the
  1099. symbols (names of variables, functions and types) defined in your
  1100. program.  This information is inherent in the text of your program and
  1101. does not change as your program executes.  GDB finds it in your
  1102. program's symbol table, in the file indicated when you started GDB
  1103. (*note Choosing Files: File Options.), or by one of the file-management
  1104. commands (*note Commands to Specify Files: Files.).
  1105.  
  1106.    Occasionally, you may need to refer to symbols that contain unusual
  1107. characters, which GDB ordinarily treats as word delimiters.  The most
  1108. frequent case is in referring to static variables in other source files
  1109. (*note Program Variables: Variables.).  File names are recorded in
  1110. object files as debugging symbols, but GDB would ordinarily parse a
  1111. typical file name, like `foo.c', as the three words `foo' `.' `c'.  To
  1112. allow GDB to recognize `foo.c' as a single symbol, enclose it in single
  1113. quotes; for example,
  1114.  
  1115.      p 'foo.c'::x
  1116.  
  1117. looks up the value of `x' in the scope of the file `foo.c'.
  1118.  
  1119. `info address SYMBOL'
  1120.      Describe where the data for SYMBOL is stored.  For a register
  1121.      variable, this says which register it is kept in.  For a
  1122.      non-register local variable, this prints the stack-frame offset at
  1123.      which the variable is always stored.
  1124.  
  1125.      Note the contrast with `print &SYMBOL', which does not work at all
  1126.      for a register variables, and for a stack local variable prints
  1127.      the exact address of the current instantiation of the variable.
  1128.  
  1129. `whatis EXP'
  1130.      Print the data type of expression EXP.  EXP is not actually
  1131.      evaluated, and any side-effecting operations (such as assignments
  1132.      or function calls) inside it do not take place. *Note Expressions:
  1133.      Expressions.
  1134.  
  1135. `whatis'
  1136.      Print the data type of `$', the last value in the value history.
  1137.  
  1138. `ptype TYPENAME'
  1139.      Print a description of data type TYPENAME.  TYPENAME may be the
  1140.      name of a type, or for C code it may have the form `struct
  1141.      STRUCT-TAG', `union UNION-TAG' or `enum ENUM-TAG'.
  1142.  
  1143. `ptype EXP'
  1144. `ptype'
  1145.      Print a description of the type of expression EXP.  `ptype'
  1146.      differs from `whatis' by printing a detailed description, instead
  1147.      of just the name of the type.  For example, if your program
  1148.      declares a variable as
  1149.  
  1150.           struct complex {double real; double imag;} v;
  1151.  
  1152.      compare the output of the two commands:
  1153.  
  1154.           (gdb) whatis v
  1155.           type = struct complex
  1156.           (gdb) ptype v
  1157.           type = struct complex {
  1158.               double real;
  1159.               double imag;
  1160.           }
  1161.  
  1162.      As with `whatis', using `ptype' without an argument refers to the
  1163.      type of `$', the last value in the value history.
  1164.  
  1165. `info types REGEXP'
  1166. `info types'
  1167.      Print a brief description of all types whose name matches REGEXP
  1168.      (or all types in your program, if you supply no argument).  Each
  1169.      complete typename is matched as though it were a complete line;
  1170.      thus, `i type value' gives information on all types in your
  1171.      program whose name includes the string `value', but `i type
  1172.      ^value$' gives information only on types whose complete name is
  1173.      `value'.
  1174.  
  1175.      This command differs from `ptype' in two ways: first, like
  1176.      `whatis', it does not print a detailed description; second, it
  1177.      lists all source files where a type is defined.
  1178.  
  1179. `info source'
  1180.      Show the name of the current source file--that is, the source file
  1181.      for the function containing the current point of execution--and
  1182.      the language it was written in.
  1183.  
  1184. `info sources'
  1185.      Print the names of all source files in your program for which
  1186.      there is debugging information, organized into two lists: files
  1187.      whose symbols have already been read, and files whose symbols will
  1188.      be read when needed.
  1189.  
  1190. `info functions'
  1191.      Print the names and data types of all defined functions.
  1192.  
  1193. `info functions REGEXP'
  1194.      Print the names and data types of all defined functions whose
  1195.      names contain a match for regular expression REGEXP. Thus, `info
  1196.      fun step' finds all functions whose names include `step'; `info
  1197.      fun ^step' finds those whose names start with `step'.
  1198.  
  1199. `info variables'
  1200.      Print the names and data types of all variables that are declared
  1201.      outside of functions (i.e., excluding local variables).
  1202.  
  1203. `info variables REGEXP'
  1204.      Print the names and data types of all variables (except for local
  1205.      variables) whose names contain a match for regular expression
  1206.      REGEXP.
  1207.  
  1208. `maint print symbols FILENAME'
  1209. `maint print psymbols FILENAME'
  1210. `maint print msymbols FILENAME'
  1211.      Write a dump of debugging symbol data into the file FILENAME.
  1212.      These commands are used to debug the GDB symbol-reading code.  Only
  1213.      symbols with debugging data are included.  If you use `maint print
  1214.      symbols', GDB includes all the symbols for which it has already
  1215.      collected full details: that is, FILENAME reflects symbols for
  1216.      only those files whose symbols GDB has read.  You can use the
  1217.      command `info sources' to find out which files these are.  If you
  1218.      use `maint print psymbols' instead, the dump shows information
  1219.      about symbols that GDB only knows partially--that is, symbols
  1220.      defined in files that GDB has skimmed, but not yet read
  1221.      completely.  Finally, `maint print msymbols' dumps just the
  1222.      minimal symbol information required for each object file from
  1223.      which GDB has read some symbols. The description of `symbol-file'
  1224.      explains how GDB reads symbols; both `info source' and
  1225.      `symbol-file' are described in *Note Commands to Specify Files:
  1226.      Files.
  1227.  
  1228. 
  1229. File: gdb.info,  Node: Altering,  Next: GDB Files,  Prev: Symbols,  Up: Top
  1230.  
  1231. Altering Execution
  1232. ******************
  1233.  
  1234.    Once you think you have found an error in your program, you might
  1235. want to find out for certain whether correcting the apparent error
  1236. would lead to correct results in the rest of the run.  You can find the
  1237. answer by experiment, using the GDB features for altering execution of
  1238. the program.
  1239.  
  1240.    For example, you can store new values into variables or memory
  1241. locations, give your program a signal, restart it at a different
  1242. address, or even return prematurely from a function to its caller.
  1243.  
  1244. * Menu:
  1245.  
  1246. * Assignment::                  Assignment to Variables
  1247. * Jumping::                     Continuing at a Different Address
  1248. * Signaling::                   Giving your program a Signal
  1249. * Returning::                   Returning from a Function
  1250. * Calling::                     Calling your Program's Functions
  1251. * Patching::                    Patching your Program
  1252.  
  1253. 
  1254. File: gdb.info,  Node: Assignment,  Next: Jumping,  Up: Altering
  1255.  
  1256. Assignment to Variables
  1257. =======================
  1258.  
  1259.    To alter the value of a variable, evaluate an assignment expression.
  1260. *Note Expressions: Expressions.  For example,
  1261.  
  1262.      print x=4
  1263.  
  1264. stores the value 4 into the variable `x', and then prints the value of
  1265. the assignment expression (which is 4). *Note Using GDB with Different
  1266. Languages: Languages, for more information on operators in supported
  1267. languages.
  1268.  
  1269.    If you are not interested in seeing the value of the assignment, use
  1270. the `set' command instead of the `print' command.  `set' is really the
  1271. same as `print' except that the expression's value is not printed and
  1272. is not put in the value history (*note Value History: Value History.). 
  1273. The expression is evaluated only for its effects.
  1274.  
  1275.    If the beginning of the argument string of the `set' command appears
  1276. identical to a `set' subcommand, use the `set variable' command instead
  1277. of just `set'.  This command is identical to `set' except for its lack
  1278. of subcommands.  For example, a program might well have a variable
  1279. `width'--which leads to an error if we try to set a new value with just
  1280. `set width=13', as we might if `set width' did not happen to be a GDB
  1281. command:
  1282.  
  1283.      (gdb) whatis width
  1284.      type = double
  1285.      (gdb) p width
  1286.      $4 = 13
  1287.      (gdb) set width=47
  1288.      Invalid syntax in expression.
  1289.  
  1290. The invalid expression, of course, is `=47'.  What we can do in order
  1291. to actually set our program's variable `width' is
  1292.  
  1293.      (gdb) set var width=47
  1294.  
  1295.    GDB allows more implicit conversions in assignments than C; you can
  1296. freely store an integer value into a pointer variable or vice versa,
  1297. and any structure can be converted to any other structure that is the
  1298. same length or shorter.
  1299.  
  1300.    To store values into arbitrary places in memory, use the `{...}'
  1301. construct to generate a value of specified type at a specified address
  1302. (*note Expressions: Expressions.).  For example, `{int}0x83040' refers
  1303. to memory location `0x83040' as an integer (which implies a certain size
  1304. and representation in memory), and
  1305.  
  1306.      set {int}0x83040 = 4
  1307.  
  1308. stores the value 4 into that memory location.
  1309.  
  1310. 
  1311. File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
  1312.  
  1313. Continuing at a Different Address
  1314. =================================
  1315.  
  1316.    Ordinarily, when you continue your program, you do so at the place
  1317. where it stopped, with the `continue' command.  You can instead
  1318. continue at an address of your own choosing, with the following
  1319. commands:
  1320.  
  1321. `jump LINESPEC'
  1322.      Resume execution at line LINESPEC.  Execution will stop
  1323.      immediately if there is a breakpoint there.  *Note Printing Source
  1324.      Lines: List, for a description of the different forms of LINESPEC.
  1325.  
  1326.      The `jump' command does not change the current stack frame, or the
  1327.      stack pointer, or the contents of any memory location or any
  1328.      register other than the program counter.  If line LINESPEC is in a
  1329.      different function from the one currently executing, the results
  1330.      may be bizarre if the two functions expect different patterns of
  1331.      arguments or of local variables.  For this reason, the `jump'
  1332.      command requests confirmation if the specified line is not in the
  1333.      function currently executing.  However, even bizarre results are
  1334.      predictable if you are well acquainted with the machine-language
  1335.      code of your program.
  1336.  
  1337. `jump *ADDRESS'
  1338.      Resume execution at the instruction at address ADDRESS.
  1339.  
  1340.    You can get much the same effect as the `jump' command by storing a
  1341. new value into the register `$pc'.  The difference is that this does
  1342. not start your program running; it only changes the address where it
  1343. *will* run when it is continued.  For example,
  1344.  
  1345.      set $pc = 0x485
  1346.  
  1347. causes the next `continue' command or stepping command to execute at
  1348. address `0x485', rather than at the address where your program stopped.
  1349. *Note Continuing and Stepping: Continuing and Stepping.
  1350.  
  1351.    The most common occasion to use the `jump' command is to back up,
  1352. perhaps with more breakpoints set, over a portion of a program that has
  1353. already executed, in order to examine its execution in more detail.
  1354.  
  1355. 
  1356. File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
  1357.  
  1358. Giving your program a Signal
  1359. ============================
  1360.  
  1361. `signal SIGNALNUM'
  1362.      Resume execution where your program stopped, but give it
  1363.      immediately the signal number SIGNALNUM.
  1364.  
  1365.      Alternatively, if SIGNALNUM is zero, continue execution without
  1366.      giving a signal.  This is useful when your program stopped on
  1367.      account of a signal and would ordinary see the signal when resumed
  1368.      with the `continue' command; `signal 0' causes it to resume
  1369.      without a signal.
  1370.  
  1371.      `signal' does not repeat when you press RET a second time after
  1372.      executing the command.
  1373.  
  1374.