2

我正在开发一个 macOS 应用程序,该应用程序使用 Google Crashpad 将客户崩溃报告上传回给我们。该工具生成的故障转储完全象征我们的应用程序,但不适用于系统库。

这与位于 /Library/Logs/DiagnosticReports 中的崩溃文件相反,后者具有系统库的符号,但通常不用于崩溃的应用程序。

我的问题是,如何在系统库中表示函数调用?我已经可以为我自己构建的应用程序atos和 dSYM 包执行此操作。但是,我无法找到有关如何为系统库执行此操作的文档。

Crashpad 的文档不是很有启发性,因为它主要针对 Linux 和 Windows:https ://www.chromium.org/developers/decoding-crash-dumps

但是,理论上我应该能够做到这一点(毕竟,macOS 的系统崩溃服务在生成自己的报告时会这样做 - 或者,也许我只需要将一些调试信息从 Xcode SDK 传递到atos?)

这是一个示例转储,删除了对我的应用程序的引用。

Operating system: Mac OS X
                  10.9.5 13F1911
CPU: amd64
     family 6 model 42 stepping 7
     4 CPUs

GPU: UNKNOWN

Crash reason:  EXC_BREAKPOINT / EXC_I386_BPT
Crash address: 0x7fff669d609d
Process uptime: 3 seconds

Thread 8 (crashed)
 0  dyld + 0x109d
    rax = 0x00007fff66a0adb0   rdx = 0x0000000000000000
    rcx = 0x0000000000000000   rbx = 0x00007fd96a50de60
    rsi = 0x0000000000000000   rdi = 0x00007fff66a0af20
    rbp = 0x000000010c2ee700   rsp = 0x000000010c2ee6e8
     r8 = 0x00007fff669f5b8c    r9 = 0x0000000000000000
    r10 = 0x00007fff669f8d26   r11 = 0x00007fff66a0af20
    r12 = 0x005b327ab9000001   r13 = 0x0000000000000000
    r14 = 0x00007fff66a0af20   r15 = 0x00007fd96a508d10
    rip = 0x00007fff669d609d
    Found by: given as instruction pointer in context
 1  dyld + 0x3df6
    rbp = 0x000000010c2ee720   rsp = 0x000000010c2ee710
    rip = 0x00007fff669d8df6
    Found by: previous frame's frame pointer
 2  libdyld.dylib + 0x12dd
    rbp = 0x000000010c2ee870   rsp = 0x000000010c2ee730
    rip = 0x00007fff86d462dd
    Found by: previous frame's frame pointer
 3  0x109d90008
    rbp = 0x000000010c2ee8d0   rsp = 0x000000010c2ee880
    rip = 0x0000000109d90008
    Found by: previous frame's frame pointer
