-
Notifications
You must be signed in to change notification settings - Fork 14
Feature/crash loop detection #80
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 2 commits
9898625
5528917
74c574c
6aa61c1
6f67d1f
ff7cf06
3480c11
a069cca
cac04c1
483f630
9f6b1c8
017ff99
67a92a3
a156236
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,8 @@ | |
| #include <jni.h> | ||
| #include <libgen.h> | ||
|
|
||
| //#include "client/crashpad_client.h" | ||
konst-sauce marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| extern std::string thread_id; | ||
| extern std::atomic_bool initialized; | ||
| extern std::mutex attribute_synchronization; | ||
|
|
@@ -11,6 +13,8 @@ extern std::atomic_bool disabled; | |
| static crashpad::CrashpadClient *client; | ||
| static std::unique_ptr<crashpad::CrashReportDatabase> database; | ||
|
|
||
| static int consecutive_crashes_count = 0; | ||
|
|
||
| bool InitializeCrashpad(jstring url, | ||
| jstring database_path, | ||
| jstring handler_path, | ||
|
|
@@ -19,6 +23,9 @@ bool InitializeCrashpad(jstring url, | |
| jobjectArray attachmentPaths, | ||
| jboolean enableClientSideUnwinding, | ||
| jint unwindingMode) { | ||
|
|
||
konst-sauce marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Initialize Crashpad Start"); | ||
|
|
||
| // avoid multi initialization | ||
| if (initialized) { | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad is already initialized"); | ||
|
|
@@ -120,9 +127,19 @@ bool InitializeCrashpad(jstring url, | |
|
|
||
| // Start crash handler | ||
| client = new crashpad::CrashpadClient(); | ||
|
|
||
| initialized = client->StartHandlerAtCrash(handler, db, db, backtraceUrl, attributes, | ||
| arguments); | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad created."); | ||
| client->EnableCrashLoopDetection(); | ||
|
||
|
|
||
| // Get consecutive crashes count BEFORE any handler started, | ||
| // as it writes extra line into CSV, what leads to getting 0 for each next ConsecutiveCrashesCount call | ||
| consecutive_crashes_count = crashpad::CrashpadClient::ConsecutiveCrashesCount(db); | ||
konst-sauce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad initialize - ConsecutiveCrashesCount %d", consecutive_crashes_count); | ||
| // initialized = client->StartHandler(handler, db, db, backtraceUrl, attributes, arguments, false, false); | ||
| // handler, db, db, url, annotations, arguments, false, false, {} | ||
| // Original | ||
| initialized = client->StartHandlerAtCrash(handler, db, db, backtraceUrl, attributes, arguments); | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad initialized %s", (initialized ? "TRUE" : "FALSE")); | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad db: %s", filePath); | ||
|
|
||
| env->ReleaseStringUTFChars(url, backtraceUrl); | ||
| env->ReleaseStringUTFChars(handler_path, handlerPath); | ||
|
|
@@ -219,10 +236,28 @@ void ReEnableCrashpad() { | |
| // Re-enable uploads if disabled | ||
| if (disabled) { | ||
| if (database == nullptr) { | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Crashpad database is null, this should not happen"); | ||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", | ||
| "Crashpad database is null, this should not happen"); | ||
| return; | ||
| } | ||
| database->GetSettings()->SetUploadsEnabled(true); | ||
| disabled = false; | ||
| } | ||
| } | ||
|
|
||
| bool EnableCrashLoopDetectionCrashpad() { | ||
konst-sauce marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| __android_log_print(ANDROID_LOG_ERROR, "Backtrace-Android", "Inside EnableCrashLoopDetectionCrashpad"); | ||
| if (client != nullptr) { | ||
| return client->EnableCrashLoopDetection(); | ||
| } else { | ||
| return false; | ||
| } | ||
| } | ||
|
|
||
| bool IsSafeModeRequiredCrashpad() { | ||
| return consecutive_crashes_count >= 5; | ||
| } | ||
|
|
||
| int ConsecutiveCrashesCountCrashpad() { | ||
| return consecutive_crashes_count; | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.