Debugging with GDB (September 2007)

Chapter 11: Altering Execution 99
counter. If line linespec is in a different function from the one currently exe-
cuting, the results may be bizarre if the two functions expect different patterns
of arguments or of local variables. For this reason, the jump command requests
confirmation if the specified line is not in the function currently executing.
However, even bizarre results are predictable if you are well acquainted with
the machine-language code of your program.
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. This does not start the execution of your program at the
specified address, instead only changes the program counter.
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. See Section 5.2 [Continuing and stepping],
page 44.
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.
11.3 Giving your program a signal
You can use the following command to send signals to your program:
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 ze ro, 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
h
RET
i
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 (see Section 5.3 [Signals], page 46). The signal command passes
the signal directly to your program.
11.4 Returning from a function
You can use the following command to return from a function: