OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [gdb-5.0/] [gdb/] [doc/] [gdb.info-3] - Diff between revs 106 and 107

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 106 Rev 107
This is ./gdb.info, produced by Makeinfo version 3.12f from gdb.texinfo.
This is ./gdb.info, produced by Makeinfo version 3.12f from gdb.texinfo.
INFO-DIR-SECTION Programming & development tools.
INFO-DIR-SECTION Programming & development tools.
START-INFO-DIR-ENTRY
START-INFO-DIR-ENTRY
* Gdb: (gdb).                     The GNU debugger.
* Gdb: (gdb).                     The GNU debugger.
END-INFO-DIR-ENTRY
END-INFO-DIR-ENTRY
   This file documents the GNU debugger GDB.
   This file documents the GNU debugger GDB.
   This is the Eighth Edition, March 2000, of `Debugging with GDB: the
   This is the Eighth Edition, March 2000, of `Debugging with GDB: the
GNU Source-Level Debugger' for GDB Version 5.0.
GNU Source-Level Debugger' for GDB Version 5.0.
   Copyright (C) 1988-2000 Free Software Foundation, Inc.
   Copyright (C) 1988-2000 Free Software Foundation, Inc.
   Permission is granted to make and distribute verbatim copies of this
   Permission is granted to make and distribute verbatim copies of this
manual provided the copyright notice and this permission notice are
manual provided the copyright notice and this permission notice are
preserved on all copies.
preserved on all copies.
   Permission is granted to copy and distribute modified versions of
   Permission is granted to copy and distribute modified versions of
this manual under the conditions for verbatim copying, provided also
this manual under the conditions for verbatim copying, provided also
that the entire resulting derived work is distributed under the terms
that the entire resulting derived work is distributed under the terms
of a permission notice identical to this one.
of a permission notice identical to this one.
   Permission is granted to copy and distribute translations of this
   Permission is granted to copy and distribute translations of this
manual into another language, under the above conditions for modified
manual into another language, under the above conditions for modified
versions.
versions.


File: gdb.info,  Node: Conditions,  Next: Break Commands,  Prev: Disabling,  Up: Breakpoints
File: gdb.info,  Node: Conditions,  Next: Break Commands,  Prev: Disabling,  Up: Breakpoints
Break conditions
Break conditions
----------------
----------------
   The simplest sort of breakpoint breaks every time your program
   The simplest sort of breakpoint breaks every time your program
reaches a specified place.  You can also specify a "condition" for a
reaches a specified place.  You can also specify a "condition" for a
breakpoint.  A condition is just a Boolean expression in your
breakpoint.  A condition is just a Boolean expression in your
programming language (*note Expressions: Expressions.).  A breakpoint
programming language (*note Expressions: Expressions.).  A breakpoint
with a condition evaluates the expression each time your program
with a condition evaluates the expression each time your program
reaches it, and your program stops only if the condition is _true_.
reaches it, and your program stops only if the condition is _true_.
   This is the converse of using assertions for program validation; in
   This is the converse of using assertions for program validation; in
that situation, you want to stop when the assertion is violated--that
that situation, you want to stop when the assertion is violated--that
is, when the condition is false.  In C, if you want to test an
is, when the condition is false.  In C, if you want to test an
assertion expressed by the condition ASSERT, you should set the
assertion expressed by the condition ASSERT, you should set the
condition `! ASSERT' on the appropriate breakpoint.
condition `! ASSERT' on the appropriate breakpoint.
   Conditions are also accepted for watchpoints; you may not need them,
   Conditions are also accepted for watchpoints; you may not need them,
since a watchpoint is inspecting the value of an expression anyhow--but
since a watchpoint is inspecting the value of an expression anyhow--but
it might be simpler, say, to just set a watchpoint on a variable name,
it might be simpler, say, to just set a watchpoint on a variable name,
and specify a condition that tests whether the new value is an
and specify a condition that tests whether the new value is an
interesting one.
interesting one.
   Break conditions can have side effects, and may even call functions
   Break conditions can have side effects, and may even call functions
in your program.  This can be useful, for example, to activate functions
in your program.  This can be useful, for example, to activate functions
that log program progress, or to use your own print functions to format
that log program progress, or to use your own print functions to format
special data structures. The effects are completely predictable unless
special data structures. The effects are completely predictable unless
there is another enabled breakpoint at the same address.  (In that
there is another enabled breakpoint at the same address.  (In that
case, GDB might see the other breakpoint first and stop your program
case, GDB might see the other breakpoint first and stop your program
without checking the condition of this one.)  Note that breakpoint
without checking the condition of this one.)  Note that breakpoint
commands are usually more convenient and flexible than break conditions
commands are usually more convenient and flexible than break conditions
for the purpose of performing side effects when a breakpoint is reached
for the purpose of performing side effects when a breakpoint is reached
(*note Breakpoint command lists: Break Commands.).
(*note Breakpoint command lists: Break Commands.).
   Break conditions can be specified when a breakpoint is set, by using
   Break conditions can be specified when a breakpoint is set, by using
`if' in the arguments to the `break' command.  *Note Setting
`if' in the arguments to the `break' command.  *Note Setting
breakpoints: Set Breaks.  They can also be changed at any time with the
breakpoints: Set Breaks.  They can also be changed at any time with the
`condition' command.
`condition' command.
   You can also use the `if' keyword with the `watch' command.  The
   You can also use the `if' keyword with the `watch' command.  The
`catch' command does not recognize the `if' keyword; `condition' is the
`catch' command does not recognize the `if' keyword; `condition' is the
only way to impose a further condition on a catchpoint.
only way to impose a further condition on a catchpoint.
`condition BNUM EXPRESSION'
`condition BNUM EXPRESSION'
     Specify EXPRESSION as the break condition for breakpoint,
     Specify EXPRESSION as the break condition for breakpoint,
     watchpoint, or catchpoint number BNUM.  After you set a condition,
     watchpoint, or catchpoint number BNUM.  After you set a condition,
     breakpoint BNUM stops your program only if the value of EXPRESSION
     breakpoint BNUM stops your program only if the value of EXPRESSION
     is true (nonzero, in C).  When you use `condition', GDB checks
     is true (nonzero, in C).  When you use `condition', GDB checks
     EXPRESSION immediately for syntactic correctness, and to determine
     EXPRESSION immediately for syntactic correctness, and to determine
     whether symbols in it have referents in the context of your
     whether symbols in it have referents in the context of your
     breakpoint.  If EXPRESSION uses symbols not referenced in the
     breakpoint.  If EXPRESSION uses symbols not referenced in the
     context of the breakpoint, GDB prints an error message:
     context of the breakpoint, GDB prints an error message:
          No symbol "foo" in current context.
          No symbol "foo" in current context.
     GDB does not actually evaluate EXPRESSION at the time the
     GDB does not actually evaluate EXPRESSION at the time the
     `condition' command (or a command that sets a breakpoint with a
     `condition' command (or a command that sets a breakpoint with a
     condition, like `break if ...') is given, however.  *Note
     condition, like `break if ...') is given, however.  *Note
     Expressions: Expressions.
     Expressions: Expressions.
`condition BNUM'
`condition BNUM'
     Remove the condition from breakpoint number BNUM.  It becomes an
     Remove the condition from breakpoint number BNUM.  It becomes an
     ordinary unconditional breakpoint.
     ordinary unconditional breakpoint.
   A special case of a breakpoint condition is to stop only when the
   A special case of a breakpoint condition is to stop only when the
breakpoint has been reached a certain number of times.  This is so
breakpoint has been reached a certain number of times.  This is so
useful that there is a special way to do it, using the "ignore count"
useful that there is a special way to do it, using the "ignore count"
of the breakpoint.  Every breakpoint has an ignore count, which is an
of the breakpoint.  Every breakpoint has an ignore count, which is an
integer.  Most of the time, the ignore count is zero, and therefore has
integer.  Most of the time, the ignore count is zero, and therefore has
no effect.  But if your program reaches a breakpoint whose ignore count
no effect.  But if your program reaches a breakpoint whose ignore count
is positive, then instead of stopping, it just decrements the ignore
is positive, then instead of stopping, it just decrements the ignore
count by one and continues.  As a result, if the ignore count value is
count by one and continues.  As a result, if the ignore count value is
N, the breakpoint does not stop the next N times your program reaches
N, the breakpoint does not stop the next N times your program reaches
it.
it.
`ignore BNUM COUNT'
`ignore BNUM COUNT'
     Set the ignore count of breakpoint number BNUM to COUNT.  The next
     Set the ignore count of breakpoint number BNUM to COUNT.  The next
     COUNT times the breakpoint is reached, your program's execution
     COUNT times the breakpoint is reached, your program's execution
     does not stop; other than to decrement the ignore count, GDB takes
     does not stop; other than to decrement the ignore count, GDB takes
     no action.
     no action.
     To make the breakpoint stop the next time it is reached, specify a
     To make the breakpoint stop the next time it is reached, specify a
     count of zero.
     count of zero.
     When you use `continue' to resume execution of your program from a
     When you use `continue' to resume execution of your program from a
     breakpoint, you can specify an ignore count directly as an
     breakpoint, you can specify an ignore count directly as an
     argument to `continue', rather than using `ignore'.  *Note
     argument to `continue', rather than using `ignore'.  *Note
     Continuing and stepping: Continuing and Stepping.
     Continuing and stepping: Continuing and Stepping.
     If a breakpoint has a positive ignore count and a condition, the
     If a breakpoint has a positive ignore count and a condition, the
     condition is not checked.  Once the ignore count reaches zero, GDB
     condition is not checked.  Once the ignore count reaches zero, GDB
     resumes checking the condition.
     resumes checking the condition.
     You could achieve the effect of the ignore count with a condition
     You could achieve the effect of the ignore count with a condition
     such as `$foo-- <= 0' using a debugger convenience variable that
     such as `$foo-- <= 0' using a debugger convenience variable that
     is decremented each time.  *Note Convenience variables:
     is decremented each time.  *Note Convenience variables:
     Convenience Vars.
     Convenience Vars.
   Ignore counts apply to breakpoints, watchpoints, and catchpoints.
   Ignore counts apply to breakpoints, watchpoints, and catchpoints.


File: gdb.info,  Node: Break Commands,  Next: Breakpoint Menus,  Prev: Conditions,  Up: Breakpoints
File: gdb.info,  Node: Break Commands,  Next: Breakpoint Menus,  Prev: Conditions,  Up: Breakpoints
Breakpoint command lists
Breakpoint command lists
------------------------
------------------------
   You can give any breakpoint (or watchpoint or catchpoint) a series of
   You can give any breakpoint (or watchpoint or catchpoint) a series of
commands to execute when your program stops due to that breakpoint.  For
commands to execute when your program stops due to that breakpoint.  For
example, you might want to print the values of certain expressions, or
example, you might want to print the values of certain expressions, or
enable other breakpoints.
enable other breakpoints.
`commands [BNUM]'
`commands [BNUM]'
`... COMMAND-LIST ...'
`... COMMAND-LIST ...'
`end'
`end'
     Specify a list of commands for breakpoint number BNUM.  The
     Specify a list of commands for breakpoint number BNUM.  The
     commands themselves appear on the following lines.  Type a line
     commands themselves appear on the following lines.  Type a line
     containing just `end' to terminate the commands.
     containing just `end' to terminate the commands.
     To remove all commands from a breakpoint, type `commands' and
     To remove all commands from a breakpoint, type `commands' and
     follow it immediately with `end'; that is, give no commands.
     follow it immediately with `end'; that is, give no commands.
     With no BNUM argument, `commands' refers to the last breakpoint,
     With no BNUM argument, `commands' refers to the last breakpoint,
     watchpoint, or catchpoint set (not to the breakpoint most recently
     watchpoint, or catchpoint set (not to the breakpoint most recently
     encountered).
     encountered).
   Pressing  as a means of repeating the last GDB command is
   Pressing  as a means of repeating the last GDB command is
disabled within a COMMAND-LIST.
disabled within a COMMAND-LIST.
   You can use breakpoint commands to start your program up again.
   You can use breakpoint commands to start your program up again.
Simply use the `continue' command, or `step', or any other command that
Simply use the `continue' command, or `step', or any other command that
resumes execution.
resumes execution.
   Any other commands in the command list, after a command that resumes
   Any other commands in the command list, after a command that resumes
execution, are ignored.  This is because any time you resume execution
execution, are ignored.  This is because any time you resume execution
(even with a simple `next' or `step'), you may encounter another
(even with a simple `next' or `step'), you may encounter another
breakpoint--which could have its own command list, leading to
breakpoint--which could have its own command list, leading to
ambiguities about which list to execute.
ambiguities about which list to execute.
   If the first command you specify in a command list is `silent', the
   If the first command you specify in a command list is `silent', the
usual message about stopping at a breakpoint is not printed.  This may
usual message about stopping at a breakpoint is not printed.  This may
be desirable for breakpoints that are to print a specific message and
be desirable for breakpoints that are to print a specific message and
then continue.  If none of the remaining commands print anything, you
then continue.  If none of the remaining commands print anything, you
see no sign that the breakpoint was reached.  `silent' is meaningful
see no sign that the breakpoint was reached.  `silent' is meaningful
only at the beginning of a breakpoint command list.
only at the beginning of a breakpoint command list.
   The commands `echo', `output', and `printf' allow you to print
   The commands `echo', `output', and `printf' allow you to print
precisely controlled output, and are often useful in silent
precisely controlled output, and are often useful in silent
breakpoints.  *Note Commands for controlled output: Output.
breakpoints.  *Note Commands for controlled output: Output.
   For example, here is how you could use breakpoint commands to print
   For example, here is how you could use breakpoint commands to print
the value of `x' at entry to `foo' whenever `x' is positive.
the value of `x' at entry to `foo' whenever `x' is positive.
     break foo if x>0
     break foo if x>0
     commands
     commands
     silent
     silent
     printf "x is %d\n",x
     printf "x is %d\n",x
     cont
     cont
     end
     end
   One application for breakpoint commands is to compensate for one bug
   One application for breakpoint commands is to compensate for one bug
so you can test for another.  Put a breakpoint just after the erroneous
so you can test for another.  Put a breakpoint just after the erroneous
line of code, give it a condition to detect the case in which something
line of code, give it a condition to detect the case in which something
erroneous has been done, and give it commands to assign correct values
erroneous has been done, and give it commands to assign correct values
to any variables that need them.  End with the `continue' command so
to any variables that need them.  End with the `continue' command so
that your program does not stop, and start with the `silent' command so
that your program does not stop, and start with the `silent' command so
that no output is produced.  Here is an example:
that no output is produced.  Here is an example:
     break 403
     break 403
     commands
     commands
     silent
     silent
     set x = y + 4
     set x = y + 4
     cont
     cont
     end
     end


File: gdb.info,  Node: Breakpoint Menus,  Next: Error in Breakpoints,  Prev: Break Commands,  Up: Breakpoints
File: gdb.info,  Node: Breakpoint Menus,  Next: Error in Breakpoints,  Prev: Break Commands,  Up: Breakpoints
Breakpoint menus
Breakpoint menus
----------------
----------------
   Some programming languages (notably C++) permit a single function
   Some programming languages (notably C++) permit a single function
name to be defined several times, for application in different contexts.
name to be defined several times, for application in different contexts.
This is called "overloading".  When a function name is overloaded,
This is called "overloading".  When a function name is overloaded,
`break FUNCTION' is not enough to tell GDB where you want a breakpoint.
`break FUNCTION' is not enough to tell GDB where you want a breakpoint.
If you realize this is a problem, you can use something like `break
If you realize this is a problem, you can use something like `break
FUNCTION(TYPES)' to specify which particular version of the function
FUNCTION(TYPES)' to specify which particular version of the function
you want.  Otherwise, GDB offers you a menu of numbered choices for
you want.  Otherwise, GDB offers you a menu of numbered choices for
different possible breakpoints, and waits for your selection with the
different possible breakpoints, and waits for your selection with the
prompt `>'.  The first two options are always `[0] cancel' and `[1]
prompt `>'.  The first two options are always `[0] cancel' and `[1]
all'.  Typing `1' sets a breakpoint at each definition of FUNCTION, and
all'.  Typing `1' sets a breakpoint at each definition of FUNCTION, and
typing `0' aborts the `break' command without setting any new
typing `0' aborts the `break' command without setting any new
breakpoints.
breakpoints.
   For example, the following session excerpt shows an attempt to set a
   For example, the following session excerpt shows an attempt to set a
breakpoint at the overloaded symbol `String::after'.  We choose three
breakpoint at the overloaded symbol `String::after'.  We choose three
particular definitions of that function name:
particular definitions of that function name:
     (gdb) b String::after
     (gdb) b String::after
     [0] cancel
     [0] cancel
     [1] all
     [1] all
     [2] file:String.cc; line number:867
     [2] file:String.cc; line number:867
     [3] file:String.cc; line number:860
     [3] file:String.cc; line number:860
     [4] file:String.cc; line number:875
     [4] file:String.cc; line number:875
     [5] file:String.cc; line number:853
     [5] file:String.cc; line number:853
     [6] file:String.cc; line number:846
     [6] file:String.cc; line number:846
     [7] file:String.cc; line number:735
     [7] file:String.cc; line number:735
     > 2 4 6
     > 2 4 6
     Breakpoint 1 at 0xb26c: file String.cc, line 867.
     Breakpoint 1 at 0xb26c: file String.cc, line 867.
     Breakpoint 2 at 0xb344: file String.cc, line 875.
     Breakpoint 2 at 0xb344: file String.cc, line 875.
     Breakpoint 3 at 0xafcc: file String.cc, line 846.
     Breakpoint 3 at 0xafcc: file String.cc, line 846.
     Multiple breakpoints were set.
     Multiple breakpoints were set.
     Use the "delete" command to delete unwanted
     Use the "delete" command to delete unwanted
      breakpoints.
      breakpoints.
     (gdb)
     (gdb)


File: gdb.info,  Node: Error in Breakpoints,  Prev: Breakpoint Menus,  Up: Breakpoints
File: gdb.info,  Node: Error in Breakpoints,  Prev: Breakpoint Menus,  Up: Breakpoints
"Cannot insert breakpoints"
"Cannot insert breakpoints"
---------------------------
---------------------------
   Under some operating systems, breakpoints cannot be used in a
   Under some operating systems, breakpoints cannot be used in a
program if any other process is running that program.  In this
program if any other process is running that program.  In this
situation, attempting to run or continue a program with a breakpoint
situation, attempting to run or continue a program with a breakpoint
causes GDB to print an error message:
causes GDB to print an error message:
     Cannot insert breakpoints.
     Cannot insert breakpoints.
     The same program may be running in another process.
     The same program may be running in another process.
   When this happens, you have three ways to proceed:
   When this happens, you have three ways to proceed:
  1. Remove or disable the breakpoints, then continue.
  1. Remove or disable the breakpoints, then continue.
  2. Suspend GDB, and copy the file containing your program to a new
  2. Suspend GDB, and copy the file containing your program to a new
     name.  Resume GDB and use the `exec-file' command to specify that
     name.  Resume GDB and use the `exec-file' command to specify that
     GDB should run your program under that name.  Then start your
     GDB should run your program under that name.  Then start your
     program again.
     program again.
  3. Relink your program so that the text segment is nonsharable, using
  3. Relink your program so that the text segment is nonsharable, using
     the linker option `-N'.  The operating system limitation may not
     the linker option `-N'.  The operating system limitation may not
     apply to nonsharable executables.
     apply to nonsharable executables.
   A similar message can be printed if you request too many active
   A similar message can be printed if you request too many active
hardware-assisted breakpoints and watchpoints:
hardware-assisted breakpoints and watchpoints:
     Stopped; cannot insert breakpoints.
     Stopped; cannot insert breakpoints.
     You may have requested too many hardware breakpoints and watchpoints.
     You may have requested too many hardware breakpoints and watchpoints.
This message is printed when you attempt to resume the program, since
This message is printed when you attempt to resume the program, since
only then GDB knows exactly how many hardware breakpoints and
only then GDB knows exactly how many hardware breakpoints and
watchpoints it needs to insert.
watchpoints it needs to insert.
   When this message is printed, you need to disable or remove some of
   When this message is printed, you need to disable or remove some of
the hardware-assisted breakpoints and watchpoints, and then continue.
the hardware-assisted breakpoints and watchpoints, and then continue.


File: gdb.info,  Node: Continuing and Stepping,  Next: Signals,  Prev: Breakpoints,  Up: Stopping
File: gdb.info,  Node: Continuing and Stepping,  Next: Signals,  Prev: Breakpoints,  Up: Stopping
Continuing and stepping
Continuing and stepping
=======================
=======================
   "Continuing" means resuming program execution until your program
   "Continuing" means resuming program execution until your program
completes normally.  In contrast, "stepping" means executing just one
completes normally.  In contrast, "stepping" means executing just one
more "step" of your program, where "step" may mean either one line of
more "step" of your program, where "step" may mean either one line of
source code, or one machine instruction (depending on what particular
source code, or one machine instruction (depending on what particular
command you use).  Either when continuing or when stepping, your
command you use).  Either when continuing or when stepping, your
program may stop even sooner, due to a breakpoint or a signal.  (If it
program may stop even sooner, due to a breakpoint or a signal.  (If it
stops due to a signal, you may want to use `handle', or use `signal 0'
stops due to a signal, you may want to use `handle', or use `signal 0'
to resume execution.  *Note Signals: Signals.)
to resume execution.  *Note Signals: Signals.)
`continue [IGNORE-COUNT]'
`continue [IGNORE-COUNT]'
`c [IGNORE-COUNT]'
`c [IGNORE-COUNT]'
`fg [IGNORE-COUNT]'
`fg [IGNORE-COUNT]'
     Resume program execution, at the address where your program last
     Resume program execution, at the address where your program last
     stopped; any breakpoints set at that address are bypassed.  The
     stopped; any breakpoints set at that address are bypassed.  The
     optional argument IGNORE-COUNT allows you to specify a further
     optional argument IGNORE-COUNT allows you to specify a further
     number of times to ignore a breakpoint at this location; its
     number of times to ignore a breakpoint at this location; its
     effect is like that of `ignore' (*note Break conditions:
     effect is like that of `ignore' (*note Break conditions:
     Conditions.).
     Conditions.).
     The argument IGNORE-COUNT is meaningful only when your program
     The argument IGNORE-COUNT is meaningful only when your program
     stopped due to a breakpoint.  At other times, the argument to
     stopped due to a breakpoint.  At other times, the argument to
     `continue' is ignored.
     `continue' is ignored.
     The synonyms `c' and `fg' (for "foreground", as the debugged
     The synonyms `c' and `fg' (for "foreground", as the debugged
     program is deemed to be the foreground program) are provided
     program is deemed to be the foreground program) are provided
     purely for convenience, and have exactly the same behavior as
     purely for convenience, and have exactly the same behavior as
     `continue'.
     `continue'.
   To resume execution at a different place, you can use `return'
   To resume execution at a different place, you can use `return'
