Wednesday, October 15, 2008

gdb: modify values of the variables

While you debugging your application you likely want to change behavior a bit.
With gdb you can change values of the variables with set command:

(gdb) whatis a
type = int
By variable name
(gdb) p a
$1 = 5
(gdb) set var a = 10
(gdb) p a
$2 = 10
By variable address
(gdb) p a
$2 = 10
(gdb) p &a
$3 = (int *) 0xbff5ada0
(gdb) set {int}0xbff5ada0 = 15
(gdb) p a
$4 = 15

No comments: