blob: c3a4f4366a3e6b7c00827e2522cc01bb3a77746a [file] [log] [blame]
Primiano Tucci4f9b6d72017-12-05 20:59:16 +00001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "perfetto/ftrace_reader/ftrace_controller.h"
18
19#include <fcntl.h>
20#include <stdint.h>
21#include <string.h>
22#include <sys/stat.h>
23#include <sys/types.h>
Hector Dearmanc61e8832018-01-25 12:10:12 +000024#include <sys/wait.h>
Hector Dearman0134e7f2018-02-13 12:35:44 +000025#include <unistd.h>
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000026
27#include <array>
28#include <string>
Florian Mayer22e4b392018-03-08 10:20:11 +000029#include <utility>
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000030
Hector Dearmanc61e8832018-01-25 12:10:12 +000031#include "perfetto/base/build_config.h"
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000032#include "perfetto/base/logging.h"
Primiano Tucci8934c6c2018-03-15 11:39:27 +000033#include "perfetto/base/time.h"
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000034#include "perfetto/base/utils.h"
Florian Mayerba3eeae2018-03-12 11:48:21 +000035#include "src/ftrace_reader/cpu_reader.h"
36#include "src/ftrace_reader/event_info.h"
37#include "src/ftrace_reader/ftrace_config_muxer.h"
38#include "src/ftrace_reader/ftrace_procfs.h"
39#include "src/ftrace_reader/proto_translation_table.h"
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000040
Primiano Tucci20b760c2018-01-19 12:36:12 +000041#include "perfetto/trace/ftrace/ftrace_event_bundle.pbzero.h"
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000042
43namespace perfetto {
44namespace {
45
Oystein Eftevaagff729592018-02-12 14:24:06 -080046#if PERFETTO_BUILDFLAG(PERFETTO_OS_ANDROID)
Florian Mayerdbd08782018-03-21 14:07:51 +000047constexpr const char* kTracingPaths[] = {
Isabelle Taylorc31a4312018-01-22 16:44:28 +000048 "/sys/kernel/tracing/", "/sys/kernel/debug/tracing/", nullptr,
49};
50#else
Florian Mayerdbd08782018-03-21 14:07:51 +000051constexpr const char* kTracingPaths[] = {
Isabelle Taylorc31a4312018-01-22 16:44:28 +000052 "/sys/kernel/debug/tracing/", nullptr,
53};
54#endif
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000055
Florian Mayerdbd08782018-03-21 14:07:51 +000056constexpr int kDefaultDrainPeriodMs = 100;
57constexpr int kMinDrainPeriodMs = 1;
58constexpr int kMaxDrainPeriodMs = 1000 * 60;
Hector Dearman6ea67b32018-02-01 15:45:15 +000059
Hector Dearman6ea67b32018-02-01 15:45:15 +000060uint32_t ClampDrainPeriodMs(uint32_t drain_period_ms) {
61 if (drain_period_ms == 0) {
62 return kDefaultDrainPeriodMs;
63 }
64 if (drain_period_ms < kMinDrainPeriodMs ||
65 kMaxDrainPeriodMs < drain_period_ms) {
66 PERFETTO_LOG("drain_period_ms was %u should be between %u and %u",
67 drain_period_ms, kMinDrainPeriodMs, kMaxDrainPeriodMs);
68 return kDefaultDrainPeriodMs;
69 }
70 return drain_period_ms;
71}
72
Hector Dearman0134e7f2018-02-13 12:35:44 +000073void WriteToFile(const char* path, const char* str) {
74 int fd = open(path, O_WRONLY);
75 if (fd == -1)
76 return;
Hector Dearman87d529c2018-02-13 15:11:11 +000077 perfetto::base::ignore_result(write(fd, str, strlen(str)));
78 perfetto::base::ignore_result(close(fd));
Hector Dearman0134e7f2018-02-13 12:35:44 +000079}
80
81void ClearFile(const char* path) {
82 int fd = open(path, O_WRONLY | O_TRUNC);
83 if (fd == -1)
84 return;
Hector Dearman87d529c2018-02-13 15:11:11 +000085 perfetto::base::ignore_result(close(fd));
Hector Dearman0134e7f2018-02-13 12:35:44 +000086}
87
Primiano Tucci4f9b6d72017-12-05 20:59:16 +000088} // namespace
89
Hector Dearman0134e7f2018-02-13 12:35:44 +000090// Method of last resort to reset ftrace state.
91// We don't know what state the rest of the system and process is so as far
92// as possible avoid allocations.
93void HardResetFtraceState() {
94 WriteToFile("/sys/kernel/debug/tracing/tracing_on", "0");
95 WriteToFile("/sys/kernel/debug/tracing/buffer_size_kb", "4");
96 WriteToFile("/sys/kernel/debug/tracing/events/enable", "0");
97 ClearFile("/sys/kernel/debug/tracing/trace");
98
99 WriteToFile("/sys/kernel/tracing/tracing_on", "0");
100 WriteToFile("/sys/kernel/tracing/buffer_size_kb", "4");
101 WriteToFile("/sys/kernel/tracing/events/enable", "0");
102 ClearFile("/sys/kernel/tracing/trace");
103}
104
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000105// static
Isabelle Taylorc31a4312018-01-22 16:44:28 +0000106// TODO(taylori): Add a test for tracing paths in integration tests.
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000107std::unique_ptr<FtraceController> FtraceController::Create(
108 base::TaskRunner* runner) {
Isabelle Taylorc31a4312018-01-22 16:44:28 +0000109 size_t index = 0;
110 std::unique_ptr<FtraceProcfs> ftrace_procfs = nullptr;
111 while (!ftrace_procfs && kTracingPaths[index]) {
112 ftrace_procfs = FtraceProcfs::Create(kTracingPaths[index++]);
113 }
114
Hector Dearman50139712018-02-23 15:43:41 +0000115 if (!ftrace_procfs)
Isabelle Taylorc31a4312018-01-22 16:44:28 +0000116 return nullptr;
Isabelle Taylorc31a4312018-01-22 16:44:28 +0000117
Hector Dearman77af1332017-12-15 11:55:33 +0000118 auto table = ProtoTranslationTable::Create(
119 ftrace_procfs.get(), GetStaticEventInfo(), GetStaticCommonFieldsInfo());
Hector Dearman50139712018-02-23 15:43:41 +0000120
121 std::unique_ptr<FtraceConfigMuxer> model = std::unique_ptr<FtraceConfigMuxer>(
122 new FtraceConfigMuxer(ftrace_procfs.get(), table.get()));
123 return std::unique_ptr<FtraceController>(new FtraceController(
124 std::move(ftrace_procfs), std::move(table), std::move(model), runner));
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000125}
126
127FtraceController::FtraceController(std::unique_ptr<FtraceProcfs> ftrace_procfs,
Hector Dearman50139712018-02-23 15:43:41 +0000128 std::unique_ptr<ProtoTranslationTable> table,
129 std::unique_ptr<FtraceConfigMuxer> model,
130 base::TaskRunner* task_runner)
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000131 : ftrace_procfs_(std::move(ftrace_procfs)),
Primiano Tucci68323b02017-12-18 10:54:13 +0100132 table_(std::move(table)),
Hector Dearman50139712018-02-23 15:43:41 +0000133 ftrace_config_muxer_(std::move(model)),
134 task_runner_(task_runner),
Primiano Tucci68323b02017-12-18 10:54:13 +0100135 weak_factory_(this) {}
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000136
137FtraceController::~FtraceController() {
Sami Kyostila247110b2018-02-14 10:18:45 +0000138 PERFETTO_DCHECK_THREAD(thread_checker_);
Hector Dearman50139712018-02-23 15:43:41 +0000139 for (const auto* sink : sinks_)
140 ftrace_config_muxer_->RemoveConfig(sink->id_);
Sami Kyostila247110b2018-02-14 10:18:45 +0000141 sinks_.clear();
142 StopIfNeeded();
143}
144
145uint64_t FtraceController::NowMs() const {
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100146 return static_cast<uint64_t>(base::GetWallTimeMs().count());
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000147}
148
Hector Dearman680a28b2018-01-11 18:34:24 +0000149// static
Sami Kyostila247110b2018-02-14 10:18:45 +0000150void FtraceController::DrainCPUs(base::WeakPtr<FtraceController> weak_this,
151 size_t generation) {
Hector Dearman680a28b2018-01-11 18:34:24 +0000152 // The controller might be gone.
153 if (!weak_this)
154 return;
Hector Dearman680a28b2018-01-11 18:34:24 +0000155 // We might have stopped tracing then quickly re-enabled it, in this case
156 // we don't want to end up with two periodic tasks for each CPU:
157 if (weak_this->generation_ != generation)
158 return;
159
Sami Kyostila247110b2018-02-14 10:18:45 +0000160 PERFETTO_DCHECK_THREAD(weak_this->thread_checker_);
161 std::bitset<kMaxCpus> cpus_to_drain;
162 {
163 std::unique_lock<std::mutex> lock(weak_this->lock_);
164 // We might have stopped caring about events.
165 if (!weak_this->listening_for_raw_trace_data_)
166 return;
167 std::swap(cpus_to_drain, weak_this->cpus_to_drain_);
168 }
169
170 for (size_t cpu = 0; cpu < weak_this->ftrace_procfs_->NumberOfCpus(); cpu++) {
171 if (!cpus_to_drain[cpu])
172 continue;
173 weak_this->OnRawFtraceDataAvailable(cpu);
174 }
175
176 // If we filled up any SHM pages while draining the data, we will have posted
177 // a task to notify traced about this. Only unblock the readers after this
178 // notification is sent to make it less likely that they steal CPU time away
179 // from traced.
180 weak_this->task_runner_->PostTask(
181 std::bind(&FtraceController::UnblockReaders, weak_this));
182}
183
184// static
185void FtraceController::UnblockReaders(
Florian Mayer22e4b392018-03-08 10:20:11 +0000186 const base::WeakPtr<FtraceController>& weak_this) {
Sami Kyostila247110b2018-02-14 10:18:45 +0000187 if (!weak_this)
188 return;
189 // Unblock all waiting readers to start moving more data into their
190 // respective staging pipes.
191 weak_this->data_drained_.notify_all();
Hector Dearman680a28b2018-01-11 18:34:24 +0000192}
193
Hector Dearman5c87a752017-12-07 12:40:04 +0000194void FtraceController::StartIfNeeded() {
195 if (sinks_.size() > 1)
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000196 return;
Florian Mayer22e4b392018-03-08 10:20:11 +0000197 PERFETTO_CHECK(!sinks_.empty());
Sami Kyostila247110b2018-02-14 10:18:45 +0000198 {
199 std::unique_lock<std::mutex> lock(lock_);
200 PERFETTO_CHECK(!listening_for_raw_trace_data_);
201 listening_for_raw_trace_data_ = true;
202 }
Hector Dearman20b3c1c2018-01-15 15:34:03 +0000203 generation_++;
Sami Kyostila247110b2018-02-14 10:18:45 +0000204 base::WeakPtr<FtraceController> weak_this = weak_factory_.GetWeakPtr();
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000205 for (size_t cpu = 0; cpu < ftrace_procfs_->NumberOfCpus(); cpu++) {
Sami Kyostila247110b2018-02-14 10:18:45 +0000206 readers_.emplace(
207 cpu, std::unique_ptr<CpuReader>(new CpuReader(
208 table_.get(), cpu, ftrace_procfs_->OpenPipeForCpu(cpu),
209 std::bind(&FtraceController::OnDataAvailable, this, weak_this,
210 generation_, cpu, GetDrainPeriodMs()))));
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000211 }
212}
213
Hector Dearman6ea67b32018-02-01 15:45:15 +0000214uint32_t FtraceController::GetDrainPeriodMs() {
Florian Mayer22e4b392018-03-08 10:20:11 +0000215 if (sinks_.empty())
Hector Dearman6ea67b32018-02-01 15:45:15 +0000216 return kDefaultDrainPeriodMs;
217 uint32_t min_drain_period_ms = kMaxDrainPeriodMs + 1;
218 for (const FtraceSink* sink : sinks_) {
219 if (sink->config().drain_period_ms() < min_drain_period_ms)
220 min_drain_period_ms = sink->config().drain_period_ms();
221 }
222 return ClampDrainPeriodMs(min_drain_period_ms);
223}
224
Hector Dearmane4cc95d2018-01-09 14:32:24 +0000225void FtraceController::ClearTrace() {
226 ftrace_procfs_->ClearTrace();
227}
228
229void FtraceController::DisableAllEvents() {
230 ftrace_procfs_->DisableAllEvents();
231}
232
233void FtraceController::WriteTraceMarker(const std::string& s) {
234 ftrace_procfs_->WriteTraceMarker(s);
235}
236
Hector Dearman5c87a752017-12-07 12:40:04 +0000237void FtraceController::StopIfNeeded() {
Florian Mayer22e4b392018-03-08 10:20:11 +0000238 if (!sinks_.empty())
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000239 return;
Sami Kyostila247110b2018-02-14 10:18:45 +0000240 {
241 // Unblock any readers that are waiting for us to drain data.
242 std::unique_lock<std::mutex> lock(lock_);
Sami Kyostila247110b2018-02-14 10:18:45 +0000243 listening_for_raw_trace_data_ = false;
244 cpus_to_drain_.reset();
245 }
246 data_drained_.notify_all();
Hector Dearman5c87a752017-12-07 12:40:04 +0000247 readers_.clear();
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000248}
249
Sami Kyostila247110b2018-02-14 10:18:45 +0000250void FtraceController::OnRawFtraceDataAvailable(size_t cpu) {
251 PERFETTO_CHECK(cpu < ftrace_procfs_->NumberOfCpus());
252 CpuReader* reader = readers_[cpu].get();
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000253 using BundleHandle =
Hector Dearmanaaa4c192018-02-19 11:57:35 +0000254 protozero::MessageHandle<protos::pbzero::FtraceEventBundle>;
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000255 std::array<const EventFilter*, kMaxSinks> filters{};
256 std::array<BundleHandle, kMaxSinks> bundles{};
Hector Dearmanc8488032018-03-02 13:12:01 +0000257 std::array<FtraceMetadata*, kMaxSinks> metadatas{};
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000258 size_t sink_count = sinks_.size();
259 size_t i = 0;
260 for (FtraceSink* sink : sinks_) {
Hector Dearmanc8488032018-03-02 13:12:01 +0000261 filters[i] = sink->event_filter();
262 metadatas[i] = sink->metadata_mutable();
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000263 bundles[i++] = sink->GetBundleForCpu(cpu);
264 }
Hector Dearmanc8488032018-03-02 13:12:01 +0000265 reader->Drain(filters, bundles, metadatas);
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000266 i = 0;
267 for (FtraceSink* sink : sinks_)
268 sink->OnBundleComplete(cpu, std::move(bundles[i++]));
269 PERFETTO_DCHECK(sinks_.size() == sink_count);
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000270}
271
272std::unique_ptr<FtraceSink> FtraceController::CreateSink(
Florian Mayer380e0042018-03-08 10:23:34 +0000273 FtraceConfig config,
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000274 FtraceSink::Delegate* delegate) {
275 PERFETTO_DCHECK_THREAD(thread_checker_);
276 if (sinks_.size() >= kMaxSinks)
277 return nullptr;
Hector Dearmancb4ba322018-02-09 14:12:27 +0000278 if (!ValidConfig(config))
279 return nullptr;
Hector Dearman50139712018-02-23 15:43:41 +0000280
281 FtraceConfigId id = ftrace_config_muxer_->RequestConfig(config);
282 if (!id)
283 return nullptr;
284
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000285 auto controller_weak = weak_factory_.GetWeakPtr();
Hector Dearman50139712018-02-23 15:43:41 +0000286 auto filter = std::unique_ptr<EventFilter>(new EventFilter(
Florian Mayer22e4b392018-03-08 10:20:11 +0000287 *table_, FtraceEventsAsSet(*ftrace_config_muxer_->GetConfig(id))));
Hector Dearman50139712018-02-23 15:43:41 +0000288
Florian Mayer380e0042018-03-08 10:23:34 +0000289 auto sink = std::unique_ptr<FtraceSink>(
290 new FtraceSink(std::move(controller_weak), id, std::move(config),
291 std::move(filter), delegate));
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000292 Register(sink.get());
293 return sink;
294}
295
Sami Kyostila247110b2018-02-14 10:18:45 +0000296void FtraceController::OnDataAvailable(
297 base::WeakPtr<FtraceController> weak_this,
298 size_t generation,
299 size_t cpu,
300 uint32_t drain_period_ms) {
301 // Called on the worker thread.
302 PERFETTO_DCHECK(cpu < ftrace_procfs_->NumberOfCpus());
303 std::unique_lock<std::mutex> lock(lock_);
304 if (!listening_for_raw_trace_data_)
305 return;
306 if (cpus_to_drain_.none()) {
307 // If this was the first CPU to wake up, schedule a drain for the next drain
308 // interval.
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100309 uint32_t delay_ms = drain_period_ms - (NowMs() % drain_period_ms);
Sami Kyostila247110b2018-02-14 10:18:45 +0000310 task_runner_->PostDelayedTask(
311 std::bind(&FtraceController::DrainCPUs, weak_this, generation),
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100312 delay_ms);
Sami Kyostila247110b2018-02-14 10:18:45 +0000313 }
314 cpus_to_drain_[cpu] = true;
315
316 // Wait until the main thread has finished draining.
317 // TODO(skyostil): The threads waiting here will all try to grab lock_
318 // when woken up. Find a way to avoid this.
319 data_drained_.wait(lock, [this, cpu] {
320 return !cpus_to_drain_[cpu] || !listening_for_raw_trace_data_;
321 });
322}
323
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000324void FtraceController::Register(FtraceSink* sink) {
325 PERFETTO_DCHECK_THREAD(thread_checker_);
326 auto it_and_inserted = sinks_.insert(sink);
327 PERFETTO_DCHECK(it_and_inserted.second);
Hector Dearman5c87a752017-12-07 12:40:04 +0000328 StartIfNeeded();
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000329}
330
331void FtraceController::Unregister(FtraceSink* sink) {
332 PERFETTO_DCHECK_THREAD(thread_checker_);
Hector Dearman50139712018-02-23 15:43:41 +0000333
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000334 size_t removed = sinks_.erase(sink);
335 PERFETTO_DCHECK(removed == 1);
Hector Dearman5c87a752017-12-07 12:40:04 +0000336
Hector Dearman50139712018-02-23 15:43:41 +0000337 ftrace_config_muxer_->RemoveConfig(sink->id_);
338
Hector Dearman5c87a752017-12-07 12:40:04 +0000339 StopIfNeeded();
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000340}
341
342FtraceSink::FtraceSink(base::WeakPtr<FtraceController> controller_weak,
Hector Dearman50139712018-02-23 15:43:41 +0000343 FtraceConfigId id,
Hector Dearmanc61e8832018-01-25 12:10:12 +0000344 FtraceConfig config,
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000345 std::unique_ptr<EventFilter> filter,
346 Delegate* delegate)
347 : controller_weak_(std::move(controller_weak)),
Hector Dearman50139712018-02-23 15:43:41 +0000348 id_(id),
Florian Mayer22e4b392018-03-08 10:20:11 +0000349 config_(std::move(config)),
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000350 filter_(std::move(filter)),
351 delegate_(delegate){};
352
353FtraceSink::~FtraceSink() {
354 if (controller_weak_)
355 controller_weak_->Unregister(this);
356};
357
358const std::set<std::string>& FtraceSink::enabled_events() {
359 return filter_->enabled_names();
360}
361
Hector Dearmanc8488032018-03-02 13:12:01 +0000362FtraceMetadata::FtraceMetadata() {
363 // A lot of the time there will only be a small number of inodes.
Anna Zappone8ce30872018-03-19 17:01:15 +0000364 inode_and_device.reserve(10);
Hector Dearmanc8488032018-03-02 13:12:01 +0000365 pids.reserve(10);
366}
367
Anna Zappone8ce30872018-03-19 17:01:15 +0000368void FtraceMetadata::AddDevice(BlockDeviceID device_id) {
369 last_seen_device_id = device_id;
Florian Mayer31746152018-03-23 15:42:05 +0000370#if PERFETTO_DCHECK_IS_ON()
371 seen_device_id = true;
372#endif
Anna Zappone4ea73c02018-03-09 16:01:21 +0000373}
374
Anna Zappone8ce30872018-03-19 17:01:15 +0000375void FtraceMetadata::AddInode(Inode inode_number) {
Florian Mayer31746152018-03-23 15:42:05 +0000376#if PERFETTO_DCHECK_IS_ON()
377 PERFETTO_DCHECK(seen_device_id);
378#endif
Florian Mayerb8e235b2018-03-22 20:32:50 +0000379 static int32_t cached_pid = 0;
380 if (!cached_pid)
381 cached_pid = getpid();
382
383 PERFETTO_DCHECK(last_seen_common_pid);
384 PERFETTO_DCHECK(cached_pid == getpid());
385 // Ignore own scanning activity.
386 if (cached_pid != last_seen_common_pid) {
387 inode_and_device.push_back(
388 std::make_pair(inode_number, last_seen_device_id));
389 }
Anna Zappone4ea73c02018-03-09 16:01:21 +0000390}
391
Florian Mayerb8e235b2018-03-22 20:32:50 +0000392void FtraceMetadata::AddCommonPid(int32_t pid) {
393 last_seen_common_pid = pid;
394}
395
Hector Dearmanf19e7c52018-03-06 10:25:01 +0000396void FtraceMetadata::AddPid(int32_t pid) {
397 // Speculative optimization aginst repated pid's while keeping
398 // faster insertion than a set.
Florian Mayer22e4b392018-03-08 10:20:11 +0000399 if (!pids.empty() && pids.back() == pid)
Hector Dearmanf19e7c52018-03-06 10:25:01 +0000400 return;
401 pids.push_back(pid);
402}
403
Florian Mayer31746152018-03-23 15:42:05 +0000404void FtraceMetadata::FinishEvent() {
405 last_seen_device_id = 0;
406#if PERFETTO_DCHECK_IS_ON()
407 seen_device_id = false;
408#endif
409 last_seen_common_pid = 0;
410}
411
Hector Dearmanf19e7c52018-03-06 10:25:01 +0000412void FtraceMetadata::Clear() {
Anna Zappone8ce30872018-03-19 17:01:15 +0000413 inode_and_device.clear();
Hector Dearmanf19e7c52018-03-06 10:25:01 +0000414 pids.clear();
415 overwrite_count = 0;
Florian Mayer31746152018-03-23 15:42:05 +0000416 FinishEvent();
Hector Dearmanf19e7c52018-03-06 10:25:01 +0000417}
418
Primiano Tucci3cbb10a2018-04-10 17:52:40 +0100419FtraceSink::Delegate::~Delegate() = default;
420
Primiano Tucci4f9b6d72017-12-05 20:59:16 +0000421} // namespace perfetto