我用以下算法表示:
。
以及
stack address
is the hex value I get from my stack dump crash report (not a .crash file, just the stack dump).
以及
<代码>slide 是LC_ 的 v。 运行<代码>otool -arch armv7 -l App_BINaire_PATH时的分数。 地雷通常为0x00001000。
以及
load address
is the complicated piece. It is actually the difference between the bottommost stack address of the main thread 以及 the FIRST address of the portion of my binary that contains symbols when running dwarfdump --arch armv7 --all DSYM_BINARY_PATH
. This is simply the symbolic address of the main
function. So if your bottom most crash address is 0x8000 以及 your main function s symbolic address is 0x2000 then your load address
is 0x6000.
Now with ALL these pieces I can calculate the symbol address 以及 put that into atos or dwarfdump: dwarfdump --lookup SYM_ADDR --arch armv7 APP_BINARY_PATH
.
倾销实例(见load Address
0x00003af4):
档案: /用户/用户/Desktop/MyApp.xcarchive/dSYMs/MyApp.app.dSYM/Contents/Resources/DWARF/MyApp(armv7)
0x00024:[0x00003af4 - 0x00003b4e]
0x00098: [0x00003b50 - 0x00003d8c] - [MyAppDelegate application: doFinishLaunching WithOptions:]
......倾销的其余部分
最困难的部分是认识到,我所包括的2个静态图书馆之一在与我的双手连接之前就已失去其标志! 这留下了捷克共和国的文号空白,因此,我最后只剩下我海关需要的三分之二符号。
Be sure to have the following flags set to NO in your static libraries xcode project so that when you link against it, you can pull in the symbols to your app s binary (which can later be stripped): COPY_PHASE_STRIP
, DEAD_CODE_STRIPPING
, 以及 STRIP_INSTALLED_PRODUCT
.
Now you may ask, "what do I do if the stack dump does not include the main function since it isn t on the main thread so that I cannot get the main function s stack address?". To that I would reply, "I haven t a friggin clue!". Just cross your fingers 以及 hope you can get a stack trace that includes the symbol address or use a crash reporting system that mimics Apple s crash logs, like PLCrashReporter.
[EDIT May 26,2013] ——
提请我注意,<代码>上载实际上是双向地址。 虽然我前面描述的内容往往可以奏效,但实际上并不正确。 可以通过讲卫生运动报告获得,但答案的点是在你没有坠毁报告时提供坠毁的标志。 在希望具有象征意义时,I ve最能将load/code> 填入“<<>>,即通过确保I登录load
与stack Address/code>。
I ve personally created a system for logging crashes (not crash reports) 以及 having them sent to an S3 bucket where I can retrieve them later for debugging. When I start my application I cache the slide
, the load address
以及 the main function address
for use if my app crashes 以及 I send up a the stack addresses
.
NOTE: The dyld functions use #include <mach-o/dyld.h>
。
。
main function address
= the last address in [NSThread callStackReturnAddresses]
when
called on the main thread
At crash time I m sure to log [NSThread callStackReturnAddresses]
以及 [NSThread callStackSymbols]
as well as the architecture which can be retrieve by having this method:
- (NSString*) arch
{
NSString* arch =
#ifdef _ARM_ARCH_7
@"armv7";
#elif defined (_ARM_ARCH_6)
@"armv6";
#else
nil;
#endif
return arch;
}
I don t yet know how to differentiate between armv7 以及 armv7s though.
So this may help in the future. I plan on taking everything I ve learned 以及 turning this into a simple crash tool - better than the natos tool (probably natos v2).
I ve updated natos to support supplying the load address
manually: https://github.com/NSProgrammer/natos