Using breakpad in cocos2d-x 3.2, dump information collection, breakpadcocos2d-x
Author: HU
Reprinted please note, original link: http://www.cnblogs.com/xioapingguo/p/4037268.html
1. Basic Steps
1. Generate conversion tools
2. Add breakpad to the Project
3. Generate *. dmp file (upload server)
4. Use the previously generated Tool to convert *. dmp files into identifiable texts.
Ii. Generate conversion tools
1. Download The BreakPad source code (now google is in harmony, find a free VPN. PS: Will baidu always be used for contempt)
Svn checkout http://google-breakpad.googlecode.com/svn/trunk/ breakpad
2. The generation tools dump_syms and minidump_stackwalk are slightly different for IOS and android.
① Enter the code path
Cd breakpad
② Configure the environment
./Configure
③ Compilation tool
Make
Android is executed in Linux and IOS on MAC.
Android: dump_syms, in breakpad/src/tools/linux/dump_syms
Minidump_stackwalk in breakpad/src/processor/minidump_stackwalk
IOS: dump_syms: Use xcode to Open google-breakpad-read-only/src/tools/mac/symupload. xcodeproj and compile it.
Note that several errors will occur during compilation: 1. Change SDKROOT in ubuntures to Latest OS x (OS X 10.x)
2. Because C ++ 11 has changed the keyword typeof to decltype, replace all types in linux_dumper.h and enteir_wrapper.h.
Minidump_stackwalk in breakpad/src/processor/minidump_stackwalk
3. Add breakpad to the Project
IOS: 1. one method is to put/breakpad/src/client/ios/Breakpad. xcodeproj, and then add Breakpad to Target Dependencies> Build Phasesk, and libBreakpad to Link Binary With Libraries. a
Another method is to directly add the breakpad/src/libBreakpad. A generated during make to the project.
2. Add the breakpad path to Build Settings-> Header Search Paths.
3. Add # import "client/ios/BreakpadController. h" to AppController. mm"
Add didfinishlaunchingwitexceptions
-(BOOL) application :( UIApplication *) application didfinishlaunchingwitexceptions :( NSDictionary *) launchOptions {
[[BreakpadController sharedInstance] start: YES];
[[BreakpadController sharedInstance] setUploadingEnabled: YES];
Window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen] bounds];
......
......
Return YES;
}
Add to applicationWillTerminate
-(Void) applicationWillTerminate :( UIApplication *) application {
/*
Called when the application is about to terminate.
See also applicationDidEnterBackground :.
*/
[[BreakpadController sharedInstance] stop];
}
Android: 1. One method is to directly add the src/client/linux/libbreakpad_client.a generated during the above make operation. The specific method and other methods are added. A is the same (I have not tried this method myself ).
Another method: First Modify/breakpad/android/Android. mk and add LOCAL_SRC_FILES.
Client/linux/dump_writer_common/thread_info.cc \
Client/linux/dump_writer_common/ucontext_reader.cc \
2. I added the code to javaactivity. in cpp, so I found/cocos2d/cocos/platform/android/Android. add LOCAL_WHOLE_STATIC_LIBRARIES to mk and breakpad_client to the end of the file (call import-module, breakpad/client/android). (note the path yourself)
3. Add # include "breakpad/client/linux/handler/exception_handler.h" to javaactivity. cpp. (note the path)
In
Jint JNI_OnLoad (JavaVM * vm, void * reserved) {JniHelper: setJavaVM (vm); google_breakpad: MinidumpDescriptor descriptor ("/sdcard/test "); // generate the dump file path and set it before the test directory. Handler = new google_breakpad: ExceptionHandler (descriptor, NULL, true,-1); return JNI_VERSION_1_4 ;}
4. Generate *. dmp file (uploaded to the server, which has not been tried yet)
Simulate a crash for testing. Add helloworld in cocos2dx
void HelloWorld::menuCloseCallback(Ref* pSender){int *i = NULL; *i = 1; return;}
In this case, as long as you press the exit button in the helloworld example, the program will crash and exit (it seems that the program cannot be generated during debugging in IOS, And it will run directly after being compiled ).
Then generate the XXXXXX-XXXXX-XXX-XXXX.dmp in the/Library/Caches directory under IOS, note that the simulator directory in xcode6 has changed/Users/xxxxx/Library/Developer/CoreSimulator
Android is in the/sdcard/test/set previously (the directory must be created first, otherwise it may not be generated successfully ).
5. Convert the *. dmp file into identifiable text using the previously generated Tool
In IOS, it is in the MAC environment (it seems to be required, but it has never been used in linux)
1. For the convenience of creating a folder, we should call it crash. Then, we should test. app. dSYM (assume the project name is test) and set minidump_stackwalk, dump_syms, role (assume that the project name is test)
2../dump_syms test. app. dSYM> test. sym
Open the first line in the generated testcpp. sym notepad and you will see: MODULE mac armv7 1FA72B1E07FD36DAB327A300E7AC86450 test
3. Use that string to execute the following command
Mkdir-p symbols/test/1FA72B1E07FD36DAB327A300E7AC86450
Mv test. sym symbols/test/1FA72B1E07FD36DAB327A300E7AC86450
4. Use the dump file.
./Minidump_stackwalk 92216F16-A538-461F-99FE-B1CB2C99AC1C.dmp./symbols> crashed. log
5. You can see where the error is (the HelloWorld: menuCloseCallback (cocos2d: Ref *) method in line 531st of HelloWorldScene. cpp)
Android must be used in linux.
1. Just like IOS, we can create a folder named crash for convenience, and then call minidump_stackwalk, dump_syms, Runtime (the assumed dmp file), and libcocos2dcpp. so (/proj. android/obj/local/armeabi)
2,./Dump_syms libcocos2dcpp. so> libcocos2dcpp. so. sym
Use busybox head-n1 libcocos2dcpp. so. sym to obtain the first line: MODULE Linux arm 7c0000da3c5cf634b4b59f034c2dffb80 libcocos2dcpp. so
3. Use that string to execute the following command
Mkdir-p./symbols/libcocos2dcpp. so/7c%da3c5cf634b4b59f034c2dffb80
Mv libcocos2dcpp. so. sym./symbols/libcocos2dcpp. so/7c%da3c5cf634b4b59f034c2dffb80
4. Use the dump file.
./Minidump_stackwalk 4b09b77b-0b49-e55f-11afa2c2-3d4c4ead.dmp./symbols> crashed. log
5. You can see where the error is (the HelloWorld: menuCloseCallback (cocos2d: Ref *) method in line 539th of HelloWorldScene. cpp)
Now, this is done. (The Code seems to have provided the dump upload function. I have not tried it. I will update it after it is successful. In addition, it is too troublesome to parse the dump file, A batch processing command can be used for parsing)