[...]
Loaded modules:
[...]
0x7fff669d5000 - 0x7fff66a08fff  dyld  0.0.0.0  (WARNING: No symbols, dyld, 1D3130FEFE7E3C4C8E74EB51895B6BA50)
0x7fff83520000 - 0x7fff83593fff  SecurityFoundation  55122.3.0.0
0x7fff8362d000 - 0x7fff837e5fff  libicucore.A.dylib  51.1.0.0
0x7fff837e6000 - 0x7fff8380dfff  libsystem_info.dylib  449.1.4.0
0x7fff83abf000 - 0x7fff83accfff  libxar.1.dylib  1.0.0.0
0x7fff83c04000 - 0x7fff83c0bfff  liblaunch.dylib  842.92.1.0
0x7fff83c0c000 - 0x7fff83cd6fff  LaunchServices  572.32.0.0
0x7fff83dd2000 - 0x7fff83dd6fff  libGIF.dylib  1.0.0.0
0x7fff83e12000 - 0x7fff83e42fff  libncurses.5.4.dylib  5.4.0.0
0x7fff841ae000 - 0x7fff8423efff  Metadata  800.30.0.0
0x7fff842d4000 - 0x7fff842d5fff  libremovefile.dylib  33.0.0.0
0x7fff84387000 - 0x7fff84475fff  libJP2.dylib  1.0.0.0
0x7fff84476000 - 0x7fff84481fff  libkxld.dylib  1.0.0.0
0x7fff844a0000 - 0x7fff844a8fff  libsystem_dnssd.dylib  522.92.3.0
0x7fff846b4000 - 0x7fff846cbfff  CFOpenDirectory  1.0.0.0
0x7fff84e1c000 - 0x7fff851fdfff  libLAPACK.dylib  1.0.0.0
0x7fff85bd0000 - 0x7fff85c92fff  CoreText  1.0.0.0
0x7fff85c93000 - 0x7fff85ce0fff  PrintCore  428.0.0.0
0x7fff85d6d000 - 0x7fff85de4fff  OSServices  600.4.0.0
0x7fff85de5000 - 0x7fff85deffff  ServiceManagement  1.0.0.0
0x7fff85e38000 - 0x7fff85e53fff  libCRFSuite.dylib  1.0.0.0
0x7fff85e84000 - 0x7fff85e84fff  libkeymgr.dylib  28.0.0.0
0x7fff85e85000 - 0x7fff85e89fff  libheimdal-asn1.dylib  1.0.0.0
0x7fff85ea1000 - 0x7fff85ea8fff  libcopyfile.dylib  103.92.1.0
0x7fff85ea9000 - 0x7fff85eb9fff  libbsm.0.dylib  1.0.0.0
0x7fff85eba000 - 0x7fff85ec1fff  libsystem_pthread.dylib  53.1.4.0  (WARNING: No symbols, libsystem_pthread.dylib, AB498556B555310E9041F67EC9E00E2C0)
0x7fff85ec2000 - 0x7fff85ec2fff  CoreServices  59.0.0.0
0x7fff85f20000 - 0x7fff85f27fff  NetFS  1.0.0.0
0x7fff864b2000 - 0x7fff864bdfff  NetAuth  1.0.0.0
0x7fff864e1000 - 0x7fff86751fff  Security  55471.14.40.0
0x7fff867a4000 - 0x7fff867adfff  libsystem_notify.dylib  121.20.1.0
0x7fff867d7000 - 0x7fff867dcfff  libunwind.dylib  35.3.0.0
0x7fff86813000 - 0x7fff86815fff  libquarantine.dylib  71.0.0.0
0x7fff86816000 - 0x7fff86827fff  libsystem_asl.dylib  217.1.4.0
0x7fff86887000 - 0x7fff868abfff  libxpc.dylib  300.90.2.0
0x7fff869ad000 - 0x7fff86aa7fff  libFontParser.dylib  1.0.0.0
0x7fff86ad3000 - 0x7fff86b2cfff  libTIFF.dylib  1.0.0.0
0x7fff86b69000 - 0x7fff86cbdfff  AudioToolbox  492.0.0.0
0x7fff86d45000 - 0x7fff86d48fff  libdyld.dylib  239.5.0.0  (WARNING: No symbols, libdyld.dylib, CAE7A50DF1563D4781C0DC41EB975D380)
0x7fff878c0000 - 0x7fff8792dfff  ATS  236.0.0.0
0x7fff8794d000 - 0x7fff8794dfff  vecLib  423.32.0.0
0x7fff87efb000 - 0x7fff87f40fff  HIServices  468.0.0.0
0x7fff87f4c000 - 0x7fff87f56fff  libcommonCrypto.dylib  60049.0.0.0
0x7fff88229000 - 0x7fff8823afff  libz.1.dylib  1.2.5.0
0x7fff8841f000 - 0x7fff88421fff  libsystem_configuration.dylib  596.15.0.0
0x7fff88422000 - 0x7fff88423fff  libsystem_sandbox.dylib  278.11.2.0
0x7fff8842b000 - 0x7fff8842bfff  ApplicationServices  48.0.0.0
0x7fff88441000 - 0x7fff88442fff  TrustEvaluationAgent  25.0.0.0
0x7fff8848a000 - 0x7fff884a5fff  libsystem_malloc.dylib  23.10.1.0  (WARNING: No symbols, libsystem_malloc.dylib, A695B4E438E9332EA77229D31E3F13850)
0x7fff884a9000 - 0x7fff8859afff  libiconv.2.dylib  7.0.0.0
0x7fff886d0000 - 0x7fff886dcfff  OpenDirectory  1.0.0.0
0x7fff88758000 - 0x7fff887a6fff  libcorecrypto.dylib  1.0.0.0
0x7fff887d2000 - 0x7fff8885bfff  ColorSync  4.7.0.0
0x7fff89c2a000 - 0x7fff89c43fff  Kerberos  6.0.0.0
0x7fff89c44000 - 0x7fff89c45fff  liblangid.dylib  1.0.0.0
0x7fff89ea8000 - 0x7fff89eadfff  libmacho.dylib  845.0.0.0
0x7fff8a24a000 - 0x7fff8a266fff  libsystem_kernel.dylib  2422.115.15.0  (WARNING: No symbols, libsystem_kernel.dylib, 34ABAF79E1473C34B05D46A566E689CC0)
0x7fff8a278000 - 0x7fff8a328fff  libvMisc.dylib  423.32.0.0
0x7fff8a342000 - 0x7fff8a3a5fff  SystemConfiguration  596.15.0.0
0x7fff8a425000 - 0x7fff8a42efff  CommonAuth  1.0.0.0
0x7fff8a5a7000 - 0x7fff8a5d0fff  libc++abi.dylib  49.1.0.0
0x7fff8a5d1000 - 0x7fff8a5edfff  libresolv.9.dylib  1.0.0.0
0x7fff8a6eb000 - 0x7fff8a71afff  libsystem_m.dylib  3047.16.0.0
0x7fff8a730000 - 0x7fff8a757fff  libsystem_network.dylib  241.4.0.0
0x7fff8abd1000 - 0x7fff8abf5fff  libJPEG.dylib  1.0.0.0
0x7fff8ad46000 - 0x7fff8b01afff  vImage  271.0.0.0
0x7fff8b20b000 - 0x7fff8b294fff  libsystem_c.dylib  997.90.5.0  (WARNING: No symbols, libsystem_c.dylib, 889AA3F9121C39858B1D5E908C5693BC0)
0x7fff8b4ac000 - 0x7fff8b4b0fff  libsystem_stats.dylib  93.90.3.0
0x7fff8b569000 - 0x7fff8b578fff  LangAnalysis  1.0.0.0
0x7fff8b579000 - 0x7fff8b579fff  Accelerate  4.0.0.0
0x7fff8bca4000 - 0x7fff8bcbffff  libPng.dylib  1.0.0.0
0x7fff8bccd000 - 0x7fff8bccdfff  libOpenScriptingUtil.dylib  1.0.0.0
0x7fff8be35000 - 0x7fff8c75efff  CoreGraphics  600.0.0.0
0x7fff8cac1000 - 0x7fff8cb08fff  libFontRegistry.dylib  1.0.0.0
0x7fff8cbaf000 - 0x7fff8cbb0fff  libsystem_blocks.dylib  63.0.0.0
0x7fff8d035000 - 0x7fff8d03bfff  libsystem_platform.dylib  24.90.1.0
0x7fff8d03c000 - 0x7fff8d03ffff  IOSurface  1.0.0.0
0x7fff8d071000 - 0x7fff8d371fff  Foundation  1056.17.0.0
0x7fff8d372000 - 0x7fff8d3d6fff  DataDetectorsCore  354.5.0.0
0x7fff8d4fd000 - 0x7fff8d4fffff  libRadiance.dylib  1.0.0.0
0x7fff8d500000 - 0x7fff8d501fff  libDiagnosticMessagesClient.dylib  1.0.0.0
0x7fff8df59000 - 0x7fff8df66fff  libbz2.1.0.dylib  1.0.5.0
0x7fff8e11e000 - 0x7fff8e127fff  SpeechSynthesis  1.0.0.0
0x7fff8e1df000 - 0x7fff8e2c9fff  libsqlite3.dylib  158.0.0.0
0x7fff8e2ca000 - 0x7fff8e2cdfff  TCC  1.0.0.0
0x7fff8e2ce000 - 0x7fff8e2cffff  libSystem.B.dylib  1197.1.1.0
0x7fff8e32c000 - 0x7fff8e387fff  AE  665.6.0.0
0x7fff8ea6a000 - 0x7fff8ea92fff  libxslt.1.dylib  3.26.0.0
0x7fff8ea93000 - 0x7fff8eb7bfff  libxml2.2.dylib  10.9.0.0
0x7fff8eb86000 - 0x7fff8ebebfff  Heimdal  1.0.0.0
0x7fff8ec48000 - 0x7fff8ef32fff  CarbonCore  1077.17.0.0
0x7fff8ef33000 - 0x7fff8f03afff  ImageIO  1.0.0.0
0x7fff8f0c1000 - 0x7fff8f12dfff  IOKit  275.0.0.0
0x7fff8f21e000 - 0x7fff8f3cbfff  libobjc.A.dylib  228.0.0.0
0x7fff8f58c000 - 0x7fff8f58dfff  libunc.dylib  28.0.0.0
0x7fff8f58e000 - 0x7fff8f659fff  libvDSP.dylib  423.32.0.0
0x7fff8f65a000 - 0x7fff8f674fff  libdispatch.dylib  339.92.1.0  (WARNING: No symbols, libdispatch.dylib, C4E4A18D3C3B3C9C8709A4270D998DE70)
0x7fff8f71f000 - 0x7fff8f771fff  libc++.1.dylib  120.0.0.0
0x7fff8fca0000 - 0x7fff8fcd9fff  QD  298.0.0.0
0x7fff8ff1e000 - 0x7fff8ff22fff  libcache.dylib  62.0.0.0
0x7fff8ff23000 - 0x7fff8ff65fff  libauto.dylib  1.0.0.0
0x7fff8ff66000 - 0x7fff8ff6dfff  libcompiler_rt.dylib  35.0.0.0
0x7fff8ff71000 - 0x7fff8ff75fff  libpam.2.dylib  3.0.0.0
0x7fff902c7000 - 0x7fff90318fff  CoreAudio  1.0.0.0
0x7fff90319000 - 0x7fff9031efff  DiskArbitration  1.0.0.0
0x7fff903aa000 - 0x7fff90545fff  CFNetwork  673.6.0.0
0x7fff90546000 - 0x7fff9056ffff  DictionaryServices  1.0.0.0
0x7fff905ee000 - 0x7fff907d3fff  CoreFoundation  855.17.0.0
0x7fff90833000 - 0x7fff909a1fff  libBLAS.dylib  1.0.0.0
0x7fff90c01000 - 0x7fff90c48fff  libcups.2.dylib  2.10.0.0
0x7fff90c49000 - 0x7fff90c78fff  GSS  1.0.0.0
0x7fff90c79000 - 0x7fff90ce6fff  SearchKit  200.1.0.0
4

