c++ - How to set a breakpoint in a specific method of a specific object? -


i have nasty bug in c++ project. there's class

class someclass {     ...     std::string *somestring;     ... } 

here's constructor

someclass(...) {     ...     somestring = new std::string("");     ... } 

and thing afterwards operate specific string, without modifying poiner value. assign string different strings time,

*somestring = "whatever"; somestring->assign("whatever"); *somestring += 'a'; 

application multithreaded , there's nasty glitch. @ point, application crashes. debugger shows variable somestring has bad pointer. , have no idea how possible

delete somestring; 

is never called.

i've looked references of string pointer , here's can tell you:

  1. delete on pointer never called.
  2. that pointer never assigned else (where may deleted later).
  3. pointer value of string never altered in way (debugger shows 'bad ptr').
  4. other class variables seem fine supposed be.

therefore, need find way check when destructor called on specific object. in fact, array of objects.

so, there way set breakpoint on destructor (or other method) on specific set of objects (i'm working on visual studio 2010 proffessional)?

if multithreading, consider implementing locking mechanism ... (if didn't already) string member. highly possible 1 thread tries write pointer being reallocated in different thread... or this. little bit more code understand problem in deeper context.


Comments