~ubuntu-branches/ubuntu/utopic/glib2.0/utopic

« back to all changes in this revision

Viewing changes to docs/reference/glib/html/glib-running.html

Tags: upstream-2.12.12
ImportĀ upstreamĀ versionĀ 2.12.12

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
 
2
<html>
 
3
<head>
 
4
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
 
5
<title>Running GLib Applications</title>
 
6
<meta name="generator" content="DocBook XSL Stylesheets V1.72.0">
 
7
<link rel="start" href="index.html" title="GLib Reference Manual">
 
8
<link rel="up" href="glib.html" title="GLib Overview">
 
9
<link rel="prev" href="glib-compiling.html" title="Compiling GLib Applications">
 
10
<link rel="next" href="glib-changes.html" title="Changes to GLib">
 
11
<meta name="generator" content="GTK-Doc V1.7 (XML mode)">
 
12
<link rel="stylesheet" href="style.css" type="text/css">
 
13
<link rel="chapter" href="glib.html" title="GLib Overview">
 
14
<link rel="chapter" href="glib-fundamentals.html" title="GLib Fundamentals">
 
15
<link rel="chapter" href="glib-core.html" title="GLib Core Application Support">
 
16
<link rel="chapter" href="glib-utilities.html" title="GLib Utilities">
 
17
<link rel="chapter" href="glib-data-types.html" title="GLib Data Types">
 
18
<link rel="chapter" href="tools.html" title="GLib Tools">
 
19
<link rel="index" href="ix01.html" title="Index">
 
20
<link rel="index" href="ix02.html" title="Index of deprecated symbols">
 
21
<link rel="index" href="ix03.html" title="Index of new symbols in 2.2">
 
22
<link rel="index" href="ix04.html" title="Index of new symbols in 2.4">
 
23
<link rel="index" href="ix05.html" title="Index of new symbols in 2.6">
 
24
<link rel="index" href="ix06.html" title="Index of new symbols in 2.8">
 
25
<link rel="index" href="ix07.html" title="Index of new symbols in 2.10">
 
26
<link rel="index" href="ix08.html" title="Index of new symbols in 2.12">
 
27
</head>
 
28
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
 
29
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle">
 
30
<td><a accesskey="p" href="glib-compiling.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td>
 
31
<td><a accesskey="u" href="glib.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td>
 
32
<td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td>
 
33
<th width="100%" align="center">GLib Reference Manual</th>
 
34
<td><a accesskey="n" href="glib-changes.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td>
 
35
</tr></table>
 
36
<div class="refentry" lang="en">
 
37
<a name="glib-running"></a><div class="titlepage"></div>
 
38
<div class="refnamediv"><table width="100%"><tr>
 
39
<td valign="top">
 
40
<h2><span class="refentrytitle">Running GLib Applications</span></h2>
 
41
<p>Running GLib Applications &#8212; 
 
42
How to run and debug your GLib application
 
43
</p>
 
44
</td>
 
45
<td valign="top" align="right"></td>
 
46
</tr></table></div>
 
47
<div class="refsect1" lang="en">
 
48
<a name="id2687186"></a><h2>Running and debugging GLib Applications</h2>
 
49
<div class="refsect2" lang="en">
 
50
<a name="id2687192"></a><h3>Environment variables</h3>
 
51
<p> 
 
52
GLib inspects a few of environment variables in addition to standard
 
53
variables like <code class="envar">LANG</code>, <code class="envar">PATH</code> or <code class="envar">HOME</code>. 
 
54
</p>
 
55
<p><a name="G_FILENAME_ENCODING"></a><b><code class="envar">G_FILENAME_ENCODING</code>.&#160;</b>
 
56
    This environment variable can be set to a comma-separated list of character
 
57
    set names. GLib assumes that filenames are encoded in the first character 
 
58
    set from that list rather than in UTF-8. The special token "@locale" can be
 
59
    used to specify the character set for the current locale.
 
60
  </p>
 
61
<p><a name="G_BROKEN_FILENAMES"></a><b><code class="envar">G_BROKEN_FILENAMES</code>.&#160;</b>
 
62
    If this environment variable is set, GLib assumes that filenames are in 
 
63
    the locale encoding rather than in UTF-8. G_FILENAME_ENCODING takes
 
64
    priority over G_BROKEN_FILENAMES. 
 
65
  </p>
 
66
<p><a name="G_MESSAGES_PREFIXED"></a><b><code class="envar">G_MESSAGES_PREFIXED</code>.&#160;</b>
 
67
    A list of log levels for which messages should be prefixed by the 
 
68
    program name and PID of the application. The default is to prefix
 
69
    everything except <code class="literal">G_LOG_LEVEL_MESSAGE</code> and <code class="literal">G_LOG_LEVEL_INFO</code>. 
 
70
  </p>
 
71
<p><a name="G_DEBUG"></a><b><code class="envar">G_DEBUG</code>.&#160;</b>
 
72
    If GLib has been configured with <code class="option">--enable-debug=yes</code>,
 
73
    this variable can be set to a list of debug options, which cause GLib
 
74
    to print out different types of debugging information.
 
75
    </p>
 
76
<div class="variablelist"><table border="0">
 
77
<col align="left" valign="top">
 
78
<tbody>
 
79
<tr>
 
80
<td><span class="term">fatal_warnings</span></td>
 
81
<td><p>Causes GLib to abort the program at the first call
 
82
           to <a href="glib-Message-Logging.html#g-warning">g_warning</a>() or
 
83
           <a href="glib-Message-Logging.html#g-critical">g_critical</a>(). This option is 
 
84
           special in that it doesn't require GLib to be configured with 
 
85
           debugging support.</p></td>
 
86
</tr>
 
87
<tr>
 
88
<td><span class="term">fatal_criticals</span></td>
 
89
<td><p>Causes GLib to abort the program at the first call
 
90
           to <a href="glib-Message-Logging.html#g-critical">g_critical</a>(). This option is 
 
91
           special in that it doesn't require GLib to be configured with 
 
92
           debugging support.</p></td>
 
93
</tr>
 
94
<tr>
 
95
<td><span class="term">gc-friendly</span></td>
 
96
<td><p>
 
97
                  Newly allocated memory that isn't directly initialized, as well
 
98
                  as memory being freed will be reset to 0. The point here is to
 
99
                  allow memory checkers and similar programs that use bohem GC alike
 
100
                  algorithms to produce more accurate results.
 
101
                  This option is special in that it doesn't require GLib to be
 
102
                  configured with debugging support.
 
103
                </p></td>
 
104
</tr>
 
105
</tbody>
 
106
</table></div>
 
107
<p>
 
108
  </p>
 
109
<p><a name="G_SLICE"></a><b><code class="envar">G_SLICE</code>.&#160;</b>
 
110
          This environment variable allows reconfiguration of the #GSlice
 
111
          memory allocator.
 
112
          </p>
 
113
<div class="variablelist"><table border="0">
 
114
<col align="left" valign="top">
 
115
<tbody><tr>
 
116
<td><span class="term">always-malloc</span></td>
 
117
<td><p>
 
118
                  This will cause all slices allocated through g_slice_alloc() and
 
119
                  released by g_slice_free1() to be actually allocated via direct
 
120
                  calls to g_malloc() and g_free().
 
121
                  This is most useful for memory checkers and similar programs that
 
122
                  use bohem GC alike algorithms to produce more accurate results.
 
123
                  It can also be in conjunction with debugging features of the system's
 
124
                  malloc implementation such as glibc's MALLOC_CHECK_=2 to debug
 
125
                  erroneous slice allocation code.
 
126
                </p></td>
 
127
</tr></tbody>
 
128
</table></div>
 
129
<p>
 
130
        </p>
 
131
<p><a name="G_RANDOM_VERSION"></a><b><code class="envar">G_RANDOM_VERSION</code>.&#160;</b>
 
132
    If this environment variable is set to '2.0', the outdated
 
133
    pseudo-random number seeding and generation algorithms from
 
134
    GLib-2.0 are used instead of the new better ones. Use the GLib-2.0
 
135
    algorithms only if you have sequences of numbers generated with
 
136
    Glib-2.0 that you need to reproduce exactly.  
 
137
  </p>
 
138
<p><a name="LIBCHARSET_ALIAS_DIR"></a><b><code class="envar">LIBCHARSET_ALIAS_DIR</code>.&#160;</b>
 
139
    Allows to specify a nonstandard location for the 
 
140
    <code class="filename">charset.aliases</code> file that is used by the
 
141
    character set conversion routines. The default location is the 
 
142
    <em class="replaceable"><code>libdir</code></em> specified at compilation time.
 
143
  </p>
 
144
<p><a name="G_WIN32_PRETEND_WIN9X"></a><b><code class="envar">G_WIN32_PRETEND_WIN9X</code>.&#160;</b>
 
145
    Setting this variable to any value forces g_win32_get_windows_version()
 
146
    to return a version code for Windows 9x. This is mainly an internal 
 
147
    debugging aid for GTK+ and GLib developers, to be able to check the 
 
148
    code paths for Windows 9x.
 
149
  </p>
 
150
</div>
 
151
<hr>
 
152
<div class="refsect2" lang="en">
 
153
<a name="id2688117"></a><h3>Traps and traces</h3>
 
154
<p>
 
155
<a class="indexterm" name="id2688125"></a>
 
156
<a class="indexterm" name="id2688132"></a>
 
157
<a class="indexterm" name="id2688139"></a>
 
158
Some code portions contain trap variables that can be set during debugging 
 
159
time if GLib has been configured with <code class="option">--enable-debug=yes</code>. 
 
160
Such traps lead to immediate code halts to examine the current program state 
 
161
and backtrace.
 
162
</p>
 
163
<p>
 
164
Currently, the following trap variables exist:
 
165
</p>
 
166
<pre class="programlisting">
 
167
static volatile gulong g_trap_free_size;
 
168
static volatile gulong g_trap_realloc_size;
 
169
static volatile gulong g_trap_malloc_size;
 
170
</pre>
 
171
<p>
 
172
If set to a size &gt; 0, <a href="glib-Memory-Allocation.html#g-free">g_free</a>(), 
 
173
<a href="glib-Memory-Allocation.html#g-realloc">g_realloc</a>() and 
 
174
<a href="glib-Memory-Allocation.html#g-malloc">g_malloc</a>() will be intercepted if the size 
 
175
matches the size of the corresponding memory block. This will only work with 
 
176
<code class="literal">g_mem_set_vtable (glib_mem_profiler_table)</code> upon startup 
 
177
though, because memory profiling is required to match on the memory block sizes.
 
178
</p>
 
179
<p>
 
180
Note that many modern debuggers support conditional breakpoints, which achieve
 
181
pretty much the same. E.g. in gdb, you can do
 
182
</p>
 
183
<pre class="programlisting">
 
184
break g_malloc
 
185
condition 1 n_bytes == 20
 
186
</pre>
 
187
<p>
 
188
to break only on g_malloc() calls where the size of the allocated memory block
 
189
is 20. 
 
190
</p>
 
191
</div>
 
192
</div>
 
193
</div>
 
194
</body>
 
195
</html>