From: kagel AT quasar DOT bloomberg DOT com Date: Thu, 30 Jan 1997 11:26:06 -0500 Message-Id: <9701301626.AA16799@quasar.bloomberg.com > To: jrubin AT bix DOT com Cc: djgpp AT delorie DOT com In-Reply-To: <5co52q$hg0@news2.delphi.com> (jrubin@bix.com) Subject: Re: Why can't GDB set a variable? Reply-To: kagel AT dg1 DOT bloomberg DOT com 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 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