2009/5/21 Dan Kegel <[email protected]>:
> On Thu, May 21, 2009 at 7:22 AM, Alex Bennee <[email protected]> wrote:
>> Is there any way I could mark an interesting location in memory with
>> the client mechanism and then get
>> Valgrind to show me a backtrace everytime the location was touched? If
>> not it would be a really useful tool :-)
>
> That would be cool.  That said, have you tried a watchpoint in gdb?
> http://stackoverflow.com/questions/58851/can-i-set-a-breakpoint-on-memory-access-in-gdb

Yep I had been trying that. The main problem was not being able to do
ith progamatically:

b 869 if awatch (void *) *&n->timer

Would of been useful. But conditinal breakpoints aren't really
designed for setting newer breakpoints.

In the end I did solve it with a client request:

          n->timer = NULL;
          fprintf(stderr,"  2:checking n=%p n->timer=%p\n", n, n->timer);
          VALGRIND_MAKE_MEM_NOACCESS(&n->timer, sizeof(n->timer));

And almost imeadiatly Valgrind showed me an invalid write:

==31858== Invalid write of size 4
==31858==    at 0x413B1D: function (snmp_interface.c:2699)

Which lead to:
    n->vc_qam[us]++;

Which funnily enough was an incorrectly sized array just before n->timer

Time spent reading Valgrind's fine manual: 10 minutes, Time spent
hacking in the macro and running Valgrind 5 minutes, Time I *would
have* saved if I had done this earlier: 4 hours ;-)

-- 
Alex, homepage: http://www.bennee.com/~alex/
CV: http://www.bennee.com/~alex/cv.php

------------------------------------------------------------------------------
Register Now for Creativity and Technology (CaT), June 3rd, NYC. CaT
is a gathering of tech-side developers & brand creativity professionals. Meet
the minds behind Google Creative Lab, Visual Complexity, Processing, & 
iPhoneDevCamp asthey present alongside digital heavyweights like Barbarian
Group, R/GA, & Big Spaceship. http://www.creativitycat.com 
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to