* commit 'f7770d59dfdc5b3b6fe94f167636b75c1c5d4a81': logd: liblog: logcat: debuggerd: Add LOG_ID_CRASH
This commit is contained in:
commit
297c19d75f
9 changed files with 33 additions and 9 deletions
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue