Home / Programming / C / gdb’ing through a function pointer into a template

gdb’ing through a function pointer into a template

Take this (badly mangled to save the names of the guilty) chunk of “code” and run it through the Intel C++ compiler with any -g option you want:


class C {
private:
int (functionA*)(args);

C(){
functionA = functionB;
}

functionC(args) {
rc = (this->*functionA)(args);
}

template <D,E> int functionB(args) const {
/* some code */
}
};

Now try debugging functionB when it’s called via functionC using gdb. In particular, try looking at the args fed to function B.

Now weep for your soul. And TotalView won’t help you now either buddy. You’re down to objdump -t library.a | c++filt | grep functionC and setting some stupid-looking C++ mangled name out of the mess you get back as the breakpoint in gdb.

There has to be a better way…

2 Comments

  1. That’s wierd Peeter, it looked okay (if missing indents) in chrome, firefox and epiphany – what browser are you using?

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.