]> git.ipfire.org Git - thirdparty/strongswan.git/commit
backtrace: Support backtraces on Windows without DbgHelp
authorMartin Willi <martin@revosec.ch>
Tue, 19 Nov 2013 17:40:51 +0000 (18:40 +0100)
committerMartin Willi <martin@revosec.ch>
Wed, 4 Jun 2014 13:52:58 +0000 (15:52 +0200)
commit2127831cdaadd42755574e474c8017b752c0e032
tree2d384992ae4c8b76c386b307c47b3072305c6c33
parenta7e943a64008ea728c6a2674d80186da766cc735
backtrace: Support backtraces on Windows without DbgHelp

While DbgHelp provides a convenient API to create backtraces, any executable
linking against DbgHelp gets a more than a significant slow down. Further, it
can only lookup global symbols, as it expects PDB files we can't produce with a
MinGW build.

With some core Kernel32.dll functionality, we can capture stack traces much
faster. Together with the optional libbfd, we can print very fine backtraces.

When --enable-bfd-backtraces is used on Windows, a libbfd.dll is required for
the build. Such a DLL can be created from the binutils sources using:

  # build binutils with mingw...

  # extract archive members from binutils libraries
  x86_64-w64-mingw32-ar x $BINUTILS/bfd/.libs/libbfd.a
  x86_64-w64-mingw32-ar x $BINUTILS/intl/libintl.a
  x86_64-w64-mingw32-ar x $BINUTILS/libiberty/libiberty.a

  # create self-contained libbfd.a, with index
  x86_64-w64-mingw32-ar qs libbfd.a *.o

  # create DLL from static library
  x86_64-w64-mingw32-dlltool -e libbfd.o -l libbfd.lib libbfd.a
  x86_64-w64-mingw32-gcc -shared libbfd.a libbfd.o -o libbfd.dll
src/libstrongswan/utils/backtrace.c