blob: a71433206d4dc4debdebf8963311192d7c2b9fee [file] [log] [blame]
Barry Warsawbb779ec1997-01-16 23:55:38 +00001Purify (tm) and Quantify (tm) are commercial software quality
Barry Warsaw93374531997-10-07 15:50:58 +00002assurance tools available from Rational Software Corporation
3<http://www.rational.com/>. Purify is essentially a memory access
Barry Warsawbb779ec1997-01-16 23:55:38 +00004verifier and leak detector; Quantify is a C level profiler. The rest
5of this file assumes you generally know how to use Purify and
6Quantify, and that you have installed valid licenses for these
Barry Warsaw93374531997-10-07 15:50:58 +00007products. If you haven't installed such licenses, you can ignore the
Barry Warsawbb779ec1997-01-16 23:55:38 +00008following since it won't help you a bit!
9
10You can easily build a Purify or Quantify instrumented version of the
Barry Warsaw93374531997-10-07 15:50:58 +000011Python interpreter by passing the PURIFY variable to the make command
Barry Warsawbb779ec1997-01-16 23:55:38 +000012at the top of the Python tree:
13
Barry Warsaw93374531997-10-07 15:50:58 +000014 make PURIFY=purify
Barry Warsawbb779ec1997-01-16 23:55:38 +000015
Barry Warsaw93374531997-10-07 15:50:58 +000016This assumes that the `purify' program is on your $PATH. Note that
17you cannot both Purify and Quantify the Python interpreter (or any
18program for that matter) at the same time. If you want to build a
19Quantify'd interpreter, do this:
Barry Warsawbb779ec1997-01-16 23:55:38 +000020
Barry Warsaw93374531997-10-07 15:50:58 +000021 make PURIFY=quantify
Barry Warsawbb779ec1997-01-16 23:55:38 +000022
23When running the regression test (make test), I have found it useful
Barry Warsaw93374531997-10-07 15:50:58 +000024to set my PURIFYOPTIONS environment variable using the following
25(bash) shell function. Check out the Purify documentation for
26details:
Barry Warsawbb779ec1997-01-16 23:55:38 +000027
28p() {
29 chainlen='-chain-length=12'
30 ignoresigs='-ignore-signals="SIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGAVRT,SIGEMT,SIGFPE,SIGKILL,SIGBUS,SIGSEGV,SIGPIPE,SIGTERM,SIGUSR1,SIGUSR2,SIGPOLL,SIGXCPU,SIGXFSZ,SIGFREEZE,SIGTHAW,SIGRTMIN,SIGRTMAX"'
31 followchild='-follow-child-processes=yes'
32 threads='-max-threads=50'
33 export PURIFYOPTIONS="$chainlen $ignoresigs $followchild $threads"
34 echo $PURIFYOPTIONS
35}
36
37Note that you may want to crank -chain-length up even further. A
38value of 20 should get you the entire stack up into the Python C code
39in all situations.
40
Barry Warsaw93374531997-10-07 15:50:58 +000041With the regression test on a fatly configured interpreter
42(i.e. including as many modules as possible in your Modules/Setup
43file), you'll probably get a gabillion UMR errors, and a few MLK
44errors. I think most of these can be safely suppressed by putting the
45following in your .purify file:
Barry Warsawbb779ec1997-01-16 23:55:38 +000046
47 suppress umr ...; "socketmodule.c"
48 suppress umr ...; time_strftime
49 suppress umr ...; "dbmmodule.c"
50 suppress umr ...; "gdbmmodule.c"
51 suppress umr ...; "grpmodule.c"
52 suppress umr ...; "nismodule.c"
53 suppress umr ...; "pwdmodule.c"
54
Barry Warsaw93374531997-10-07 15:50:58 +000055This will still leave you with just a few UMR, mostly in the readline
56library, which you can safely ignore. A lot of work has gone into
57Python 1.5 to plug as many leaks as possible.
Barry Warsawbb779ec1997-01-16 23:55:38 +000058
59Using Purify or Quantify in this way will give you coarse grained
60reports on the whole Python interpreter. You can actually get more
61fine grained control over both by linking with the optional `pure'
62module, which exports (most of) the Purify and Quantify C API's into
63Python. To link in this module (it must be statically linked), edit
64your Modules/Setup file for your site, and rebuild the interpreter.
65You might want to check out the comments in the Modules/puremodule.c
66file for some idiosyncrasies.
67
68Using this module, you can actually profile or leak test a small
69section of code, instead of the whole interpreter. Using this in
70conjuction with pdb.py, dbx, or the profiler.py module really gives
71you quite a bit of introspective power.
Barry Warsaw93374531997-10-07 15:50:58 +000072
73Naturally there are a couple of caveats. This has only been tested
74with Purify 4.0.1 and Quantify 2.1-beta on Solaris 2.5. Purify 4.0.1
75does not work with Solaris 2.6, but Purify 4.1 which reportedly will,
76is currently in beta test. There are funky problems when Purify'ing a
77Python interpreter build with threads. I've had a lot of problems
78getting this to work, so I generally don't build with threads when I'm
79Purify'ing. If you get this to work, let us know!
80
81-Barry Warsaw <bwarsaw@cnri.reston.va.us>