Merge "processor: Only fall back to legacy tracks for legacy events"
diff --git a/src/trace_processor/importers/proto/track_event_parser.cc b/src/trace_processor/importers/proto/track_event_parser.cc
index cb88ec7..2ca1a28 100644
--- a/src/trace_processor/importers/proto/track_event_parser.cc
+++ b/src/trace_processor/importers/proto/track_event_parser.cc
@@ -457,8 +457,12 @@
base::Optional<UniqueTid> upid;
// Determine track from track_uuid specified in either TrackEvent or
- // TrackEventDefaults. If none is set, fall back to the track specified by the
- // sequence's (or event's) pid + tid or a default track.
+ // TrackEventDefaults. If a non-default track is not set, we either:
+ // a) fall back to the track specified by the sequence's (or event's) pid +
+ // tid (only in case of legacy tracks/events, i.e. events that don't
+ // specify an explicit track uuid or use legacy event phases instead of
+ // TrackEvent types), or
+ // b) a default track.
if (track_uuid) {
base::Optional<TrackId> opt_track_id =
track_tracker->GetDescriptorTrack(track_uuid);
@@ -480,9 +484,10 @@
if (process_track_row)
upid = storage->process_track_table().upid()[*process_track_row];
}
- } else if (sequence_state->state()->pid_and_tid_valid() ||
- (legacy_event.has_pid_override() &&
- legacy_event.has_tid_override())) {
+ } else if ((!event.has_track_uuid() || !event.has_type()) &&
+ (sequence_state->state()->pid_and_tid_valid() ||
+ (legacy_event.has_pid_override() &&
+ legacy_event.has_tid_override()))) {
uint32_t pid = static_cast<uint32_t>(sequence_state->state()->pid());
uint32_t tid = static_cast<uint32_t>(sequence_state->state()->tid());
if (legacy_event.has_pid_override())
diff --git a/test/trace_processor/track_event_tracks.textproto b/test/trace_processor/track_event_tracks.textproto
index 368732e..b76fa36 100644
--- a/test/trace_processor/track_event_tracks.textproto
+++ b/test/trace_processor/track_event_tracks.textproto
@@ -244,4 +244,35 @@
name: "event3_on_t1"
type: 3
}
-}
\ No newline at end of file
+}
+
+# Override the track to the default descriptor track for an event with a
+# TrackEvent type. Should appear on the default descriptor track instead of
+# "t1".
+packet {
+ trusted_packet_sequence_id: 1
+ timestamp: 30000
+ track_event {
+ track_uuid: 0
+ categories: "cat"
+ name: "event1_on_t1"
+ type: 3
+ }
+}
+
+# But a legacy event without TrackEvent type falls back to legacy tracks (based
+# on ThreadDescriptor / async IDs / legacy instant scopes). This instant event
+# should appear on the process track "p2".
+packet {
+ trusted_packet_sequence_id: 1
+ timestamp: 31000
+ track_event {
+ track_uuid: 0
+ categories: "cat"
+ name: "event1_on_t1"
+ legacy_event {
+ phase: 73 # 'I'
+ instant_event_scope: 2 # Process scope
+ }
+ }
+}
diff --git a/test/trace_processor/track_event_tracks_slices.out b/test/trace_processor/track_event_tracks_slices.out
index 444ccb9..a031897 100644
--- a/test/trace_processor/track_event_tracks_slices.out
+++ b/test/trace_processor/track_event_tracks_slices.out
@@ -9,3 +9,5 @@
"[NULL]","[NULL]","t3","p1",11000,0,"cat","event1_on_t3",0
"[NULL]","p2","[NULL]","[NULL]",21000,0,"cat","event1_on_p2",0
"[NULL]","[NULL]","t4","p2",22000,0,"cat","event1_on_t4",0
+"Default Track","[NULL]","[NULL]","[NULL]",30000,0,"cat","event1_on_t1",0
+"[NULL]","p2","[NULL]","[NULL]",31000,0,"cat","event1_on_t1",5