What is the reason for the g++ abi::__cxa_demangle function to not return the return value for member functions?
Here's a working example of this behavior
#include <execinfo.h>
#include <cxxabi.h>
#include <iostream>
struct Foo {
void operator()() const
{
constexpr int buf_size = 100;
static void *buffer[buf_size];
int nptrs = backtrace(buffer, buf_size);
char **strings = backtrace_symbols(buffer, nptrs);
for(int i = 0; i < nptrs; ++i) {
auto str = std::string(strings[i]);
auto first = str.find_last_of('(') + 1;
auto last = str.find_last_of(')');
auto mas = str.find_last_of('+');
int status;
char* result = abi::__cxa_demangle(str.substr(first, mas-first).c_str(), nullptr, nullptr, &status);
if (status == 0) std::cout << result << std::endl;
}
}
};
int main () {
Foo f;
f();
}
and after compiling with
g++ foo.cpp -std=c++11 -rdynamic
the output is
Foo::operator()() const
Is there a way to get a consistent behavior, this is, getting also the return value for the member functions?