Merge "fix regression from android_lookupEventTag_len()"
am: 9fa133cc28

Change-Id: I8aa5cddb87290eaf86536b567b34cb3119839911
diff --git a/debuggerd/tombstone.cpp b/debuggerd/tombstone.cpp
index 459e4cc..1e47483 100644
--- a/debuggerd/tombstone.cpp
+++ b/debuggerd/tombstone.cpp
@@ -576,9 +576,9 @@
       AndroidLogEntry e;
       char buf[512];
       android_log_processBinaryLogBuffer(entry, &e, g_eventTagMap, buf, sizeof(buf));
-      _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8s: %s\n",
+      _LOG(log, logtype::LOGS, "%s.%03d %5d %5d %c %-8.*s: %s\n",
          timeBuf, entry->nsec / 1000000, entry->pid, entry->tid,
-         'I', e.tag, e.message);
+         'I', (int)e.tagLen, e.tag, e.message);
       continue;
     }
 
diff --git a/logcat/logcat.cpp b/logcat/logcat.cpp
index 51d1a3a..f08a6cd 100644
--- a/logcat/logcat.cpp
+++ b/logcat/logcat.cpp
@@ -186,7 +186,9 @@
         goto error;
     }
 
-    if (android_log_shouldPrintLine(g_logformat, entry.tag, entry.priority)) {
+    if (android_log_shouldPrintLine(g_logformat,
+                                    std::string(entry.tag, entry.tagLen).c_str(),
+                                    entry.priority)) {
         bool match = regexOk(entry);
 
         g_printCount += match;
diff --git a/logcat/tests/logcat_test.cpp b/logcat/tests/logcat_test.cpp
index 1baaf11..bc0ea52 100644
--- a/logcat/tests/logcat_test.cpp
+++ b/logcat/tests/logcat_test.cpp
@@ -78,6 +78,26 @@
     EXPECT_EQ(4, count);
 }
 
+TEST(logcat, event_tag_filter) {
+    FILE *fp;
+
+    ASSERT_TRUE(NULL != (fp = popen(
+      "logcat -b events -d -s auditd am_proc_start am_pss am_proc_bound dvm_lock_sample am_wtf 2>/dev/null",
+      "r")));
+
+    char buffer[BIG_BUFFER];
+
+    int count = 0;
+
+    while (fgets(buffer, sizeof(buffer), fp)) {
+        ++count;
+    }
+
+    pclose(fp);
+
+    EXPECT_LT(4, count);
+}
+
 TEST(logcat, year) {
 
     if (android_log_clockid() == CLOCK_MONOTONIC) {