1 // Copyright 2023 The ChromiumOS Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 pub use cros_tracing_types::static_strings::StaticString;
6 pub use perfetto::*;
7
8 setup_perfetto!(
9 cros_tracing,
10 crosvm,
11 "General crosvm trace points",
12 perfetto_tags!(),
13 block,
14 "Block device trace points",
15 perfetto_tags!("devices"),
16 gpu,
17 "GPU device trace points",
18 perfetto_tags!("devices"),
19 gpu_display,
20 "GPU display device trace points",
21 perfetto_tags!("devices"),
22 virtqueue,
23 "General virtqueue trace points",
24 perfetto_tags!("devices"),
25 net,
26 "Net device trace points",
27 perfetto_tags!("devices"),
28 future,
29 "Async trace points",
30 perfetto_tags!()
31 );
32
33 // We offset host builtin clock values by 32 so they can be correctly translated to guest clocks.
34 // See go/bstar-perfetto
35 pub const HOST_GUEST_CLOCK_ID_OFFSET: u32 = 32;
36
init()37 pub fn init() {
38 register_categories();
39 // This tracing crate only supports system backend for now. If we want crosvm to start/end
40 // a trace then we'd want to add some functions in this crate for that.
41 perfetto::init_tracing(perfetto::BackendType::System);
42 }
43
init_in_process()44 pub fn init_in_process() {
45 register_categories();
46 perfetto::init_tracing(perfetto::BackendType::InProcess);
47 }
48
49 // TODO(b/263902691): implement for Perfetto.
50 #[macro_export]
51 macro_rules! push_descriptors {
52 ($fd_vec:expr) => {};
53 }
54
55 // TODO(b/263902691): implement for Perfetto.
56 #[macro_export]
57 macro_rules! trace_simple_print {
58 ($($t:tt)+) => {};
59 }
60