1// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT
2package glib
3
4import (
5 "github.com/ebitengine/purego"
6
7 "github.com/bnema/puregotk/pkg/core"
8)
9
10var xOnErrorQuery func(string)
11
12// Prompts the user with
13// `[E]xit, [H]alt, show [S]tack trace or [P]roceed`.
14// This function is intended to be used for debugging use only.
15// The following example shows how it can be used together with
16// the g_log() functions.
17//
18// |[<!-- language="C" -->
19// #include <glib.h>
20//
21// static void
22// log_handler (const gchar *log_domain,
23//
24// GLogLevelFlags log_level,
25// const gchar *message,
26// gpointer user_data)
27//
28// {
29// g_log_default_handler (log_domain, log_level, message, user_data);
30//
31// g_on_error_query (MY_PROGRAM_NAME);
32// }
33//
34// int
35// main (int argc, char *argv[])
36//
37// {
38// g_log_set_handler (MY_LOG_DOMAIN,
39// G_LOG_LEVEL_WARNING |
40// G_LOG_LEVEL_ERROR |
41// G_LOG_LEVEL_CRITICAL,
42// log_handler,
43// NULL);
44// ...
45//
46// ]|
47//
48// If "[E]xit" is selected, the application terminates with a call
49// to _exit(0).
50//
51// If "[S]tack" trace is selected, g_on_error_stack_trace() is called.
52// This invokes gdb, which attaches to the current process and shows
53// a stack trace. The prompt is then shown again.
54//
55// If "[P]roceed" is selected, the function returns.
56//
57// This function may cause different actions on non-UNIX platforms.
58//
59// On Windows consider using the `G_DEBUGGER` environment
60// variable (see [Running GLib Applications](running.html)) and
61// calling g_on_error_stack_trace() instead.
62func OnErrorQuery(PrgNameVar string) {
63
64 xOnErrorQuery(PrgNameVar)
65
66}
67
68var xOnErrorStackTrace func(uintptr)
69
70// Invokes gdb, which attaches to the current process and shows a
71// stack trace. Called by g_on_error_query() when the "[S]tack trace"
72// option is selected. You can get the current process's program name
73// with g_get_prgname(), assuming that you have called gtk_init() or
74// gdk_init().
75//
76// This function may cause different actions on non-UNIX platforms.
77//
78// When running on Windows, this function is *not* called by
79// g_on_error_query(). If called directly, it will raise an
80// exception, which will crash the program. If the `G_DEBUGGER` environment
81// variable is set, a debugger will be invoked to attach and
82// handle that exception (see [Running GLib Applications](running.html)).
83func OnErrorStackTrace(PrgNameVar *string) {
84
85 PrgNameVarPtr := core.GStrdupNullable(PrgNameVar)
86 defer core.GFreeNullable(PrgNameVarPtr)
87
88 xOnErrorStackTrace(PrgNameVarPtr)
89
90}
91
92func init() {
93 core.SetPackageName("GLIB", "glib-2.0")
94 core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"})
95 var libs []uintptr
96 for _, libPath := range core.GetPaths("GLIB") {
97 lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL)
98 if err != nil {
99 panic(err)
100 }
101 libs = append(libs, lib)
102 }
103
104 core.PuregoSafeRegister(&xOnErrorQuery, libs, "g_on_error_query")
105 core.PuregoSafeRegister(&xOnErrorStackTrace, libs, "g_on_error_stack_trace")
106
107}