Allow using debug help API with non-MSVC compilers

MinGW64 and TDM-GCC come with imagehlp.h and can compile the code using debug
help API too, so enable wxUSE_DBGHELP when using these compilers by default
and also allow enabling it via a configure option.
This commit is contained in:
Vadim Zeitlin 2016-03-14 00:55:33 +01:00
parent f62d6bf6fd
commit 841af56084
7 changed files with 164 additions and 22 deletions

88
configure vendored
View File

@ -1195,6 +1195,7 @@ enable_protocol_http
enable_protocol_ftp
enable_protocol_file
enable_threads
enable_dbghelp
enable_iniconf
enable_regkey
enable_docview
@ -2127,6 +2128,7 @@ Optional Features:
--enable-protocol-ftp FTP support in wxProtocol
--enable-protocol-file FILE support in wxProtocol
--enable-threads use threads
--enable-dbghelp use dbghelp.dll API (Win32 only)
--enable-iniconf use wxIniConfig (Win32 only)
--enable-regkey use wxRegKey class (Win32 only)
--enable-docview use document view architecture
@ -7747,6 +7749,35 @@ fi
if test "$wxUSE_MSW" = 1 ; then
enablestring=disable
defaultval=
if test -z "$defaultval"; then
if test x"$enablestring" = xdisable; then
defaultval=yes
else
defaultval=no
fi
fi
# Check whether --enable-dbghelp was given.
if test "${enable_dbghelp+set}" = set; then :
enableval=$enable_dbghelp;
if test "$enableval" = yes; then
wx_cv_use_dbghelp='wxUSE_DBGHELP=yes'
else
wx_cv_use_dbghelp='wxUSE_DBGHELP=no'
fi
else
wx_cv_use_dbghelp='wxUSE_DBGHELP=${'DEFAULT_wxUSE_DBGHELP":-$defaultval}"
fi
eval "$wx_cv_use_dbghelp"
enablestring=
defaultval=
if test -z "$defaultval"; then
@ -35884,6 +35915,63 @@ if test "$wxUSE_AUTOID_MANAGEMENT" = "yes"; then
fi
if test "$USE_WIN32" = 1 ; then
if test "$wxUSE_DBGHELP" = "yes"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if debug help API is available" >&5
$as_echo_n "checking if debug help API is available... " >&6; }
if ${wx_cv_lib_debughlp+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <windows.h>
#include <imagehlp.h>
int
main ()
{
#ifndef API_VERSION_NUMBER
#error API_VERSION_NUMBER not defined!
#endif
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"; then :
wx_cv_lib_debughlp=yes
else
wx_cv_lib_debughlp=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $wx_cv_lib_debughlp" >&5
$as_echo "$wx_cv_lib_debughlp" >&6; }
if test "$wx_cv_lib_debughlp" = yes; then
$as_echo "#define wxUSE_DBGHELP 1" >>confdefs.h
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Debug help API and wxStackWalker won't be available" >&5
$as_echo "$as_me: WARNING: Debug help API and wxStackWalker won't be available" >&2;}
fi
fi
if test "$wxUSE_INICONF" = "yes"; then
$as_echo "#define wxUSE_INICONF 1" >>confdefs.h

View File

@ -744,6 +744,7 @@ WX_ARG_FEATURE(protocol_file, [ --enable-protocol-file FILE support in wxProto
WX_ARG_FEATURE(threads, [ --enable-threads use threads], wxUSE_THREADS)
if test "$wxUSE_MSW" = 1 ; then
WX_ARG_DISABLE(dbghelp, [ --enable-dbghelp use dbghelp.dll API (Win32 only)], wxUSE_DBGHELP)
WX_ARG_ENABLE(iniconf, [ --enable-iniconf use wxIniConfig (Win32 only)], wxUSE_INICONF)
WX_ARG_FEATURE(regkey, [ --enable-regkey use wxRegKey class (Win32 only)], wxUSE_REGKEY)
fi
@ -7159,6 +7160,34 @@ if test "$wxUSE_AUTOID_MANAGEMENT" = "yes"; then
fi
if test "$USE_WIN32" = 1 ; then
if test "$wxUSE_DBGHELP" = "yes"; then
AC_CACHE_CHECK([if debug help API is available], wx_cv_lib_debughlp,
[
dnl we need just the header, not the library, as we load the
dnl DLL dynamically anyhow during run-time
AC_LANG_PUSH(C++)
AC_TRY_COMPILE(
[#include <windows.h>
#include <imagehlp.h>],
[
#ifndef API_VERSION_NUMBER
#error API_VERSION_NUMBER not defined!
#endif
],
wx_cv_lib_debughlp=yes,
wx_cv_lib_debughlp=no
)
AC_LANG_POP()
]
)
if test "$wx_cv_lib_debughlp" = yes; then
AC_DEFINE(wxUSE_DBGHELP)
else
AC_MSG_WARN([Debug help API and wxStackWalker won't be available])
fi
fi
if test "$wxUSE_INICONF" = "yes"; then
AC_DEFINE(wxUSE_INICONF)
fi

View File

@ -1668,6 +1668,18 @@
// Crash debugging helpers
// ----------------------------------------------------------------------------
// Set this to 1 to use dbghelp.dll for providing stack traces in crash
// reports.
//
// Default is 1 if the compiler supports it, 0 for old MinGW.
//
// Recommended setting: 1, there is not much gain in disabling this
#if defined(__VISUALC__) || defined(__MINGW64_TOOLCHAIN__)
#define wxUSE_DBGHELP 1
#else
#define wxUSE_DBGHELP 0
#endif
// Set this to 1 to be able to use wxCrashReport::Generate() to create mini
// dumps of your program when it crashes (or at any other moment)
//

View File

@ -10,8 +10,11 @@
#ifndef _WX_MSW_DEBUGHLPH_H_
#define _WX_MSW_DEBUGHLPH_H_
#include "wx/dynlib.h"
#include "wx/defs.h"
#if wxUSE_DBGHELP
#include "wx/dynlib.h"
#include "wx/msw/wrapwin.h"
#ifdef __VISUALC__
@ -31,26 +34,6 @@
#include "wx/msw/private.h"
// wxUSE_DBGHELP can be predefined on the compiler command line to force using
// dbghelp.dll even if it's not detected or, on the contrary, avoid using even
// if it's available.
#ifndef wxUSE_DBGHELP
// The only compiler which is known to have the necessary headers is MSVC.
#ifdef __VISUALC__
// MSVC7.1 shipped with API v9 and we don't support anything earlier
// anyhow.
#if API_VERSION_NUMBER >= 9
#define wxUSE_DBGHELP 1
#else
#define wxUSE_DBGHELP 0
#endif
#else
#define wxUSE_DBGHELP 0
#endif
#endif
#if wxUSE_DBGHELP
/*
The table below shows which functions are exported by dbghelp.dll.

View File

@ -1560,7 +1560,7 @@
// SDK components manually, you need to change this setting.
//
// Recommended setting: 1
#if defined(_MSC_VER) && _MSC_VER >= 1700 && !defined(_USING_V110_SDK71_)
#if defined(_MSC_VER) && _MSC_VER >= 1700
#define wxUSE_WINRT 1
#else
#define wxUSE_WINRT 0
@ -1668,6 +1668,18 @@
// Crash debugging helpers
// ----------------------------------------------------------------------------
// Set this to 1 to use dbghelp.dll for providing stack traces in crash
// reports.
//
// Default is 1 if the compiler supports it, 0 for old MinGW.
//
// Recommended setting: 1, there is not much gain in disabling this
#if defined(__VISUALC__) || defined(__MINGW64_TOOLCHAIN__)
#define wxUSE_DBGHELP 1
#else
#define wxUSE_DBGHELP 0
#endif
// Set this to 1 to be able to use wxCrashReport::Generate() to create mini
// dumps of your program when it crashes (or at any other moment)
//

View File

@ -180,6 +180,18 @@
// Crash debugging helpers
// ----------------------------------------------------------------------------
// Set this to 1 to use dbghelp.dll for providing stack traces in crash
// reports.
//
// Default is 1 if the compiler supports it, 0 for old MinGW.
//
// Recommended setting: 1, there is not much gain in disabling this
#if defined(__VISUALC__) || defined(__MINGW64_TOOLCHAIN__)
#define wxUSE_DBGHELP 1
#else
#define wxUSE_DBGHELP 0
#endif
// Set this to 1 to be able to use wxCrashReport::Generate() to create mini
// dumps of your program when it crashes (or at any other moment)
//

View File

@ -691,6 +691,12 @@
#define wxUSE_TIMEPICKCTRL_GENERIC 0
#if defined(__VISUALC__) || defined(__MINGW64_TOOLCHAIN__)
#define wxUSE_DBGHELP 0
#else
#define wxUSE_DBGHELP 0
#endif
#define wxUSE_CRASHREPORT 0
/* --- end MSW options --- */