windows: Add support for generating crash backtraces using Dr. MingW
This commit is contained in:
@ -92,6 +92,11 @@ endif
|
||||
|
||||
if OS_WIN32
|
||||
win32_ldflags = -mwindows -Wl,--tsaware $(WIN32_LARGE_ADDRESS_AWARE)
|
||||
|
||||
if HAVE_EXCHNDL
|
||||
exchndl = -lexchndl
|
||||
endif
|
||||
|
||||
else
|
||||
libm = -lm
|
||||
endif
|
||||
@ -186,6 +191,7 @@ gimp_@GIMP_APP_VERSION@_LDADD = \
|
||||
$(GTK_MAC_INTEGRATION_LIBS) \
|
||||
$(DBUS_GLIB_LIBS) \
|
||||
$(gimpconsoleldadd) \
|
||||
$(exchndl) \
|
||||
$(GIMPRC)
|
||||
|
||||
|
||||
|
37
app/main.c
37
app/main.c
@ -35,8 +35,14 @@
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
#include <io.h> /* get_osfhandle */
|
||||
|
||||
#ifdef HAVE_EXCHNDL
|
||||
#include <time.h>
|
||||
#include <exchndl.h>
|
||||
#endif
|
||||
|
||||
#endif /* G_OS_WIN32 */
|
||||
|
||||
#ifndef GIMP_CONSOLE_COMPILATION
|
||||
#include <gdk/gdk.h>
|
||||
#else
|
||||
@ -354,6 +360,37 @@ main (int argc,
|
||||
g_free (bin_dir);
|
||||
}
|
||||
|
||||
#ifdef HAVE_EXCHNDL
|
||||
/* Use Dr. Mingw (dumps backtrace on crash) if it is available. */
|
||||
{
|
||||
time_t t;
|
||||
gchar *filename;
|
||||
gchar *dir;
|
||||
gchar *path;
|
||||
|
||||
/* This has to be the non-roaming directory (i.e., the local
|
||||
directory) as backtraces correspond to the binaries on this
|
||||
system. */
|
||||
dir = g_build_filename (g_get_user_data_dir (),
|
||||
GIMPDIR, GIMP_USER_VERSION, "CrashLog",
|
||||
NULL);
|
||||
/* Ensure the path exists. */
|
||||
g_mkdir_with_parents (dir, 0700);
|
||||
|
||||
time (&t);
|
||||
filename = g_strdup_printf ("%s-crash-%" G_GUINT64_FORMAT ".txt",
|
||||
g_get_prgname(), t);
|
||||
path = g_build_filename (dir, filename, NULL);
|
||||
g_free (filename);
|
||||
g_free (dir);
|
||||
|
||||
ExcHndlInit ();
|
||||
ExcHndlSetLogFileNameA (path);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _WIN64
|
||||
{
|
||||
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
|
||||
|
12
configure.ac
12
configure.ac
@ -785,6 +785,18 @@ PKG_CHECK_MODULES(HARFBUZZ, harfbuzz >= harfbuzz_required_version,,
|
||||
PKG_CHECK_MODULES(GEXIV2, gexiv2 >= gexiv2_required_version,,
|
||||
[add_deps_error([gexiv2 >= gexiv2_required_version])])
|
||||
|
||||
#####################
|
||||
# Check for Dr. Mingw
|
||||
#####################
|
||||
|
||||
if test "x$platform_win32" = "xyes"; then
|
||||
# Check for Dr. Mingw
|
||||
AC_CHECK_LIB(exchndl, ExcHndlSetLogFileNameA,
|
||||
[AC_DEFINE(HAVE_EXCHNDL, 1, [Define to 1 when Dr. MingW is available])]
|
||||
)
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_EXCHNDL, test "x$ac_cv_lib_exchndl_ExcHndlSetLogFileNameA" = "xyes")
|
||||
|
||||
##########################################
|
||||
# Check for some special functions we need
|
||||
##########################################
|
||||
|
@ -17,6 +17,10 @@ framework_cocoa = -framework Cocoa
|
||||
endif
|
||||
|
||||
if OS_WIN32
|
||||
if HAVE_EXCHNDL
|
||||
exchndl = -lexchndl
|
||||
endif
|
||||
|
||||
gimp_def = gimp.def
|
||||
gimpui_def = gimpui.def
|
||||
libgimp_export_symbols = -export-symbols $(srcdir)/gimp.def
|
||||
@ -388,6 +392,7 @@ libgimp_@GIMP_API_VERSION@_la_LIBADD = \
|
||||
$(libgimpconfig) \
|
||||
$(libgimpcolor) \
|
||||
$(libgimpbase) \
|
||||
$(exchndl) \
|
||||
$(CAIRO_LIBS) \
|
||||
$(GEGL_LIBS) \
|
||||
$(GDK_PIXBUF_LIBS) \
|
||||
|
@ -53,6 +53,12 @@
|
||||
|
||||
#ifndef G_OS_WIN32
|
||||
#include "libgimpbase/gimpsignal.h"
|
||||
|
||||
#ifdef HAVE_EXCHNDL
|
||||
#include <time.h>
|
||||
#include <exchndl.h>
|
||||
#endif
|
||||
|
||||
#else
|
||||
#include <signal.h>
|
||||
#endif
|
||||
@ -295,6 +301,37 @@ gimp_main (const GimpPlugInInfo *info,
|
||||
g_free (bin_dir);
|
||||
}
|
||||
|
||||
#ifdef HAVE_EXCHNDL
|
||||
/* Use Dr. Mingw (dumps backtrace on crash) if it is available. */
|
||||
{
|
||||
time_t t;
|
||||
gchar *filename;
|
||||
gchar *dir;
|
||||
gchar *path;
|
||||
|
||||
/* This has to be the non-roaming directory (i.e., the local
|
||||
directory) as backtraces correspond to the binaries on this
|
||||
system. */
|
||||
dir = g_build_filename (g_get_user_data_dir (),
|
||||
GIMPDIR, GIMP_USER_VERSION, "CrashLog",
|
||||
NULL);
|
||||
/* Ensure the path exists. */
|
||||
g_mkdir_with_parents (dir, 0700);
|
||||
|
||||
time (&t);
|
||||
filename = g_strdup_printf ("%s-crash-%" G_GUINT64_FORMAT ".txt",
|
||||
g_get_prgname(), t);
|
||||
path = g_build_filename (dir, filename, NULL);
|
||||
g_free (filename);
|
||||
g_free (dir);
|
||||
|
||||
ExcHndlInit ();
|
||||
ExcHndlSetLogFileNameA (path);
|
||||
|
||||
g_free (path);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef _WIN64
|
||||
{
|
||||
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
|
||||
|
Reference in New Issue
Block a user