summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--debuggerd/libdebuggerd/tombstone.cpp46
1 files changed, 19 insertions, 27 deletions
diff --git a/debuggerd/libdebuggerd/tombstone.cpp b/debuggerd/libdebuggerd/tombstone.cpp
index 433bb4657..0b8a9362b 100644
--- a/debuggerd/libdebuggerd/tombstone.cpp
+++ b/debuggerd/libdebuggerd/tombstone.cpp
@@ -474,7 +474,7 @@ static EventTagMap* g_eventTagMap = NULL;
474 474
475static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned int tail) { 475static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned int tail) {
476 bool first = true; 476 bool first = true;
477 struct logger_list* logger_list; 477 logger_list* logger_list;
478 478
479 if (!log->should_retrieve_logcat) { 479 if (!log->should_retrieve_logcat) {
480 return; 480 return;
@@ -488,11 +488,9 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned
488 return; 488 return;
489 } 489 }
490 490
491 struct log_msg log_entry;
492
493 while (true) { 491 while (true) {
492 log_msg log_entry;
494 ssize_t actual = android_logger_list_read(logger_list, &log_entry); 493 ssize_t actual = android_logger_list_read(logger_list, &log_entry);
495 struct logger_entry* entry;
496 494
497 if (actual < 0) { 495 if (actual < 0) {
498 if (actual == -EINTR) { 496 if (actual == -EINTR) {
@@ -515,8 +513,6 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned
515 // high-frequency debug diagnostics should just be written to 513 // high-frequency debug diagnostics should just be written to
516 // the tombstone file. 514 // the tombstone file.
517 515
518 entry = &log_entry.entry_v1;
519
520 if (first) { 516 if (first) {
521 _LOG(log, logtype::LOGS, "--------- %slog %s\n", 517 _LOG(log, logtype::LOGS, "--------- %slog %s\n",
522 tail ? "tail end of " : "", filename); 518 tail ? "tail end of " : "", filename);
@@ -527,19 +523,8 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned
527 // 523 //
528 // We want to display it in the same format as "logcat -v threadtime" 524 // We want to display it in the same format as "logcat -v threadtime"
529 // (although in this case the pid is redundant). 525 // (although in this case the pid is redundant).
530 static const char* kPrioChars = "!.VDIWEFS";
531 unsigned hdr_size = log_entry.entry.hdr_size;
532 if (!hdr_size) {
533 hdr_size = sizeof(log_entry.entry_v1);
534 }
535 if ((hdr_size < sizeof(log_entry.entry_v1)) ||
536 (hdr_size > sizeof(log_entry.entry))) {
537 continue;
538 }
539 char* msg = reinterpret_cast<char*>(log_entry.buf) + hdr_size;
540
541 char timeBuf[32]; 526 char timeBuf[32];
542 time_t sec = static_cast<time_t>(entry->sec); 527 time_t sec = static_cast<time_t>(log_entry.entry.sec);
543 struct tm tmBuf; 528 struct tm tmBuf;
544 struct tm* ptm; 529 struct tm* ptm;
545 ptm = localtime_r(&sec, &tmBuf); 530 ptm = localtime_r(&sec, &tmBuf);
@@ -547,17 +532,23 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned
547 532
548 if (log_entry.id() == LOG_ID_EVENTS) { 533 if (log_entry.id() == LOG_ID_EVENTS) {
549 if (!g_eventTagMap) { 534 if (!g_eventTagMap) {
550 g_eventTagMap = android_openEventTagMap(NULL); 535 g_eventTagMap = android_openEventTagMap(nullptr);
551 } 536 }
552 AndroidLogEntry e; 537 AndroidLogEntry e;
553 char buf[512]; 538 char buf[512];
554 android_log_processBinaryLogBuffer(entry, &e, g_eventTagMap, buf, sizeof(buf)); 539 if (android_log_processBinaryLogBuffer(&log_entry.entry_v1, &e, g_eventTagMap, buf,
555 _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8.*s: %s\n", 540 sizeof(buf)) == 0) {
556 timeBuf, entry->nsec / 1000000, entry->pid, entry->tid, 541 _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8.*s: %s\n", timeBuf,
557 'I', (int)e.tagLen, e.tag, e.message); 542 log_entry.entry.nsec / 1000000, log_entry.entry.pid, log_entry.entry.tid, 'I',
543 (int)e.tagLen, e.tag, e.message);
544 }
558 continue; 545 continue;
559 } 546 }
560 547
548 char* msg = log_entry.msg();
549 if (msg == nullptr) {
550 continue;
551 }
561 unsigned char prio = msg[0]; 552 unsigned char prio = msg[0];
562 char* tag = msg + 1; 553 char* tag = msg + 1;
563 msg = tag + strlen(tag) + 1; 554 msg = tag + strlen(tag) + 1;
@@ -568,20 +559,21 @@ static void dump_log_file(log_t* log, pid_t pid, const char* filename, unsigned
568 *nl-- = '\0'; 559 *nl-- = '\0';
569 } 560 }
570 561
562 static const char* kPrioChars = "!.VDIWEFS";
571 char prioChar = (prio < strlen(kPrioChars) ? kPrioChars[prio] : '?'); 563 char prioChar = (prio < strlen(kPrioChars) ? kPrioChars[prio] : '?');
572 564
573 // Look for line breaks ('\n') and display each text line 565 // Look for line breaks ('\n') and display each text line
574 // on a separate line, prefixed with the header, like logcat does. 566 // on a separate line, prefixed with the header, like logcat does.
575 do { 567 do {
576 nl = strchr(msg, '\n'); 568 nl = strchr(msg, '\n');
577 if (nl) { 569 if (nl != nullptr) {
578 *nl = '\0'; 570 *nl = '\0';
579 ++nl; 571 ++nl;
580 } 572 }
581 573
582 _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n", 574 _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n", timeBuf,
583 timeBuf, entry->nsec / 1000000, entry->pid, entry->tid, 575 log_entry.entry.nsec / 1000000, log_entry.entry.pid, log_entry.entry.tid, prioChar, tag,
584 prioChar, tag, msg); 576 msg);
585 } while ((msg = nl)); 577 } while ((msg = nl));
586 } 578 }
587 579