summaryrefslogtreecommitdiffstats
path: root/third_party/tcmalloc
diff options
context:
space:
mode:
authordmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 12:05:52 +0000
committerdmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-08 12:05:52 +0000
commita4ccba05f5b9a67c327a4d891712949e2cc1448e (patch)
tree1b3452413285766b6facd92144ea722926338b73 /third_party/tcmalloc
parent70f02ffc235e311a494fb4f6c15c3027fc917bb5 (diff)
downloadchromium_src-a4ccba05f5b9a67c327a4d891712949e2cc1448e.zip
chromium_src-a4ccba05f5b9a67c327a4d891712949e2cc1448e.tar.gz
chromium_src-a4ccba05f5b9a67c327a4d891712949e2cc1448e.tar.bz2
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
Diffstat (limited to 'third_party/tcmalloc')
-rw-r--r--third_party/tcmalloc/chromium/src/base/logging.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/third_party/tcmalloc/chromium/src/base/logging.h b/third_party/tcmalloc/chromium/src/base/logging.h
index 5b5b5db..02f84f4 100644
--- a/third_party/tcmalloc/chromium/src/base/logging.h
+++ b/third_party/tcmalloc/chromium/src/base/logging.h
@@ -56,6 +56,10 @@
// do logging on a best-effort basis.
#if defined(_MSC_VER)
#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)
#include <sys/syscall.h>
#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) {
assert(strlen(buf)+1 < sizeof(buf));
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));
+#endif // defined(__ANDROID__) || defined(ANDROID)
if ((severity) == FATAL) {
// LOG(FATAL) indicates a big problem, so don't run atexit() calls
tcmalloc::Abort();