views:

151

answers:

2

I downloaded LibC source from opensource.apple.com, but since it's part of one monolithic library /usr/lib/libSystem.B.dylib would I have to somehow rebuild the entire thing?

I have a BSD command line program, ported from Linux. I want to be able to set breakpoints in LibC functions and step through. I'm trying to close in on what seems to be heap corruption in my program (which doesn't occur on Linux - I've already ported back to Linux and run memcheck there.)

A: 

Have you take a look at the Kernel Debug Kit from Apple (http://developer.apple.com/sdk/) ? I know that it contains kernel symbols, but I am not sure if libc is part of the SDK.

Laurent Etiemble
A: 

You can build Valgrind yourself - either use the last version released on 10.5, or look on the bug tracker for the Snow Leopard support bug, which has a patch.

Alternately, try the memory debugging tools in the malloc(3) manual.

alex strange
I tried valgrind on Snow Leopard. I only had to work around syscalls the patch doesn't cover - sigwait() for instance. (Useful porting experience.) In the end, valgrind told me no more than what the debugger did - Invalid Write (through a trashed pointer value). I still want to be able to step through the libC call to see when the pointer becomes invalid. Thanks anyway.
Erik Olson