Running and debugging GLib Applications
GLib inspects a few of environment variables in addition to standard
This environment variable can be set to a comma-separated list of character
set names. GLib assumes that filenames are encoded in the first character
set from that list rather than in UTF-8. The special token "@locale" can be
used to specify the character set for the current locale.
A list of log levels for which messages should be prefixed by the
program name and PID of the application. The default is to prefix
Causes GLib to abort the program at the first call to g_critical(). This option is special in that it doesn't require GLib to be configured with debugging support.
Newly allocated memory that isn't directly initialized, as well as memory being freed will be reset to 0. The point here is to allow memory checkers and similar programs that use bohem GC alike algorithms to produce more accurate results. This option is special in that it doesn't require GLib to be configured with debugging support.
This will cause all slices allocated through g_slice_alloc() and released by g_slice_free1() to be actually allocated via direct calls to g_malloc() and g_free(). This is most useful for memory checkers and similar programs that use bohem GC alike algorithms to produce more accurate results. It can also be in conjunction with debugging features of the system's malloc implementation such as glibc's MALLOC_CHECK_=2 to debug erroneous slice allocation code.
If this environment variable is set to '2.0', the outdated
pseudo-random number seeding and generation algorithms from
GLib-2.0 are used instead of the new better ones. Use the GLib-2.0
algorithms only if you have sequences of numbers generated with
Glib-2.0 that you need to reproduce exactly.
Allows to specify a nonstandard location for the
charset.aliases file that is used by the
character set conversion routines. The default location is the
libdir specified at compilation time.
Setting this variable to any value forces g_win32_get_windows_version()
to return a version code for Windows 9x. This is mainly an internal
debugging aid for GTK+ and GLib developers, to be able to check the
code paths for Windows 9x.
Traps and traces
Some code portions contain trap variables that can be set during debugging
time if GLib has been configured with
Such traps lead to immediate code halts to examine the current program state
Currently, the following trap variables exist:
static volatile gulong g_trap_free_size; static volatile gulong g_trap_realloc_size; static volatile gulong g_trap_malloc_size;
If set to a size > 0, g_free(),
g_malloc() will be intercepted if the size
matches the size of the corresponding memory block. This will only work with
g_mem_set_vtable (glib_mem_profiler_table) upon startup
though, because memory profiling is required to match on the memory block sizes.
Note that many modern debuggers support conditional breakpoints, which achieve pretty much the same. E.g. in gdb, you can do
break g_malloc condition 1 n_bytes == 20
to break only on g_malloc() calls where the size of the allocated memory block is 20.