delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/12/21/17:46:38

From: Robert Hoehne <robert DOT hoehne AT gmx DOT net>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gdb
Date: Sun, 21 Dec 1997 23:14:26 +0100
Organization: none provided
Lines: 99
Message-ID: <349D94C2.BA9710FA@gmx.net>
References: <349D2485 DOT C77BDD2D AT nsi DOT co DOT il>
NNTP-Posting-Host: isdn25.hrz.tu-chemnitz.de
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

ppr. P. V Prok schrieb:
> 
> I use gdb in DJGPP environment. I need to change value of global
> variable and store it to executable. I perform the following:
> 
>     set write on
>     file ....exe
>     set xx=1
> 
> but gdb sais it cannot acces to xx. I've tried to run program first.
> Then it changes value, but only in memory.

What an interesting fact. I never heard about it, but now ...

In general it works (at least for my short examples), but sometimes
there are
some tricks needed, especially when the variable has a name, which is
in some matter known to gdb. For instance, my first try was the
following:

#include <stdio.h>
int vv = 1;
int v = 1;
int main()
{
  printf("%d %d\n",vv,v);
  return 0;
}


Here now an interesting gdb session:

--------------------------------------------------------------------------
O:\RHIDE\TEST>gdb
GDB is free software and you are welcome to distribute copies of it
 under certain conditions; type "show copying" to see the conditions.
There is absolutely no warranty for GDB; type "show warranty" for
details.
GDB 4.16 (go32), Copyright 1996 Free Software Foundation, Inc.
(gdb) set write on
(gdb) file t.exe
Reading symbols from t.exe...done.
(gdb) p v
$1 = 1
(gdb) set v=2
Ambiguous set command "v=2": .
(gdb)
---------COMMENT BY ME----
BUT now it comes!!
---------END OF COMMENT---
(gdb) p vv
$2 = 1
(gdb) set vv=2
(gdb) p vv
$3 = 2
(gdb) r
Starting program: o:/rhide/test/t.exe
2 1

Program exited normally.
(gdb)
--------------------------------------------------------------------------------

That means, you can do such things not with all variable names (or they
must
be quoted something). But it works!!

Only a guess: Maybe you will have problems
with all variable names, which are abbreviations of a set-command in
gdb, like
in my case for the ´set variable´-command. To proof this I tried it with
a
variable

int va = 1;

and here the result:
---------------------------------------
(gdb) p va
$1 = 1
(gdb) set va=2
A parse error in expression, near `2'.
(gdb) set 'va'=2
(gdb) p va
$2 = 2
(gdb)
---------------------------------------

BTW: Thanks for posting this question, so I could learn a little bit
more about the features of gdb.

Robert
-- 
******************************************************
* email:   Robert Hoehne <robert DOT hoehne AT gmx DOT net>     *
* Post:    Am Berg 3, D-09573 Dittmannsdorf, Germany *
* WWW:     http://www.tu-chemnitz.de/~sho/rho        *
******************************************************

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019