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