我的应用程序中有一些代码向我发送未捕获异常的堆栈跟踪。
"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 未按预期工作.
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
.
当我输入这个问题时,我发现了这一点: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.
}
预先感谢您的任何帮助或指导。