(*note Returning from a function: Returning.) to go back to the calling
(*note Returning from a function: Returning.) to go back to the calling
function; or `jump' (*note Continuing at a different address: Jumping.)
function; or `jump' (*note Continuing at a different address: Jumping.)
to go to an arbitrary location in your program.
to go to an arbitrary location in your program.
   A typical technique for using stepping is to set a breakpoint (*note
   A typical technique for using stepping is to set a breakpoint (*note
Breakpoints; watchpoints; and catchpoints: Breakpoints.) at the
Breakpoints; watchpoints; and catchpoints: Breakpoints.) at the
beginning of the function or the section of your program where a problem
beginning of the function or the section of your program where a problem
is believed to lie, run your program until it stops at that breakpoint,
is believed to lie, run your program until it stops at that breakpoint,
and then step through the suspect area, examining the variables that are
and then step through the suspect area, examining the variables that are
interesting, until you see the problem happen.
interesting, until you see the problem happen.
`step'
`step'
     Continue running your program until control reaches a different
     Continue running your program until control reaches a different
     source line, then stop it and return control to GDB.  This command
     source line, then stop it and return control to GDB.  This command
     is abbreviated `s'.
     is abbreviated `s'.
          _Warning:_ If you use the `step' command while control is
          _Warning:_ If you use the `step' command while control is
          within a function that was compiled without debugging
          within a function that was compiled without debugging
          information, execution proceeds until control reaches a
          information, execution proceeds until control reaches a
          function that does have debugging information.  Likewise, it
          function that does have debugging information.  Likewise, it
          will not step into a function which is compiled without
          will not step into a function which is compiled without
          debugging information.  To step through functions without
          debugging information.  To step through functions without
          debugging information, use the `stepi' command, described
          debugging information, use the `stepi' command, described
          below.
          below.
     The `step' command only stops at the first instruction of a source
     The `step' command only stops at the first instruction of a source
     line.  This prevents the multiple stops that could otherwise occur
     line.  This prevents the multiple stops that could otherwise occur
     in switch statements, for loops, etc.  `step' continues to stop if
     in switch statements, for loops, etc.  `step' continues to stop if
     a function that has debugging information is called within the
     a function that has debugging information is called within the
     line.  In other words, `step' _steps inside_ any functions called
     line.  In other words, `step' _steps inside_ any functions called
     within the line.
     within the line.
     Also, the `step' command only enters a function if there is line
     Also, the `step' command only enters a function if there is line
     number information for the function.  Otherwise it acts like the
     number information for the function.  Otherwise it acts like the
     `next' command.  This avoids problems when using `cc -gl' on MIPS
     `next' command.  This avoids problems when using `cc -gl' on MIPS
     machines.  Previously, `step' entered subroutines if there was any
     machines.  Previously, `step' entered subroutines if there was any
     debugging information about the routine.
     debugging information about the routine.
`step COUNT'
`step COUNT'
     Continue running as in `step', but do so COUNT times.  If a
     Continue running as in `step', but do so COUNT times.  If a
     breakpoint is reached, or a signal not related to stepping occurs
     breakpoint is reached, or a signal not related to stepping occurs
     before COUNT steps, stepping stops right away.
     before COUNT steps, stepping stops right away.
`next [COUNT]'
`next [COUNT]'
     Continue to the next source line in the current (innermost) stack
     Continue to the next source line in the current (innermost) stack
     frame.  This is similar to `step', but function calls that appear
     frame.  This is similar to `step', but function calls that appear
     within the line of code are executed without stopping.  Execution
     within the line of code are executed without stopping.  Execution
     stops when control reaches a different line of code at the
     stops when control reaches a different line of code at the
     original stack level that was executing when you gave the `next'
     original stack level that was executing when you gave the `next'
     command.  This command is abbreviated `n'.
     command.  This command is abbreviated `n'.
     An argument COUNT is a repeat count, as for `step'.
     An argument COUNT is a repeat count, as for `step'.
     The `next' command only stops at the first instruction of a source
     The `next' command only stops at the first instruction of a source
     line.  This prevents multiple stops that could otherwise occur in
     line.  This prevents multiple stops that could otherwise occur in
     switch statements, for loops, etc.
     switch statements, for loops, etc.
`finish'
`finish'
     Continue running until just after function in the selected stack
     Continue running until just after function in the selected stack
     frame returns.  Print the returned value (if any).
     frame returns.  Print the returned value (if any).
     Contrast this with the `return' command (*note Returning from a
     Contrast this with the `return' command (*note Returning from a
     function: Returning.).
     function: Returning.).
