Re: breakpoint for accessing memory location

Daniel Jacobowitz
2006-10-19T20:12:27Z

On Thu, Oct 19, 2006 at 10:10:46PM +0200, Erik Leunissen wrote:
> Hi,
>
> I've got a shared lib that I programmed to store some data on the heap
> in order to retrieve them later. The main program which loads the shared
> lib appears to overwrite that location in memory, before the next time I
> want to use it (which is weird because the main program shouldn't have a
> clue about this particular action of the shared lib).
>
> So, in order to find out which part of the main program is being nasty,
> I want to set some kind of breakpoint that alerts me whenever that
> memory location is being written to.
>
> Is that possible using gdb?
>
>
> (P.S. In the manual, I found the gdb command [break *address], but from
> its behaviour, I think it's meant to do something different from what I
> want.)

Take a look at "watchpoints" in the manual. They should be exactly
what you need.

--
Daniel Jacobowitz
CodeSourcery