Merge "Fix typo in perfetto docs"
diff --git a/examples/sdk/BUILD.gn b/examples/sdk/BUILD.gn
index 8da2991..a801d29 100644
--- a/examples/sdk/BUILD.gn
+++ b/examples/sdk/BUILD.gn
@@ -20,7 +20,6 @@
"trace_categories.cc",
"trace_categories.h",
]
- configs -= [ "//gn/standalone:extra_warnings" ]
cflags = [ "-DPERFETTO_SDK_EXAMPLE_USE_INTERNAL_HEADERS" ]
testonly = true
deps = [
diff --git a/include/perfetto/tracing/internal/track_event_data_source.h b/include/perfetto/tracing/internal/track_event_data_source.h
index 2361352..633f3e2 100644
--- a/include/perfetto/tracing/internal/track_event_data_source.h
+++ b/include/perfetto/tracing/internal/track_event_data_source.h
@@ -361,7 +361,7 @@
TrackRegistry::Get()->UpdateTrack(track, desc.SerializeAsString());
Base::template Trace([&](typename Base::TraceContext ctx) {
TrackEventInternal::WriteTrackDescriptor(
- track, ctx.tls_inst_->trace_writer.get());
+ track, ctx.tls_inst_->trace_writer.get(), ctx.GetIncrementalState());
});
}
@@ -453,11 +453,8 @@
// Make sure incremental state is valid.
TraceWriterBase* trace_writer = ctx.tls_inst_->trace_writer.get();
TrackEventIncrementalState* incr_state = ctx.GetIncrementalState();
- if (incr_state->was_cleared) {
- incr_state->was_cleared = false;
- TrackEventInternal::ResetIncrementalState(trace_writer,
- trace_timestamp);
- }
+ TrackEventInternal::ResetIncrementalStateIfRequired(
+ trace_writer, incr_state, trace_timestamp);
// Write the track descriptor before any event on the track.
if (track) {
@@ -516,7 +513,7 @@
TrackRegistry::Get()->UpdateTrack(track, std::move(callback));
Base::template Trace([&](typename Base::TraceContext ctx) {
TrackEventInternal::WriteTrackDescriptor(
- track, ctx.tls_inst_->trace_writer.get());
+ track, ctx.tls_inst_->trace_writer.get(), ctx.GetIncrementalState());
});
}
diff --git a/include/perfetto/tracing/internal/track_event_internal.h b/include/perfetto/tracing/internal/track_event_internal.h
index 5bb6ec2..538274c 100644
--- a/include/perfetto/tracing/internal/track_event_internal.h
+++ b/include/perfetto/tracing/internal/track_event_internal.h
@@ -160,8 +160,15 @@
perfetto::protos::pbzero::TrackEvent::Type,
TraceTimestamp timestamp = {GetClockId(), GetTimeNs()});
- static void ResetIncrementalState(TraceWriterBase*, TraceTimestamp);
-
+ static void ResetIncrementalStateIfRequired(
+ TraceWriterBase* trace_writer,
+ TrackEventIncrementalState* incr_state,
+ TraceTimestamp timestamp) {
+ if (incr_state->was_cleared) {
+ incr_state->was_cleared = false;
+ ResetIncrementalState(trace_writer, incr_state, timestamp);
+ }
+ }
// TODO(altimin): Remove this method once Chrome uses
// EventContext::AddDebugAnnotation directly.
template <typename T>
@@ -184,15 +191,18 @@
auto it_and_inserted = incr_state->seen_tracks.insert(track.uuid);
if (PERFETTO_LIKELY(!it_and_inserted.second))
return;
- WriteTrackDescriptor(track, trace_writer);
+ WriteTrackDescriptor(track, trace_writer, incr_state);
}
// Unconditionally write a track descriptor into the trace.
template <typename TrackType>
static void WriteTrackDescriptor(const TrackType& track,
- TraceWriterBase* trace_writer) {
- TrackRegistry::Get()->SerializeTrack(
- track, NewTracePacket(trace_writer, {GetClockId(), GetTimeNs()}));
+ TraceWriterBase* trace_writer,
+ TrackEventIncrementalState* incr_state) {
+ TraceTimestamp ts = {GetClockId(), GetTimeNs()};
+ ResetIncrementalStateIfRequired(trace_writer, incr_state, ts);
+ TrackRegistry::Get()->SerializeTrack(track,
+ NewTracePacket(trace_writer, ts));
}
// Get the current time in nanoseconds in the trace clock timebase.
@@ -214,6 +224,10 @@
static const Track kDefaultTrack;
private:
+ static void ResetIncrementalState(TraceWriterBase*,
+ TrackEventIncrementalState* incr_state,
+ TraceTimestamp);
+
static protozero::MessageHandle<protos::pbzero::TracePacket> NewTracePacket(
TraceWriterBase*,
TraceTimestamp,
diff --git a/include/perfetto/tracing/internal/track_event_macros.h b/include/perfetto/tracing/internal/track_event_macros.h
index c82134d..a901524 100644
--- a/include/perfetto/tracing/internal/track_event_macros.h
+++ b/include/perfetto/tracing/internal/track_event_macros.h
@@ -87,9 +87,16 @@
} // namespace internal
// Defines the TrackEvent data source for the current track event namespace.
+// `virtual ~TrackEvent` is added to avoid `-Wweak-vtables` warning.
+// Learn more : aosp/2019906
#define PERFETTO_INTERNAL_DECLARE_TRACK_EVENT_DATA_SOURCE() \
struct TrackEvent : public ::perfetto::internal::TrackEventDataSource< \
- TrackEvent, &internal::kCategoryRegistry> {}
+ TrackEvent, &internal::kCategoryRegistry> { \
+ virtual ~TrackEvent(); \
+ }
+
+#define PERFETTO_INTERNAL_DEFINE_TRACK_EVENT_DATA_SOURCE() \
+ TrackEvent::~TrackEvent() = default;
// At compile time, turns a category name represented by a static string into an
// index into the current category registry. A build error will be generated if
diff --git a/include/perfetto/tracing/track_event.h b/include/perfetto/tracing/track_event.h
index 7e226f0..45499eb 100644
--- a/include/perfetto/tracing/track_event.h
+++ b/include/perfetto/tracing/track_event.h
@@ -184,12 +184,13 @@
// Allocate storage for each category by using this macro once per track event
// namespace.
-#define PERFETTO_TRACK_EVENT_STATIC_STORAGE() \
- namespace PERFETTO_TRACK_EVENT_NAMESPACE { \
- PERFETTO_INTERNAL_CATEGORY_STORAGE() \
- } /* namespace PERFETTO_TRACK_EVENT_NAMESPACE */ \
- PERFETTO_DEFINE_DATA_SOURCE_STATIC_MEMBERS( \
- PERFETTO_TRACK_EVENT_NAMESPACE::TrackEvent, \
+#define PERFETTO_TRACK_EVENT_STATIC_STORAGE() \
+ namespace PERFETTO_TRACK_EVENT_NAMESPACE { \
+ PERFETTO_INTERNAL_CATEGORY_STORAGE() \
+ PERFETTO_INTERNAL_DEFINE_TRACK_EVENT_DATA_SOURCE() \
+ } /* namespace PERFETTO_TRACK_EVENT_NAMESPACE */ \
+ PERFETTO_DEFINE_DATA_SOURCE_STATIC_MEMBERS( \
+ PERFETTO_TRACK_EVENT_NAMESPACE::TrackEvent, \
perfetto::internal::TrackEventDataSourceTraits)
// Ignore GCC warning about a missing argument for a variadic macro parameter.
diff --git a/protos/perfetto/trace/ftrace/ftrace_event.proto b/protos/perfetto/trace/ftrace/ftrace_event.proto
index e23b909..f7b4d53 100644
--- a/protos/perfetto/trace/ftrace/ftrace_event.proto
+++ b/protos/perfetto/trace/ftrace/ftrace_event.proto
@@ -499,5 +499,7 @@
KvmWfxArm64FtraceEvent kvm_wfx_arm64 = 401;
TrapRegFtraceEvent trap_reg = 402;
VgicUpdateIrqPendingFtraceEvent vgic_update_irq_pending = 403;
+ WakeupSourceActivateFtraceEvent wakeup_source_activate = 404;
+ WakeupSourceDeactivateFtraceEvent wakeup_source_deactivate = 405;
}
}
diff --git a/protos/perfetto/trace/ftrace/power.proto b/protos/perfetto/trace/ftrace/power.proto
index f38015a..7279e24 100644
--- a/protos/perfetto/trace/ftrace/power.proto
+++ b/protos/perfetto/trace/ftrace/power.proto
@@ -42,3 +42,11 @@
optional uint32 gpu_id = 1;
optional uint32 state = 2;
}
+message WakeupSourceActivateFtraceEvent {
+ optional string name = 1;
+ optional uint64 state = 2;
+}
+message WakeupSourceDeactivateFtraceEvent {
+ optional string name = 1;
+ optional uint64 state = 2;
+}
diff --git a/protos/perfetto/trace/perfetto_trace.proto b/protos/perfetto/trace/perfetto_trace.proto
index cede0b6..39b2ad0 100644
--- a/protos/perfetto/trace/perfetto_trace.proto
+++ b/protos/perfetto/trace/perfetto_trace.proto
@@ -5528,6 +5528,14 @@
optional uint32 gpu_id = 1;
optional uint32 state = 2;
}
+message WakeupSourceActivateFtraceEvent {
+ optional string name = 1;
+ optional uint64 state = 2;
+}
+message WakeupSourceDeactivateFtraceEvent {
+ optional string name = 1;
+ optional uint64 state = 2;
+}
// End of protos/perfetto/trace/ftrace/power.proto
@@ -6325,6 +6333,8 @@
KvmWfxArm64FtraceEvent kvm_wfx_arm64 = 401;
TrapRegFtraceEvent trap_reg = 402;
VgicUpdateIrqPendingFtraceEvent vgic_update_irq_pending = 403;
+ WakeupSourceActivateFtraceEvent wakeup_source_activate = 404;
+ WakeupSourceDeactivateFtraceEvent wakeup_source_deactivate = 405;
}
}
diff --git a/src/trace_processor/importers/ftrace/ftrace_descriptors.cc b/src/trace_processor/importers/ftrace/ftrace_descriptors.cc
index ea7c8a2..1692c44 100644
--- a/src/trace_processor/importers/ftrace/ftrace_descriptors.cc
+++ b/src/trace_processor/importers/ftrace/ftrace_descriptors.cc
@@ -24,7 +24,7 @@
namespace trace_processor {
namespace {
-std::array<MessageDescriptor, 404> descriptors{{
+std::array<MessageDescriptor, 406> descriptors{{
{nullptr, 0, {}},
{nullptr, 0, {}},
{nullptr, 0, {}},
@@ -4343,6 +4343,24 @@
{"vcpu_id", ProtoSchemaType::kUint64},
},
},
+ {
+ "wakeup_source_activate",
+ 2,
+ {
+ {},
+ {"name", ProtoSchemaType::kString},
+ {"state", ProtoSchemaType::kUint64},
+ },
+ },
+ {
+ "wakeup_source_deactivate",
+ 2,
+ {
+ {},
+ {"name", ProtoSchemaType::kString},
+ {"state", ProtoSchemaType::kUint64},
+ },
+ },
}};
} // namespace
diff --git a/src/traced/probes/ftrace/event_info.cc b/src/traced/probes/ftrace/event_info.cc
index af0dfb5..f24895d 100644
--- a/src/traced/probes/ftrace/event_info.cc
+++ b/src/traced/probes/ftrace/event_info.cc
@@ -6622,6 +6622,32 @@
kUnsetFtraceId,
332,
kUnsetSize},
+ {"wakeup_source_activate",
+ "power",
+ {
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "name", 1, ProtoSchemaType::kString,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "state", 2, ProtoSchemaType::kUint64,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ },
+ kUnsetFtraceId,
+ 404,
+ kUnsetSize},
+ {"wakeup_source_deactivate",
+ "power",
+ {
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "name", 1, ProtoSchemaType::kString,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ {kUnsetOffset, kUnsetSize, FtraceFieldType::kInvalidFtraceFieldType,
+ "state", 2, ProtoSchemaType::kUint64,
+ TranslationStrategy::kInvalidTranslationStrategy},
+ },
+ kUnsetFtraceId,
+ 405,
+ kUnsetSize},
{"sys_enter",
"raw_syscalls",
{
diff --git a/src/traced/probes/ftrace/test/data/synthetic/events/power/wakeup_source_activate/format b/src/traced/probes/ftrace/test/data/synthetic/events/power/wakeup_source_activate/format
new file mode 100644
index 0000000..b8b39d8
--- /dev/null
+++ b/src/traced/probes/ftrace/test/data/synthetic/events/power/wakeup_source_activate/format
@@ -0,0 +1,12 @@
+name: wakeup_source_activate
+ID: 123
+format:
+ field:unsigned short common_type; offset:0; size:2; signed:0;
+ field:unsigned char common_flags; offset:2; size:1; signed:0;
+ field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
+ field:int common_pid; offset:4; size:4; signed:1;
+
+ field:__data_loc char[] name; offset:8; size:4; signed:0;
+ field:u64 state; offset:16; size:8; signed:0;
+
+print fmt: "%s state=0x%lx", __get_str(name), (unsigned long)REC->state
diff --git a/src/traced/probes/ftrace/test/data/synthetic/events/power/wakeup_source_deactivate/format b/src/traced/probes/ftrace/test/data/synthetic/events/power/wakeup_source_deactivate/format
new file mode 100644
index 0000000..03e9b39
--- /dev/null
+++ b/src/traced/probes/ftrace/test/data/synthetic/events/power/wakeup_source_deactivate/format
@@ -0,0 +1,12 @@
+name: wakeup_source_deactivate
+ID: 124
+format:
+ field:unsigned short common_type; offset:0; size:2; signed:0;
+ field:unsigned char common_flags; offset:2; size:1; signed:0;
+ field:unsigned char common_preempt_count; offset:3; size:1; signed:0;
+ field:int common_pid; offset:4; size:4; signed:1;
+
+ field:__data_loc char[] name; offset:8; size:4; signed:0;
+ field:u64 state; offset:16; size:8; signed:0;
+
+print fmt: "%s state=0x%lx", __get_str(name), (unsigned long)REC->state
diff --git a/src/tracing/internal/track_event_internal.cc b/src/tracing/internal/track_event_internal.cc
index 3717fb2..c439c54 100644
--- a/src/tracing/internal/track_event_internal.cc
+++ b/src/tracing/internal/track_event_internal.cc
@@ -308,8 +308,10 @@
}
// static
-void TrackEventInternal::ResetIncrementalState(TraceWriterBase* trace_writer,
- TraceTimestamp timestamp) {
+void TrackEventInternal::ResetIncrementalState(
+ TraceWriterBase* trace_writer,
+ TrackEventIncrementalState* incr_state,
+ TraceTimestamp timestamp) {
auto default_track = ThreadTrack::Current();
{
// Mark any incremental state before this point invalid. Also set up
@@ -329,8 +331,8 @@
// trace points won't explicitly reference it. We also write the process
// descriptor from every thread that writes trace events to ensure it gets
// emitted at least once.
- WriteTrackDescriptor(default_track, trace_writer);
- WriteTrackDescriptor(ProcessTrack::Current(), trace_writer);
+ WriteTrackDescriptor(default_track, trace_writer, incr_state);
+ WriteTrackDescriptor(ProcessTrack::Current(), trace_writer, incr_state);
}
// static
diff --git a/src/tracing/test/api_integrationtest.cc b/src/tracing/test/api_integrationtest.cc
index 26d8a03..0a4d461 100644
--- a/src/tracing/test/api_integrationtest.cc
+++ b/src/tracing/test/api_integrationtest.cc
@@ -1406,7 +1406,7 @@
if (packet.has_track_descriptor()) {
if (packet.trusted_packet_sequence_id() == main_thread_sequence) {
descs.push_back(packet.track_descriptor());
- } else {
+ } else if (packet.track_descriptor().has_thread()) {
thread_descs.push_back(packet.track_descriptor());
}
}
@@ -1431,9 +1431,8 @@
EXPECT_EQ("goodbye.exe", descs[2].name());
// The child thread records only its own thread descriptor (twice, since it
- // was mutated). The child thread also emits another copy of the process
- // descriptor.
- EXPECT_EQ(3u, thread_descs.size());
+ // was mutated).
+ ASSERT_EQ(2u, thread_descs.size());
EXPECT_EQ("TestThread", thread_descs[0].name());
EXPECT_NE(0, thread_descs[0].thread().pid());
EXPECT_NE(0, thread_descs[0].thread().tid());
@@ -1478,7 +1477,8 @@
continue;
if (packet.has_track_descriptor()) {
auto td = packet.track_descriptor();
- EXPECT_TRUE(td.has_process());
+ if (!td.has_process())
+ continue;
EXPECT_NE(0, td.process().pid());
EXPECT_TRUE(td.has_chrome_process());
EXPECT_EQ("testing.exe", td.process().process_name());
diff --git a/tools/ftrace_proto_gen/event_list b/tools/ftrace_proto_gen/event_list
index de39399..d60a545 100644
--- a/tools/ftrace_proto_gen/event_list
+++ b/tools/ftrace_proto_gen/event_list
@@ -398,3 +398,5 @@
kvm/kvm_wfx_arm64
kvm/trap_reg
kvm/vgic_update_irq_pending
+power/wakeup_source_activate
+power/wakeup_source_deactivate
diff --git a/ui/release/channels.json b/ui/release/channels.json
index dbda68f..1540749 100644
--- a/ui/release/channels.json
+++ b/ui/release/channels.json
@@ -6,7 +6,7 @@
},
{
"name": "canary",
- "rev": "88e543ae67d219635038cd007ab3b5a45a0e2614"
+ "rev": "433c9fe808b23a28f3bcfaaf026830d908be4104"
},
{
"name": "autopush",