boostorg / stacktrace

C++ library for storing and printing backtraces.
https://boost.org/libs/stacktrace
425 stars 72 forks source link

Using boost::stacktrace with MinGW 5.3.0 bundled with Qt 5.8 #16

Closed abelharisov closed 6 years ago

abelharisov commented 7 years ago

Hello! I have small example with boost::stacktrace: just setup handler, crash and write trace. Everything is ok, but stacktrace doesn't contains source file names and lines numbers:

Crashed:
 0# 0x0040166D in C:\workspace\build-botsapp-Desktop_Qt_5_8_0_MinGW_32bit-Debug\booststacktracetest\debug\booststacktracetest.exe
 1# 0x75D97790 in C:\Windows\System32\msvcrt.dll

How to fix this issue? I tried several configurations: BOOST_STACKTRACE_USE_WINDBG, BOOST_STACKTRACE_USE_BACKTRACE, BOOST_STACKTRACE_USE_LIBUNWIND. Last one even doesn't write stacktrace.

Code:

#include <signal.h>
#include <cstdlib>
#include <iostream>

#define BOOST_STACKTRACE_USE_BACKTRACE
#include <boost/stacktrace.hpp>

void my_signal_handler(int signum)
{
    ::signal(signum, SIG_DFL);
    boost::stacktrace::stacktrace st;
    std::cout << "Crashed:\n" << st << std::endl;
    std::_Exit(-1);
}

void crash()
{
    throw std::runtime_error("test");
}

int main(int argc, char *argv[])
{
    ::signal(SIGSEGV, &my_signal_handler);
    ::signal(SIGABRT, &my_signal_handler);

    crash();
}
apolukhin commented 7 years ago

That's a known problem. I'll try to come up with a solution soon.

abelharisov commented 7 years ago

Thank you! I will be waiting for it. There is another project, drmingw. It can print stack trace for mingw. I hope, it can help you in some way.

apolukhin commented 6 years ago

Dup of #14