bombela / backward-cpp

A beautiful stack trace pretty printer for C++
MIT License
3.65k stars 465 forks source link

Unable to trace in mingw #305

Open jeremy-rifkin opened 11 months ago

jeremy-rifkin commented 11 months ago

I have mingw-w64 and libbfd installed in msys2. When I try to do a simple stacktrace with -DBACKWARD_HAS_BFD=1 I get this

Stack trace (most recent call last):
The specified module could not be found.

#1    Object "", at 0x9200000000, in  ??
Attempt to access invalid address.

#0    Object "", at 0x7ff682df8eb5, in  ??

Is there a way to get traces working in mingw?

pvzzombs commented 1 month ago

I also get this issue too. My c++ compiler details:

Using built-in specs.
COLLECT_GCC=C:\Apps\mingw64\bin\g++.exe
COLLECT_LTO_WRAPPER=C:/Apps/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/13.2.0/lto-wrapper.exe
OFFLOAD_TARGET_NAMES=nvptx-none
Target: x86_64-w64-mingw32
Configured with: ../configure --prefix=/R/winlibs64_stage/inst_gcc-13.2.0/share/gcc --build=x86_64-w64-mingw32 --host=x86_64-w64-mingw32 --enable-offload-targets=nvptx-none --with-pkgversion='MinGW-W64 x86_64-msvcrt-posix-seh, built by Brecht Sanders' --with-tune=generic --enable-checking=release --enable-threads=posix --disable-sjlj-exceptions --disable-libunwind-exceptions --disable-serial-configure --disable-bootstrap --enable-host-shared --enable-plugin --disable-default-ssp --disable-rpath --disable-libstdcxx-debug --disable-version-specific-runtime-libs --with-stabs --disable-symvers --enable-languages=c,c++,fortran,lto,objc,obj-c++ --disable-gold --disable-nls --disable-stage1-checking --disable-win32-registry --disable-multilib --enable-ld --enable-libquadmath --enable-libada --enable-libssp --enable-libstdcxx --enable-lto --enable-fully-dynamic-string --enable-libgomp --enable-graphite --enable-mingw-wildcard --enable-libstdcxx-time --enable-libstdcxx-pch --with-mpc=/d/Prog/winlibs64_stage/custombuilt --with-mpfr=/d/Prog/winlibs64_stage/custombuilt --with-gmp=/d/Prog/winlibs64_stage/custombuilt --with-isl=/d/Prog/winlibs64_stage/custombuilt --disable-libstdcxx-backtrace --enable-install-libiberty --enable-__cxa_atexit --without-included-gettext --with-diagnostics-color=auto --enable-clocale=generic --with-libiconv --with-system-zlib --with-build-sysroot=/R/winlibs64_stage/gcc-13.2.0/build_mingw/mingw-w64 CFLAGS='-I/d/Prog/winlibs64_stage/custombuilt/include/libdl-win32 -Wno-int-conversion  -march=nocona -msahf -mtune=generic -O2' CXXFLAGS='-Wno-int-conversion  -march=nocona -msahf -mtune=generic -O2' LDFLAGS='-pthread -Wl,--no-insert-timestamp -Wl,--dynamicbase -Wl,--high-entropy-va -Wl,--nxcompat -Wl,--tsaware'
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 13.2.0 (MinGW-W64 x86_64-msvcrt-posix-seh, built by Brecht Sanders)

Here is a test file: main.cpp

#include <iostream>
#include "backward.hpp"

int main(int argc, char const *argv[]) {
  using namespace backward;
  StackTrace st; st.load_here(32);
  Printer p; p.print(st);
  return 0;
}

Compile commands:

g++ -g main.cpp -o main.exe -lDbghelp

Executable Output (After running ./main.exe):

Stack trace (most recent call last):
The specified module could not be found.

#1    Object "", at 0xc400000000, in  ??
Attempt to access invalid address.

#0    Object "", at 0x7ff683d3a735, in  ??