- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我有一个 spindump 集合,专注于需要分析的应用程序,但我不确定如何准确地分析这些。我见过其他一些开发人员能够在心理上或使用软件快速解析这些问题,然后返回给我详细信息,说明挂起将在何处发生等等,我希望了解如何正确分析这些问题。
去哪里正确分析 spindumps?
最佳答案
通常:
在两种情况下您可能想要检查 spindump:
第一种情况可以从 spindump 中看到,多次调用同一个函数。在这种情况下使用 Activity Monitor 是个好东西——在那里对挂起的进程进行采样,您可以通过多种有用的方式查看它,隐藏不重要的帧等。
第二种情况可以看不同线程同时等待锁。
这是一个小例子:
+ 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]
这告诉我,MyApp 已经通过 main 等,最终进入函数 CFRunLoopRunSpecific
,然后是 __CFRunLoopRun
– 从那里 (2557) 它调用__CFRunLoopServiceMachPort
,它调用了 mach_msg
并在 mach_msg_trap
处陷入陷阱(调用系统调用)——当它返回时,堆栈跟踪返回到 CFRunLoopRunSpecific
,其中调用了 __CFRunLoopRun
,然后调用了 __CFRunLoopDoObservers
,依此类推。
请注意,这不是任何挂起进程的 spindump - 您可以通过这种方式对任何正在运行的进程进行采样,并查看在该采样期间调用了哪些函数。然而,无限循环将一遍又一遍地重复调用某个函数 - 将一遍又一遍地调用相同的调用树。当然,这可能意味着一个简单的 for 循环,但如果 for 循环由于某种原因不是无限的,那是您可以检查的地方。不幸的是,这些旋转转储通常很长,具体取决于您调用的函数,因此可能需要一些时间来检查
行开头的 + 号仅表示一行的开头 - 没有 + 号的行表示新线程的开头。这 !和 : 符号组成一条线,因此您可以更轻松地查看后续调用 - 即哪些调用处于同一级别。此外, |字符也可以使用。
数字表示应用在该特定调用中花费的时间 - 它们包含在样本数中。采样的工作原理是,采样的应用程序每隔几毫秒就会暂停一次,并检查每个线程的堆栈帧。如果该应用仍在同一函数中,则该函数会获得 +1。
关于objective-c - spindump分析说明?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10709577/
我是一名优秀的程序员,十分优秀!