Can I set a conditional breakpoint in base class method which triggers only if it's an instance of specific derived class?

Viewed 3148

Let's say I have some base class A and two derived classes B and C. Class A has some method called f().

Is there a way to set a conditional breakpoint in A::f() in visual studio which will be hit only when my 'this' is actually an instance of class C?

For example


    void A::f()
    {
    some code and a breakpoint 
    }

    void foo(A* a)
    {
       a->f();
    }

    void bar()
    {
       A a;
       B b;
       C c;
       foo(&a); // breakpoint isn't hit
       foo(&b); // breakpoint isn't hit
       foo(&c); // breakpoint is hit
    }

I've managed to achieve it by testing virtual table pointer in breakpoint's condition but there's got to be a better(more easy) way.

Thanks in advance.

EDIT: Modifying source code as was suggested in comments is not kind of a solution I'm looking for. It has to be done only by means of VC++ debugger.

4 Answers
Related