1 回答 1

2

我对 Crashpad 不是很熟悉,但是通过查看报告,我想我知道发生了什么。

一般来说,您的符号化过程适用于任何库——您的或 Apple 的。你只需要指向atos一个符号源,给它加载地址+偏移量,你就很好了。dSYM 是很好的来源,但可执行文件也可以是来源。

但是,关键部分是访问与崩溃发生时加载到您的进程中的库版本相匹配的符号源。为了帮助完成此过程,Apple 平台上的二进制文件由 UUID 标识。您可以使用 读取此 uuid dwarfdump -u /path/to/binary

一种方法是在发生崩溃的设备上尝试符号化过程。这就是 ReportCrash 的工作原理。而且,为什么它可以象征苹果的二进制文件。原因(我假设)它无法为您的应用程序工作是您从工件中删除符号。

然而,以这种方式进行符号化有一些缺点。一大问题是您通常无法访问 dSYM。dSYM 包含比地址->符号信息更多的信息。所以,如果可以的话,你肯定想使用它们。

另一种方法是事后进行符号化,仅使用报告中的数据。这样做的最大问题是您仍然需要访问符号源。根据您再次发布的报告,Crashpad 的符号系统似乎可以找到/加载dyld. 有用的是,它包含该特定二进制文件的 uuid。但是,如果您碰巧没有 10.9.5 (13F1911) 附带的 dyld 副本,那么您就不走运了。即使访问 10.9 的 macOS SDK 也是不够的,因为您需要特定的构建。

鉴于 CrashPad 对这么少的二进制文件产生了警告,它似乎至少应该尝试做一些符号化。也许需要一些额外的配置?我知道 Apple 几年前对符号查找 API 进行了一些修改(我相信是 iOS 7 时间框架),这使得设备上的符号化过程更加复杂。难道是CrashPad从那以后就没有更新了吗?

这是托管崩溃报告系统存在的原因之一。Crashlytics(我曾经从事的一项服务)为所有平台的每个 Apple OS 版本编制索引,以便它可以进行高质量的服务器端符号化来解决这个问题。还有很多其他服务。您是否考虑过托管解决方案?

于 2018-07-11T13:10:48.557 回答