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 {
int (functionA*)(args);

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…


Leave a Reply

Your email address will not be published. Required fields are marked *

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