Mail Archives: djgpp/1997/01/30/11:47:38
Errors-To: postmaster AT ns1
From: jrubin AT bix DOT com (jrubin)
Newsgroups: comp.os.msdos.djgpp
Date: 29 Jan 1997 18:31:54 GMT
Organization: BIX
Lines: 32
Nntp-Posting-Host: ns.delphi.com
X-Newsreader: TIN [version 1.2 PL2]
Dj-Gateway: from newsgroup comp.os.msdos.djgpp
Content-Type: text
Content-Length: 522
GDB claims to be changing the value of the variable 'x',
but the program doesn't seem to notice. When GDB exits,
it reports failure to close the image file.
File test.c:
------------
#include <stdio.h>
int x = 1;
int main(void)
{
printf("test.c: x = %d\n",x);
return 0;
}
--------------
gcc -g test.c
gdb a.out
(gdb) p x
$1 = 1
(gdb) set var x = 100
(gdb) p x
$2 = 100
(gdb) r
No, no. When you entered the run (r) command GDB reloaded the executable from disk
and wiped out your change to 'x'. Try this:
gdb a.out
(gdb) b main
Breakpoint 1 at 0x101a88
(gdb) r
Starting program: c:/jsc/runtime/a.out
(gdb) p x
$1 = 1
(gdb) set var x = 100
(gdb) p x
$2 = 100
(gdb) step
(gdb) p x
$2 = 100
(gdb) cont
test.c: x = 100
(gdb) q
--
Art S. Kagel, kagel AT quasar DOT bloomberg DOT com
A proverb is no proverb to you 'till life has illustrated it. -- John Keats
- Raw text -