johnno1962 / Xtrace

Trace Objective-C method calls by class or instance
MIT License
1.83k stars 132 forks source link

Feature request: add tracing of outer context (callers within call stack) #8

Closed stanislaw closed 10 years ago

stanislaw commented 10 years ago

Hello, @johnno1962!

First of all thanks for Xtrace - it is really great to call -xtrace on arbitrary objects and see what's going on!

For last two days I've been investigating some bugs related either to RestKit or to CoreData. I tried to use xtrace on classes of my interest and found that xtrace has a lack of support of caller tracing.

What I mean is that for example when I call -xtrace on some object I also want to see the outer context: who calls this method, who calls caller and so on... I hope this will be easy thing to add since [NSThread callStackSymbols] can provide this information.

What would also be great is to have an option to configure stack depth of what Xtrace should trace. For example if this option is set to 1 then I see only the last caller of my object's method. If I set more I will see more callers within call stack.

I hope my request is clear. Please let me know what you think.


P.S. You realized one of the projects I dreamed about writing a such myself :) now it's great to just have such intelligent implementation that you did.

Thanks again for Xtrace!

johnno1962 commented 10 years ago

Hi, you can show the caller to one level using [Xtrace showCaller:YES] with the esisting code. It would be possible to extend this but the questtion would be how to restrict the amount of output so that the traces where not buried in call stack data.

stanislaw commented 10 years ago

Ah! I missed +showCaller, because it is not documented in README page.

As for restriction of output - this would be a nice option to have but I'm not sure how much work it requires to be done. If it is not an easy one, I can live without it. It is you who decides if it deserves its place within Xtrace :smile:

Thanks for quick turnaround!

stanislaw commented 10 years ago

Here is small follow-up to this issue:

Using Xtrace I was able to investigate this issue with RestKit which I have just reported to RestKit as https://github.com/RestKit/RestKit/issues/2020.

From now on I will always use Xtrace as part of my debugging tool set.

I really recommend you adding a note about +showCaller to README documentation as enabling this option was helpful to me when I did my investigation.

Thanks again for Xtrace.

johnno1962 commented 10 years ago

Thanks for the nudge. I’ve put in a short reminder showCaller: is available as an option for folks. Happy Xtrace helped you out.