[stacktrace] libbacktrace callback for backtrace_pcinfo invalid return value

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[stacktrace] libbacktrace callback for backtrace_pcinfo invalid return value

Boost - Dev mailing list
Hello all

See also: https://stackoverflow.com/questions/54333608/boost-stacktrace-not-demangling-names-when-cross-compiled
I am cross compiling boost on Unix for Windows with MINGW. I am using libbacktrace compiled using the same toolchain from here: https://github.com/ianlancetaylor/libbacktrace
Digging through the code of libbacktrace I was able to deduce that in a success case the return value of backtrace_pcinfo will be the return value of the callback supplied to that function (for DWARF search). The callback boost is giving looks like this:

inline int libbacktrace_full_callback(void *data, uintptr_t /*pc*/, const char *filename, int lineno, const char *function) {
pc_data& d = *static_cast<pc_data*>(data);
if (d.filename && filename) {
*d.filename = filename;
}
if (d.function && function) {
*d.function = function;
}
d.line = lineno;
return 0;
}

As you can see it will always return 0. This causes an issue with the way the function is called:
::backtrace_pcinfo:(
state,
reinterpret_cast<uintptr_t>(addr),
boost::stacktrace::detail::libbacktrace_full_callback,
boost::stacktrace::detail::libbacktrace_error_callback,
&data
)
||
::backtrace_syminfo:(
state,
reinterpret_cast<uintptr_t>(addr),
boost::stacktrace::detail::libbacktrace_syminfo_callback,
boost::stacktrace::detail::libbacktrace_error_callback,
&data
);

If the symbol is found using backtrace_pcinfo the return value will be 0. If its not found it will be 0. It will always use the value provided by backtrace_syminfo.
Is this intended?
BR
Cromon


_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost