logd: liblog: logcat: debuggerd: Add LOG_ID_CRASH
Change-Id: Iea453764a1a4fc1661f461f10c641c30150e4d20
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 @@
}
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 @@
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 @@
[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 @@
[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 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 @@
[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 @@
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 @@
" -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 @@
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 @@
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 @@
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);