blob: 18f8e7d3e6bbd661264a72bed5e21b5b28b1c8af [file] [log] [blame]
sewardjde4a1d02002-03-22 01:27:54 +00001
24 February 2002
3
4Greetings, KDE developer. Some of you may have noticed, in recent
5days, that I have posted some bug reports to kde-core-devel@kde.org,
6containing traces like the following:
7
8 Use of uninitialised CPU condition code
9 at 0x471A4196: KateBuffer::parseBlock(KateBufBlock *) (katebuffer.cpp:446)
10 by 0x471A3B58: KateBuffer::line(unsigned int) (katebuffer.cpp:343)
11 by 0x471C684B: KateDocument::updateLines(int, int)
12 (../../kdecore/ksharedptr.h:126)
13 by 0x471C1C3E: KateDocument::makeAttribs() (katedocument.cpp:2302)
14
15These errors were detected using this tool, Valgrind.
16
17The purpose of this small doc is to guide you in using Valgrind to
18find and fix memory management bugs in KDE3.
19
20 ---------------------------------------------------
21
22Here's a getting-started-quickly checklist. It might sound daunting,
23but once set up things work fairly well.
24
25
26* You need an x86 box running a Linux 2.4 kernel, with glibc-2.2.X and
27 XFree86 4.1.0. In practice this means practically any recent,
28 mainstream Linux distro. Valgrind is developed on a vanilla Red Hat
29 7.2 installation, so at least works ok there. I imagine Mandrake 8
30 and SuSE 7.X would be ok too. It has been known to work (and still
31 should) on Red Hat 7.1 and 6.2 too.
32
33
34* You need a reasonably fast machine, since programs run 25-100 x
35 slower on Valgrind. I work with a 400 MHz AMD K6-III with 256 M of
36 memory. Interactive programs like kate, konqueror, etc, are just
37 about usable, but a faster machine would be better.
38
39
40* You need at least 256M of memory for reasonable behaviour. Valgrind
41 inflates the memory use of KDE apps approximately 4-5 x, so (eg)
42 konqueror needs ~ 140M of memory to get started. This is very bad;
43 I hope to improve it (the current memory manager has a design problem).
44
45
46* You need to compile the KDE to be debugged, using a decent gcc/g++:
47
48 - gcc 2.96-*, which comes with Red Hat 7.2, is buggy. It sometimes
49 generates code with reads below %esp, even for simple functions.
50 This means you will be flooded with errors which are nothing to
51 do with your program. As of 18 Feb 02, you can use the
52 --workaround-gcc296-bugs=yes flag to ignore them. See the
53 manual for details; this is not really a good solution.
54
55 - I recommend you use gcc/g++ 2.95.3. It seems to compile
56 KDE without problems, and does not suffer from the above bug. It's
57 what I have been using.
58
59 - gcc-3.0.X -- I have not really tried gcc 3.0.X very much with
60 Valgrind, but others seem to think it works ok.
61
62 It's ok to build Valgrind with the default gcc on Red Hat 7.2.
63
64
65* So: build valgrind -- see the README file. (it's easy).
66
67* Build as much of KDE+Qt as you can with -g and without -O, for
68 the usual reasons.
69
70* Use it!
71 /path/to/valgrind $KDEDIR/bin/kate
72 (or whatever).
73
74* If you are debugging KDE apps, be prepared for the fact that
75 Valgrind finds bugs in the underlying Qt (qt-copy from CVS) too.
76
77* Please read the Valgrind manual, docs/index.html. It contains
78 considerable details about how to use it, what's really going on,
79 etc.
80
81* The source locations in error messages can be way wrong sometimes;
82 please treat them with suspicion. In particular, it will sometimes
83 say that a source location is in a header file (.h) when really it
84 is in some totally unrelated source (.cpp) file. I'm working on it ...
85
86* There are some significant limitations:
87 - No threads! You can run programs linked with libpthread.so,
88 but only until the point where they do clone(); at that point
89 Valgrind will abort.
90 - No MMX, SSE, SSE2 insns. Basically a 486 instruction set only.
91 - Various other minor limitations listed in the manual.
92
93* Valgrind is still under active development. If you have trouble
94 with it, please let me know (jseward@acm.org) and I'll see if I
95 can help you out.
96
97
98Have fun! If you find Valgrind useful in finding and fixing bugs,
99I shall consider my efforts to have been worthwhile.
100
101Julian Seward (jseward@acm.org)