`until'
`until'
`u'
`u'
     Continue running until a source line past the current line, in the
     Continue running until a source line past the current line, in the
     current stack frame, is reached.  This command is used to avoid
     current stack frame, is reached.  This command is used to avoid
     single stepping through a loop more than once.  It is like the
     single stepping through a loop more than once.  It is like the
     `next' command, except that when `until' encounters a jump, it
     `next' command, except that when `until' encounters a jump, it
     automatically continues execution until the program counter is
     automatically continues execution until the program counter is
     greater than the address of the jump.
     greater than the address of the jump.
     This means that when you reach the end of a loop after single
     This means that when you reach the end of a loop after single
     stepping though it, `until' makes your program continue execution
     stepping though it, `until' makes your program continue execution
     until it exits the loop.  In contrast, a `next' command at the end
     until it exits the loop.  In contrast, a `next' command at the end
     of a loop simply steps back to the beginning of the loop, which
     of a loop simply steps back to the beginning of the loop, which
     forces you to step through the next iteration.
     forces you to step through the next iteration.
     `until' always stops your program if it attempts to exit the
     `until' always stops your program if it attempts to exit the
     current stack frame.
     current stack frame.
     `until' may produce somewhat counterintuitive results if the order
     `until' may produce somewhat counterintuitive results if the order
     of machine code does not match the order of the source lines.  For
     of machine code does not match the order of the source lines.  For
     example, in the following excerpt from a debugging session, the `f'
     example, in the following excerpt from a debugging session, the `f'
     (`frame') command shows that execution is stopped at line `206';
     (`frame') command shows that execution is stopped at line `206';
     yet when we use `until', we get to line `195':
     yet when we use `until', we get to line `195':
          (gdb) f
          (gdb) f
          #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
          #0  main (argc=4, argv=0xf7fffae8) at m4.c:206
          206                 expand_input();
          206                 expand_input();
          (gdb) until
          (gdb) until
          195             for ( ; argc > 0; NEXTARG) {
          195             for ( ; argc > 0; NEXTARG) {
     This happened because, for execution efficiency, the compiler had
     This happened because, for execution efficiency, the compiler had
     generated code for the loop closure test at the end, rather than
     generated code for the loop closure test at the end, rather than
     the start, of the loop--even though the test in a C `for'-loop is
     the start, of the loop--even though the test in a C `for'-loop is
     written before the body of the loop.  The `until' command appeared
     written before the body of the loop.  The `until' command appeared
     to step back to the beginning of the loop when it advanced to this
     to step back to the beginning of the loop when it advanced to this
     expression; however, it has not really gone to an earlier
     expression; however, it has not really gone to an earlier
     statement--not in terms of the actual machine code.
     statement--not in terms of the actual machine code.
     `until' with no argument works by means of single instruction
     `until' with no argument works by means of single instruction
     stepping, and hence is slower than `until' with an argument.
     stepping, and hence is slower than `until' with an argument.
`until LOCATION'
`until LOCATION'
`u LOCATION'
`u LOCATION'
     Continue running your program until either the specified location
     Continue running your program until either the specified location
     is reached, or the current stack frame returns.  LOCATION is any of
     is reached, or the current stack frame returns.  LOCATION is any of
     the forms of argument acceptable to `break' (*note Setting
     the forms of argument acceptable to `break' (*note Setting
     breakpoints: Set Breaks.).  This form of the command uses
     breakpoints: Set Breaks.).  This form of the command uses
     breakpoints, and hence is quicker than `until' without an argument.
     breakpoints, and hence is quicker than `until' without an argument.
`stepi'
`stepi'
`stepi ARG'
`stepi ARG'
`si'
`si'
     Execute one machine instruction, then stop and return to the
     Execute one machine instruction, then stop and return to the
     debugger.
     debugger.
     It is often useful to do `display/i $pc' when stepping by machine
     It is often useful to do `display/i $pc' when stepping by machine
     instructions.  This makes GDB automatically display the next
     instructions.  This makes GDB automatically display the next
     instruction to be executed, each time your program stops.  *Note
     instruction to be executed, each time your program stops.  *Note
     Automatic display: Auto Display.
     Automatic display: Auto Display.
     An argument is a repeat count, as in `step'.
     An argument is a repeat count, as in `step'.
`nexti'
`nexti'
`nexti ARG'
`nexti ARG'
`ni'
`ni'
     Execute one machine instruction, but if it is a function call,
     Execute one machine instruction, but if it is a function call,
     proceed until the function returns.
     proceed until the function returns.
     An argument is a repeat count, as in `next'.
     An argument is a repeat count, as in `next'.


File: gdb.info,  Node: Signals,  Next: Thread Stops,  Prev: Continuing and Stepping,  Up: Stopping
File: gdb.info,  Node: Signals,  Next: Thread Stops,  Prev: Continuing and Stepping,  Up: Stopping
Signals
Signals
=======
=======
   A signal is an asynchronous event that can happen in a program.  The
   A signal is an asynchronous event that can happen in a program.  The
operating system defines the possible kinds of signals, and gives each
operating system defines the possible kinds of signals, and gives each
kind a name and a number.  For example, in Unix `SIGINT' is the signal
kind a name and a number.  For example, in Unix `SIGINT' is the signal
a program gets when you type an interrupt character (often `C-c');
a program gets when you type an interrupt character (often `C-c');
`SIGSEGV' is the signal a program gets from referencing a place in
`SIGSEGV' is the signal a program gets from referencing a place in
memory far away from all the areas in use; `SIGALRM' occurs when the
memory far away from all the areas in use; `SIGALRM' occurs when the
alarm clock timer goes off (which happens only if your program has
alarm clock timer goes off (which happens only if your program has
requested an alarm).
requested an alarm).
   Some signals, including `SIGALRM', are a normal part of the
   Some signals, including `SIGALRM', are a normal part of the
functioning of your program.  Others, such as `SIGSEGV', indicate
functioning of your program.  Others, such as `SIGSEGV', indicate
errors; these signals are "fatal" (they kill your program immediately)
errors; these signals are "fatal" (they kill your program immediately)
if the program has not specified in advance some other way to handle
if the program has not specified in advance some other way to handle
the signal.  `SIGINT' does not indicate an error in your program, but
the signal.  `SIGINT' does not indicate an error in your program, but
it is normally fatal so it can carry out the purpose of the interrupt:
it is normally fatal so it can carry out the purpose of the interrupt:
to kill the program.
to kill the program.
   GDB has the ability to detect any occurrence of a signal in your
   GDB has the ability to detect any occurrence of a signal in your
program.  You can tell GDB in advance what to do for each kind of
program.  You can tell GDB in advance what to do for each kind of
signal.
signal.
   Normally, GDB is set up to ignore non-erroneous signals like
   Normally, GDB is set up to ignore non-erroneous signals like
`SIGALRM' (so as not to interfere with their role in the functioning of
`SIGALRM' (so as not to interfere with their role in the functioning of
your program) but to stop your program immediately whenever an error
your program) but to stop your program immediately whenever an error
signal happens.  You can change these settings with the `handle'
signal happens.  You can change these settings with the `handle'
command.
command.
`info signals'
`info signals'
`info handle'
`info handle'
     Print a table of all the kinds of signals and how GDB has been
     Print a table of all the kinds of signals and how GDB has been
     told to handle each one.  You can use this to see the signal
     told to handle each one.  You can use this to see the signal
     numbers of all the defined types of signals.
     numbers of all the defined types of signals.
     `info handle' is an alias for `info signals'.
     `info handle' is an alias for `info signals'.
`handle SIGNAL KEYWORDS...'
`handle SIGNAL KEYWORDS...'
     Change the way GDB handles signal SIGNAL.  SIGNAL can be the
     Change the way GDB handles signal SIGNAL.  SIGNAL can be the
     number of a signal or its name (with or without the `SIG' at the
     number of a signal or its name (with or without the `SIG' at the
     beginning).  The KEYWORDS say what change to make.
     beginning).  The KEYWORDS say what change to make.
   The keywords allowed by the `handle' command can be abbreviated.
   The keywords allowed by the `handle' command can be abbreviated.
Their full names are:
Their full names are:
`nostop'
`nostop'
     GDB should not stop your program when this signal happens.  It may
     GDB should not stop your program when this signal happens.  It may
     still print a message telling you that the signal has come in.
     still print a message telling you that the signal has come in.
`stop'
`stop'
     GDB should stop your program when this signal happens.  This
     GDB should stop your program when this signal happens.  This
     implies the `print' keyword as well.
     implies the `print' keyword as well.
`print'
`print'
     GDB should print a message when this signal happens.
     GDB should print a message when this signal happens.
`noprint'
`noprint'
     GDB should not mention the occurrence of the signal at all.  This
     GDB should not mention the occurrence of the signal at all.  This
     implies the `nostop' keyword as well.
     implies the `nostop' keyword as well.
`pass'
`pass'
     GDB should allow your program to see this signal; your program can
     GDB should allow your program to see this signal; your program can
     handle the signal, or else it may terminate if the signal is fatal
     handle the signal, or else it may terminate if the signal is fatal
     and not handled.
     and not handled.
`nopass'
`nopass'
     GDB should not allow your program to see this signal.
     GDB should not allow your program to see this signal.
   When a signal stops your program, the signal is not visible to the
   When a signal stops your program, the signal is not visible to the
program until you continue.  Your program sees the signal then, if
program until you continue.  Your program sees the signal then, if
`pass' is in effect for the signal in question _at that time_.  In
`pass' is in effect for the signal in question _at that time_.  In
other words, after GDB reports a signal, you can use the `handle'
other words, after GDB reports a signal, you can use the `handle'
command with `pass' or `nopass' to control whether your program sees
command with `pass' or `nopass' to control whether your program sees
that signal when you continue.
that signal when you continue.
   You can also use the `signal' command to prevent your program from
   You can also use the `signal' command to prevent your program from
seeing a signal, or cause it to see a signal it normally would not see,
seeing a signal, or cause it to see a signal it normally would not see,
or to give it any signal at any time.  For example, if your program
or to give it any signal at any time.  For example, if your program
stopped due to some sort of memory reference error, you might store
stopped due to some sort of memory reference error, you might store
correct values into the erroneous variables and continue, hoping to see
correct values into the erroneous variables and continue, hoping to see
more execution; but your program would probably terminate immediately as
more execution; but your program would probably terminate immediately as
a result of the fatal signal once it saw the signal.  To prevent this,
a result of the fatal signal once it saw the signal.  To prevent this,
you can continue with `signal 0'.  *Note Giving your program a signal:
you can continue with `signal 0'.  *Note Giving your program a signal:
Signaling.
Signaling.


File: gdb.info,  Node: Thread Stops,  Prev: Signals,  Up: Stopping
File: gdb.info,  Node: Thread Stops,  Prev: Signals,  Up: Stopping
Stopping and starting multi-thread programs
Stopping and starting multi-thread programs
===========================================
===========================================
   When your program has multiple threads (*note Debugging programs
   When your program has multiple threads (*note Debugging programs
with multiple threads: Threads.), you can choose whether to set
with multiple threads: Threads.), you can choose whether to set
breakpoints on all threads, or on a particular thread.
breakpoints on all threads, or on a particular thread.
`break LINESPEC thread THREADNO'
`break LINESPEC thread THREADNO'
`break LINESPEC thread THREADNO if ...'
`break LINESPEC thread THREADNO if ...'
     LINESPEC specifies source lines; there are several ways of writing
     LINESPEC specifies source lines; there are several ways of writing
     them, but the effect is always to specify some source line.
     them, but the effect is always to specify some source line.
     Use the qualifier `thread THREADNO' with a breakpoint command to
     Use the qualifier `thread THREADNO' with a breakpoint command to
     specify that you only want GDB to stop the program when a
     specify that you only want GDB to stop the program when a
     particular thread reaches this breakpoint.  THREADNO is one of the
     particular thread reaches this breakpoint.  THREADNO is one of the
     numeric thread identifiers assigned by GDB, shown in the first
     numeric thread identifiers assigned by GDB, shown in the first
     column of the `info threads' display.
     column of the `info threads' display.
     If you do not specify `thread THREADNO' when you set a breakpoint,
     If you do not specify `thread THREADNO' when you set a breakpoint,
     the breakpoint applies to _all_ threads of your program.
     the breakpoint applies to _all_ threads of your program.
     You can use the `thread' qualifier on conditional breakpoints as
     You can use the `thread' qualifier on conditional breakpoints as
     well; in this case, place `thread THREADNO' before the breakpoint
     well; in this case, place `thread THREADNO' before the breakpoint
     condition, like this:
     condition, like this:
          (gdb) break frik.c:13 thread 28 if bartab > lim
          (gdb) break frik.c:13 thread 28 if bartab > lim
   Whenever your program stops under GDB for any reason, _all_ threads
   Whenever your program stops under GDB for any reason, _all_ threads
of execution stop, not just the current thread.  This allows you to
of execution stop, not just the current thread.  This allows you to
examine the overall state of the program, including switching between
examine the overall state of the program, including switching between
threads, without worrying that things may change underfoot.
threads, without worrying that things may change underfoot.
   Conversely, whenever you restart the program, _all_ threads start
   Conversely, whenever you restart the program, _all_ threads start
