sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 1 | |
sewardj | 4018392 | 2002-06-19 20:52:32 +0000 | [diff] [blame] | 2 | 19 June 2002 |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 3 | |
| 4 | The purpose of this small doc is to guide you in using Valgrind to |
| 5 | find and fix memory management bugs in KDE3. |
| 6 | |
| 7 | --------------------------------------------------- |
| 8 | |
| 9 | Here's a getting-started-quickly checklist. It might sound daunting, |
| 10 | but once set up things work fairly well. |
| 11 | |
| 12 | |
sewardj | 365a851 | 2002-07-01 08:30:05 +0000 | [diff] [blame] | 13 | * You need an x86 box running a Linux 2.2 or 2.4 kernel, with glibc |
| 14 | 2.1.X or 2.2.X and XFree86 3.X or 4.X. In practice this means |
| 15 | practically any recent Linux distro. Valgrind is developed on a |
| 16 | vanilla Red Hat 7.2 installation, so at least works ok there. |
| 17 | I imagine Mandrake 8 and SuSE 7.X would be ok too. It is known to |
| 18 | work on Red Hats 6.2, 7.2 and 7.3, at the very least. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | * You need a reasonably fast machine, since programs run 25-100 x |
sewardj | 365a851 | 2002-07-01 08:30:05 +0000 | [diff] [blame] | 22 | slower on Valgrind. I work with a 1133 MHz PIII with 512 M of |
| 23 | memory. Interactive programs like kate, konqueror, etc, are |
| 24 | usable, but in all, the faster your machine, the more useful |
| 25 | valgrind will be. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 26 | |
| 27 | |
| 28 | * You need at least 256M of memory for reasonable behaviour. Valgrind |
sewardj | 365a851 | 2002-07-01 08:30:05 +0000 | [diff] [blame] | 29 | inflates the memory use of KDE apps approximately 3-4 x, so (eg) |
| 30 | konqueror needs ~ 140M of memory to get started, although to be fair, |
| 31 | at least 40 M of that is due to reading the debug info -- this is for |
| 32 | a konqueror and all libraries built with -O -g. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 33 | |
| 34 | |
| 35 | * You need to compile the KDE to be debugged, using a decent gcc/g++: |
| 36 | |
| 37 | - gcc 2.96-*, which comes with Red Hat 7.2, is buggy. It sometimes |
| 38 | generates code with reads below %esp, even for simple functions. |
| 39 | This means you will be flooded with errors which are nothing to |
sewardj | 365a851 | 2002-07-01 08:30:05 +0000 | [diff] [blame] | 40 | do with your program. You can use the --workaround-gcc296-bugs=yes |
| 41 | flag to ignore them. See the manual for details; this is not really |
| 42 | a good solution. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 43 | |
| 44 | - I recommend you use gcc/g++ 2.95.3. It seems to compile |
| 45 | KDE without problems, and does not suffer from the above bug. It's |
| 46 | what I have been using. |
| 47 | |
sewardj | 365a851 | 2002-07-01 08:30:05 +0000 | [diff] [blame] | 48 | - gcc-3. 3.0.4 was observed to have a scheduling bug causing it to |
| 49 | occasionally generate writes below the stack pointer. gcc-3.1 seems |
| 50 | better in that respect. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 51 | |
| 52 | It's ok to build Valgrind with the default gcc on Red Hat 7.2. |
| 53 | |
| 54 | |
sewardj | 365a851 | 2002-07-01 08:30:05 +0000 | [diff] [blame] | 55 | * So: build valgrind -- see the README file. It's the standard |
| 56 | ./configure ; make ; make install deal. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 57 | |
| 58 | * Build as much of KDE+Qt as you can with -g and without -O, for |
| 59 | the usual reasons. |
| 60 | |
| 61 | * Use it! |
| 62 | /path/to/valgrind $KDEDIR/bin/kate |
| 63 | (or whatever). |
| 64 | |
| 65 | * If you are debugging KDE apps, be prepared for the fact that |
| 66 | Valgrind finds bugs in the underlying Qt (qt-copy from CVS) too. |
| 67 | |
| 68 | * Please read the Valgrind manual, docs/index.html. It contains |
| 69 | considerable details about how to use it, what's really going on, |
| 70 | etc. |
| 71 | |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 72 | * There are some significant limitations: |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 73 | - No MMX, SSE, SSE2 insns. Basically a 486 instruction set only. |
| 74 | - Various other minor limitations listed in the manual. |
| 75 | |
sewardj | 4018392 | 2002-06-19 20:52:32 +0000 | [diff] [blame] | 76 | * If you have trouble with it, please let me know (jseward@acm.org) |
| 77 | and I'll see if I can help you out. |
sewardj | de4a1d0 | 2002-03-22 01:27:54 +0000 | [diff] [blame] | 78 | |
| 79 | |
| 80 | Have fun! If you find Valgrind useful in finding and fixing bugs, |
| 81 | I shall consider my efforts to have been worthwhile. |
| 82 | |
| 83 | Julian Seward (jseward@acm.org) |