add new GDebugFlag for fatal_criticals handle G_DEBUG=fatal_criticals, to
[platform/upstream/glib.git] / docs / reference / glib / running.sgml
1 <refentry id="glib-running" revision="17 Jan 2002">
2 <refmeta>
3 <refentrytitle>Running GLib Applications</refentrytitle>
4 <manvolnum>3</manvolnum>
5 <refmiscinfo>GLib Library</refmiscinfo>
6 </refmeta>
7
8 <refnamediv>
9 <refname>Running GLib Applications</refname>
10 <refpurpose>
11 How to run and debug your GLib application
12 </refpurpose>
13 </refnamediv>
14
15 <refsect1>
16 <title>Running and debugging GLib Applications</title>
17
18 <refsect2>
19 <title>Environment variables</title>
20
21 <para> 
22 GLib inspects a few of environment variables in addition to standard
23 variables like <envar>LANG</envar>, <envar>PATH</envar> or <envar>HOME</envar>. 
24 </para>
25
26 <formalpara id="G_FILENAME_ENCODING">
27   <title><envar>G_FILENAME_ENCODING</envar></title>
28
29   <para>
30     This environment variable can be set to a comma-separated list of character
31     set names. GLib assumes that filenames are encoded in the first character 
32     set from that list rather than in UTF-8. The special token "@locale" can be
33     used to specify the character set for the current locale.
34   </para>
35 </formalpara>
36
37 <formalpara id="G_BROKEN_FILENAMES">
38   <title><envar>G_BROKEN_FILENAMES</envar></title>
39
40   <para>
41     If this environment variable is set, GLib assumes that filenames are in 
42     the locale encoding rather than in UTF-8. G_FILENAME_ENCODING takes
43     priority over G_BROKEN_FILENAMES. 
44   </para>
45 </formalpara>
46
47 <formalpara>
48   <title><envar>G_MESSAGES_PREFIXED</envar></title>
49
50   <para>
51     A list of log levels for which messages should be prefixed by the 
52     program name and PID of the application. The default is to prefix
53     everything except <literal>G_LOG_LEVEL_MESSAGE</literal> and <literal>G_LOG_LEVEL_INFO</literal>. 
54   </para>
55 </formalpara>
56
57 <formalpara>
58   <title><envar>G_DEBUG</envar></title>
59
60   <para>
61     If GLib has been configured with <option>--enable-debug=yes</option>,
62     this variable can be set to a list of debug options, which cause GLib
63     to print out different types of debugging information.
64     <variablelist>
65       <varlistentry>
66         <term>fatal_warnings</term>
67         <listitem><para>Causes GLib to abort the program at the first call
68            to <link linkend="g-warning">g_warning</link>() or
69            <link linkend="g-critical">g_critical</link>(). This option is 
70            special in that it doesn't require GLib to be configured with 
71            debugging support.</para>
72         </listitem>
73       </varlistentry>
74       <varlistentry>
75         <term>fatal_criticals</term>
76         <listitem><para>Causes GLib to abort the program at the first call
77            to <link linkend="g-critical">g_critical</link>(). This option is 
78            special in that it doesn't require GLib to be configured with 
79            debugging support.</para>
80         </listitem>
81       </varlistentry>
82     </variablelist>
83   </para>
84 </formalpara>
85
86 <formalpara>
87   <title><envar>G_RANDOM_VERSION</envar></title>
88
89   <para>
90     If this environment variable is set to '2.0', the outdated
91     pseudo-random number seeding and generation algorithms from
92     GLib-2.0 are used instead of the new better ones. Use the GLib-2.0
93     algorithms only if you have sequences of numbers generated with
94     Glib-2.0 that you need to reproduce exactly.  
95   </para>
96 </formalpara> 
97
98 <formalpara>
99   <title><envar>LIBCHARSET_ALIAS_DIR</envar></title>
100
101   <para>
102     Allows to specify a nonstandard location for the 
103     <filename>charset.aliases</filename> file that is used by the
104     character set conversion routines. The default location is the 
105     <replaceable>libdir</replaceable> specified at compilation time.
106   </para>
107 </formalpara> 
108
109 <formalpara>
110   <title><envar>G_WIN32_PRETEND_WIN9X</envar></title>
111
112   <para>
113     Setting this variable to any value forces g_win32_get_windows_version()
114     to return a version code for Windows 9x. This is mainly an internal 
115     debugging aid for GTK+ and GLib developers, to be able to check the 
116     code paths for Windows 9x.
117   </para>
118 </formalpara> 
119
120 </refsect2>
121
122 <refsect2>
123 <title>Traps and traces</title>
124
125 <para>
126 Some code portions contain trap variables that can be set during debugging 
127 time if GLib has been configured with <option>--enable-debug=yes</option>. 
128 Such traps lead to immediate code halts to examine the current program state 
129 and backtrace.
130 </para>
131
132 <para>
133 Currently, the following trap variables exist:
134 <programlisting>
135 static volatile gulong g_trap_free_size;
136 static volatile gulong g_trap_realloc_size;
137 static volatile gulong g_trap_malloc_size;
138 </programlisting>
139 If set to a size > 0, <link linkend="g-free">g_free</link>(), 
140 <link linkend="g-realloc">g_realloc</link>() and 
141 <link linkend="g-malloc">g_malloc</link>() will be intercepted if the size 
142 matches the size of the corresponding memory block. This will only work with 
143 <literal>g_mem_set_vtable (glib_mem_profiler_table)</literal> upon startup 
144 though, because memory profiling is required to match on the memory block sizes.
145 </para>
146 </refsect2>
147
148 </refsect1>
149
150 </refentry>