1
1
mirror of https://gitlab.gnome.org/GNOME/gimp.git synced 2025-10-06 05:22:40 +02:00

Compare commits

...

1 Commits

Author SHA1 Message Date
Bruno Lopes
dde4c46407 Use LLDB or GDB on Windows 2024-05-06 16:29:59 -03:00
9 changed files with 29 additions and 236 deletions

View File

@@ -312,8 +312,6 @@ gimp_eek (const gchar *reason,
* trace if the rest fails. */
g_printerr ("%s: %s: %s\n", full_prog_name, reason, message);
#if ! defined (G_OS_WIN32) || defined (HAVE_EXCHNDL)
if (use_handler)
{
#ifndef GIMP_CONSOLE_COMPILATION
@@ -347,15 +345,10 @@ gimp_eek (const gchar *reason,
g_snprintf (timestamp, 16, "%"G_GINT64_FORMAT, the_errors_gimp->config->last_release_timestamp);
args[7] = timestamp;
#ifndef G_OS_WIN32
/* On Win32, the trace has already been processed by ExcHnl
* and is waiting for us in a text file.
*/
fd = g_fopen (backtrace_file, "w");
has_backtrace = gimp_stack_trace_print ((const gchar *) full_prog_name,
fd, NULL);
fclose (fd);
#endif
/* We don't care about any return value. If it fails, too
* bad, we just won't have any stack trace.
@@ -412,7 +405,6 @@ gimp_eek (const gchar *reason,
}
#endif /* ! G_OS_WIN32 */
}
#endif /* ! G_OS_WIN32 || HAVE_EXCHNDL */
#if defined (G_OS_WIN32) && ! defined (GIMP_CONSOLE_COMPILATION)
/* g_on_error_* don't do anything reasonable on Win32. */

View File

@@ -79,7 +79,6 @@ libapp = static_library('app',
gimpconsole_deps = [
cairo,
dbghelp,
drmingw,
gdk_pixbuf,
gegl,
gexiv2,

View File

@@ -30,23 +30,8 @@
#include "errors.h"
#include "signals.h"
#ifdef G_OS_WIN32
#ifdef HAVE_EXCHNDL
#include <windows.h>
#include <time.h>
#include <exchndl.h>
static LPTOP_LEVEL_EXCEPTION_FILTER g_prevExceptionFilter = NULL;
static LONG WINAPI gimp_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo);
#endif
#else
static void gimp_sigfatal_handler (gint sig_num) G_GNUC_NORETURN;
#endif
void
gimp_init_signal_handlers (gchar **backtrace_file)
@@ -54,9 +39,6 @@ gimp_init_signal_handlers (gchar **backtrace_file)
time_t t;
gchar *filename;
gchar *dir;
#if defined (G_OS_WIN32) && defined (HAVE_EXCHNDL)
wchar_t *backtrace_file_utf16;
#endif
#ifdef G_OS_WIN32
/* This has to be the non-roaming directory (i.e., the local
@@ -76,35 +58,8 @@ gimp_init_signal_handlers (gchar **backtrace_file)
g_free (filename);
g_free (dir);
#ifdef G_OS_WIN32
/* Use Dr. Mingw (dumps backtrace on crash) if it is available. Do
* nothing otherwise on Win32.
* The user won't get any stack trace from glib anyhow.
* Without Dr. MinGW, It's better to let Windows inform about the
* program error, and offer debugging (if the user has installed MSVC
* or some other compiler that knows how to install itself as a
* handler for program errors).
*/
#ifdef HAVE_EXCHNDL
/* Order is very important here. We need to add our signal handler
* first, then run ExcHndlInit() which will add its own handler, so
* that ExcHnl's handler runs first since that's in FILO order.
*/
if (! g_prevExceptionFilter)
g_prevExceptionFilter = SetUnhandledExceptionFilter (gimp_sigfatal_handler);
ExcHndlInit ();
if ((backtrace_file_utf16 = g_utf8_to_utf16 (*backtrace_file, -1, NULL, NULL, NULL)))
{
ExcHndlSetLogFileNameW (backtrace_file_utf16);
g_free (backtrace_file_utf16);
}
#endif /* HAVE_EXCHNDL */
#else
#ifndef G_OS_WIN32
/* Handle fatal signals */
@@ -133,46 +88,16 @@ gimp_init_signal_handlers (gchar **backtrace_file)
/* Restart syscalls on SIGCHLD */
gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
#endif /* G_OS_WIN32 */
}
#ifdef G_OS_WIN32
#ifdef HAVE_EXCHNDL
static LONG WINAPI
gimp_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo)
{
EXCEPTION_RECORD *er;
int fatal;
if (pExceptionInfo == NULL ||
pExceptionInfo->ExceptionRecord == NULL)
return EXCEPTION_CONTINUE_SEARCH;
er = pExceptionInfo->ExceptionRecord;
fatal = I_RpcExceptionFilter (er->ExceptionCode);
/* IREF() returns EXCEPTION_CONTINUE_SEARCH for fatal exceptions */
if (fatal == EXCEPTION_CONTINUE_SEARCH)
{
/* Just in case, so that we don't loop or anything similar, just
* re-establish previous handler.
*/
SetUnhandledExceptionFilter (g_prevExceptionFilter);
/* Now process the exception. */
gimp_fatal_error ("unhandled exception");
}
if (g_prevExceptionFilter && g_prevExceptionFilter != gimp_sigfatal_handler)
return g_prevExceptionFilter (pExceptionInfo);
else
return EXCEPTION_CONTINUE_SEARCH;
}
#endif
#else
signal (SIGTERM, gimp_sigfatal_handler);
signal (SIGABRT, gimp_sigfatal_handler);
signal (SIGSEGV, gimp_sigfatal_handler);
signal (SIGFPE, gimp_sigfatal_handler);
#endif /* ! G_OS_WIN32 */
}
/* gimp core signal handler for fatal signals */
@@ -181,21 +106,23 @@ gimp_sigfatal_handler (gint sig_num)
{
switch (sig_num)
{
#ifndef G_OS_WIN32
case SIGHUP:
case SIGINT:
case SIGQUIT:
#endif
case SIGTERM:
gimp_terminate (g_strsignal (sig_num));
break;
case SIGABRT:
case SIGBUS:
case SIGSEGV:
case SIGFPE:
#ifndef G_OS_WIN32
case SIGBUS:
#endif
default:
gimp_fatal_error (g_strsignal (sig_num));
break;
}
}
#endif /* G_OS_WIN32 */

