如何从 iOS 崩溃日志中获取汇编代码

问题描述

我正在处理难以重现的内存崩溃问题,并使用 wwdc18 session 414 中提供的指南以及来自此 so article 的其他线索进行故障排除

表示堆栈跟踪没有问题(见底部),但是当我尝试从最后一帧反汇编地址时,我从 lldb 控制台收到此错误

(lldb) disassemble -a 0x00000001052faed4
error: error reading data from section __text
error: Failed to disassemble memory in function at 0x1052faed4.

内存崩溃很困难,在这种情况下,我真的需要从汇编代码获取更多线索来解决问题。

遗憾的是,WWDC 视频在设置/配置过程中飞速运行,表明它应该正常工作...但它没有。我怀疑视频中可能缺少某些关键配置?有谁知道如何获得汇编代码

作为参考,这是符号化堆栈跟踪的顶部(显示崩溃线程)

Thread[0] EXC_BAD_ACCESS (SIGSEGV) (KERN_INVALID_ADDRESS at 0x8000000000000010 -> 0x0000000000000010 (possible pointer authentication failure))
[  0] 0x00000001052faed4 myApp`Flux.FASFluxdispatcher.invokeCallback(token: Swift.String) -> () + 60
[  1] 0x00000001052faecf myApp `Flux.FASFluxdispatcher.invokeCallback(token: Swift.String) -> () + 55
[  2] 0x00000001052fb2eb myApp `closure #1 () -> () in Flux.FASFluxdispatcher.dodispatch(action: Any) -> () + 195
[  3] 0x00000001052feeb7 myApp `partial apply forwarder for reabstraction thunk helper from @callee_guaranteed () -> (@error @owned Swift.Error) to @escaping @callee_guaranteed () -> (@out (),@error @owned Swift.Error) + 19
[  4] 0x00000001bff1ef30 autoreleasepool<A>(invoking:) + 64 (ObjectiveC.swift:172)
[  5] 0x00000001052fb5af myApp `Flux.FASFluxdispatcher.dispatchAction(action: Any) -> () + 339
[  6] 0x00000001052ff77f myApp `partial apply forwarder for closure #1 () -> () in Flux.FASActionCreator.dispatchAsync(action: Any,completion: Swift.Optional<() -> ()>) -> () + 111
[  7] 0x00000001052fc0bf myApp `reabstraction thunk helper from @escaping @callee_guaranteed () -> () to @escaping @callee_uNowned @convention(block) () -> () + 19
[  8] 0x000000019967024c _dispatch_call_block_and_release + 32 (init.c:1454)
[  9] 0x0000000199671db0 _dispatch_client_callout + 20 (object.m:559)
[ 10] 0x000000019967f7ac _dispatch_main_queue_callback_4CF + 836 (inline_internal.h:2548)
[ 11] 0x00000001999f911c __CFRUNLOOP_IS_SERVICING_THE_MAIN_disPATCH_QUEUE__ + 16 (CFRunLoop.c:1790)
[ 12] 0x00000001999f3120 __CFRunLoopRun + 2508 (CFRunLoop.c:3118)
[ 13] 0x00000001999f221c CFRunLoopRunSpecific + 600 (CFRunLoop.c:3242)
[ 14] 0x00000001b15bc784 GSEventRunModal + 164 (GSEvent.c:2259)
[ 15] 0x000000019c432ee8 -[UIApplication _run] + 1072 (UIApplication.m:3253)
[ 16] 0x000000019c43875c UIApplicationMain + 168 (UIApplication.m:4707)
[ 17] 0x0000000104edcf67 myApp `main + 67 at AppDelegate.swift:29:9
[ 18] 0x00000001996b26b0 start + 4

Thread[1]
[  0] 0x00000001c79cd1ac __psynch_cvwait + 8
[  1] etc...

解决方法

dSYM 中的 DWARF 文件只有符号信息和调试信息,它不包含二进制文件的文本和数据段的完整副本。如果文件系统上的 dSYM 旁边有二进制文件的副本,lldb 将在加载 dSYM 时加载该副本。或者您可以使用 target modules add 命令告诉 lldb 将二进制文件加载到当前会话中。