Where I can place global catch(…) in android cocos2dx project in order to able to collect all the cpp exceptions in my project?
I have a cocos2dx project for presentation display for android.
When my cpp code crashed I want to be able to catch all the exceptions and at least shutdown gracefuly.
(And at max - collect the logs and save them \ send to server).
I know that cpp exceptions can’t go to JAVA on android. So I think solution can be, at first, to be able to catch all cpp exceptions. At windows I have main.cpp when I can place global catch(...) like that:
but at android its different.
Maybe there is some good solution for such, I suppose, often problem?
Ok then,
first - crashliticas can’t do send logs to another server, and its works highly rely on android Activity, so my original question is still remains active.
The questions is what is the simple way of implementing exception intercepting above cocos app?
I wonder, maybe catch exceptions somewhere at Java_org_cocos2dx_lib_Cocos2dxRenderer.cpp around cocos2d::Director::getInstance()->mainLoop(); call ? Or in that case I will miss something?
Unless you’re trying to get rid of Crashlytics so that you don’t have to include their SDK or rely on them I would recommend just using their SDK and integration.
First off I’d try to catch errors where they occur. Possibly compile w/exceptions and try/catch around code you know may fail. Check for error values or errno after suspect calls.
You’ll prob want to catch Java’s unhandled exceptions and NDK’s signals (SIGSEGV, et al) for all crashes within your or cocos2d-x’s C/C++ code.
LMGTFY (prob repeat some links, but did a quick research session)
You should be able to set up two different handlers for global exceptions. You’ll need to serialize/parse the stack traces and figure out how to send the data you want back to your server.
Thanks for the links! I will try it soon and report how it will go (together with integrate android sturdo build - debug (cocos 15 where are you?))).
Frankly, I doubt that crashlitics can provide good stacktrace for cpp crash (more than just SIGFAULT somewhere but It would be great if it can).
Google has acquired Crashlytics to make it part of their Firebase exception reporting. It is really hard to get C++ stack traces and Crashlytics is very good at unwinding the stack.