Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

In the iPad app that I'm creating, I'm trying to handle the uncaught Exceptions by outputting the callStackSymbols of the exception. This can be done with [NSException callStackSymbols]

However, I'd like to be able to see the callStackSymbols on all the other active threads as well. I know I can use [NSThread callStackSymbols] on any thread, but I need to loop through all the active threads to do so.

Is this possible?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
437 views
Welcome To Ask or Share your Answers For Others

1 Answer

This is a complex area, as Sedate Alien noted. You will need to implement your own stack walking to retrieve a stack trace from the other active threads; APIs such as backtrace(3) and +[NSThread callStackSymbols] will only produce a backtrace for the current thread.

Since I'm familiar with the PLCrashReporter code, I'll just use it for examples:

Note that all this code is a bit unusual, as it executes within a signal handler and is written to be async-safe; if you're unfamiliar with the complications around signal handling, this is a good starting point: http://www.mikeash.com/pyblog/friday-qa-2011-04-01-signal-handling.html

Implementing this kind of thing correctly is a gigantic headache; I would really recommend that you make use of PLCrashReporter, or one of the products built on top of it (QuincyKit, HockeyApp, Atlassian JMC, etc).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...