If I have class Foo { bar() { stuff(); // line 120 } virtual ~Foo() {} }; class FooSubclass : public Foo { }; I want to be able to do something like $ br foo.cxx:120 if ptype(*this) == "FooSubclass*" so that I can filter breakpoints on the subtype of Foo thanks
You can use the typeof convenience function: https://github.com/tromey/gdb-helpers/blob/master/gdbhelpers/typeof.py This could be upstreamed I suppose. In this particular case you can probably use dynamic_cast though. Could you try: break foo.cxx:120 if dynamic_cast<FooSubclass*>(this) ?
Note: I'm debugging LibreOffice. doing this $ br VclReferenceBase::acquire if dynamic_cast<ToolBox*>(this) will stop at every acquire regardless of the type of this doing this $ br VclReferenceBase::acquire if dynamic_cast<ToolBox*>(this) != nullptr will never stop
And I reboot my machine, and for some reason $ br VclReferenceBase::acquire if dynamic_cast<ToolBox*>(this) starts working, hmmmm thanks for the suggestion!