[geeks] Glowing Review: Rational Purify

Jonathan C. Patschke jp at celestrion.net
Fri Jun 13 12:22:53 CDT 2008


On Fri, 13 Jun 2008, Joshua Boyd wrote:

> Is this code strictly Windows?  If it were possible it would be really
> cool to know if valgrind would have found the problems, but valgrind
> is pretty much linux only.

Well, it depends.  I have a framework I've written that is
cross-platform.  I develop is on Mac OS X, run it on Windows, and will
eventually run it full-time on HP-UX and FreeBSD.

Into that framework there are drivers which plug in.  All but one of
those drivers are Windows-specific because they wrap around some
vendor-supplied user-mode drivers.  I'm in the process of writing an OS
X driver for one of the USB devices, but that's low-priority, as it
really only benefits me.

On top of that framework are a few applications, one of which is the
application in question.  It has quite a lot of Win32-specific code in
it.  In fact, one of the bugs Purify found only exists when running on
Win32.  I was allocating a block of memory with calloc() and freeing it
with PR_Free().  On Unix, NSPR usually wraps the standard C allocation
functions--you can tell it to use boehm or something else.  On Windows,
NSPR uses HeapAlloc(), which is not the same allocation mechanism the
Microsoft C RTL uses.  Sometimes you can allocate with one and free with
the other; usually, you cannot.

My experience with valgrind has been that it's a very useful tool.  Its
output isn't nearly as verbose as Purify.  Valgrind gives you a good
idea of where your bugs are.  Purify says "Here, right there, on that
line of code with the red arrow next to it, you did this particular
boneheaded thing."

But, if you can't afford Purify (especially given what IBM charges for
Unix-like platforms) and you can port your code to Linux, valgrind is
not a bad second choice.

-- 
Jonathan Patschke | "There is more to life than increasing its speed."
Elgin, TX         |                                   --Mahatma Gandhi
USA               |



More information about the geeks mailing list