
136
Chapter 16. Altering Execution
$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 program variable
g
did not change, and you silently set the
gnutarget
to an invalid value. 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 spec-
ified type at a specified address (refer to Section 10.1
Expressions
). 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.
16.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 instead continue at an address of your own choosing, with the fol-
lowing commands:
jump
linespec
Resume execution at line
linespec
. Execution stops again immediately if there is a break-
point there. Refer to Section 9.1
Printing source lines
, for a description of the different forms of
linespec
. It is common practice to use the
tbreak
command in conjunction with
jump
. Refer
to Section 7.1.1
Setting breakpoints
.
The
jump
command does not change the current stack frame, or the stack pointer, or 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 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.
Summary of Contents for ENTERPRISE LINUX 3 - SECURITY GUIDE
Page 1: ...Red Hat Enterprise Linux 3 Debugging with gdb ...
Page 12: ...2 Chapter 1 Debugging with gdb ...
Page 28: ...18 Chapter 4 Getting In and Out of gdb ...
Page 34: ...24 Chapter 5 gdb Commands ...
Page 44: ...34 Chapter 6 Running Programs Under gdb ...
Page 68: ...58 Chapter 8 Examining the Stack ...
Page 98: ...88 Chapter 10 Examining Data ...
Page 112: ...102 Chapter 12 Tracepoints ...
Page 118: ...108 Chapter 13 Debugging Programs That Use Overlays ...
Page 138: ...128 Chapter 14 Using gdb with Different Languages ...
Page 144: ...134 Chapter 15 Examining the Symbol Table ...
Page 170: ...160 Chapter 19 Debugging remote programs ...
Page 198: ...188 Chapter 21 Controlling gdb ...
Page 204: ...194 Chapter 22 Canned Sequences of Commands ...
Page 206: ...196 Chapter 23 Command Interpreters ...
Page 216: ...206 Chapter 25 Using gdb under gnu Emacs ...
Page 296: ...286 Chapter 27 gdb Annotations ...
Page 300: ...290 Chapter 28 Reporting Bugs in gdb ...
Page 322: ...312 Chapter 30 Using History Interactively ...
Page 362: ...352 Appendix D gdb Remote Serial Protocol ...
Page 380: ...370 Appendix F GNU GENERAL PUBLIC LICENSE ...
Page 386: ...376 Appendix G GNU Free Documentation License ...
Page 410: ......