]> git.sur5r.net Git - i3/i3/blob - docs/debugging
Merge branch 'next'
[i3/i3] / docs / debugging
1 Debugging i3: How To
2 ====================
3 Michael Stapelberg <michael+i3@stapelberg.de>
4 July 2011
5
6 This document describes how to debug i3 suitably for sending us useful bug
7 reports, even if you have no clue of C programming.
8
9 First of all: Thank you for being interested in debugging i3. It really means
10 something to us to get your bug fixed. If you have any questions about the
11 debugging and/or need further help, do not hesitate to contact us!
12
13 == Enabling logging
14
15 i3 logs useful information to stdout. To have a clearly defined place where log
16 files will be saved, you should redirect stdout and stderr in your
17 +~/.xsession+. While you’re at it, putting each run of i3 in a separate log
18 file with date/time in its filename is a good idea to not get confused about
19 the different log files later on.
20
21 --------------------------------------------------------------------
22 exec /usr/bin/i3 >~/i3log-$(date +'%F-%k-%M-%S') 2>&1
23 --------------------------------------------------------------------
24
25 To enable verbose output and all levels of debug output (required when
26 attaching logfiles to bugreports), add the parameters +-V -d all+, like this:
27
28 --------------------------------------------------------------------
29 exec /usr/bin/i3 -V -d all >~/i3log-$(date +'%F-%k-%M-%S') 2>&1
30 --------------------------------------------------------------------
31
32 == Enabling core dumps
33
34 When i3 crashes, often you have the chance of getting a 'core dump' (an image
35 of the memory of the i3 process which can be loaded into a debugger). To get a
36 core dump, you have to make sure that the user limit for core dump files is set
37 high enough. Many systems ship with a default value which even forbids core
38 dumps completely. To disable the limit completely and thus enable core dumps,
39 use the following command (in your +~/.xsession+, before starting i3):
40
41 -------------------
42 ulimit -c unlimited
43 -------------------
44
45 Furthermore, to easily recognize core dumps and allow multiple of them, you
46 should set a custom core dump filename pattern, using a command like the
47 following:
48
49 ---------------------------------------------
50 sudo sysctl -w kernel.core_pattern=core.%e.%p
51 ---------------------------------------------
52
53 This will generate files which have the executable’s file name (%e) and the
54 process id (%p) in it. You can save this setting across reboots using
55 +/etc/sysctl.conf+.
56
57 == Compiling with debug symbols
58
59 To actually get useful core dumps, you should make sure that your version of i3
60 is compiled with debug symbols, that is, that the symbols are not stripped
61 during the build process. You can check whether your executable contains
62 symbols by issuing the following command:
63
64 ----------------
65 file $(which i3)
66 ----------------
67
68 You should get an output like this:
69 ------------------------------------------------------------------------------
70 /usr/bin/i3: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically
71 linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
72 ------------------------------------------------------------------------------
73
74 Notice the +not stripped+, which is the important part. If you have a version
75 which is stripped, please have a look if your distribution provides debug
76 symbols (package +i3-wm-dbg+ on Debian for example) or if you can turn off
77 stripping. If nothing helps, please build i3 from source.
78
79 == Generating a backtrace
80
81 Once you have made sure that your i3 is compiled with debug symbols and that
82 core dumps are enabled, you can start making sense out of the core dumps.
83
84 Because the core dump depends on the original executable (and its debug
85 symbols), please do this as soon as you encounter the problem. If you
86 re-compile i3, your core dump might be useless afterwards.
87
88 Please install +gdb+, a debugger for C. No worries, you don’t need to learn it
89 now.  Start gdb using the following command (replacing the actual name of the
90 core dump of course):
91
92 ----------------------------
93 gdb $(which i3) core.i3.3849
94 ----------------------------
95
96 Then, generate a backtrace using:
97
98 --------------
99 backtrace full
100 --------------
101
102 == Sending bug reports/debugging on IRC
103
104 When sending bug reports, please paste the relevant part of the log (if in
105 doubt, please send us rather too much information than too less) and the whole
106 backtrace (if there was a core dump).
107
108 When debugging with us in IRC, be prepared to use a so called nopaste service
109 such as http://nopaste.info or http://pastebin.com because pasting large
110 amounts of text in IRC sometimes leads to incomplete lines (servers have line
111 length limitations) or flood kicks.