### Function

# Gimp stack_trace_print

since: 2.10

#### Declaration [src]

    gboolean
    gimp_stack_trace_print (
      const gchar* prog_name,
      gpointer stream,
      gchar** trace
    )

#### Description [src]

Attempts to generate a stack trace at current code position in `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.

The stack trace, once generated, will either be printed to `stream` or returned as a newly allocated string in `trace`, if not `NULL`.

In some error cases (e.g. segmentation fault), trying to allocate more memory will trigger more segmentation faults and therefore loop our error handling (which is just wrong). Therefore printing to a file description is an implementation without any memory allocation.

Available since: 2.10

#### Parameters

`prog_name`

  Type: `const gchar*`

  The program to attach to.

  The data is owned by the caller of the function.
  The value is a NUL terminated UTF-8 string.

`stream`

  Type: `gpointer`

  A FILE* stream.

  The argument can be `NULL`.
  The data is owned by the caller of the function.

`trace`

  Type: `gchar**`

  Location to store a newly allocated string of the trace.

  The argument will be set by the function.
  The argument can be `NULL`.
  The caller of the function takes ownership of the returned data, and is responsible for freeing it.
  The value is a NUL terminated UTF-8 string.

#### Return value

Type: `gboolean`

`TRUE` if a stack trace could be generated, `FALSE` otherwise.