blob: c641510e426bf23297e68eb3951947c10c76f263 [file] [log] [blame]
Barry Warsawbb779ec1997-01-16 23:55:38 +00001Purify (tm) and Quantify (tm) are commercial software quality
Thomas Wouters00ee7ba2006-08-21 19:07:27 +00002assurance tools available from IBM <http://www.ibm.com/software/rational/>.
3Purify 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
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000023Starting with Python 2.3, pymalloc is enabled by default. This
24will cause many supurious warnings. Modify Objects/obmalloc.c
25and enable Py_USING_MEMORY_DEBUGGER by uncommenting it.
26README.valgrind has more details about why this is necessary.
27See below about setting up suppressions. Some tests may not
28run well with Purify due to heavy memory or CPU usage. These
29tests may include: test_largefile, test_import, and test_long.
30
31Please report any findings (problems or no warnings) to python-dev@python.org.
32It may be useful to submit a bug report for any problems.
33
Barry Warsawbb779ec1997-01-16 23:55:38 +000034When running the regression test (make test), I have found it useful
Barry Warsaw93374531997-10-07 15:50:58 +000035to set my PURIFYOPTIONS environment variable using the following
36(bash) shell function. Check out the Purify documentation for
37details:
Barry Warsawbb779ec1997-01-16 23:55:38 +000038
39p() {
40 chainlen='-chain-length=12'
41 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"'
42 followchild='-follow-child-processes=yes'
43 threads='-max-threads=50'
44 export PURIFYOPTIONS="$chainlen $ignoresigs $followchild $threads"
45 echo $PURIFYOPTIONS
46}
47
48Note that you may want to crank -chain-length up even further. A
49value of 20 should get you the entire stack up into the Python C code
50in all situations.
51
Barry Warsaw93374531997-10-07 15:50:58 +000052With the regression test on a fatly configured interpreter
53(i.e. including as many modules as possible in your Modules/Setup
54file), you'll probably get a gabillion UMR errors, and a few MLK
55errors. I think most of these can be safely suppressed by putting the
56following in your .purify file:
Barry Warsawbb779ec1997-01-16 23:55:38 +000057
58 suppress umr ...; "socketmodule.c"
59 suppress umr ...; time_strftime
Georg Brandl0a7ac7d2008-05-26 10:29:35 +000060 suppress umr ...; "_dbmmodule.c"
61 suppress umr ...; "_gdbmmodule.c"
Barry Warsawbb779ec1997-01-16 23:55:38 +000062 suppress umr ...; "grpmodule.c"
63 suppress umr ...; "nismodule.c"
64 suppress umr ...; "pwdmodule.c"
65
Thomas Wouters00ee7ba2006-08-21 19:07:27 +000066Note: this list is very old and may not be accurate any longer.
67It's possible some of these no longer need to be suppressed.
68You will also need to suppress warnings (at least umr)
69from Py_ADDRESS_IN_RANGE.
70
Barry Warsaw93374531997-10-07 15:50:58 +000071This will still leave you with just a few UMR, mostly in the readline
72library, which you can safely ignore. A lot of work has gone into
73Python 1.5 to plug as many leaks as possible.
Barry Warsawbb779ec1997-01-16 23:55:38 +000074
75Using Purify or Quantify in this way will give you coarse grained
76reports on the whole Python interpreter. You can actually get more
77fine grained control over both by linking with the optional `pure'
78module, which exports (most of) the Purify and Quantify C API's into
79Python. To link in this module (it must be statically linked), edit
80your Modules/Setup file for your site, and rebuild the interpreter.
81You might want to check out the comments in the Modules/puremodule.c
82file for some idiosyncrasies.
83
84Using this module, you can actually profile or leak test a small
85section of code, instead of the whole interpreter. Using this in
86conjuction with pdb.py, dbx, or the profiler.py module really gives
87you quite a bit of introspective power.
Barry Warsaw93374531997-10-07 15:50:58 +000088
89Naturally there are a couple of caveats. This has only been tested
90with Purify 4.0.1 and Quantify 2.1-beta on Solaris 2.5. Purify 4.0.1
91does not work with Solaris 2.6, but Purify 4.1 which reportedly will,
92is currently in beta test. There are funky problems when Purify'ing a
93Python interpreter build with threads. I've had a lot of problems
94getting this to work, so I generally don't build with threads when I'm
95Purify'ing. If you get this to work, let us know!
96
97-Barry Warsaw <bwarsaw@cnri.reston.va.us>