Enable tcmalloc's logging in Android.

BUG=162208
R=bulach@chromium.org, willchan@chromium.org

Review URL: https://codereview.chromium.org/14845011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@198879 0039d316-1c4b-4281-b951-d872f2087c98
parent 70f02ffc
...@@ -56,6 +56,10 @@ ...@@ -56,6 +56,10 @@
// do logging on a best-effort basis. // do logging on a best-effort basis.
#if defined(_MSC_VER) #if defined(_MSC_VER)
#define WRITE_TO_STDERR(buf, len) WriteToStderr(buf, len); // in port.cc #define WRITE_TO_STDERR(buf, len) WriteToStderr(buf, len); // in port.cc
#elif defined(__ANDROID__) || defined(ANDROID)
#include <android/log.h>
#define WRITE_TO_STDERR(buf, len) \
__android_log_write(ANDROID_LOG_ERROR, "gperftools", buf)
#elif defined(HAVE_SYS_SYSCALL_H) #elif defined(HAVE_SYS_SYSCALL_H)
#include <sys/syscall.h> #include <sys/syscall.h>
#define WRITE_TO_STDERR(buf, len) syscall(SYS_write, STDERR_FILENO, buf, len) #define WRITE_TO_STDERR(buf, len) syscall(SYS_write, STDERR_FILENO, buf, len)
...@@ -204,7 +208,30 @@ inline void LogPrintf(int severity, const char* pat, va_list ap) { ...@@ -204,7 +208,30 @@ inline void LogPrintf(int severity, const char* pat, va_list ap) {
assert(strlen(buf)+1 < sizeof(buf)); assert(strlen(buf)+1 < sizeof(buf));
strcat(buf, "\n"); strcat(buf, "\n");
} }
#if defined(__ANDROID__) || defined(ANDROID)
android_LogPriority priority = ANDROID_LOG_UNKNOWN;
switch (severity) {
case INFO: {
priority = ANDROID_LOG_INFO;
break;
}
case WARNING: {
priority = ANDROID_LOG_WARN;
break;
}
case ERROR: {
priority = ANDROID_LOG_ERROR;
break;
}
case FATAL: {
priority = ANDROID_LOG_FATAL;
break;
}
}
__android_log_write(priority, "gperftools", buf);
#else // defined(__ANDROID__) || defined(ANDROID)
WRITE_TO_STDERR(buf, strlen(buf)); WRITE_TO_STDERR(buf, strlen(buf));
#endif // defined(__ANDROID__) || defined(ANDROID)
if ((severity) == FATAL) { if ((severity) == FATAL) {
// LOG(FATAL) indicates a big problem, so don't run atexit() calls // LOG(FATAL) indicates a big problem, so don't run atexit() calls
tcmalloc::Abort(); tcmalloc::Abort();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment