glib-running.html   [plain text]


<html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Running GLib Applications</title><meta name="generator" content="DocBook XSL Stylesheets V1.65.1"><link rel="home" href="index.html" title="GLib Reference Manual"><link rel="up" href="glib.html" title="GLib Overview"><link rel="previous" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="next" href="glib-changes.html" title="Changes to GLib"><link rel="chapter" href="glib.html" title="GLib Overview"><link rel="refentry" href="glib-building.html" title="Compiling the GLib package"><link rel="refentry" href="glib-cross-compiling.html" title="Cross-compiling the GLib package"><link rel="refentry" href="glib-compiling.html" title="Compiling GLib Applications"><link rel="refentry" href="glib-running.html" title="Running GLib Applications"><link rel="refentry" href="glib-changes.html" title="Changes to GLib"><link rel="refentry" href="glib-resources.html" title="Mailing lists and bug reports"><link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals"><link rel="refentry" href="glib-Basic-Types.html" title="Basic Types"><link rel="refentry" href="glib-Limits-of-Basic-Types.html" title="Limits of Basic Types"><link rel="refentry" href="glib-Standard-Macros.html" title="Standard Macros"><link rel="refentry" href="glib-Type-Conversion-Macros.html" title="Type Conversion Macros"><link rel="refentry" href="glib-Byte-Order-Macros.html" title="Byte Order Macros"><link rel="refentry" href="glib-Numerical-Definitions.html" title="Numerical Definitions"><link rel="refentry" href="glib-Miscellaneous-Macros.html" title="Miscellaneous Macros"><link rel="refentry" href="glib-Atomic-Operations.html" title="Atomic Operations"><link rel="chapter" href="glib-core.html" title="GLib Core Application Support"><link rel="refentry" href="glib-The-Main-Event-Loop.html" title="The Main Event Loop"><link rel="refentry" href="glib-Threads.html" title="
Threads"><link rel="refentry" href="glib-Thread-Pools.html" title="Thread Pools"><link rel="refentry" href="glib-Asynchronous-Queues.html" title="Asynchronous Queues"><link rel="refentry" href="glib-Dynamic-Loading-of-Modules.html" title="Dynamic Loading of Modules"><link rel="refentry" href="glib-Memory-Allocation.html" title="Memory Allocation"><link rel="refentry" href="glib-IO-Channels.html" title="IO Channels"><link rel="refentry" href="glib-Error-Reporting.html" title="Error Reporting"><link rel="refentry" href="glib-Warnings-and-Assertions.html" title="Message Output and Debugging Functions"><link rel="refentry" href="glib-Message-Logging.html" title="Message Logging"><link rel="chapter" href="glib-utilities.html" title="GLib Utilities"><link rel="refentry" href="glib-String-Utility-Functions.html" title="String Utility Functions"><link rel="refentry" href="glib-Character-Set-Conversion.html" title="Character Set Conversion"><link rel="refentry" href="glib-Unicode-Manipulation.html" title="Unicode Manipulation"><link rel="refentry" href="glib-I18N.html" title="Internationalization"><link rel="refentry" href="glib-Date-and-Time-Functions.html" title="Date and Time Functions"><link rel="refentry" href="glib-Random-Numbers.html" title="Random Numbers"><link rel="refentry" href="glib-Hook-Functions.html" title="Hook Functions"><link rel="refentry" href="glib-Miscellaneous-Utility-Functions.html" title="Miscellaneous Utility Functions"><link rel="refentry" href="glib-Lexical-Scanner.html" title="Lexical Scanner"><link rel="refentry" href="glib-Automatic-String-Completion.html" title="Automatic String Completion"><link rel="refentry" href="glib-Timers.html" title="Timers"><link rel="refentry" href="glib-Spawning-Processes.html" title="Spawning Processes"><link rel="refentry" href="glib-File-Utilities.html" title="File Utilities"><link rel="refentry" href="glib-Shell-related-Utilities.html" title="Shell-related Utilities"><link rel="refentry" href="glib-Glob-style-pattern-matching.html" title="Glob-style pattern matching"><link rel="refentry" href="glib-Simple-XML-Subset-Parser.html" title="Simple XML Subset Parser"><link rel="refentry" href="glib-Windows-Compatability-Functions.html" title="Windows Compatibility Functions"><link rel="chapter" href="glib-data-types.html" title="GLib Data Types"><link rel="refentry" href="glib-Memory-Chunks.html" title="Memory Chunks"><link rel="refentry" href="glib-Doubly-Linked-Lists.html" title="Doubly-Linked Lists"><link rel="refentry" href="glib-Singly-Linked-Lists.html" title="Singly-Linked Lists"><link rel="refentry" href="glib-Double-ended-Queues.html" title="Double-ended Queues"><link rel="refentry" href="glib-Trash-Stacks.html" title="Trash Stacks"><link rel="refentry" href="glib-Hash-Tables.html" title="Hash Tables"><link rel="refentry" href="glib-Strings.html" title="Strings"><link rel="refentry" href="glib-String-Chunks.html" title="String Chunks"><link rel="refentry" href="glib-Arrays.html" title="Arrays"><link rel="refentry" href="glib-Pointer-Arrays.html" title="Pointer Arrays"><link rel="refentry" href="glib-Byte-Arrays.html" title="Byte Arrays"><link rel="refentry" href="glib-Balanced-Binary-Trees.html" title="Balanced Binary Trees"><link rel="refentry" href="glib-N-ary-Trees.html" title="N-ary Trees"><link rel="refentry" href="glib-Quarks.html" title="Quarks"><link rel="refentry" href="glib-Keyed-Data-Lists.html" title="Keyed Data Lists"><link rel="refentry" href="glib-Datasets.html" title="Datasets"><link rel="refentry" href="glib-Relations-and-Tuples.html" title="Relations and Tuples"><link rel="refentry" href="glib-Caches.html" title="Caches"><link rel="refentry" href="glib-Memory-Allocators.html" title="Memory Allocators"><link rel="chapter" href="tools.html" title="GLib Tools"><link rel="refentry" href="glib-gettextize.html" title="glib-gettextize"><link rel="index" href="ix01.html" title="Index"><link rel="section" href="glib-running.html#id2971016" title="Running and debugging GLib Applications"><meta name="generator" content="GTK-Doc V1.2 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="glib-compiling.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="glib.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GLib Reference Manual</th><td><a accesskey="n" href="glib-changes.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr></table><div class="refentry" lang="en"><a name="glib-running"></a><div class="titlepage"><div></div><div></div></div><div class="refnamediv"><h2><span class="refentrytitle">Running GLib Applications</span></h2><p>Running GLib Applications &#8212; 
How to run and debug your GLib application
</p></div><div class="refsect1" lang="en"><a name="id2971016"></a><h2>Running and debugging GLib Applications</h2><div class="refsect2" lang="en"><a name="id2971022"></a><h3>Environment variables</h3><p> 
GLib inspects a few of environment variables in addition to standard
variables like <tt class="envar">LANG</tt>, <tt class="envar">PATH</tt> or <tt class="envar">HOME</tt>. 
</p><p><a name="G_FILENAME_ENCODING"></a><b><tt class="envar">G_FILENAME_ENCODING</tt></b>
    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.
  </p><p><a name="G_BROKEN_FILENAMES"></a><b><tt class="envar">G_BROKEN_FILENAMES</tt></b>
    If this environment variable is set, GLib assumes that filenames are in 
    the locale encoding rather than in UTF-8. G_FILENAME_ENCODING takes
    priority over G_BROKEN_FILENAMES. 
  </p><p><b><tt class="envar">G_MESSAGES_PREFIXED</tt></b>
    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
    everything except <tt class="literal">G_LOG_LEVEL_MESSAGE</tt> and <tt class="literal">G_LOG_LEVEL_INFO</tt>. 
  </p><p><b><tt class="envar">G_DEBUG</tt></b>
    If GLib has been configured with <tt class="option">--enable-debug=yes</tt>,
    this variable can be set to a list of debug options, which cause GLib
    to print out different types of debugging information.
    </p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><span class="term">fatal_warnings</span></td><td><p>Causes GLib to abort the program at the first call
           to <a href="glib-Message-Logging.html#g-warning">g_warning</a>(). This option is 
           special in that it doesn't require GLib to be configured with 
           debugging support.</p></td></tr></tbody></table></div><p>
  </p><p><b><tt class="envar">G_RANDOM_VERSION</tt></b>
    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.  
  </p><p><b><tt class="envar">LIBCHARSET_ALIAS_DIR</tt></b>
    Allows to specify a nonstandard location for the 
    <tt class="filename">charset.aliases</tt> file that is used by the
    character set conversion routines. The default location is the 
    <i class="replaceable"><tt>libdir</tt></i> specified at compilation time.
  </p></div><hr><div class="refsect2" lang="en"><a name="id2971808"></a><h3>Traps and traces</h3><p>
Some code portions contain trap variables that can be set during debugging 
time if GLib has been configured with <tt class="option">--enable-debug=yes</tt>. 
Such traps lead to immediate code halts to examine the current program state 
and backtrace.
</p><p>
Currently, the following trap variables exist:
</p><pre class="programlisting">
static volatile gulong g_trap_free_size;
static volatile gulong g_trap_realloc_size;
static volatile gulong g_trap_malloc_size;
</pre><p>
If set to a size &gt; 0, <a href="glib-Memory-Allocation.html#g-free">g_free</a>(), 
<a href="glib-Memory-Allocation.html#g-realloc">g_realloc</a>() and 
<a href="glib-Memory-Allocation.html#g-malloc">g_malloc</a>() will be intercepted if the size 
matches the size of the corresponding memory block. This will only work with 
<tt class="literal">g_mem_set_vtable (glib_mem_profiler_table)</tt> upon startup 
though, because memory profiling is required to match on the memory block sizes.
</p></div></div></div><table class="navigation" width="100%" summary="Navigation footer" cellpadding="2" cellspacing="0"><tr valign="middle"><td align="left"><a accesskey="p" href="glib-compiling.html"><b>&lt;&lt; Compiling GLib Applications</b></a></td><td align="right"><a accesskey="n" href="glib-changes.html"><b>Changes to GLib &gt;&gt;</b></a></td></tr></table></body></html>