List Info

Thread: GDB command to write to memory




GDB command to write to memory
country flaguser name
United States
2008-02-28 00:38:05
The command x is used to examine memory but i don't find the
command to write
directly a value in memory. I've tried X but it is not
recognized.

Thanks
-- 
View this message in context: http://www.nabble.com/GDB-command-t
o-write-to-memory-tp15730605p15730605.html
Sent from the Sourceware - gdb list mailing list archive at
Nabble.com.


Re: GDB command to write to memory
country flaguser name
United States
2008-02-28 02:30:57


Guillaume MENANT wrote:
> 
> The command x is used to examine memory but i don't
find the command to
> write directly a value in memory. I've tried X but it
is not recognized.
> 
> Thanks
> 
The only solution i've found is the "set var"
command but it's limited in
use. Is there a more flexible command ?
-- 
View this message in context: http://www.nabble.com/GDB-command-t
o-write-to-memory-tp15730605p15731837.html
Sent from the Sourceware - gdb list mailing list archive at
Nabble.com.


Re: GDB command to write to memory
country flaguser name
Germany
2008-02-28 03:42:09
Guillaume MENANT <guillaume.menantgeensys.com> writes:

> The only solution i've found is the "set var"
command but it's limited in
> use. Is there a more flexible command ?

(gdb) set 0xdeadbeef = 42

Andreas.

-- 
Andreas Schwab, SuSE Labs, schwabsuse.de
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg,
Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5
214B 8276 4ED5
"And now for something completely different."

Re: GDB command to write to memory
country flaguser name
United States
2008-02-28 13:29:16
On Wed, 2008-02-27 at 22:38 -0800, Guillaume MENANT wrote:
> The command x is used to examine memory but i don't
find the command to write
> directly a value in memory. I've tried X but it is not
recognized.

There's no such command.  The general method is to use
an assignment expression.  You use a cast to determine
the size of memory (byte, word...) you want to write.

(gdb) set *(char *) 0xabcd = -1

You can do tricky things by using or omitting
"signed", 
and usually write up to an 8-byte word by using "long
long".




[1-4]

about | contact  Other archives ( Real Estate discussion Medical topics )