[asan] Add support for Android debug message.

Add ASan report to the "debug message" field in Android tombstones.

llvm-svn: 306184
This commit is contained in:
Evgeniy Stepanov
2017-06-23 23:38:20 +00:00
parent 4b2f8a4b87
commit 90e5c30836
3 changed files with 18 additions and 0 deletions

View File

@@ -204,6 +204,14 @@ class ScopedInErrorReport {
error_report_callback(buffer_copy.data());
}
if (halt_on_error_ && common_flags()->abort_on_error) {
// On Android the message is truncated to 512 characters.
// FIXME: implement "compact" error format, possibly without, or with
// highly compressed stack traces?
// FIXME: or just use the summary line as abort message?
SetAbortMessage(buffer_copy.data());
}
// In halt_on_error = false mode, reset the current error object (before
// unlocking).
if (!halt_on_error_)

View File

@@ -810,8 +810,11 @@ INLINE void LogMessageOnPrintf(const char *str) {}
#if SANITIZER_LINUX
// Initialize Android logging. Any writes before this are silently lost.
void AndroidLogInit();
void SetAbortMessage(const char *);
#else
INLINE void AndroidLogInit() {}
// FIXME: MacOS implementation could use CRSetCrashLogMessage.
INLINE void SetAbortMessage(const char *) {}
#endif
#if SANITIZER_ANDROID

View File

@@ -551,6 +551,13 @@ void LogMessageOnPrintf(const char *str) {
WriteToSyslog(str);
}
#if SANITIZER_ANDROID && __ANDROID_API__ >= 21
extern "C" void android_set_abort_message(const char *msg);
void SetAbortMessage(const char *str) { android_set_abort_message(str); }
#else
void SetAbortMessage(const char *str) {}
#endif
#endif // SANITIZER_LINUX
} // namespace __sanitizer