diff options
author | Mark Salyzyn <salyzyn@google.com> | 2014-04-17 23:12:09 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-04-17 23:12:10 +0000 |
commit | 3ad0af6d0422b1659ad6912802693cffd45be3b9 (patch) | |
tree | 03403563186b1396d6c422692d4d0c6ca42c1c80 | |
parent | 0516aded0e3006272ec390fd418d311e06b1d328 (diff) | |
parent | 99f47a9e7c4374f2bbfc18e4a97aa7848245ea33 (diff) | |
download | system_core-3ad0af6d0422b1659ad6912802693cffd45be3b9.zip system_core-3ad0af6d0422b1659ad6912802693cffd45be3b9.tar.gz system_core-3ad0af6d0422b1659ad6912802693cffd45be3b9.tar.bz2 |
Merge "logd: liblog: logcat: debuggerd: Add LOG_ID_CRASH"
-rw-r--r-- | debuggerd/utility.cpp | 3 | ||||
-rw-r--r-- | include/log/log.h | 1 | ||||
-rw-r--r-- | liblog/log_read.c | 3 | ||||
-rw-r--r-- | liblog/log_read_kern.c | 3 | ||||
-rw-r--r-- | liblog/logd_write.c | 5 | ||||
-rw-r--r-- | liblog/logd_write_kern.c | 3 | ||||
-rw-r--r-- | logcat/logcat.cpp | 20 | ||||
-rw-r--r-- | logd/LogBuffer.cpp | 2 | ||||
-rw-r--r-- | logd/tests/logd_test.cpp | 2 |
9 files changed, 33 insertions, 9 deletions
diff --git a/debuggerd/utility.cpp b/debuggerd/utility.cpp index 9b20914..d4c252f 100644 --- a/debuggerd/utility.cpp +++ b/debuggerd/utility.cpp @@ -24,6 +24,7 @@ #include <sys/wait.h> #include <backtrace/Backtrace.h> +#include <log/log.h> #include <log/logd.h> const int sleep_time_usec = 50000; // 0.05 seconds @@ -64,7 +65,7 @@ void _LOG(log_t* log, int scopeFlags, const char* fmt, ...) { } if (want_log_write) { - __android_log_write(ANDROID_LOG_INFO, "DEBUG", buf); + __android_log_buf_write(LOG_ID_CRASH, ANDROID_LOG_INFO, "DEBUG", buf); if (want_amfd_write) { int written = write_to_am(log->amfd, buf, len); if (written <= 0) { diff --git a/include/log/log.h b/include/log/log.h index d469f40..5b76c1a 100644 --- a/include/log/log.h +++ b/include/log/log.h @@ -550,6 +550,7 @@ typedef enum log_id { LOG_ID_RADIO = 1, LOG_ID_EVENTS = 2, LOG_ID_SYSTEM = 3, + LOG_ID_CRASH = 4, LOG_ID_MAX } log_id_t; diff --git a/liblog/log_read.c b/liblog/log_read.c index 15be748..0ff94bf 100644 --- a/liblog/log_read.c +++ b/liblog/log_read.c @@ -196,7 +196,8 @@ static const char *LOG_NAME[LOG_ID_MAX] = { [LOG_ID_MAIN] = "main", [LOG_ID_RADIO] = "radio", [LOG_ID_EVENTS] = "events", - [LOG_ID_SYSTEM] = "system" + [LOG_ID_SYSTEM] = "system", + [LOG_ID_CRASH] = "crash", }; const char *android_log_id_to_name(log_id_t log_id) diff --git a/liblog/log_read_kern.c b/liblog/log_read_kern.c index d9a6b2e..021fe47 100644 --- a/liblog/log_read_kern.c +++ b/liblog/log_read_kern.c @@ -58,7 +58,8 @@ static const char *LOG_NAME[LOG_ID_MAX] = { [LOG_ID_MAIN] = "main", [LOG_ID_RADIO] = "radio", [LOG_ID_EVENTS] = "events", - [LOG_ID_SYSTEM] = "system" + [LOG_ID_SYSTEM] = "system", + [LOG_ID_CRASH] = "crash" }; const char *android_log_id_to_name(log_id_t log_id) diff --git a/liblog/logd_write.c b/liblog/logd_write.c index 9c73dad..94722d3 100644 --- a/liblog/logd_write.c +++ b/liblog/logd_write.c @@ -54,7 +54,7 @@ static pthread_mutex_t log_init_lock = PTHREAD_MUTEX_INITIALIZER; static int logd_fd = -1; #if FAKE_LOG_DEVICE #define WEAK __attribute__((weak)) -static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1 }; +static int log_fds[(int)LOG_ID_MAX] = { -1, -1, -1, -1, -1 }; #endif /* @@ -243,7 +243,8 @@ static const char *LOG_NAME[LOG_ID_MAX] = { [LOG_ID_MAIN] = "main", [LOG_ID_RADIO] = "radio", [LOG_ID_EVENTS] = "events", - [LOG_ID_SYSTEM] = "system" + [LOG_ID_SYSTEM] = "system", + [LOG_ID_CRASH] = "crash" }; const WEAK char *android_log_id_to_name(log_id_t log_id) diff --git a/liblog/logd_write_kern.c b/liblog/logd_write_kern.c index 5ef349b..c29c28f 100644 --- a/liblog/logd_write_kern.c +++ b/liblog/logd_write_kern.c @@ -93,6 +93,9 @@ static int __write_to_log_kernel(log_id_t log_id, struct iovec *vec, size_t nr) int log_fd; if (/*(int)log_id >= 0 &&*/ (int)log_id < (int)LOG_ID_MAX) { + if (log_id == LOG_ID_CRASH) { + log_id = LOG_ID_MAIN; + } log_fd = log_fds[(int)log_id]; } else { return -EBADF; diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp index ca97208..995a42e 100644 --- a/logcat/logcat.cpp +++ b/logcat/logcat.cpp @@ -227,8 +227,9 @@ static void show_help(const char *cmd) " -T <count> print only the most recent <count> lines (does not imply -d)\n" " -g get the size of the log's ring buffer and exit\n" " -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio',\n" - " 'events' or 'all'. Multiple -b parameters are allowed and\n" - " results are interleaved. The default is -b main -b system.\n" + " 'events', 'crash' or 'all'. Multiple -b parameters are\n" + " allowed and results are interleaved. The default is\n" + " -b main -b system -b crash.\n" " -B output the log in binary.\n" " -S output statistics.\n" " -G <size> set size of log ring buffer, may suffix with K or M.\n" @@ -447,10 +448,17 @@ int main(int argc, char **argv) if (android_name_to_log_id("events") == LOG_ID_EVENTS) { dev->next = new log_device_t("events", true, 'e'); if (dev->next) { + dev = dev->next; android::g_devCount++; needBinary = true; } } + if (android_name_to_log_id("crash") == LOG_ID_CRASH) { + dev->next = new log_device_t("crash", false, 'c'); + if (dev->next) { + android::g_devCount++; + } + } break; } @@ -607,6 +615,14 @@ int main(int argc, char **argv) devices->next = new log_device_t("system", false, 's'); android::g_devCount++; } + if (android_name_to_log_id("crash") == LOG_ID_CRASH) { + if (devices->next) { + devices->next->next = new log_device_t("crash", false, 'c'); + } else { + devices->next = new log_device_t("crash", false, 'c'); + } + android::g_devCount++; + } } if (android::g_logRotateSizeKBytes != 0 diff --git a/logd/LogBuffer.cpp b/logd/LogBuffer.cpp index 70f3e91..8dcab87 100644 --- a/logd/LogBuffer.cpp +++ b/logd/LogBuffer.cpp @@ -165,7 +165,7 @@ void LogBuffer::prune(log_id_t id, unsigned long pruneRows) { size_t worst_sizes = 0; size_t second_worst_sizes = 0; - if (mPrune.worstUidEnabled()) { + if ((id != LOG_ID_CRASH) && mPrune.worstUidEnabled()) { LidStatistics &l = stats.id(id); UidStatisticsCollection::iterator iu; for (iu = l.begin(); iu != l.end(); ++iu) { diff --git a/logd/tests/logd_test.cpp b/logd/tests/logd_test.cpp index 70f8fe9..9ad8973 100644 --- a/logd/tests/logd_test.cpp +++ b/logd/tests/logd_test.cpp @@ -31,7 +31,7 @@ */ static void my_android_logger_get_statistics(char *buf, size_t len) { - snprintf(buf, len, "getStatistics 0 1 2 3"); + snprintf(buf, len, "getStatistics 0 1 2 3 4"); int sock = socket_local_client("logd", ANDROID_SOCKET_NAMESPACE_RESERVED, SOCK_STREAM); |