As Nick already suggested, start with --track-origins=yes.

That should be the first thing to try.

As an alternative (if your build times are short or it's difficult to debug the code with gdb) then you can 'instrument' your code with conditions. For instance, if you think the variable "widget" is the culprit, then somewhere before the reported error add something like

if (widget == 0)
{
     std::cout << "widget condition true\n";
}

Agreed; this is useful if --track-origins=yes doesn't help.

A somewhat more general way to force an immediate test is

  #include <valgrind/memcheck.h>
  ...
  VALGRIND_CHECK_MEM_IS_DEFINED(pointer, length)   or
  VALGRIND_CHECK_VALUE_IS_DEFINED(lvalue)

I've found those two to be useful in tracking down difficult errors.

J



_______________________________________________
Valgrind-users mailing list
Valgrind-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/valgrind-users

Reply via email to