executing.  _This is true even when single-stepping_ with commands like
executing.  _This is true even when single-stepping_ with commands like
`step' or `next'.
`step' or `next'.
   In particular, GDB cannot single-step all threads in lockstep.
   In particular, GDB cannot single-step all threads in lockstep.
Since thread scheduling is up to your debugging target's operating
Since thread scheduling is up to your debugging target's operating
system (not controlled by GDB), other threads may execute more than one
system (not controlled by GDB), other threads may execute more than one
statement while the current thread completes a single step.  Moreover,
statement while the current thread completes a single step.  Moreover,
in general other threads stop in the middle of a statement, rather than
in general other threads stop in the middle of a statement, rather than
at a clean statement boundary, when the program stops.
at a clean statement boundary, when the program stops.
   You might even find your program stopped in another thread after
   You might even find your program stopped in another thread after
continuing or even single-stepping.  This happens whenever some other
continuing or even single-stepping.  This happens whenever some other
thread runs into a breakpoint, a signal, or an exception before the
thread runs into a breakpoint, a signal, or an exception before the
first thread completes whatever you requested.
first thread completes whatever you requested.
   On some OSes, you can lock the OS scheduler and thus allow only a
   On some OSes, you can lock the OS scheduler and thus allow only a
single thread to run.
single thread to run.
`set scheduler-locking MODE'
`set scheduler-locking MODE'
     Set the scheduler locking mode.  If it is `off', then there is no
     Set the scheduler locking mode.  If it is `off', then there is no
     locking and any thread may run at any time.  If `on', then only the
     locking and any thread may run at any time.  If `on', then only the
     current thread may run when the inferior is resumed.  The `step'
     current thread may run when the inferior is resumed.  The `step'
     mode optimizes for single-stepping.  It stops other threads from
     mode optimizes for single-stepping.  It stops other threads from
     "seizing the prompt" by preempting the current thread while you are
     "seizing the prompt" by preempting the current thread while you are
     stepping.  Other threads will only rarely (or never) get a chance
     stepping.  Other threads will only rarely (or never) get a chance
     to run when you step.  They are more likely to run when you `next'
     to run when you step.  They are more likely to run when you `next'
     over a function call, and they are completely free to run when you
     over a function call, and they are completely free to run when you
     use commands like `continue', `until', or `finish'.  However,
     use commands like `continue', `until', or `finish'.  However,
     unless another thread hits a breakpoint during its timeslice, they
     unless another thread hits a breakpoint during its timeslice, they
     will never steal the GDB prompt away from the thread that you are
     will never steal the GDB prompt away from the thread that you are
     debugging.
     debugging.
`show scheduler-locking'
`show scheduler-locking'
     Display the current scheduler locking mode.
     Display the current scheduler locking mode.


File: gdb.info,  Node: Stack,  Next: Source,  Prev: Stopping,  Up: Top
File: gdb.info,  Node: Stack,  Next: Source,  Prev: Stopping,  Up: Top
Examining the Stack
Examining the Stack
*******************
*******************
   When your program has stopped, the first thing you need to know is
   When your program has stopped, the first thing you need to know is
where it stopped and how it got there.
where it stopped and how it got there.
   Each time your program performs a function call, information about
   Each time your program performs a function call, information about
the call is generated.  That information includes the location of the
the call is generated.  That information includes the location of the
call in your program, the arguments of the call, and the local
call in your program, the arguments of the call, and the local
variables of the function being called.  The information is saved in a
variables of the function being called.  The information is saved in a
block of data called a "stack frame".  The stack frames are allocated
block of data called a "stack frame".  The stack frames are allocated
in a region of memory called the "call stack".
in a region of memory called the "call stack".
   When your program stops, the GDB commands for examining the stack
   When your program stops, the GDB commands for examining the stack
allow you to see all of this information.
allow you to see all of this information.
   One of the stack frames is "selected" by GDB and many GDB commands
   One of the stack frames is "selected" by GDB and many GDB commands
refer implicitly to the selected frame.  In particular, whenever you
refer implicitly to the selected frame.  In particular, whenever you
ask GDB for the value of a variable in your program, the value is found
ask GDB for the value of a variable in your program, the value is found
in the selected frame.  There are special GDB commands to select
in the selected frame.  There are special GDB commands to select
whichever frame you are interested in. *Note Selecting a frame:
whichever frame you are interested in. *Note Selecting a frame:
Selection.
Selection.
   When your program stops, GDB automatically selects the currently
   When your program stops, GDB automatically selects the currently
executing frame and describes it briefly, similar to the `frame'
executing frame and describes it briefly, similar to the `frame'
command (*note Information about a frame: Frame Info.).
command (*note Information about a frame: Frame Info.).
* Menu:
* Menu:
* Frames::                      Stack frames
* Frames::                      Stack frames
* Backtrace::                   Backtraces
* Backtrace::                   Backtraces
* Selection::                   Selecting a frame
* Selection::                   Selecting a frame
* Frame Info::                  Information on a frame
* Frame Info::                  Information on a frame


File: gdb.info,  Node: Frames,  Next: Backtrace,  Up: Stack
File: gdb.info,  Node: Frames,  Next: Backtrace,  Up: Stack
Stack frames
Stack frames
============
============
   The call stack is divided up into contiguous pieces called "stack
   The call stack is divided up into contiguous pieces called "stack
frames", or "frames" for short; each frame is the data associated with
frames", or "frames" for short; each frame is the data associated with
one call to one function.  The frame contains the arguments given to
one call to one function.  The frame contains the arguments given to
the function, the function's local variables, and the address at which
the function, the function's local variables, and the address at which
the function is executing.
the function is executing.
   When your program is started, the stack has only one frame, that of
   When your program is started, the stack has only one frame, that of
the function `main'.  This is called the "initial" frame or the
the function `main'.  This is called the "initial" frame or the
"outermost" frame.  Each time a function is called, a new frame is
"outermost" frame.  Each time a function is called, a new frame is
made.  Each time a function returns, the frame for that function
made.  Each time a function returns, the frame for that function
invocation is eliminated.  If a function is recursive, there can be
invocation is eliminated.  If a function is recursive, there can be
many frames for the same function.  The frame for the function in which
many frames for the same function.  The frame for the function in which
execution is actually occurring is called the "innermost" frame.  This
execution is actually occurring is called the "innermost" frame.  This
is the most recently created of all the stack frames that still exist.
is the most recently created of all the stack frames that still exist.
   Inside your program, stack frames are identified by their addresses.
   Inside your program, stack frames are identified by their addresses.
A stack frame consists of many bytes, each of which has its own
A stack frame consists of many bytes, each of which has its own
address; each kind of computer has a convention for choosing one byte
address; each kind of computer has a convention for choosing one byte
whose address serves as the address of the frame.  Usually this address
whose address serves as the address of the frame.  Usually this address
is kept in a register called the "frame pointer register" while
is kept in a register called the "frame pointer register" while
execution is going on in that frame.
execution is going on in that frame.
   GDB assigns numbers to all existing stack frames, starting with zero
   GDB assigns numbers to all existing stack frames, starting with zero
for the innermost frame, one for the frame that called it, and so on
for the innermost frame, one for the frame that called it, and so on
upward.  These numbers do not really exist in your program; they are
upward.  These numbers do not really exist in your program; they are
assigned by GDB to give you a way of designating stack frames in GDB
assigned by GDB to give you a way of designating stack frames in GDB
commands.
commands.
   Some compilers provide a way to compile functions so that they
   Some compilers provide a way to compile functions so that they
operate without stack frames.  (For example, the gcc option
operate without stack frames.  (For example, the gcc option
     `-fomit-frame-pointer'
     `-fomit-frame-pointer'
   generates functions without a frame.)  This is occasionally done
   generates functions without a frame.)  This is occasionally done
with heavily used library functions to save the frame setup time.  GDB
with heavily used library functions to save the frame setup time.  GDB
has limited facilities for dealing with these function invocations.  If
has limited facilities for dealing with these function invocations.  If
the innermost function invocation has no stack frame, GDB nevertheless
the innermost function invocation has no stack frame, GDB nevertheless
regards it as though it had a separate frame, which is numbered zero as
regards it as though it had a separate frame, which is numbered zero as
usual, allowing correct tracing of the function call chain.  However,
usual, allowing correct tracing of the function call chain.  However,
GDB has no provision for frameless functions elsewhere in the stack.
GDB has no provision for frameless functions elsewhere in the stack.
`frame ARGS'
`frame ARGS'
     The `frame' command allows you to move from one stack frame to
     The `frame' command allows you to move from one stack frame to
     another, and to print the stack frame you select.  ARGS may be
     another, and to print the stack frame you select.  ARGS may be
     either the address of the frame or the stack frame number.
     either the address of the frame or the stack frame number.
     Without an argument, `frame' prints the current stack frame.
     Without an argument, `frame' prints the current stack frame.
`select-frame'
`select-frame'
     The `select-frame' command allows you to move from one stack frame
     The `select-frame' command allows you to move from one stack frame
     to another without printing the frame.  This is the silent version
     to another without printing the frame.  This is the silent version
     of `frame'.
     of `frame'.


File: gdb.info,  Node: Backtrace,  Next: Selection,  Prev: Frames,  Up: Stack
File: gdb.info,  Node: Backtrace,  Next: Selection,  Prev: Frames,  Up: Stack
Backtraces
Backtraces
==========
==========
   A backtrace is a summary of how your program got where it is.  It
   A backtrace is a summary of how your program got where it is.  It
shows one line per frame, for many frames, starting with the currently
shows one line per frame, for many frames, starting with the currently
executing frame (frame zero), followed by its caller (frame one), and
executing frame (frame zero), followed by its caller (frame one), and
on up the stack.
on up the stack.
`backtrace'
`backtrace'
`bt'
`bt'
     Print a backtrace of the entire stack: one line per frame for all
     Print a backtrace of the entire stack: one line per frame for all
     frames in the stack.
     frames in the stack.
     You can stop the backtrace at any time by typing the system
     You can stop the backtrace at any time by typing the system
     interrupt character, normally `C-c'.
     interrupt character, normally `C-c'.
`backtrace N'
`backtrace N'
`bt N'
`bt N'
     Similar, but print only the innermost N frames.
     Similar, but print only the innermost N frames.
