Chapter 16. Altering Execution
137
jump *
address
Resume execution at the instruction at address
address
.
On many systems, you can get much the same effect as the
jump
command by storing a new value
into the register
$pc
. The difference is that this does not start your program running; it only changes
the address of where it
will
run when you continue. For example,
set $pc = 0x485
makes the next
continue
command or stepping command execute at address
0x485
, rather than at
the address where your program stopped. Refer to Section 7.2
Continuing and stepping
.
The most common occasion to use the
jump
command is to back up--perhaps with more breakpoints
set--over a portion of a program that has already executed, in order to examine its execution in more
detail.
16.3. Giving your program a signal
signal
signal
Resume execution where your program stopped, but immediately give it the signal
signal
.
signal
can be the name or the number of a signal. For example, on many systems
signal 2
and
signal SIGINT
are both ways of sending an interrupt signal.
Alternatively, if
signal
is zero, continue execution without giving a signal. This is useful when
your program stopped on account of a signal and would ordinary see the signal when resumed
with the
continue
command;
signal 0
causes it to resume without a signal.
signal
does not repeat when you press [RET] a second time after executing the command.
Invoking the
signal
command is not the same as invoking the
kill
utility from the shell. Sending
a signal with
kill
causes gdb to decide what to do with the signal depending on the signal handling
tables (refer to Section 7.3
Signals
). The
signal
command passes the signal directly to your program.
16.4. Returning from a function
return
return
expression
You can cancel execution of a function call with the
return
command. If you give an
expression
argument, its value is used as the function’s return value.
When you use
return
, gdb discards the selected stack frame (and all frames within it). You can think
of this as making the discarded frame return prematurely. If you wish to specify a value to be returned,
give that value as the argument to
return
.
This pops the selected stack frame (refer to Section 8.3
Selecting a frame
), and any other frames inside
of it, leaving its caller as the innermost remaining frame. That frame becomes selected. The specified
value is stored in the registers used for returning values of functions.
The
return
command does not resume execution; it leaves the program stopped in the state that
would exist if the function had just returned. In contrast, the
finish
command (refer to Section 7.2
Continuing and stepping
) resumes execution until the selected stack frame returns naturally.
Содержание ENTERPRISE LINUX 4 - DEVELOPER TOOLS GUIDE
Страница 1: ...Red Hat Enterprise Linux 4 Debugging with gdb ...
Страница 12: ...2 Chapter 1 Debugging with gdb ...
Страница 28: ...18 Chapter 4 Getting In and Out of gdb ...
Страница 34: ...24 Chapter 5 gdb Commands ...
Страница 44: ...34 Chapter 6 Running Programs Under gdb ...
Страница 68: ...58 Chapter 8 Examining the Stack ...
Страница 98: ...88 Chapter 10 Examining Data ...
Страница 112: ...102 Chapter 12 Tracepoints ...
Страница 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Страница 138: ...128 Chapter 14 Using gdb with Different Languages ...
Страница 144: ...134 Chapter 15 Examining the Symbol Table ...
Страница 170: ...160 Chapter 19 Debugging remote programs ...
Страница 198: ...188 Chapter 21 Controlling gdb ...
Страница 204: ...194 Chapter 22 Canned Sequences of Commands ...
Страница 206: ...196 Chapter 23 Command Interpreters ...
Страница 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Страница 296: ...286 Chapter 27 gdb Annotations ...
Страница 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Страница 322: ...312 Chapter 30 Using History Interactively ...
Страница 362: ...352 Appendix D gdb Remote Serial Protocol ...
Страница 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Страница 386: ...376 Appendix G GNU Free Documentation License ...
Страница 410: ......