libgimpbase: consistent gimp_stack_trace namespace for stack trace functions

Change the rest of the source accordingly.
This commit is contained in:
Michael Natterer 2018-02-22 12:35:43 +01:00
parent e93f458026
commit 374fee451c
8 changed files with 53 additions and 49 deletions

3
NEWS
View File

@ -68,7 +68,8 @@ Libgimp:
procedures. If for instance, a second-level plug-in is interrupted
interactively, we don't want to process this as an error but as a
cancellation.
- New gimp_print_stack_trace() and gimp_on_error_query() for debug.
- New gimp_stack_trace_available(), gimp_stack_trace_print() and
gimp_stack_trace_query() for debugging.
GUI and Usability:

View File

@ -1244,7 +1244,7 @@ prefs_dialog_new (Gimp *gimp,
* which case the feature is always available.
*/
hbox = NULL;
if (! gimp_utils_backtrace_available (TRUE))
if (! gimp_stack_trace_available (TRUE))
{
#ifndef HAVE_EXECINFO_H
hbox = prefs_hint_box_new (GIMP_ICON_DIALOG_WARNING,

View File

@ -322,7 +322,7 @@ gimp_eek (const gchar *reason,
* and is waiting for us in a text file.
*/
fd = g_fopen (backtrace_file, "w");
has_backtrace = gimp_print_stack_trace ((const gchar *) full_prog_name,
has_backtrace = gimp_stack_trace_print ((const gchar *) full_prog_name,
fd, NULL);
fclose (fd);
#endif
@ -357,7 +357,7 @@ gimp_eek (const gchar *reason,
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
gimp_on_error_query ((const gchar *) full_prog_name);
gimp_stack_trace_query ((const gchar *) full_prog_name);
}
break;
@ -368,7 +368,7 @@ gimp_eek (const gchar *reason,
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
gimp_print_stack_trace ((const gchar *) full_prog_name,
gimp_stack_trace_print ((const gchar *) full_prog_name,
stdout, NULL);
}
break;

View File

@ -127,6 +127,7 @@ gui_message (Gimp *gimp,
}
g_mutex_unlock (&mutex);
}
if (gen_trace)
{
/* We need to create the trace here because for multi-thread
@ -134,7 +135,7 @@ gui_message (Gimp *gimp,
* function will simply be useless. It needs to happen in the
* buggy thread to be meaningful.
*/
gimp_print_stack_trace (NULL, NULL, &trace);
gimp_stack_trace_print (NULL, NULL, &trace);
}
if (g_strcmp0 (GIMP_ACRONYM, domain) != 0)

View File

@ -1917,7 +1917,7 @@ gimp_plugin_sigfatal_handler (gint sig_num)
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
gimp_on_error_query (progname);
gimp_stack_trace_query (progname);
}
break;
@ -1927,7 +1927,7 @@ gimp_plugin_sigfatal_handler (gint sig_num)
sigemptyset (&sigset);
sigprocmask (SIG_SETMASK, &sigset, NULL);
gimp_print_stack_trace (progname, stdout, NULL);
gimp_stack_trace_print (progname, stdout, NULL);
}
break;
}

View File

@ -110,7 +110,6 @@ EXPORTS
gimp_micro_version
gimp_minor_version
gimp_offset_type_get_type
gimp_on_error_query
gimp_orientation_type_get_type
gimp_paint_application_mode_get_type
gimp_param_memsize_get_type
@ -150,7 +149,6 @@ EXPORTS
gimp_plug_in_directory
gimp_plug_in_directory_file
gimp_precision_get_type
gimp_print_stack_trace
gimp_progress_command_get_type
gimp_rectangle_intersect
gimp_rectangle_union
@ -160,7 +158,10 @@ EXPORTS
gimp_select_criterion_get_type
gimp_signal_private
gimp_size_type_get_type
gimp_stack_trace_available
gimp_stack_trace_mode_get_type
gimp_stack_trace_print
gimp_stack_trace_query
gimp_strip_uline
gimp_stroke_method_get_type
gimp_sysconf_directory

View File

@ -1086,7 +1086,39 @@ gimp_flags_value_get_abbrev (GFlagsClass *flags_class,
}
/**
* gimp_print_stack_trace:
* gimp_stack_trace_available:
* @optimal: whether we get optimal traces.
*
* Returns #TRUE if we have dependencies to generate backtraces. If
* @optimal is #TRUE, the function will return #TRUE only when we
* are able to generate optimal traces (i.e. with GDB or LLDB);
* otherwise we return #TRUE even if only backtrace() API is available.
*
* On Win32, we return TRUE if Dr. Mingw is built-in, FALSE otherwise.
*
* Since: 2.10
**/
gboolean
gimp_stack_trace_available (gboolean optimal)
{
#ifndef G_OS_WIN32
if (gimp_utils_gdb_available (7, 0) ||
gimp_utils_lldb_available (0, 0))
return TRUE;
#ifdef HAVE_EXECINFO_H
if (! optimal)
return TRUE;
#endif
#else /* G_OS_WIN32 */
#ifdef HAVE_EXCHNDL
return TRUE;
#endif
#endif /* G_OS_WIN32 */
return FALSE;
}
/**
* gimp_stack_trace_print:
* @prog_name: the program to attach to.
* @stream: a #FILE * stream.
* @trace: location to store a newly allocated string of the trace.
@ -1114,7 +1146,7 @@ gimp_flags_value_get_abbrev (GFlagsClass *flags_class,
* Since: 2.10
**/
gboolean
gimp_print_stack_trace (const gchar *prog_name,
gimp_stack_trace_print (const gchar *prog_name,
gpointer stream,
gchar **trace)
{
@ -1273,7 +1305,7 @@ gimp_print_stack_trace (const gchar *prog_name,
}
/**
* gimp_on_error_query:
* gimp_stack_trace_query:
* @prog_name: the program to attach to.
*
* This is mostly the same as g_on_error_query() except that we use our
@ -1284,7 +1316,7 @@ gimp_print_stack_trace (const gchar *prog_name,
* Since: 2.10
**/
void
gimp_on_error_query (const gchar *prog_name)
gimp_stack_trace_query (const gchar *prog_name)
{
#ifndef G_OS_WIN32
gchar buf[16];
@ -1312,7 +1344,7 @@ gimp_on_error_query (const gchar *prog_name)
else if ((buf[0] == 'S' || buf[0] == 's')
&& buf[1] == '\n')
{
if (! gimp_print_stack_trace (prog_name, stdout, NULL))
if (! gimp_stack_trace_print (prog_name, stdout, NULL))
g_fprintf (stderr, "%s\n", "Stack trace not available on your system.");
goto retry;
}
@ -1321,37 +1353,6 @@ gimp_on_error_query (const gchar *prog_name)
#endif
}
/**
* gimp_utils_backtrace_available:
* @optimal: whether we get optimal traces.
*
* Returns #TRUE if we have dependencies to generate backtraces. If
* @optimal is #TRUE, the function will return #TRUE only when we
* are able to generate optimal traces (i.e. with GDB or LLDB);
* otherwise we return #TRUE even if only backtrace() API is available.
*
* On Win32, we return TRUE if Dr. Mingw is built-in, FALSE otherwise.
*
* Since: 2.10
**/
gboolean
gimp_utils_backtrace_available (gboolean optimal)
{
#ifndef G_OS_WIN32
if (gimp_utils_gdb_available (7, 0) ||
gimp_utils_lldb_available (0, 0))
return TRUE;
#ifdef HAVE_EXECINFO_H
if (! optimal)
return TRUE;
#endif
#else /* G_OS_WIN32 */
#ifdef HAVE_EXCHNDL
return TRUE;
#endif
#endif /* G_OS_WIN32 */
return FALSE;
}
/* Private functions. */

View File

@ -75,11 +75,11 @@ const gchar * gimp_flags_value_get_help (GFlagsClass *flags_class,
const gchar * gimp_flags_value_get_abbrev (GFlagsClass *flags_class,
GFlagsValue *flags_value);
gboolean gimp_print_stack_trace (const gchar *prog_name,
gboolean gimp_stack_trace_available (gboolean optimal);
gboolean gimp_stack_trace_print (const gchar *prog_name,
gpointer stream,
gchar **trace);
void gimp_on_error_query (const gchar *prog_name);
gboolean gimp_utils_backtrace_available (gboolean optimal);
void gimp_stack_trace_query (const gchar *prog_name);
G_END_DECLS