This is the mail archive of the gdb@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: how to r/w memory


On Mon, Jun 15, 2009 at 10:47 PM, loody<miloody@gmail.com> wrote:

> From the gdb document, we can use "x/nfu address" to read memory, but
> how we can write it?

I usually do:
  (gdb) set *(int *)0x80000000 = 0

If GDB knows has debug info associated with the memory location,
  (gdb) print var = 2
or
  (gdb) set var = 3
also work for me.

If GDB knows the symbol, but doesn't have debug info for it, you'll have
to do cast again:
  (gdb) set *(int *)&var = 4

Cheers,
-- 
Paul Pluzhnikov


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]