Search code examples
cvisual-studio-2012visual-studio-debugging

Visual Studio is it possible to break when a type is first used?


I've been handed this gigantic code base, written in C, that I need to step through and find a certain feature so I can reverse engineer and modify it. Since this code is hundreds of thousands of lines long, you can imagine that this process is quite slow. I have an idea for how to speed it along, but I don't know if it is possible. I have something that resembles this:

struct A{
   /* some data */
};

struct B{
   A* a;
   /* some data */
};
/* note A and B are defined in different files */

I want Visual Studio to break when B->a is first assigned/modified on any arbitrary instance of B. Is this possible to do in Visual Studio Professional 2012?


Solution

  • You can set a breakpoint on the constructor for type B (or the equivalent of a constructor in your C code). When that triggers, you can set a memory breakpoint on B->a and wait for that one to trigger.