|
Boost : |
Subject: [boost] [stacktrace] libbacktrace callback for backtrace_pcinfo invalid return value
From: Muazin Mugadr (mugadr.m_at_[hidden])
Date: 2019-01-24 16:42:57
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
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk