Why are my xmethods not being invoked?

Paul Smith psmith@gnu.org
Wed Jan 25 01:20:48 GMT 2023


I have a C++ program that has a home-grown smart pointer wrapper and I
want to create an xmethod for operator-> and operator* for this type.

I've followed all the rules carefully (I think!) and used the
std::unique_ptr<> xmethods from the GCC STL as an example, but the
match() method on my XMethodMatcher object is not ever getting called.

I added gdb.write() calls before I register the matcher class, and in
the __init__() of my matcher class, and in the match() method of my
matcher class.

When I start GDB I see the gdb.write() output when I register and
output for the init() of the matcher class so I know that's happening.
I can also see my operators shown in the output of "info xmethod":

  (gdb) info xmethod
    MyRefObject:
      operator->
      operator*
    ...

But, when I try to print a value using "*o" or "o->xxx" where "o" is a
local variable of type MyRefObject<Foo>, the gdb.write() call in my
match() method is never invoked at all.

How does GDB decide which xmethod match() functions should be invoked,
and which should not be invoked?  Is there some other magic I need to
do to get this hooked up?


More information about the Gdb mailing list