This is the mail archive of the
gdb@sourceware.org
mailing list for the GDB project.
Re: How to watch for changes in a location of memory
- From: "Eran Ifrah" <eran dot ifrah at gmail dot com>
- To: "gdb Mailing List" <gdb at sources dot redhat dot com>
- Date: Fri, 8 Aug 2008 10:37:50 +0200
- Subject: Re: How to watch for changes in a location of memory
- References: <20080808081041.GA32701@geppetto>
You might want to try the 'watch' command which will causes gdb to
break whenever the memory at a given addr has been modified
Read here for more details:
http://sources.redhat.com/gdb/current/onlinedocs/gdb_6.html#SEC34
Eran
On Fri, Aug 8, 2008 at 10:10 AM, Stefano Sabatini
<stefano.sabatini-lala@poste.it> wrote:
> Hi all,
>
> I would like to check a variable in memory, I don't know in which
> function is modified, so I can't do a simple watch on a variable name.
>
> So I wonder if it is possible (gdb 6.8) to watch for a variable using
> the location rather than the var name.
>
> I'll try to express it more clearly: for example if I have a struct:
> FooCtx* ctx;
>
> containing a field foo, ctx is defined somewhere in the code, and may
> be accessed from different contexts, for example:
>
> trash->junk->ctx->foo;
> bar->ctx->foo;
>
> etc.
>
> How can I monitor for changes in ctx->foo simply specifying its
> location in memory (&ctx->foo), is it currently possible with gdb at
> all?
>
> Sorry if I overlooked something obvious.
>
> Thanks in advance, regards.
>
--
Eran Ifrah
eran.ifrah@gmail.com