libgimpbase: allow NULL prog_name in gimp_print_stack_trace().

The only debugger command which uses this value currently is gdb. And
even there, it doesn't look mandatory. The alternative call using "-p"
option does not require the program name. The manual doesn't say if
calling with the program name has any advantage (but I don't see why it
would, the PID is enough to find a process). Just in case, I leave the
prog_name parameter (because it's easier to make a parameter useless
than changing a libgimp* API) but simply allows setting it to NULL.
This commit is contained in:
Jehan 2018-02-12 01:50:19 +01:00
parent 040533249c
commit 4e293a8696
1 changed files with 9 additions and 5 deletions

View File

@ -1084,10 +1084,10 @@ gimp_flags_value_get_abbrev (GFlagsClass *flags_class,
* @trace: location to store a newly allocated string of the trace.
*
* Attempts to generate a stack trace at current code position in
* @prog_name. @prog_name is mostly a helper, but it has to be the
* program name of the current program. This function is not meant to
* generate stack trace for third-party programs, and will attach the
* current process id only.
* @prog_name. @prog_name is mostly a helper and can be set to NULL.
* Nevertheless if set, it has to be the current program name (argv[0]).
* This function is not meant to generate stack trace for third-party
* programs, and will attach the current process id only.
* Internally, this function uses `gdb` or `lldb` if they are available,
* or the stacktrace() API on platforms where it is available. It always
* fails on Win32.
@ -1135,6 +1135,9 @@ gimp_print_stack_trace (const gchar *prog_name,
gchar *args[7] = { "gdb", "-batch", "-ex", "backtrace full",
(gchar *) prog_name, NULL, NULL };
if (prog_name == NULL)
args[4] = "-p";
args[5] = gimp_pid;
/* Redirect the debugger output. */
@ -1255,11 +1258,12 @@ gimp_print_stack_trace (const gchar *prog_name,
}
/**
* gimp_print_stack_trace:
* gimp_on_error_query:
* @prog_name: the program to attach to.
*
* This is mostly the same as g_on_error_query() except that we use our
* own backtrace function, much more complete.
* @prog_name must be the current program name (argv[0]).
* It does nothing on Win32.
*
* Since: 2.10