traced_probes: process tree - handle ClearIncrementalState()
Lets us not lose long-standing process/thread data when tracing to a ring
buffer. Might also help with noticing process renames (e.g. USAPs).
I believe we don't really need any corresponding trace processor changes at
this point, as it always uses the last (for the whole trace) description for a
given pid.
Bug: 132394650
Change-Id: I2818d9889651830f9edf54e154f7fed01f2dd0fd
diff --git a/src/traced/probes/probes_producer.cc b/src/traced/probes/probes_producer.cc
index 1933344..afe2ded 100644
--- a/src/traced/probes/probes_producer.cc
+++ b/src/traced/probes/probes_producer.cc
@@ -96,6 +96,7 @@
{
DataSourceDescriptor desc;
desc.set_name(kProcessStatsSourceName);
+ desc.set_handles_incremental_state_clear(true);
endpoint_->RegisterDataSource(desc);
}
@@ -396,6 +397,19 @@
endpoint_->NotifyFlushComplete(flush_request_id);
}
+void ProbesProducer::ClearIncrementalState(
+ const DataSourceInstanceID* data_source_ids,
+ size_t num_data_sources) {
+ for (size_t i = 0; i < num_data_sources; i++) {
+ DataSourceInstanceID ds_id = data_source_ids[i];
+ auto it = data_sources_.find(ds_id);
+ if (it == data_sources_.end() || !it->second->started)
+ continue;
+
+ it->second->ClearIncrementalState();
+ }
+}
+
// This function is called by the FtraceController in batches, whenever it has
// read one or more pages from one or more cpus and written that into the
// userspace tracing buffer. If more than one ftrace data sources are active,