Re: Dtrace for tracing memory frees
Re: Dtrace for tracing memory frees
- Subject: Re: Dtrace for tracing memory frees
- From: Jakub Bednar <email@hidden>
- Date: Wed, 2 Jul 2008 18:23:46 +0200
Well,
I tried what You have suggested but I'm little bit confused.
I used XCode-3.1 to build the tool. I run it in Object Allocations and
it
probably doesn't crash, because no error message or Crash Reporter
window showed. Or how should I get the crash report?
I've tried attaching gdb to the process created by Object Allocations.
But it shows that executable ended normally.
Running from Terminal and XCode shows me the SIGSEGV.
I've also another question. I know how to set environment variables
when running executable from instruments. But how can I set them
when running from XCode and XCode-Debugger.
Thanks a lot,
Jakub
On Jul 2, 2008, at 1:41 PM, Ken Thomases wrote:
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