Merge "processor: Add debug logs for clock snapshots & increment stat only once" am: bc9475ac0b am: 6549f3d939

Original change: https://android-review.googlesource.com/c/platform/external/perfetto/+/1325091

Change-Id: I357da76a67bf93fdaa28d8bf159ec4d5b86cadd7
diff --git a/src/trace_processor/importers/common/clock_tracker.cc b/src/trace_processor/importers/common/clock_tracker.cc
index 96d8010..6a21085 100644
--- a/src/trace_processor/importers/common/clock_tracker.cc
+++ b/src/trace_processor/importers/common/clock_tracker.cc
@@ -119,6 +119,8 @@
         return;
       }
 
+      PERFETTO_DLOG("Detected non-monotonic clock with ID %" PRIu64, clock_id);
+
       // For the other clocks the best thing we can do is mark it as
       // non-monotonic and refuse to use it as a source clock in the resolution
       // graph. We can still use it as a target clock, but not viceversa.
@@ -208,6 +210,9 @@
 
   ClockPath path = FindPath(src_clock_id, target_clock_id);
   if (!path.valid()) {
+    PERFETTO_DLOG("No path from clock %" PRIu64 " to %" PRIu64
+                  " at timestamp %" PRId64,
+                  src_clock_id, target_clock_id, src_timestamp);
     context_->storage->IncrementStats(stats::clock_sync_failure);
     return base::nullopt;
   }
diff --git a/src/trace_processor/importers/proto/proto_trace_parser.cc b/src/trace_processor/importers/proto/proto_trace_parser.cc
index 6419f0f..d11afc4 100644
--- a/src/trace_processor/importers/proto/proto_trace_parser.cc
+++ b/src/trace_processor/importers/proto/proto_trace_parser.cc
@@ -289,10 +289,9 @@
         protos::pbzero::BUILTIN_CLOCK_MONOTONIC_COARSE,
         static_cast<int64_t>(entry.timestamp()));
 
-    if (!maybe_timestamp) {
-      context_->storage->IncrementStats(stats::clock_sync_failure);
+    // ToTraceTime() increments the clock_sync_failure error stat in this case.
+    if (!maybe_timestamp)
       continue;
-    }
 
     int64_t timestamp = *maybe_timestamp;