]> git.sesse.net Git - vlc/blob - doc/developer/debugging.xml
.
[vlc] / doc / developer / debugging.xml
1 <appendix> <title> Advanced debugging </title>
2
3   <para>
4 We never debug our code, because we don't put bugs in. Okay, you want
5 some real stuff. Sam still uses <function> printf() </function> to
6 find out where it crashes. For real programmers, here is a summary
7 of what you can do if you have problems.
8   </para>
9
10   <sect1> <title> Where does it crash ? </title>
11
12     <para>
13 The best way to know that is to use gdb. You can start using it with
14 good chances by configuring with <parameter> --enable-debug </parameter>.
15 It will add <parameter> -g </parameter> to the compiler <parameter>
16 CFLAGS</parameter>, and activate some additional safety checks. Just
17 run <command> gdb vlc</command>, type <command> run myfile.vob</command>,
18 and wait until it crashes. You can view where it stopped with
19 <command>bt</command>, and print variables with <command>print
20 &lt;C-style&gt;</command>.
21     </para>
22
23     <para>
24 If you run into troubles, you may want to turn the optimizations off.
25 Optimizations (especially inline functions) may confuse the debugger.
26 Use <parameter> --disable-optimizations </parameter> in that case.
27     </para>
28
29   </sect1>
30
31   <sect1> <title> Other problems </title>
32
33     <para>
34 It may be more complicated than that, for instance unpredictable
35 behaviour, random bug or performance issue. You have several options
36 to deal with this. If you experience unpredictable behaviour, I hope
37 you don't have a heap or stack corruption (eg. writing in an unallocated
38 space), because they are hard to find. If you are really desperate, have
39 a look at something like ElectricFence or dmalloc. Under GNU/Linux, an
40 easy check is to type <command> export MALLOC_CHECK_=2 </command> before
41 launching vlc (see <command> malloc(3) </command> for more information).
42     </para>
43
44     <para>
45 VLC offers a "trace-mode". It can create a log file with very accurate dates
46 and messages of what it does, so it is useful to detect performance
47 issues or lock-ups. Compile with <parameter> --enable-trace </parameter>
48 and tune the <parameter> TRACE_* </parameter> flags in <filename>
49 include/config.h </filename> to enable certain types of messages (log
50 file writing can take up a lot of time, and will have side effects).
51     </para>
52
53   </sect1>
54
55 </appendix>