`backtrace -N'
`backtrace -N'
`bt -N'
`bt -N'
     Similar, but print only the outermost N frames.
     Similar, but print only the outermost N frames.
   The names `where' and `info stack' (abbreviated `info s') are
   The names `where' and `info stack' (abbreviated `info s') are
additional aliases for `backtrace'.
additional aliases for `backtrace'.
   Each line in the backtrace shows the frame number and the function
   Each line in the backtrace shows the frame number and the function
name.  The program counter value is also shown--unless you use `set
name.  The program counter value is also shown--unless you use `set
print address off'.  The backtrace also shows the source file name and
print address off'.  The backtrace also shows the source file name and
line number, as well as the arguments to the function.  The program
line number, as well as the arguments to the function.  The program
counter value is omitted if it is at the beginning of the code for that
counter value is omitted if it is at the beginning of the code for that
line number.
line number.
   Here is an example of a backtrace.  It was made with the command `bt
   Here is an example of a backtrace.  It was made with the command `bt
3', so it shows the innermost three frames.
3', so it shows the innermost three frames.
     #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
     #0  m4_traceon (obs=0x24eb0, argc=1, argv=0x2b8c8)
         at builtin.c:993
         at builtin.c:993
     #1  0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
     #1  0x6e38 in expand_macro (sym=0x2b600) at macro.c:242
     #2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
     #2  0x6840 in expand_token (obs=0x0, t=177664, td=0xf7fffb08)
         at macro.c:71
         at macro.c:71
     (More stack frames follow...)
     (More stack frames follow...)
The display for frame zero does not begin with a program counter value,
The display for frame zero does not begin with a program counter value,
indicating that your program has stopped at the beginning of the code
indicating that your program has stopped at the beginning of the code
for line `993' of `builtin.c'.
for line `993' of `builtin.c'.


File: gdb.info,  Node: Selection,  Next: Frame Info,  Prev: Backtrace,  Up: Stack
File: gdb.info,  Node: Selection,  Next: Frame Info,  Prev: Backtrace,  Up: Stack
Selecting a frame
Selecting a frame
=================
=================
   Most commands for examining the stack and other data in your program
   Most commands for examining the stack and other data in your program
work on whichever stack frame is selected at the moment.  Here are the
work on whichever stack frame is selected at the moment.  Here are the
commands for selecting a stack frame; all of them finish by printing a
commands for selecting a stack frame; all of them finish by printing a
brief description of the stack frame just selected.
brief description of the stack frame just selected.
`frame N'
`frame N'
`f N'
`f N'
     Select frame number N.  Recall that frame zero is the innermost
     Select frame number N.  Recall that frame zero is the innermost
     (currently executing) frame, frame one is the frame that called the
     (currently executing) frame, frame one is the frame that called the
     innermost one, and so on.  The highest-numbered frame is the one
     innermost one, and so on.  The highest-numbered frame is the one
     for `main'.
     for `main'.
`frame ADDR'
`frame ADDR'
`f ADDR'
`f ADDR'
     Select the frame at address ADDR.  This is useful mainly if the
     Select the frame at address ADDR.  This is useful mainly if the
     chaining of stack frames has been damaged by a bug, making it
     chaining of stack frames has been damaged by a bug, making it
     impossible for GDB to assign numbers properly to all frames.  In
     impossible for GDB to assign numbers properly to all frames.  In
     addition, this can be useful when your program has multiple stacks
     addition, this can be useful when your program has multiple stacks
     and switches between them.
     and switches between them.
     On the SPARC architecture, `frame' needs two addresses to select
     On the SPARC architecture, `frame' needs two addresses to select
     an arbitrary frame: a frame pointer and a stack pointer.
     an arbitrary frame: a frame pointer and a stack pointer.
     On the MIPS and Alpha architecture, it needs two addresses: a stack
     On the MIPS and Alpha architecture, it needs two addresses: a stack
     pointer and a program counter.
     pointer and a program counter.
     On the 29k architecture, it needs three addresses: a register stack
     On the 29k architecture, it needs three addresses: a register stack
     pointer, a program counter, and a memory stack pointer.
     pointer, a program counter, and a memory stack pointer.
`up N'
`up N'
     Move N frames up the stack.  For positive numbers N, this advances
     Move N frames up the stack.  For positive numbers N, this advances
     toward the outermost frame, to higher frame numbers, to frames
     toward the outermost frame, to higher frame numbers, to frames
     that have existed longer.  N defaults to one.
     that have existed longer.  N defaults to one.
`down N'
`down N'
     Move N frames down the stack.  For positive numbers N, this
     Move N frames down the stack.  For positive numbers N, this
     advances toward the innermost frame, to lower frame numbers, to
     advances toward the innermost frame, to lower frame numbers, to
     frames that were created more recently.  N defaults to one.  You
     frames that were created more recently.  N defaults to one.  You
     may abbreviate `down' as `do'.
     may abbreviate `down' as `do'.
   All of these commands end by printing two lines of output describing
   All of these commands end by printing two lines of output describing
the frame.  The first line shows the frame number, the function name,
the frame.  The first line shows the frame number, the function name,
the arguments, and the source file and line number of execution in that
the arguments, and the source file and line number of execution in that
frame.  The second line shows the text of that source line.
frame.  The second line shows the text of that source line.
   For example:
   For example:
     (gdb) up
     (gdb) up
     #1  0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
     #1  0x22f0 in main (argc=1, argv=0xf7fffbf4, env=0xf7fffbfc)
         at env.c:10
         at env.c:10
     10              read_input_file (argv[i]);
     10              read_input_file (argv[i]);
   After such a printout, the `list' command with no arguments prints
   After such a printout, the `list' command with no arguments prints
ten lines centered on the point of execution in the frame.  *Note
ten lines centered on the point of execution in the frame.  *Note
Printing source lines: List.
Printing source lines: List.
`up-silently N'
`up-silently N'
`down-silently N'
`down-silently N'
     These two commands are variants of `up' and `down', respectively;
     These two commands are variants of `up' and `down', respectively;
     they differ in that they do their work silently, without causing
     they differ in that they do their work silently, without causing
     display of the new frame.  They are intended primarily for use in
     display of the new frame.  They are intended primarily for use in
     GDB command scripts, where the output might be unnecessary and
     GDB command scripts, where the output might be unnecessary and
     distracting.
     distracting.


File: gdb.info,  Node: Frame Info,  Prev: Selection,  Up: Stack
File: gdb.info,  Node: Frame Info,  Prev: Selection,  Up: Stack
Information about a frame
Information about a frame
=========================
=========================
   There are several other commands to print information about the
   There are several other commands to print information about the
selected stack frame.
selected stack frame.
`frame'
`frame'
`f'
`f'
     When used without any argument, this command does not change which
     When used without any argument, this command does not change which
     frame is selected, but prints a brief description of the currently
     frame is selected, but prints a brief description of the currently
     selected stack frame.  It can be abbreviated `f'.  With an
     selected stack frame.  It can be abbreviated `f'.  With an
     argument, this command is used to select a stack frame.  *Note
     argument, this command is used to select a stack frame.  *Note
     Selecting a frame: Selection.
     Selecting a frame: Selection.
`info frame'
`info frame'
`info f'
`info f'
     This command prints a verbose description of the selected stack
     This command prints a verbose description of the selected stack
     frame, including:
     frame, including:
        * the address of the frame
        * the address of the frame
        * the address of the next frame down (called by this frame)
        * the address of the next frame down (called by this frame)
        * the address of the next frame up (caller of this frame)
        * the address of the next frame up (caller of this frame)
        * the language in which the source code corresponding to this
        * the language in which the source code corresponding to this
          frame is written
          frame is written
        * the address of the frame's arguments
        * the address of the frame's arguments
        * the address of the frame's local variables
        * the address of the frame's local variables
        * the program counter saved in it (the address of execution in
        * the program counter saved in it (the address of execution in
          the caller frame)
          the caller frame)
        * which registers were saved in the frame
        * which registers were saved in the frame
     The verbose description is useful when something has gone wrong
     The verbose description is useful when something has gone wrong
     that has made the stack format fail to fit the usual conventions.
     that has made the stack format fail to fit the usual conventions.
