client lib: Add a DCHECK to ThreadTracks for tid != 0
tid 0 is invalid, but if accidentally passed to ThreadTrack's
constructor, it would create a reference to a thread track with the
same uuid as the corresponding process track.
Change-Id: I920cf760e12e2658a2219282b44854d4be0803c3
diff --git a/include/perfetto/tracing/track.h b/include/perfetto/tracing/track.h
index 8a4df74..f297b08 100644
--- a/include/perfetto/tracing/track.h
+++ b/include/perfetto/tracing/track.h
@@ -91,8 +91,11 @@
static Track Global(uint64_t id) { return Track(id, Track()); }
protected:
- static Track MakeThreadTrack(base::PlatformThreadId tid_) {
- return Track(static_cast<uint64_t>(tid_), MakeProcessTrack());
+ static Track MakeThreadTrack(base::PlatformThreadId tid) {
+ // If tid were 0 here (which is an invalid tid), we would create a thread
+ // track with a uuid that conflicts with the corresponding ProcessTrack.
+ PERFETTO_DCHECK(tid != 0);
+ return Track(static_cast<uint64_t>(tid), MakeProcessTrack());
}
static Track MakeProcessTrack() { return Track(process_uuid, Track()); }