((gdb)) p g $1 = 1 ((gdb)) set g=4

((gdb)) p g $2 = 1 ((gdb)) r

The program being debugged has been started already. Start it from the beginning? (y or n) y

Starting program: /home/smith/cc_progs/a.out

"/home/smith/cc_progs/a.out": can't open to read symbols: Invalid bfd target.

((gdb)) show g

The current BFD target is "=4".

The steps shown above sets the gnutarget to an invalid value in place of the program variable g.

In order to set the variable g, use

((gdb)) set var g=4

GDB allows more implicit conversions in assignments than C; you can freely store an integer value into a pointer variable or vice versa, and you can convert any structure to any other structure that is the same length or shorter.

To store values into arbitrary places in memory, use the '{...}' construct to generate a value of specified type at a specified address (see“Expressions” (page 83)). For example, {int}0x83040 refers to memory location 0x83040 as an integer (which implies a certain size and representation in memory), and

set {int}0x83040 = 4

stores the value 4 into that memory location.

11.2 Continuing at a different address

Ordinarily, when you continue your program, you do so at the place where it stopped, with the continue command. You can continue at a selected address using one of the following commands:

jump linespec Resume execution at line linespec. Execution stops again immediately if there is a breakpoint there. See “Printing source lines” (page 77), for a description of the different forms of linespec. It is common practice to use the tbreak command in conjunction with jump. See “Breakpoints” (page 51).

The jump command does not change the current stack frame, the stack pointer, the contents of any memory location or any register other than the program counter. If line linespec is in a different function from the one currently executing, the results may be bizarre if the two functions expect different patterns of arguments

120 Altering Execution