-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
Hi,
I'm building with mingw-w64 on Windows and using libbacktrace as implementation. I try to get function names using name() on a frame, but I got register_frame_ctor. But other functions like address(),, source_file() and source_line() are working correctly.
Reproducing
Here is an example:
#define BOOST_STACKTRACE_USE_BACKTRACE
#include <backtrace.h>
#include <boost/stacktrace.hpp>
#include <iostream>
int main()
{
boost::stacktrace::stacktrace trace;
for (unsigned i = 0; i < trace.size(); ++i) {
std::cout << '#' << i << ' ' << trace[i].name() << " (" << trace[i].address() << ") at " << trace[i].source_file() << ':' << trace[i].source_line() << '\n';
}
return 0;
}Result: (I have already installed boost headers and libbacktrace at E:/libraries/xxx and built libbacktrace)
PS C:\Desktop\demo> g++ main.cpp -o main.exe -IE:/libraries/boost/include -IE:/libraries/libbacktrace -lbacktrace -std=c++20 -g
PS C:\Desktop\demo> ./main
#0 register_frame_ctor (0x7ff7ac312dcc) at E:/libraries/boost/include/boost/stacktrace/stacktrace.hpp:109
#1 register_frame_ctor (0x7ff7ac3014a2) at C:/Desktop/demo/main.cpp:8
#2 register_frame_ctor (0x7ff7ac3012ef) at :0
#3 register_frame_ctor (0x7ff7ac301406) at :0
#4 register_frame_ctor (0x7ffdada7e8d7) at :0
#5 register_frame_ctor (0x7ffdae90c53c) at :0Expected Behavior
trace[i].name() should return correct function names (such as main).
Environment
- OS: Windows 11 24H2
- Compiler: MinGW-w64 GCC 14.2.0 x86_64 posix-seh-msvcrt
- Boost: 1.88.0
Investigation
I found the possible reason using debugger: function calling backtrace_syminfo. For some reason, this function doesn't work.
I change the code in include/boost/stacktrace/detail/libbacktrace_impls.hpp to as following, so it will use debug info and it turns to works on my machine.
if (state) { // line 173
::backtrace_pcinfo(
state,
reinterpret_cast<uintptr_t>(addr),
boost::stacktrace::detail::libbacktrace_full_callback,
boost::stacktrace::detail::libbacktrace_error_callback,
&data
);
// removed backtrace_syminfo
}apolukhin
Metadata
Metadata
Assignees
Labels
No labels