[gimp] windows: Add support for generating crash backtraces using Dr. MingW
- From: Mukund Sivaraman <muks src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] windows: Add support for generating crash backtraces using Dr. MingW
- Date: Sat, 2 Jan 2016 14:05:51 +0000 (UTC)
commit 6a6604871fe9493cb0f7ec331d0629a4a4764973
Author: Mukund Sivaraman <muks banu com>
Date: Mon Aug 31 18:56:51 2015 +0530
windows: Add support for generating crash backtraces using Dr. MingW
app/Makefile.am | 6 ++++++
app/main.c | 37 +++++++++++++++++++++++++++++++++++++
configure.ac | 12 ++++++++++++
libgimp/Makefile.am | 5 +++++
libgimp/gimp.c | 37 +++++++++++++++++++++++++++++++++++++
5 files changed, 97 insertions(+), 0 deletions(-)
---
diff --git a/app/Makefile.am b/app/Makefile.am
index f46ef97..acd124f 100644
--- a/app/Makefile.am
+++ b/app/Makefile.am
@@ -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)
diff --git a/app/main.c b/app/main.c
index c3c1dba..f498a79 100644
--- a/app/main.c
+++ b/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);
diff --git a/configure.ac b/configure.ac
index a909906..36305a7 100644
--- a/configure.ac
+++ b/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
##########################################
diff --git a/libgimp/Makefile.am b/libgimp/Makefile.am
index f857e59..ac154c5 100644
--- a/libgimp/Makefile.am
+++ b/libgimp/Makefile.am
@@ -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) \
diff --git a/libgimp/gimp.c b/libgimp/gimp.c
index b871909..1835fc9 100644
--- a/libgimp/gimp.c
+++ b/libgimp/gimp.c
@@ -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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]