traced: Add initial timestamp

The trace currently includes a clock snapshot at the physical
beginning of the trace but since this is taken at read time
this may be after the trace has ended. This adds an additional
clock snapshot taken at the time the trace actually began and
reported at read time.

Bug: 130543265
Test: take a trace and look at first packet
Change-Id: I360eec3b71dd3e372914183218a939eb88443acf
diff --git a/src/tracing/core/tracing_service_impl.h b/src/tracing/core/tracing_service_impl.h
index c643b3a..40cb924 100644
--- a/src/tracing/core/tracing_service_impl.h
+++ b/src/tracing/core/tracing_service_impl.h
@@ -448,6 +448,11 @@
     // The number of received triggers we've emitted into the trace output.
     size_t num_triggers_emitted_into_trace = 0;
 
+    // Initial clock snapshot, captured at trace start time (when state goes
+    // to TracingSession::STARTED). Emitted into the trace when the consumer
+    // first begins reading the trace.
+    std::vector<TracePacket> initial_clock_snapshot_;
+
     State state = DISABLED;
 
     // If the consumer detached the session, this variable defines the key used
@@ -491,7 +496,7 @@
                                TracingSession* tracing_session,
                                DataSourceInstance* instance);
   void SnapshotSyncMarker(std::vector<TracePacket>*);
-  void SnapshotClocks(std::vector<TracePacket>*);
+  void SnapshotClocks(std::vector<TracePacket>*, bool set_timestamp = true);
   void SnapshotStats(TracingSession*, std::vector<TracePacket>*);
   TraceStats GetTraceStats(TracingSession* tracing_session);
   void MaybeEmitTraceConfig(TracingSession*, std::vector<TracePacket>*);