`info frame ADDR'
`info frame ADDR'
`info f ADDR'
`info f ADDR'
     Print a verbose description of the frame at address ADDR, without
     Print a verbose description of the frame at address ADDR, without
     selecting that frame.  The selected frame remains unchanged by this
     selecting that frame.  The selected frame remains unchanged by this
     command.  This requires the same kind of address (more than one
     command.  This requires the same kind of address (more than one
     for some architectures) that you specify in the `frame' command.
     for some architectures) that you specify in the `frame' command.
     *Note Selecting a frame: Selection.
     *Note Selecting a frame: Selection.
`info args'
`info args'
     Print the arguments of the selected frame, each on a separate line.
     Print the arguments of the selected frame, each on a separate line.
`info locals'
`info locals'
     Print the local variables of the selected frame, each on a separate
     Print the local variables of the selected frame, each on a separate
     line.  These are all variables (declared either static or
     line.  These are all variables (declared either static or
     automatic) accessible at the point of execution of the selected
     automatic) accessible at the point of execution of the selected
     frame.
     frame.
`info catch'
`info catch'
     Print a list of all the exception handlers that are active in the
     Print a list of all the exception handlers that are active in the
     current stack frame at the current point of execution.  To see
     current stack frame at the current point of execution.  To see
     other exception handlers, visit the associated frame (using the
     other exception handlers, visit the associated frame (using the
     `up', `down', or `frame' commands); then type `info catch'.  *Note
     `up', `down', or `frame' commands); then type `info catch'.  *Note
     Setting catchpoints: Set Catchpoints.
     Setting catchpoints: Set Catchpoints.


File: gdb.info,  Node: Source,  Next: Data,  Prev: Stack,  Up: Top
File: gdb.info,  Node: Source,  Next: Data,  Prev: Stack,  Up: Top
Examining Source Files
Examining Source Files
**********************
**********************
   GDB can print parts of your program's source, since the debugging
   GDB can print parts of your program's source, since the debugging
information recorded in the program tells GDB what source files were
information recorded in the program tells GDB what source files were
used to build it.  When your program stops, GDB spontaneously prints
used to build it.  When your program stops, GDB spontaneously prints
the line where it stopped.  Likewise, when you select a stack frame
the line where it stopped.  Likewise, when you select a stack frame
(*note Selecting a frame: Selection.), GDB prints the line where
(*note Selecting a frame: Selection.), GDB prints the line where
execution in that frame has stopped.  You can print other portions of
execution in that frame has stopped.  You can print other portions of
source files by explicit command.
source files by explicit command.
   If you use GDB through its GNU Emacs interface, you may prefer to
   If you use GDB through its GNU Emacs interface, you may prefer to
use Emacs facilities to view source; see *Note Using GDB under GNU
use Emacs facilities to view source; see *Note Using GDB under GNU
Emacs: Emacs.
Emacs: Emacs.
* Menu:
* Menu:
* List::                        Printing source lines
* List::                        Printing source lines
* Search::                      Searching source files
* Search::                      Searching source files
* Source Path::                 Specifying source directories
* Source Path::                 Specifying source directories
* Machine Code::                Source and machine code
* Machine Code::                Source and machine code


File: gdb.info,  Node: List,  Next: Search,  Up: Source
File: gdb.info,  Node: List,  Next: Search,  Up: Source
Printing source lines
Printing source lines
=====================
=====================
   To print lines from a source file, use the `list' command
   To print lines from a source file, use the `list' command
(abbreviated `l').  By default, ten lines are printed.  There are
(abbreviated `l').  By default, ten lines are printed.  There are
several ways to specify what part of the file you want to print.
several ways to specify what part of the file you want to print.
   Here are the forms of the `list' command most commonly used:
   Here are the forms of the `list' command most commonly used:
`list LINENUM'
`list LINENUM'
     Print lines centered around line number LINENUM in the current
     Print lines centered around line number LINENUM in the current
     source file.
     source file.
`list FUNCTION'
`list FUNCTION'
     Print lines centered around the beginning of function FUNCTION.
     Print lines centered around the beginning of function FUNCTION.
`list'
`list'
     Print more lines.  If the last lines printed were printed with a
     Print more lines.  If the last lines printed were printed with a
     `list' command, this prints lines following the last lines
     `list' command, this prints lines following the last lines
     printed; however, if the last line printed was a solitary line
     printed; however, if the last line printed was a solitary line
     printed as part of displaying a stack frame (*note Examining the
     printed as part of displaying a stack frame (*note Examining the
     Stack: Stack.), this prints lines centered around that line.
     Stack: Stack.), this prints lines centered around that line.
`list -'
`list -'
     Print lines just before the lines last printed.
     Print lines just before the lines last printed.
   By default, GDB prints ten source lines with any of these forms of
   By default, GDB prints ten source lines with any of these forms of
the `list' command.  You can change this using `set listsize':
the `list' command.  You can change this using `set listsize':
`set listsize COUNT'
`set listsize COUNT'
     Make the `list' command display COUNT source lines (unless the
     Make the `list' command display COUNT source lines (unless the
     `list' argument explicitly specifies some other number).
     `list' argument explicitly specifies some other number).
`show listsize'
`show listsize'
     Display the number of lines that `list' prints.
     Display the number of lines that `list' prints.
   Repeating a `list' command with  discards the argument, so it
   Repeating a `list' command with  discards the argument, so it
is equivalent to typing just `list'.  This is more useful than listing
is equivalent to typing just `list'.  This is more useful than listing
the same lines again.  An exception is made for an argument of `-';
the same lines again.  An exception is made for an argument of `-';
that argument is preserved in repetition so that each repetition moves
that argument is preserved in repetition so that each repetition moves
up in the source file.
up in the source file.
   In general, the `list' command expects you to supply zero, one or two
   In general, the `list' command expects you to supply zero, one or two
"linespecs".  Linespecs specify source lines; there are several ways of
"linespecs".  Linespecs specify source lines; there are several ways of
writing them, but the effect is always to specify some source line.
writing them, but the effect is always to specify some source line.
Here is a complete description of the possible arguments for `list':
Here is a complete description of the possible arguments for `list':
`list LINESPEC'
`list LINESPEC'
     Print lines centered around the line specified by LINESPEC.
     Print lines centered around the line specified by LINESPEC.
`list FIRST,LAST'
`list FIRST,LAST'
     Print lines from FIRST to LAST.  Both arguments are linespecs.
     Print lines from FIRST to LAST.  Both arguments are linespecs.
`list ,LAST'
`list ,LAST'
     Print lines ending with LAST.
     Print lines ending with LAST.
`list FIRST,'
`list FIRST,'
     Print lines starting with FIRST.
     Print lines starting with FIRST.
`list +'
`list +'
     Print lines just after the lines last printed.
     Print lines just after the lines last printed.
`list -'
`list -'
     Print lines just before the lines last printed.
     Print lines just before the lines last printed.
`list'
`list'
     As described in the preceding table.
     As described in the preceding table.
   Here are the ways of specifying a single source line--all the kinds
   Here are the ways of specifying a single source line--all the kinds
of linespec.
of linespec.
`NUMBER'
`NUMBER'
     Specifies line NUMBER of the current source file.  When a `list'
     Specifies line NUMBER of the current source file.  When a `list'
     command has two linespecs, this refers to the same source file as
     command has two linespecs, this refers to the same source file as
     the first linespec.
     the first linespec.
`+OFFSET'
`+OFFSET'
     Specifies the line OFFSET lines after the last line printed.  When
     Specifies the line OFFSET lines after the last line printed.  When
     used as the second linespec in a `list' command that has two, this
     used as the second linespec in a `list' command that has two, this
     specifies the line OFFSET lines down from the first linespec.
     specifies the line OFFSET lines down from the first linespec.
`-OFFSET'
`-OFFSET'
     Specifies the line OFFSET lines before the last line printed.
     Specifies the line OFFSET lines before the last line printed.
`FILENAME:NUMBER'
`FILENAME:NUMBER'
     Specifies line NUMBER in the source file FILENAME.
     Specifies line NUMBER in the source file FILENAME.
`FUNCTION'
`FUNCTION'
     Specifies the line that begins the body of the function FUNCTION.
     Specifies the line that begins the body of the function FUNCTION.
     For example: in C, this is the line with the open brace.
     For example: in C, this is the line with the open brace.
`FILENAME:FUNCTION'
`FILENAME:FUNCTION'
     Specifies the line of the open-brace that begins the body of the
     Specifies the line of the open-brace that begins the body of the
     function FUNCTION in the file FILENAME.  You only need the file
     function FUNCTION in the file FILENAME.  You only need the file
     name with a function name to avoid ambiguity when there are
     name with a function name to avoid ambiguity when there are
     identically named functions in different source files.
     identically named functions in different source files.
`*ADDRESS'
`*ADDRESS'
     Specifies the line containing the program address ADDRESS.
     Specifies the line containing the program address ADDRESS.
     ADDRESS may be any expression.
     ADDRESS may be any expression.


File: gdb.info,  Node: Search,  Next: Source Path,  Prev: List,  Up: Source
File: gdb.info,  Node: Search,  Next: Source Path,  Prev: List,  Up: Source
Searching source files
Searching source files
======================
======================
   There are two commands for searching through the current source file
   There are two commands for searching through the current source file
for a regular expression.
for a regular expression.
`forward-search REGEXP'
`forward-search REGEXP'
`search REGEXP'
`search REGEXP'
     The command `forward-search REGEXP' checks each line, starting
     The command `forward-search REGEXP' checks each line, starting
     with the one following the last line listed, for a match for
     with the one following the last line listed, for a match for
     REGEXP.  It lists the line that is found.  You can use the synonym
     REGEXP.  It lists the line that is found.  You can use the synonym
     `search REGEXP' or abbreviate the command name as `fo'.
     `search REGEXP' or abbreviate the command name as `fo'.
`reverse-search REGEXP'
`reverse-search REGEXP'
     The command `reverse-search REGEXP' checks each line, starting
     The command `reverse-search REGEXP' checks each line, starting
     with the one before the last line listed and going backward, for a
     with the one before the last line listed and going backward, for a
     match for REGEXP.  It lists the line that is found.  You can
     match for REGEXP.  It lists the line that is found.  You can
     abbreviate this command as `rev'.
     abbreviate this command as `rev'.


File: gdb.info,  Node: Source Path,  Next: Machine Code,  Prev: Search,  Up: Source
File: gdb.info,  Node: Source Path,  Next: Machine Code,  Prev: Search,  Up: Source
Specifying source directories
Specifying source directories
=============================
=============================
   Executable programs sometimes do not record the directories of the
   Executable programs sometimes do not record the directories of the
source files from which they were compiled, just the names.  Even when
source files from which they were compiled, just the names.  Even when
they do, the directories could be moved between the compilation and
they do, the directories could be moved between the compilation and
your debugging session.  GDB has a list of directories to search for
your debugging session.  GDB has a list of directories to search for
source files; this is called the "source path".  Each time GDB wants a
source files; this is called the "source path".  Each time GDB wants a
source file, it tries all the directories in the list, in the order
source file, it tries all the directories in the list, in the order
they are present in the list, until it finds a file with the desired
they are present in the list, until it finds a file with the desired
name.  Note that the executable search path is _not_ used for this
name.  Note that the executable search path is _not_ used for this
purpose.  Neither is the current working directory, unless it happens
purpose.  Neither is the current working directory, unless it happens
to be in the source path.
to be in the source path.
   If GDB cannot find a source file in the source path, and the object
   If GDB cannot find a source file in the source path, and the object
program records a directory, GDB tries that directory too.  If the
program records a directory, GDB tries that directory too.  If the
source path is empty, and there is no record of the compilation
source path is empty, and there is no record of the compilation
directory, GDB looks in the current directory as a last resort.
directory, GDB looks in the current directory as a last resort.
   Whenever you reset or rearrange the source path, GDB clears out any
   Whenever you reset or rearrange the source path, GDB clears out any
information it has cached about where source files are found and where
information it has cached about where source files are found and where
each line is in the file.
each line is in the file.
   When you start GDB, its source path includes only `cdir' and `cwd',
   When you start GDB, its source path includes only `cdir' and `cwd',
in that order.  To add other directories, use the `directory' command.
in that order.  To add other directories, use the `directory' command.
`directory DIRNAME ...'
`directory DIRNAME ...'
`dir DIRNAME ...'
`dir DIRNAME ...'
     Add directory DIRNAME to the front of the source path.  Several
     Add directory DIRNAME to the front of the source path.  Several
     directory names may be given to this command, separated by `:'
     directory names may be given to this command, separated by `:'
     (`;' on MS-DOS and MS-Windows, where `:' usually appears as part
     (`;' on MS-DOS and MS-Windows, where `:' usually appears as part
     of absolute file names) or whitespace.  You may specify a
     of absolute file names) or whitespace.  You may specify a
     directory that is already in the source path; this moves it
     directory that is already in the source path; this moves it
     forward, so GDB searches it sooner.
     forward, so GDB searches it sooner.
     You can use the string `$cdir' to refer to the compilation
     You can use the string `$cdir' to refer to the compilation
     directory (if one is recorded), and `$cwd' to refer to the current
     directory (if one is recorded), and `$cwd' to refer to the current
     working directory.  `$cwd' is not the same as `.'--the former
     working directory.  `$cwd' is not the same as `.'--the former
     tracks the current working directory as it changes during your GDB
     tracks the current working directory as it changes during your GDB
     session, while the latter is immediately expanded to the current
     session, while the latter is immediately expanded to the current
     directory at the time you add an entry to the source path.
     directory at the time you add an entry to the source path.
`directory'
`directory'
     Reset the source path to empty again.  This requires confirmation.
     Reset the source path to empty again.  This requires confirmation.
`show directories'
`show directories'
     Print the source path: show which directories it contains.
     Print the source path: show which directories it contains.
   If your source path is cluttered with directories that are no longer
   If your source path is cluttered with directories that are no longer
of interest, GDB may sometimes cause confusion by finding the wrong
of interest, GDB may sometimes cause confusion by finding the wrong
versions of source.  You can correct the situation as follows:
versions of source.  You can correct the situation as follows:
  1. Use `directory' with no argument to reset the source path to empty.
  1. Use `directory' with no argument to reset the source path to empty.
  2. Use `directory' with suitable arguments to reinstall the
  2. Use `directory' with suitable arguments to reinstall the
     directories you want in the source path.  You can add all the
     directories you want in the source path.  You can add all the
     directories in one command.
     directories in one command.


File: gdb.info,  Node: Machine Code,  Prev: Source Path,  Up: Source
File: gdb.info,  Node: Machine Code,  Prev: Source Path,  Up: Source
Source and machine code
Source and machine code
=======================
=======================
   You can use the command `info line' to map source lines to program
   You can use the command `info line' to map source lines to program
addresses (and vice versa), and the command `disassemble' to display a
addresses (and vice versa), and the command `disassemble' to display a
range of addresses as machine instructions.  When run under GNU Emacs
range of addresses as machine instructions.  When run under GNU Emacs
mode, the `info line' command causes the arrow to point to the line
mode, the `info line' command causes the arrow to point to the line
specified.  Also, `info line' prints addresses in symbolic form as well
specified.  Also, `info line' prints addresses in symbolic form as well
as hex.
as hex.
`info line LINESPEC'
`info line LINESPEC'
     Print the starting and ending addresses of the compiled code for
     Print the starting and ending addresses of the compiled code for
     source line LINESPEC.  You can specify source lines in any of the
     source line LINESPEC.  You can specify source lines in any of the
     ways understood by the `list' command (*note Printing source
     ways understood by the `list' command (*note Printing source
     lines: List.).
     lines: List.).
   For example, we can use `info line' to discover the location of the
   For example, we can use `info line' to discover the location of the
object code for the first line of function `m4_changequote':
object code for the first line of function `m4_changequote':
     (gdb) info line m4_changequote
     (gdb) info line m4_changequote
     Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
     Line 895 of "builtin.c" starts at pc 0x634c and ends at 0x6350.
We can also inquire (using `*ADDR' as the form for LINESPEC) what
We can also inquire (using `*ADDR' as the form for LINESPEC) what
source line covers a particular address:
source line covers a particular address:
     (gdb) info line *0x63ff
     (gdb) info line *0x63ff
     Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
     Line 926 of "builtin.c" starts at pc 0x63e4 and ends at 0x6404.
   After `info line', the default address for the `x' command is
   After `info line', the default address for the `x' command is
changed to the starting address of the line, so that `x/i' is
changed to the starting address of the line, so that `x/i' is
sufficient to begin examining the machine code (*note Examining memory:
sufficient to begin examining the machine code (*note Examining memory:
Memory.).  Also, this address is saved as the value of the convenience
Memory.).  Also, this address is saved as the value of the convenience
variable `$_' (*note Convenience variables: Convenience Vars.).
variable `$_' (*note Convenience variables: Convenience Vars.).
`disassemble'
`disassemble'
     This specialized command dumps a range of memory as machine
     This specialized command dumps a range of memory as machine
     instructions.  The default memory range is the function
     instructions.  The default memory range is the function
     surrounding the program counter of the selected frame.  A single
     surrounding the program counter of the selected frame.  A single
     argument to this command is a program counter value; GDB dumps the
     argument to this command is a program counter value; GDB dumps the
     function surrounding this value.  Two arguments specify a range of
     function surrounding this value.  Two arguments specify a range of
     addresses (first inclusive, second exclusive) to dump.
     addresses (first inclusive, second exclusive) to dump.
   The following example shows the disassembly of a range of addresses
   The following example shows the disassembly of a range of addresses
of HP PA-RISC 2.0 code:
of HP PA-RISC 2.0 code:
     (gdb) disas 0x32c4 0x32e4
     (gdb) disas 0x32c4 0x32e4
     Dump of assembler code from 0x32c4 to 0x32e4:
     Dump of assembler code from 0x32c4 to 0x32e4:
     0x32c4 :      addil 0,dp
     0x32c4 :      addil 0,dp
     0x32c8 :      ldw 0x22c(sr0,r1),r26
     0x32c8 :      ldw 0x22c(sr0,r1),r26
     0x32cc :      ldil 0x3000,r31
     0x32cc :      ldil 0x3000,r31
     0x32d0 :      ble 0x3f8(sr4,r31)
     0x32d0 :      ble 0x3f8(sr4,r31)
     0x32d4 :      ldo 0(r31),rp
     0x32d4 :      ldo 0(r31),rp
     0x32d8 :      addil -0x800,dp
     0x32d8 :      addil -0x800,dp
     0x32dc :      ldo 0x588(r1),r26
     0x32dc :      ldo 0x588(r1),r26
     0x32e0 :      ldil 0x3000,r31
     0x32e0 :      ldil 0x3000,r31
     End of assembler dump.
     End of assembler dump.
   Some architectures have more than one commonly-used set of
   Some architectures have more than one commonly-used set of
instruction mnemonics or other syntax.
instruction mnemonics or other syntax.
`set disassembly-flavor INSTRUCTION-SET'
`set disassembly-flavor INSTRUCTION-SET'
     Select the instruction set to use when disassembling the program
     Select the instruction set to use when disassembling the program
     via the `disassemble' or `x/i' commands.
     via the `disassemble' or `x/i' commands.
     Currently this command is only defined for the Intel x86 family.
     Currently this command is only defined for the Intel x86 family.
     You can set INSTRUCTION-SET to either `intel' or `att'.  The
     You can set INSTRUCTION-SET to either `intel' or `att'.  The
     default is `att', the AT&T flavor used by default by Unix
     default is `att', the AT&T flavor used by default by Unix
     assemblers for x86-based targets.
     assemblers for x86-based targets.


File: gdb.info,  Node: Data,  Next: Languages,  Prev: Source,  Up: Top
File: gdb.info,  Node: Data,  Next: Languages,  Prev: Source,  Up: Top
Examining Data
Examining Data
**************
**************
   The usual way to examine data in your program is with the `print'
   The usual way to examine data in your program is with the `print'
command (abbreviated `p'), or its synonym `inspect'.  It evaluates and
command (abbreviated `p'), or its synonym `inspect'.  It evaluates and
prints the value of an expression of the language your program is
prints the value of an expression of the language your program is
written in (*note Using GDB with Different Languages: Languages.).
written in (*note Using GDB with Different Languages: Languages.).
`print EXPR'
`print EXPR'
`print /F EXPR'
`print /F EXPR'
     EXPR is an expression (in the source language).  By default the
     EXPR is an expression (in the source language).  By default the
     value of EXPR is printed in a format appropriate to its data type;
     value of EXPR is printed in a format appropriate to its data type;
     you can choose a different format by specifying `/F', where F is a
     you can choose a different format by specifying `/F', where F is a
     letter specifying the format; see *Note Output formats: Output
     letter specifying the format; see *Note Output formats: Output
     Formats.
     Formats.
`print'
`print'
`print /F'
`print /F'
     If you omit EXPR, GDB displays the last value again (from the
     If you omit EXPR, GDB displays the last value again (from the
     "value history"; *note Value history: Value History.).  This
     "value history"; *note Value history: Value History.).  This
     allows you to conveniently inspect the same value in an
     allows you to conveniently inspect the same value in an
     alternative format.
     alternative format.
   A more low-level way of examining data is with the `x' command.  It
   A more low-level way of examining data is with the `x' command.  It
examines data in memory at a specified address and prints it in a
examines data in memory at a specified address and prints it in a
specified format.  *Note Examining memory: Memory.
specified format.  *Note Examining memory: Memory.
   If you are interested in information about types, or about how the
   If you are interested in information about types, or about how the
fields of a struct or a class are declared, use the `ptype EXP' command
fields of a struct or a class are declared, use the `ptype EXP' command
rather than `print'.  *Note Examining the Symbol Table: Symbols.
rather than `print'.  *Note Examining the Symbol Table: Symbols.
* Menu:
* Menu:
* Expressions::                 Expressions
* Expressions::                 Expressions
* Variables::                   Program variables
* Variables::                   Program variables
* Arrays::                      Artificial arrays
* Arrays::                      Artificial arrays
* Output Formats::              Output formats
* Output Formats::              Output formats
* Memory::                      Examining memory
* Memory::                      Examining memory
* Auto Display::                Automatic display
* Auto Display::                Automatic display
* Print Settings::              Print settings
* Print Settings::              Print settings
* Value History::               Value history
* Value History::               Value history
* Convenience Vars::            Convenience variables
* Convenience Vars::            Convenience variables
* Registers::                   Registers
* Registers::                   Registers
* Floating Point Hardware::     Floating point hardware
* Floating Point Hardware::     Floating point hardware
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.