ddd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to break on a write to a specific mem location?


From: Andrew Lees
Subject: Re: how to break on a write to a specific mem location?
Date: Sun, 13 Apr 2003 21:30:45 +1000
User-agent: KMail/1.4.3

On Saturday 12 April 2003 02:35, J.H.M. Dassen (Ray) wrote:
> On Fri, Apr 11, 2003 at 07:52:55 -0700, address@hidden wrote:
> >    I am trying to debug a bug that looks like memory corruption: the
> >    content of a memory location which should not change after start up is
> >    in reality altered. I want to find out the backtrace when that
> > happens.
>
> Sounds like a situation I'd try Electric Fence on.
>
> HTH,
> Ray

Electirc fence can be *very* useful.  For future refence, if you need to trap 
on write to a specific location *after* it has been allocated and set as 
desired, set a breakpoint where you know the data is good, and print out the 
adress of the variable of interest.  The print has the side effect of setting 
a debugger variable "$n" to the address of the variable.  Then set a 
watchpoint on a dereference of the $n variable, which never goes out of 
scope.  Providing only a limited number of watchpoints are set, and the 
variable is of suitable type, and you are using a processor with hardware 
watchpoint abilties, the processor's harware watchpoint mechanism will be 
used, and your program will run at full speed.  Summarising:

print &variable
[$<n> variable set]
watch *$<n>
continue

regards,

Andy Lees.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]