gpt4 book ai didi

objective-c - spindump分析说明?

转载 作者:太空狗 更新时间:2023-10-30 03:19:08 28 4
gpt4 key购买 nike

我有一个 spindump 集合,专注于需要分析的应用程序,但我不确定如何准确地分析这些。我见过其他一些开发人员能够在心理上或使用软件快速解析这些问题,然后返回给我详细信息,说明挂起将在何处发生等等,我希望了解如何正确分析这些问题。

去哪里正确分析 spindumps?

最佳答案

通常:

  • 通过崩溃报告,您可以获得堆栈跟踪
  • 使用 spindumps,您可以在一段时间内同时获得多个堆栈跟踪。

在两种情况下您可能想要检查 spindump:

  1. 无限循环,可能一遍又一遍地调用同一个函数
  2. 僵局。

第一种情况可以从 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/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com