View File

@@ -7,7 +7,6 @@ ${MINGW_PACKAGE_PREFIX}-atk \
${MINGW_PACKAGE_PREFIX}-brotli \
${MINGW_PACKAGE_PREFIX}-cairo \
${MINGW_PACKAGE_PREFIX}-cfitsio \
${MINGW_PACKAGE_PREFIX}-drmingw \
${MINGW_PACKAGE_PREFIX}-gettext-tools \
${MINGW_PACKAGE_PREFIX}-gexiv2 \
${MINGW_PACKAGE_PREFIX}-ghostscript \

View File

@@ -29,11 +29,6 @@
#else
#ifdef HAVE_EXCHNDL
#include <time.h>
#include <exchndl.h>
#endif
#include <signal.h>
#endif

View File

@@ -57,11 +57,6 @@
#else
#ifdef HAVE_EXCHNDL
#include <time.h>
#include <exchndl.h>
#endif
#include <signal.h>
#endif
@@ -102,21 +97,8 @@
static void gimp_close (void);
#ifdef G_OS_WIN32
#ifdef HAVE_EXCHNDL
static LONG WINAPI gimp_plugin_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo);
static LPTOP_LEVEL_EXCEPTION_FILTER _prevExceptionFilter = NULL;
static gchar *plug_in_backtrace_path = NULL;
#endif
#else /* ! G_OS_WIN32 */
static void gimp_plugin_sigfatal_handler (gint sig_num);
#endif /* G_OS_WIN32 */
static GimpPlugIn *PLUG_IN = NULL;
static GimpPDB *PDB = NULL;
@@ -216,49 +198,6 @@ gimp_main (GType plug_in_type,
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;
wchar_t *plug_in_backtrace_path_utf16;
/* 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);
plug_in_backtrace_path = g_build_filename (dir, filename, NULL);
g_free (filename);
g_free (dir);
/* Similar to core crash handling in app/signals.c, the order here
* is very important!
*/
if (! _prevExceptionFilter)
_prevExceptionFilter = SetUnhandledExceptionFilter (gimp_plugin_sigfatal_handler);
ExcHndlInit ();
plug_in_backtrace_path_utf16 = g_utf8_to_utf16 (plug_in_backtrace_path,
-1, NULL, NULL, NULL);
if (plug_in_backtrace_path_utf16)
{
ExcHndlSetLogFileNameW (plug_in_backtrace_path_utf16);
g_free (plug_in_backtrace_path_utf16);
}
}
#endif /* HAVE_EXCHNDL */
#ifndef _WIN64
{
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
@@ -392,6 +331,12 @@ gimp_main (GType plug_in_type,
/* Restart syscalls interrupted by SIGCHLD */
gimp_signal_private (SIGCHLD, SIG_DFL, SA_RESTART);
#else
signal (SIGTERM, gimp_plugin_sigfatal_handler);
signal (SIGABRT, gimp_plugin_sigfatal_handler);
signal (SIGSEGV, gimp_plugin_sigfatal_handler);
signal (SIGFPE, gimp_plugin_sigfatal_handler);
#endif /* ! G_OS_WIN32 */
#ifdef G_OS_WIN32
@@ -584,11 +529,6 @@ gimp_quit (void)
{
gimp_close ();
#if defined G_OS_WIN32 && defined HAVE_EXCHNDL
if (plug_in_backtrace_path)
g_free (plug_in_backtrace_path);
#endif
exit (EXIT_SUCCESS);
}
@@ -961,71 +901,34 @@ gimp_close (void)
#ifdef G_OS_WIN32
#ifdef HAVE_EXCHNDL
static LONG WINAPI
gimp_plugin_sigfatal_handler (PEXCEPTION_POINTERS pExceptionInfo)
{
g_printerr ("Plugin signal handler: %s: fatal error\n", progname);
SetUnhandledExceptionFilter (_prevExceptionFilter);
/* For simplicity, do not make a difference between QUERY and ALWAYS
* on Windows (at least not for now).
*/
if (stack_trace_mode != GIMP_STACK_TRACE_NEVER &&
g_file_test (plug_in_backtrace_path, G_FILE_TEST_IS_REGULAR))
{
FILE *stream;
guchar buffer[256];
size_t read_len;
stream = g_fopen (plug_in_backtrace_path, "r");
do
{
/* Just read and output directly the file content. */
read_len = fread (buffer, 1, sizeof (buffer) - 1, stream);
buffer[read_len] = '\0';
g_printerr ("%s", buffer);
}
while (read_len);
fclose (stream);
}
if (_prevExceptionFilter && _prevExceptionFilter != gimp_plugin_sigfatal_handler)
return _prevExceptionFilter (pExceptionInfo);
else
return EXCEPTION_CONTINUE_SEARCH;
}
#endif /* HAVE_EXCHNDL */
#else /* ! G_OS_WIN32 */
static void
gimp_plugin_sigfatal_handler (gint sig_num)
{
switch (sig_num)
{
#ifndef G_OS_WIN32
case SIGHUP:
case SIGINT:
case SIGQUIT:
#endif
case SIGTERM:
g_printerr ("%s terminated: %s\n", progname, g_strsignal (sig_num));
break;
case SIGABRT:
case SIGBUS:
case SIGSEGV:
case SIGFPE:
#ifndef G_OS_WIN32
case SIGBUS:
case SIGPIPE:
#endif
default:
g_printerr ("%s: fatal error: %s\n", progname, g_strsignal (sig_num));
#ifndef G_OS_WIN32
switch (stack_trace_mode)
{
case GIMP_STACK_TRACE_NEVER:
break;
case GIMP_STACK_TRACE_QUERY:
{
sigset_t sigset;
@@ -1046,6 +949,7 @@ gimp_plugin_sigfatal_handler (gint sig_num)
}
break;
}
#endif
break;
}
@@ -1056,8 +960,6 @@ gimp_plugin_sigfatal_handler (gint sig_num)
exit (EXIT_FAILURE);
}
#endif /* G_OS_WIN32 */
void
_gimp_config (GPConfig *config)
{

View File

@@ -350,7 +350,6 @@ libgimp = library('gimp-'+ gimp_api_version,
gdk_pixbuf,
gegl,
gexiv2,
drmingw,
pango,
pangoft2,
],

View File

@@ -1151,7 +1151,6 @@ gimp_flags_value_get_abbrev (GFlagsClass *flags_class,
gboolean
gimp_stack_trace_available (gboolean optimal)
{
#ifndef G_OS_WIN32
gchar *lld_path = NULL;
gboolean has_lldb = FALSE;
@@ -1177,11 +1176,6 @@ gimp_stack_trace_available (gboolean optimal)
if (! optimal)
return TRUE;
#endif
#else /* G_OS_WIN32 */
#ifdef HAVE_EXCHNDL
return TRUE;
#endif
#endif /* G_OS_WIN32 */
return FALSE;
}

View File

@@ -590,22 +590,9 @@ libunwind = ( get_option('libunwind')
conf.set('HAVE_LIBUNWIND', libunwind.found())
## Check for Dr. Mingw
drmingw = no_dep
if platform_windows
exchndl = cc.find_library('exchndl', required: false)
exchndl_fn = cc.has_function('ExcHndlSetLogFileNameW', dependencies: exchndl)
if exchndl.found() and exchndl_fn
drmingw = declare_dependency(dependencies: exchndl)
endif
endif
conf.set('HAVE_EXCHNDL', drmingw.found())
detailed_backtraces = (
libbacktrace.found() or
libunwind.found() or
drmingw.found()
libunwind.found()
)
################################################################################
@@ -2058,7 +2045,6 @@ final_message = [
''' Check updates at startup: @0@'''.format(check_update),
''' Language selection: @0@'''.format(isocodes.found()),
''' Vector icons: @0@'''.format(have_vector_icons),
''' Dr. Mingw (Win32): @0@'''.format(drmingw.found()),
''' Relocatable Bundle: @0@'''.format(relocatable_bundle),
''' Default ICC directory: @0@'''.format(icc_directory),
''' 32-bit DLL folder (Win32): @0@'''.format(get_option('win32-32bits-dll-folder')),