xcode Spindump 分析说明?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10709577/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spindump analysis instructions?
提问by ylluminate
I have a collection of spindumps focused on an app that need to be analyzed, however I'm not sure precisely how to analyze these. I've seen some other developers who are able to quickly parse these either mentally or with software and come back to me with details on where hangs are coming to play and so forth and I'm hoping to understand how to properly analyze these.
我有一系列针对需要分析的应用程序的自旋转储,但是我不确定如何准确地分析这些。我见过其他一些开发人员,他们能够通过心理或软件快速解析这些内容,然后向我提供有关挂起的位置等的详细信息,我希望了解如何正确分析这些内容。
Where does one go to properly analyze spindumps?
去哪里正确分析自旋转储?
采纳答案by Charlie Monroe
Generally:
一般来说:
- with a crash report, you get a stack trace
- with spindumps, you get multiple stack traces over a period of time together.
- 有了崩溃报告,你就会得到一个堆栈跟踪
- 使用自旋转储,您可以在一段时间内获得多个堆栈跟踪。
There are two cases in which you might want to examine a spindump:
在两种情况下,您可能想要检查自旋转储:
- an infinite loop, probably calling the same function over and over
- deadlock.
- 一个无限循环,可能一遍又一遍地调用相同的函数
- 僵局。
The first case can be seen from the spindump by many calls to the same function over and over. A good thing to use in such situations is Activity Monitor – take sample of a hung process there and you can view it in several useful ways, hiding unimportant frames, etc.
从旋转转储中可以看到第一种情况,多次调用同一个函数。在这种情况下使用的一个好东西是活动监视器 - 在那里获取挂起进程的样本,您可以通过几种有用的方式查看它,隐藏不重要的帧等。
The second case can be viewed by different threads waiting on locks at the same time.
第二种情况可以通过不同的线程同时等待锁来查看。
Here is a little example:
这是一个小例子:
+ 2663 start (in MyApp) + 52 [0x100001bb4]
+ 2663 main (in MyApp) + 39 [0x100001be7] main.m:65
+ 2663 NSApplicationMain (in AppKit) + 869 [0x7fff8ea27cb6]
+ 2663 -[NSApplication run] (in AppKit) + 517 [0x7fff8ea83283]
+ 2663 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] (in AppKit) + 128 [0x7fff8ea8bed2]
+ 2663 _DPSNextEvent (in AppKit) + 685 [0x7fff8ea8c613]
+ 2663 BlockUntilNextEventMatchingListInMode (in HIToolbox) + 62 [0x7fff8dd53cd3]
+ 2663 ReceiveNextEventCommon (in HIToolbox) + 356 [0x7fff8dd53e42]
+ 2663 RunCurrentEventLoopInMode (in HIToolbox) + 209 [0x7fff8dd540a4]
+ 2663 CFRunLoopRunSpecific (in CoreFoundation) + 290 [0x7fff95dec6b2]
+ 2557 __CFRunLoopRun (in CoreFoundation) + 1078 [0x7fff95decee6]
+ ! 2556 __CFRunLoopServiceMachPort (in CoreFoundation) + 195 [0x7fff95de7803]
+ ! : 2556 mach_msg (in libsystem_kernel.dylib) + 70 [0x7fff93630c42]
+ ! : 2556 mach_msg_trap (in libsystem_kernel.dylib) + 10 [0x7fff93631686]
+ ! 1 __CFRunLoopServiceMachPort (in CoreFoundation) + 199 [0x7fff95de7807]
+ 97 __CFRunLoopRun (in CoreFoundation) + 728 [0x7fff95decd88]
+ ! 97 __CFRunLoopDoObservers (in CoreFoundation) + 369 [0x7fff95e11921]
+ ! 97 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ (in CoreFoundation) + 23 [0x7fff95e119b7]
+ ! 97 __83-[NSWindow _postWindowNeedsDisplayOrLayoutOrUpdateConstraintsUnlessPostingDisabled]_block_invoke_01208 (in AppKit) + 46 [0x7fff8f05a971]
+ ! 90 _handleWindowNeedsDisplayOrLayoutOrUpdateConstraints (in AppKit) + 738 [0x7fff8ea8f2ac]
+ ! : 89 -[NSView displayIfNeeded] (in AppKit) + 1830 [0x7fff8ea8fd73]
What this tells me, is that MyApp has gone through main, etc. and finally got into a function CFRunLoopRunSpecific
, then __CFRunLoopRun
– from there (2557) it called __CFRunLoopServiceMachPort
, which called mach_msg
and got into a trap at mach_msg_trap
(calling a syscall) – when it got back, the stack trace returned to CFRunLoopRunSpecific
, where __CFRunLoopRun
was called, which then calls __CFRunLoopDoObservers
, and so on.
这告诉我的是,MyApp 经历了 main 等,最后进入了一个函数CFRunLoopRunSpecific
,然后__CFRunLoopRun
——从那里(2557)它调用了__CFRunLoopServiceMachPort
,它mach_msg
在mach_msg_trap
(调用系统调用)时调用并进入了一个陷阱——当它返回时,堆栈跟踪返回到CFRunLoopRunSpecific
,__CFRunLoopRun
被调用的位置,然后调用__CFRunLoopDoObservers
,依此类推。
Note that this isn't a spindump of any hanging process - you can sample this way any running process and view what functions were called during that sample. An infinite loop, however, will have a repeating calls to some function over and over again - there will be the same call tree over and over again. Of course, this can mean a simple for cycle, but that's where you can examine, if the for cycle isn't for some reason infinite. Unfortunately, these spin dumps are usually quite long, depending on what function you are calling, so it may take some time to examine
请注意,这不是任何挂起进程的旋转转储 - 您可以通过这种方式对任何正在运行的进程进行采样,并查看在该示例期间调用了哪些函数。然而,一个无限循环会一遍又一遍地重复调用某个函数——一遍又一遍地会有相同的调用树。当然,这可能意味着一个简单的 for 循环,但您可以在这里检查 for 循环是否由于某种原因不是无限的。不幸的是,这些自旋转储通常很长,具体取决于您调用的函数,因此可能需要一些时间来检查
The + sign at the beginning of the row simply indicates a beginning of a line - lines without the + sign indicate a beginning of a new thread. The ! and : signs make a line, so it's easier for you to see subsequent calls - i.e. which calls are at the same level. Further, | character can be also used.
行开头的 + 号仅表示一行的开始 - 没有 + 号的行表示新线程的开始。这 !和 : 标志排成一行,因此您可以更轻松地查看后续调用 - 即哪些调用处于同一级别。此外,| 也可以使用字符。
The numbers mean how long the app spent in that particular call - they are in the number of samples. The sampling works that the sampled app gets suspended every few millisecond and the stack frame is examined of each thread. If the app is still in the same function, the function gets +1.
这些数字表示应用程序在该特定呼叫中花费的时间 - 它们在样本数量中。采样工作是采样的应用程序每隔几毫秒暂停一次,并检查每个线程的堆栈帧。如果应用程序仍在同一功能中,则该功能会获得 +1。
回答by blaa
I found this when searching the Mac Developer Resources for 'spindump'. I've never seen one, but this TechNote referred to in the ReportCrash(8) manual page seems to show you how to read crash logs:
我在 Mac 开发人员资源中搜索“spindump”时发现了这一点。我从未见过,但是 ReportCrash(8) 手册页中提到的这个 TechNote 似乎向您展示了如何阅读崩溃日志:
https://developer.apple.com/library/mac/#technotes/tn2004/tn2123.html
https://developer.apple.com/library/mac/#technotes/tn2004/tn2123.html
And ReportCrash(8) referred to Spindump(8), my apologies. https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/ReportCrash.8.html
并且 ReportCrash(8) 提到了 Spindump(8),我很抱歉。 https://developer.apple.com/library/mac/#documentation/Darwin/Reference/ManPages/man8/ReportCrash.8.html
But apparently this doesn't help you out. I'll leave it up here just as well.
但显然这对你没有帮助。我也会把它放在这里。
Hope this helps someone out somehow.
希望这能以某种方式帮助某人。