Occasionally the debugger will not be able to hit a breakpoint in C++ code. For instance in Visual Studio the breakpoint will be grayed out or something similar. Now, considering that you double checked that the breakpoint is in fact active, here are a couple of reasons why you might have this problem.

1. The debugging symbol files are outdated.  

In Visual Studio these are *.pdb files, while in Rad Studio these have the extension *.tds. A simple way of fixing this is to delete the debugging symbol files and rebuild the solution. Rebuilding should delete and recreate the files if necessary, but to be 120% sure you can delete them yourself.

See also this SO answer Stackoverflow post

 2. The code is not compiled into the executable.

While you are working in the IDE the breakpoint will look fine and dandy, but then it becomes inactive or “un-hittable” the moment you run the executable. The problem may be that the code not included in the executable due to conditional compilation. For instance, consider what happens in the following pseudocode if CALL_INNER is not defined:

class ExampleClass
{
    void Outer()
    {
#ifdef CALL_INNER
        Inner();
#endif
    }

    void Inner()
    {
        // Do stuff
    }
}

Assuming there are no other calls to Inner(), other than the one in Outer(), then any compiler today will optimize away Inner() when CALL_INNER is not defined. So breakpoints in Inner() cannot ever be hit.

Advertisements