summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Salyzyn2017-03-10 16:31:54 -0600
committerMark Salyzyn2017-03-13 12:31:09 -0500
commit501c373916e292764400dbae735f44b33378400f (patch)
tree56946d23a00461d2a462658f36689faa1d9d71a3 /logd/LogTags.cpp
parent488525b47ba23b2548f3bf6aa2f4ce6267b2d9b5 (diff)
downloadplatform-system-core-501c373916e292764400dbae735f44b33378400f.tar.gz
platform-system-core-501c373916e292764400dbae735f44b33378400f.tar.xz
platform-system-core-501c373916e292764400dbae735f44b33378400f.zip
logd: specify clang format
Switch _all_ file's coding style to match to ease all future changes. SideEffects: None Test: compile Bug: 35373582 Change-Id: I470cb17f64fa48f14aafc02f574e296bffe3a3f3
Diffstat (limited to 'logd/LogTags.cpp')
-rw-r--r--logd/LogTags.cpp147
1 files changed, 73 insertions, 74 deletions
diff --git a/logd/LogTags.cpp b/logd/LogTags.cpp
index 64aa219e9..67649b1e7 100644
--- a/logd/LogTags.cpp
+++ b/logd/LogTags.cpp
@@ -50,11 +50,13 @@ static uid_t sniffUid(const char* comment, const char* endp) {
50 if (!comment) return AID_ROOT; 50 if (!comment) return AID_ROOT;
51 51
52 if (*comment == '#') ++comment; 52 if (*comment == '#') ++comment;
53 while ((comment < endp) && (*comment != '\n') && isspace(*comment)) ++comment; 53 while ((comment < endp) && (*comment != '\n') && isspace(*comment))
54 ++comment;
54 static const char uid_str[] = "uid="; 55 static const char uid_str[] = "uid=";
55 if (((comment + strlen(uid_str)) >= endp) || 56 if (((comment + strlen(uid_str)) >= endp) ||
56 fastcmp<strncmp>(comment, uid_str, strlen(uid_str)) || 57 fastcmp<strncmp>(comment, uid_str, strlen(uid_str)) ||
57 !isdigit(comment[strlen(uid_str)])) return AID_ROOT; 58 !isdigit(comment[strlen(uid_str)]))
59 return AID_ROOT;
58 char* cp; 60 char* cp;
59 unsigned long Uid = strtoul(comment + 4, &cp, 10); 61 unsigned long Uid = strtoul(comment + 4, &cp, 10);
60 if ((cp > endp) || (Uid >= INT_MAX)) return AID_ROOT; 62 if ((cp > endp) || (Uid >= INT_MAX)) return AID_ROOT;
@@ -86,34 +88,32 @@ bool LogTags::RebuildFileEventLogTags(const char* filename, bool warn) {
86 } 88 }
87 89
88 // dump what we already know back into the file? 90 // dump what we already know back into the file?
89 fd = TEMP_FAILURE_RETRY(open(filename, 91 fd = TEMP_FAILURE_RETRY(open(
90 O_WRONLY | O_TRUNC | O_CLOEXEC | 92 filename, O_WRONLY | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_BINARY));
91 O_NOFOLLOW | O_BINARY));
92 if (fd >= 0) { 93 if (fd >= 0) {
93 time_t now = time(NULL); 94 time_t now = time(NULL);
94 struct tm tm; 95 struct tm tm;
95 localtime_r(&now, &tm); 96 localtime_r(&now, &tm);
96 char timebuf[20]; 97 char timebuf[20];
97 size_t len = strftime(timebuf, sizeof(timebuf), 98 size_t len =
98 "%Y-%m-%d %H:%M:%S", &tm); 99 strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", &tm);
99 android::base::WriteStringToFd( 100 android::base::WriteStringToFd(
100 android::base::StringPrintf( 101 android::base::StringPrintf(
101 "# Rebuilt %.20s, content owned by logd\n", timebuf), 102 "# Rebuilt %.20s, content owned by logd\n", timebuf),
102 fd); 103 fd);
103 for (const auto& it : tag2total) { 104 for (const auto& it : tag2total) {
104 android::base::WriteStringToFd(formatEntry_locked(it.first, 105 android::base::WriteStringToFd(
105 AID_ROOT), 106 formatEntry_locked(it.first, AID_ROOT), fd);
106 fd);
107 } 107 }
108 TEMP_FAILURE_RETRY(close(fd)); 108 TEMP_FAILURE_RETRY(close(fd));
109 } 109 }
110 } 110 }
111 111
112 if (warn) { 112 if (warn) {
113 android::prdebug(((fd < 0) ? 113 android::prdebug(
114 "%s failed to rebuild" : 114 ((fd < 0) ? "%s failed to rebuild"
115 "%s missing, damaged or truncated; rebuilt"), 115 : "%s missing, damaged or truncated; rebuilt"),
116 filename); 116 filename);
117 } 117 }
118 118
119 if (fd >= 0) { 119 if (fd >= 0) {
@@ -126,10 +126,9 @@ bool LogTags::RebuildFileEventLogTags(const char* filename, bool warn) {
126 return true; 126 return true;
127} 127}
128 128
129void LogTags::AddEventLogTags(uint32_t tag, uid_t uid, 129void LogTags::AddEventLogTags(uint32_t tag, uid_t uid, const std::string& Name,
130 const std::string& Name, 130 const std::string& Format, const char* source,
131 const std::string& Format, 131 bool warn) {
132 const char* source, bool warn) {
133 std::string Key = Name; 132 std::string Key = Name;
134 if (Format.length()) Key += "+" + Format; 133 if (Format.length()) Key += "+" + Format;
135 134
@@ -178,8 +177,8 @@ void LogTags::AddEventLogTags(uint32_t tag, uid_t uid,
178 WritePersistEventLogTags(tag, uid, source); 177 WritePersistEventLogTags(tag, uid, source);
179 } else if (warn && !newOne && source) { 178 } else if (warn && !newOne && source) {
180 // For the files, we want to report dupes. 179 // For the files, we want to report dupes.
181 android::prdebug("Multiple tag %" PRIu32 " %s %s %s", tag, 180 android::prdebug("Multiple tag %" PRIu32 " %s %s %s", tag, Name.c_str(),
182 Name.c_str(), Format.c_str(), source); 181 Format.c_str(), source);
183 } 182 }
184} 183}
185 184
@@ -193,7 +192,7 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
193 } 192 }
194 std::string content; 193 std::string content;
195 if (android::base::ReadFileToString(filename, &content)) { 194 if (android::base::ReadFileToString(filename, &content)) {
196 char* cp = (char*) content.c_str(); 195 char* cp = (char*)content.c_str();
197 char* endp = cp + content.length(); 196 char* endp = cp + content.length();
198 197
199 { 198 {
@@ -228,16 +227,19 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
228 std::string Name(name, cp - name); 227 std::string Name(name, cp - name);
229#ifdef ALLOW_NOISY_LOGGING_OF_PROBLEM_WITH_LOTS_OF_TECHNICAL_DEBT 228#ifdef ALLOW_NOISY_LOGGING_OF_PROBLEM_WITH_LOTS_OF_TECHNICAL_DEBT
230 static const size_t maximum_official_tag_name_size = 24; 229 static const size_t maximum_official_tag_name_size = 24;
231 if (warn && (Name.length() > maximum_official_tag_name_size)) { 230 if (warn &&
232 android::prdebug("tag name too long %s", Name.c_str()); 231 (Name.length() > maximum_official_tag_name_size)) {
232 android::prdebug("tag name too long %s", Name.c_str());
233 } 233 }
234#endif 234#endif
235 if (hasAlpha && ((cp >= endp) || (*cp == '#') || isspace(*cp))) { 235 if (hasAlpha &&
236 ((cp >= endp) || (*cp == '#') || isspace(*cp))) {
236 if (Tag > emptyTag) { 237 if (Tag > emptyTag) {
237 if (*cp != '\n') lineStart = NULL; 238 if (*cp != '\n') lineStart = NULL;
238 continue; 239 continue;
239 } 240 }
240 while ((cp < endp) && (*cp != '\n') && isspace(*cp)) ++cp; 241 while ((cp < endp) && (*cp != '\n') && isspace(*cp))
242 ++cp;
241 const char* format = cp; 243 const char* format = cp;
242 uid_t uid = AID_ROOT; 244 uid_t uid = AID_ROOT;
243 while ((cp < endp) && (*cp != '\n')) { 245 while ((cp < endp) && (*cp != '\n')) {
@@ -263,7 +265,9 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
263 } 265 }
264 lineStart = NULL; 266 lineStart = NULL;
265 } 267 }
266 } else if (!isspace(*cp)) break; 268 } else if (!isspace(*cp)) {
269 break;
270 }
267 } 271 }
268 cp++; 272 cp++;
269 } 273 }
@@ -273,8 +277,7 @@ void LogTags::ReadFileEventLogTags(const char* filename, bool warn) {
273} 277}
274 278
275// Extract a 4-byte value from a byte stream. 279// Extract a 4-byte value from a byte stream.
276static inline uint32_t get4LE(const char* msg) 280static inline uint32_t get4LE(const char* msg) {
277{
278 const uint8_t* src = reinterpret_cast<const uint8_t*>(msg); 281 const uint8_t* src = reinterpret_cast<const uint8_t*>(msg);
279 return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24); 282 return src[0] | (src[1] << 8) | (src[2] << 16) | (src[3] << 24);
280} 283}
@@ -284,8 +287,8 @@ static inline uint32_t get4LE(const char* msg)
284// database with any found. 287// database with any found.
285void LogTags::ReadPersistEventLogTags() { 288void LogTags::ReadPersistEventLogTags() {
286 struct logger_list* logger_list = android_logger_list_alloc( 289 struct logger_list* logger_list = android_logger_list_alloc(
287 ANDROID_LOG_RDONLY | ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK, 290 ANDROID_LOG_RDONLY | ANDROID_LOG_PSTORE | ANDROID_LOG_NONBLOCK, 0,
288 0, (pid_t)0); 291 (pid_t)0);
289 if (!logger_list) return; 292 if (!logger_list) return;
290 293
291 struct logger* e = android_logger_open(logger_list, LOG_ID_EVENTS); 294 struct logger* e = android_logger_open(logger_list, LOG_ID_EVENTS);
@@ -305,8 +308,9 @@ void LogTags::ReadPersistEventLogTags() {
305 if (log_msg.entry.len <= sizeof(uint32_t)) continue; 308 if (log_msg.entry.len <= sizeof(uint32_t)) continue;
306 uint32_t Tag = get4LE(msg); 309 uint32_t Tag = get4LE(msg);
307 if (Tag != TAG_DEF_LOG_TAG) continue; 310 if (Tag != TAG_DEF_LOG_TAG) continue;
308 uid_t uid = (log_msg.entry.hdr_size >= sizeof(logger_entry_v4)) ? 311 uid_t uid = (log_msg.entry.hdr_size >= sizeof(logger_entry_v4))
309 log_msg.entry.uid : AID_ROOT; 312 ? log_msg.entry.uid
313 : AID_ROOT;
310 314
311 std::string Name; 315 std::string Name;
312 std::string Format; 316 std::string Format;
@@ -433,8 +437,7 @@ uint32_t LogTags::nameToTag(const char* name) const {
433// writer lock. We use this call to invent a new deterministically 437// writer lock. We use this call to invent a new deterministically
434// random tag, unique is cleared if no conflicts. If format is NULL, 438// random tag, unique is cleared if no conflicts. If format is NULL,
435// we are in readonly mode. 439// we are in readonly mode.
436uint32_t LogTags::nameToTag_locked(const std::string& name, 440uint32_t LogTags::nameToTag_locked(const std::string& name, const char* format,
437 const char* format,
438 bool& unique) { 441 bool& unique) {
439 key2tag_const_iterator ik; 442 key2tag_const_iterator ik;
440 443
@@ -462,7 +465,7 @@ uint32_t LogTags::nameToTag_locked(const std::string& name,
462 size_t Hash = key2tag.hash_function()(Key); 465 size_t Hash = key2tag.hash_function()(Key);
463 uint32_t Tag = Hash; 466 uint32_t Tag = Hash;
464 // This sets an upper limit on the conflics we are allowed to deal with. 467 // This sets an upper limit on the conflics we are allowed to deal with.
465 for (unsigned i = 0; i < 256; ) { 468 for (unsigned i = 0; i < 256;) {
466 tag2name_const_iterator it = tag2name.find(Tag); 469 tag2name_const_iterator it = tag2name.find(Tag);
467 if (it == tag2name.end()) return Tag; 470 if (it == tag2name.end()) return Tag;
468 std::string localKey(it->second); 471 std::string localKey(it->second);
@@ -471,15 +474,14 @@ uint32_t LogTags::nameToTag_locked(const std::string& name,
471 localKey += "+" + iform->second; 474 localKey += "+" + iform->second;
472 } 475 }
473 unique = !!it->second.compare(localKey); 476 unique = !!it->second.compare(localKey);
474 if (!unique) return Tag; // unlikely except in a race 477 if (!unique) return Tag; // unlikely except in a race
475 478
476 ++i; 479 ++i;
477 // Algorithm to convert hash to next tag 480 // Algorithm to convert hash to next tag
478 if (i < 32) { 481 if (i < 32) {
479 Tag = (Hash >> i); 482 Tag = (Hash >> i);
480 // size_t is 32 bits, or upper word zero, rotate 483 // size_t is 32 bits, or upper word zero, rotate
481 if ((sizeof(Hash) <= 4) || 484 if ((sizeof(Hash) <= 4) || ((Hash & (uint64_t(-1LL) << 32)) == 0)) {
482 ((Hash & (uint64_t(-1LL) << 32)) == 0)) {
483 Tag |= Hash << (32 - i); 485 Tag |= Hash << (32 - i);
484 } 486 }
485 } else { 487 } else {
@@ -501,7 +503,7 @@ void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
501 android::RWLock::AutoRLock readLock(rwlock); 503 android::RWLock::AutoRLock readLock(rwlock);
502 504
503 tag2total_const_iterator itot = tag2total.find(tag); 505 tag2total_const_iterator itot = tag2total.find(tag);
504 if (itot == tag2total.end()) return; // source is a static entry 506 if (itot == tag2total.end()) return; // source is a static entry
505 507
506 size_t lastTotal = itot->second; 508 size_t lastTotal = itot->second;
507 509
@@ -525,7 +527,7 @@ void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
525 __android_log_event_list ctx(TAG_DEF_LOG_TAG); 527 __android_log_event_list ctx(TAG_DEF_LOG_TAG);
526 ctx << tag << Name << Format; 528 ctx << tag << Name << Format;
527 std::string buffer(ctx); 529 std::string buffer(ctx);
528 if (buffer.length() <= 0) return; // unlikely 530 if (buffer.length() <= 0) return; // unlikely
529 531
530 /* 532 /*
531 * struct { 533 * struct {
@@ -562,18 +564,17 @@ void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
562 564
563 android_pmsg_log_header_t pmsgHeader = { 565 android_pmsg_log_header_t pmsgHeader = {
564 .magic = LOGGER_MAGIC, 566 .magic = LOGGER_MAGIC,
565 .len = (uint16_t)(sizeof(pmsgHeader) + sizeof(header) + 567 .len = (uint16_t)(sizeof(pmsgHeader) + sizeof(header) + sizeof(outTag) +
566 sizeof(outTag) + buffer.length()), 568 buffer.length()),
567 .uid = (uint16_t)AID_ROOT, 569 .uid = (uint16_t)AID_ROOT,
568 .pid = (uint16_t)getpid(), 570 .pid = (uint16_t)getpid(),
569 }; 571 };
570 572
571 struct iovec Vec[] = { 573 struct iovec Vec[] = { { (unsigned char*)&pmsgHeader, sizeof(pmsgHeader) },
572 { (unsigned char*)&pmsgHeader, sizeof(pmsgHeader) }, 574 { (unsigned char*)&header, sizeof(header) },
573 { (unsigned char*)&header, sizeof(header) }, 575 { (unsigned char*)&outTag, sizeof(outTag) },
574 { (unsigned char*)&outTag, sizeof(outTag) }, 576 { (unsigned char*)const_cast<char*>(buffer.data()),
575 { (unsigned char*)const_cast<char*>(buffer.data()), buffer.length() } 577 buffer.length() } };
576 };
577 578
578 tag2uid_const_iterator ut = tag2uid.find(tag); 579 tag2uid_const_iterator ut = tag2uid.find(tag);
579 if (ut == tag2uid.end()) { 580 if (ut == tag2uid.end()) {
@@ -582,7 +583,7 @@ void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
582 pmsgHeader.uid = (uint16_t)uid; 583 pmsgHeader.uid = (uint16_t)uid;
583 TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec))); 584 TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
584 } else { 585 } else {
585 for (auto &it : ut->second) { 586 for (auto& it : ut->second) {
586 pmsgHeader.uid = (uint16_t)it; 587 pmsgHeader.uid = (uint16_t)it;
587 TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec))); 588 TEMP_FAILURE_RETRY(writev(pmsg_fd, Vec, arraysize(Vec)));
588 } 589 }
@@ -590,8 +591,8 @@ void LogTags::WritePmsgEventLogTags(uint32_t tag, uid_t uid) {
590} 591}
591 592
592void LogTags::WriteDynamicEventLogTags(uint32_t tag, uid_t uid) { 593void LogTags::WriteDynamicEventLogTags(uint32_t tag, uid_t uid) {
593 static const int mode = O_WRONLY | O_APPEND | 594 static const int mode =
594 O_CLOEXEC | O_NOFOLLOW | O_BINARY; 595 O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
595 596
596 int fd = openFile(dynamic_event_log_tags, mode, true); 597 int fd = openFile(dynamic_event_log_tags, mode, true);
597 if (fd < 0) return; 598 if (fd < 0) return;
@@ -612,8 +613,8 @@ void LogTags::WriteDynamicEventLogTags(uint32_t tag, uid_t uid) {
612} 613}
613 614
614void LogTags::WriteDebugEventLogTags(uint32_t tag, uid_t uid) { 615void LogTags::WriteDebugEventLogTags(uint32_t tag, uid_t uid) {
615 static const int mode = O_WRONLY | O_APPEND | 616 static const int mode =
616 O_CLOEXEC | O_NOFOLLOW | O_BINARY; 617 O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_BINARY;
617 618
618 static bool one = true; 619 static bool one = true;
619 int fd = openFile(debug_event_log_tags, mode, one); 620 int fd = openFile(debug_event_log_tags, mode, one);
@@ -636,16 +637,14 @@ void LogTags::WriteDebugEventLogTags(uint32_t tag, uid_t uid) {
636} 637}
637 638
638// How we maintain some runtime or reboot stickiness 639// How we maintain some runtime or reboot stickiness
639void LogTags::WritePersistEventLogTags(uint32_t tag, 640void LogTags::WritePersistEventLogTags(uint32_t tag, uid_t uid,
640 uid_t uid, const char* source) { 641 const char* source) {
641 // very unlikely 642 // very unlikely
642 bool etc = source && !strcmp(source, system_event_log_tags); 643 bool etc = source && !strcmp(source, system_event_log_tags);
643 if (etc) return; 644 if (etc) return;
644 645
645 bool dynamic = source && !strcmp(source, dynamic_event_log_tags); 646 bool dynamic = source && !strcmp(source, dynamic_event_log_tags);
646 bool debug = (!dynamic && 647 bool debug = (!dynamic && source && !strcmp(source, debug_event_log_tags)) ||
647 source &&
648 !strcmp(source, debug_event_log_tags)) ||
649 !__android_log_is_debuggable(); 648 !__android_log_is_debuggable();
650 649
651 WritePmsgEventLogTags(tag, uid); 650 WritePmsgEventLogTags(tag, uid);
@@ -658,7 +657,7 @@ void LogTags::WritePersistEventLogTags(uint32_t tag,
658 if (itot != tag2total.end()) lastTotal = itot->second; 657 if (itot != tag2total.end()) lastTotal = itot->second;
659 } 658 }
660 659
661 if (lastTotal == 0) { // denotes first time for this one 660 if (lastTotal == 0) { // denotes first time for this one
662 if (!dynamic || !RebuildFileEventLogTags(dynamic_event_log_tags)) { 661 if (!dynamic || !RebuildFileEventLogTags(dynamic_event_log_tags)) {
663 WriteDynamicEventLogTags(tag, uid); 662 WriteDynamicEventLogTags(tag, uid);
664 } 663 }
@@ -694,9 +693,9 @@ uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) {
694 tag2uid_const_iterator ut = tag2uid.find(Tag); 693 tag2uid_const_iterator ut = tag2uid.find(Tag);
695 if (updateUid) { 694 if (updateUid) {
696 if ((ut != tag2uid.end()) && 695 if ((ut != tag2uid.end()) &&
697 (ut->second.find(uid) == ut->second.end())) { 696 (ut->second.find(uid) == ut->second.end())) {
698 unique = write; // write passthrough to update uid counts 697 unique = write; // write passthrough to update uid counts
699 if (!write) Tag = emptyTag; // deny read access 698 if (!write) Tag = emptyTag; // deny read access
700 } 699 }
701 } else { 700 } else {
702 unique = write && (ut != tag2uid.end()); 701 unique = write && (ut != tag2uid.end());
@@ -705,7 +704,7 @@ uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) {
705 } 704 }
706 705
707 if (Tag == emptyTag) return Tag; 706 if (Tag == emptyTag) return Tag;
708 WritePmsgEventLogTags(Tag, uid); // record references periodically 707 WritePmsgEventLogTags(Tag, uid); // record references periodically
709 if (!unique) return Tag; 708 if (!unique) return Tag;
710 709
711 bool updateWrite = false; 710 bool updateWrite = false;
@@ -728,7 +727,9 @@ uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) {
728 if (updateUid) { 727 if (updateUid) {
729 // Add it to the uid list 728 // Add it to the uid list
730 if ((ut == tag2uid.end()) || 729 if ((ut == tag2uid.end()) ||
731 (ut->second.find(uid) != ut->second.end())) return Tag; 730 (ut->second.find(uid) != ut->second.end())) {
731 return Tag;
732 }
732 const_cast<uid_list&>(ut->second).emplace(uid); 733 const_cast<uid_list&>(ut->second).emplace(uid);
733 updateWrite = true; 734 updateWrite = true;
734 } else { 735 } else {
@@ -791,8 +792,7 @@ uint32_t LogTags::nameToTag(uid_t uid, const char* name, const char* format) {
791 return Tag; 792 return Tag;
792} 793}
793 794
794std::string LogTags::formatEntry(uint32_t tag, uid_t uid, 795std::string LogTags::formatEntry(uint32_t tag, uid_t uid, const char* name,
795 const char* name,
796 const char* format) { 796 const char* format) {
797 if (!format || !format[0]) { 797 if (!format || !format[0]) {
798 return android::base::StringPrintf("%" PRIu32 "\t%s\n", tag, name); 798 return android::base::StringPrintf("%" PRIu32 "\t%s\n", tag, name);
@@ -802,9 +802,8 @@ std::string LogTags::formatEntry(uint32_t tag, uid_t uid,
802 if (len > strlen(tabs)) len = strlen(tabs); 802 if (len > strlen(tabs)) len = strlen(tabs);
803 std::string Uid; 803 std::string Uid;
804 if (uid != AID_ROOT) Uid = android::base::StringPrintf(" # uid=%u", uid); 804 if (uid != AID_ROOT) Uid = android::base::StringPrintf(" # uid=%u", uid);
805 return android::base::StringPrintf("%" PRIu32 "\t%s%s\t%s%s\n", 805 return android::base::StringPrintf("%" PRIu32 "\t%s%s\t%s%s\n", tag, name,
806 tag, name, &tabs[len], format, 806 &tabs[len], format, Uid.c_str());
807 Uid.c_str());
808} 807}
809 808
810std::string LogTags::formatEntry_locked(uint32_t tag, uid_t uid, 809std::string LogTags::formatEntry_locked(uint32_t tag, uid_t uid,
@@ -830,7 +829,7 @@ std::string LogTags::formatEntry_locked(uint32_t tag, uid_t uid,
830 829
831 // Show all, one for each registered uid (we are group root) 830 // Show all, one for each registered uid (we are group root)
832 std::string ret; 831 std::string ret;
833 for (auto &it : ut->second) { 832 for (auto& it : ut->second) {
834 ret += formatEntry(tag, it, name, format); 833 ret += formatEntry(tag, it, name, format);
835 } 834 }
836 return ret; 835 return ret;
@@ -841,8 +840,8 @@ std::string LogTags::formatEntry(uint32_t tag, uid_t uid) {
841 return formatEntry_locked(tag, uid); 840 return formatEntry_locked(tag, uid);
842} 841}
843 842
844std::string LogTags::formatGetEventTag(uid_t uid, 843std::string LogTags::formatGetEventTag(uid_t uid, const char* name,
845 const char* name, const char* format) { 844 const char* format) {
846 bool all = name && (name[0] == '*') && !name[1]; 845 bool all = name && (name[0] == '*') && !name[1];
847 bool list = !name || all; 846 bool list = !name || all;
848 std::string ret; 847 std::string ret;
@@ -864,7 +863,7 @@ std::string LogTags::formatGetEventTag(uid_t uid,
864 // first uid in list so as to manufacture an accurate reference 863 // first uid in list so as to manufacture an accurate reference
865 tag2uid_const_iterator ut = tag2uid.find(tag); 864 tag2uid_const_iterator ut = tag2uid.find(tag);
866 if ((ut != tag2uid.end()) && 865 if ((ut != tag2uid.end()) &&
867 (ut->second.begin() != ut->second.end())) { 866 (ut->second.begin() != ut->second.end())) {
868 uid = *(ut->second.begin()); 867 uid = *(ut->second.begin());
869 } 868 }
870 } 869 }