I use marmalade sdk and there is no support for structured exceptions handling. I need to catch any exception (null pointer, devision by zero or any else) and do some actions before app will crashed (send crash report). How can I do this in native c++ under gcc-arm compiller?
Asked
Active
Viewed 2,539 times
0
-
What did you try? Where did it fail?? – πάντα ῥεῖ Mar 26 '14 at 10:43
-
There is a bug in game app, but it don't repeats after reload and doing the same thing. I want to store some last game actions that user done before app crashes and send it by email after that. – user3463684 Mar 26 '14 at 11:17
2 Answers
0
I need to catch any exception
To do so you can use the ellipsis syntax of catch
:
try {
doStuff(); // May throw
}
// catch all exceptions derived from std::exception
catch(const std::exception& ex) {
std::cerr << "Caught exception: '" << ex.what() << "'" << std::endl;
}
catch(...) { // catch everything but unkown
}
Also ensure that your build system doesn't suppress exceptions and RTTI explicitly with the -fno-exceptions
and -fno-rtti
compiler flags.

πάντα ῥεῖ
- 1
- 13
- 116
- 190
-
int main() { try { int* p = NULL; *p = 5; } catch (...) { } } //this code doesn't work as this is not standard c++ exception, but I need catch such exceptions – user3463684 Mar 26 '14 at 12:10
-
Dereferencing a `NULL` pointer doesn't throw an exception. It's just UB to do so. I'm afraid you'll need to put `assert()` calls in your code to catch up with such errors. – πάντα ῥεῖ Mar 26 '14 at 12:12
0
I've already asked it here. I tried it with the flag enable-exceptions=1
in options
. But it never worked for me. There was a thread on Marmalade regarding the exception handling and it was mentioned there that Marmalade doesn't support them and it was demanded by the community to include this.

Community
- 1
- 1

0xC0DED00D
- 19,522
- 20
- 117
- 184
-
enable-exceptions works only for standard c++ exception, but null pointer and segmentation fault is not c++ exceptions. I tried to catch segmentation fault signal, but signal handler not call in marmalade. May be there is any configs for compiller in icf file or anywhere else to turn signals on? – user3463684 Mar 28 '14 at 05:32