Re: Dtrace for tracing memory frees
Re: Dtrace for tracing memory frees
- Subject: Re: Dtrace for tracing memory frees
- From: Ken Thomases <email@hidden>
- Date: Wed, 2 Jul 2008 06:41:09 -0500
On Jul 1, 2008, at 9:03 AM, Jakub Bednar wrote:
I'm running MAC OS X Leopard with X-Code 3.1.
I have a C++ tool causing SIGSEGV when ending.
The SIGSEGV is caused by deleting a dynamic object holded
by a static object. I think its because the dynamic object was
unwillingly deleted somewhere else, as its pointer is publicly
accessible.
I thought I can use dtrace to print stack whenever a specified
address is deleted.
I think you'll find using the ObjectAlloc template for Instruments to
be a much easier and more complete solution. From Xcode, Run > Start
With Performance Tool > Object Allocations.
It essentially does what you're trying to do.
Once your program has crashed, you can get the problem address from
the crash report. Then, in the ObjectAlloc data, you can search for
that address. Use the Diagram View to get a list by addresses. Click
the arrow-in-circle that appears next to the address when you hover
over it to see a full history of allocations and deallocations for
that address. Enable the Extended Detail View to see the stack trace
for each event having to do with that address.
If you use ObjectAlloc, you have to start it with that instrument.
ObjectAlloc can't attach to an already-running process. That means
that it won't be running in such a way that Xcode will automatically
debug it when the SIGSEGV happens. That's why I directed you to the
crash report. If you instead need to use the debugger, you can tell
Xcode to explicitly attach to the process after Instruments has
launched it. You might want to put a call to sleep() early in main()
to give you the opportunity to attach. Once the process has stopped
in the debugger due to the signal, you probably want to hit the pause
button in Instruments to have it stop collecting trace data while the
process is just sitting doing nothing.
Cheers,
Ken
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden