我的应用程序中有一些代码向我发送未捕获异常的堆栈跟踪。
"0 CoreFoundation 0x3ad073ff <redacted> + 186",
"1 libobjc.A.dylib 0x39412963 objc_exception_throw + 30",
"2 CoreFoundation 0x3ad0729d <redacted> + 0",
"3 Foundation 0x39f3b7b3 <redacted> + 90",
"4 UIKit 0x34a3ae29 <redacted> + 4184",
"5 MyApp 0x0001feab -[MAMyClassA firstMethod:withParameter1:andParameter2:] + 374",
"6 MyApp 0x000f76b5 -[MAMyClassB secondMethod:withParameter1:andParameter2:] + 164",
"7 UIKit 0x34bd0fe1 <redacted> + 84",
"8 UIKit 0x34af2047 <redacted> + 70",
"9 UIKit 0x34af1ffb <redacted> + 30",
"10 UIKit 0x34af1fd5 <redacted> + 44",
...
如您所见,Apple 的大多数方法都替换为<redacted>
. 我已经能够使用从 Apple 库中提取符号及其相应的基地址nm
,但地址不匹配。他们落后 1 分。
我已经按照此处的说明计算了地址:iOS 崩溃报告:atos not working as expected。
Symbol address = (base address of framework) - (base address of symbol from crash report) + (virtual memory slide [vmaddr]).
例如,我得到的是 0xC2345,但返回的实际符号地址nm
是 0xC2344。我知道这是正确的符号。我已经在不同的崩溃报告中使用不同框架(UIKit、Foundation、CoreFoundation 等)中的不同地址进行了尝试,结果是相同的:该值始终为 1。我必须从我得到的内容中减去 1崩溃报告以获取由nm
.
当我输入这个问题时,我发现:Wrong method implementation address from otool for armv7? .
这是否意味着每次我要查找地址时都必须执行以下逻辑?
if ((symbol address) mod 2 == 1) {
// This is a thumb instruction so it may be 2 or four bytes
Subtract 1 from the symbol address and then use it to lookup the symbol.
}
else {
// This is a standard 4-byte ARM instruction.
Perform symbol lookup with the address as is.
}
提前感谢您的任何帮助或指导。