From 13313d403ac27761463732ba9cb883b93f56aa53 Mon Sep 17 00:00:00 2001 From: Vikram Auradkar Date: Thu, 16 Jun 2022 00:19:18 +0000 Subject: [PATCH] tracing: Add noop tracing BUG=b:213154559 TEST=presubmit Change-Id: Idfe23544c8381e664d913c4a80742f4e25a30006 Change-Id: I2bb0b59098ae183c45e92fcf15e1bcfe834df204 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3707622 Reviewed-by: Daniel Verkamp Tested-by: kokoro Commit-Queue: Vikram Auradkar --- Cargo.toml | 1 + tracing/Cargo.toml | 9 +++++++++ tracing/src/lib.rs | 8 ++++++++ tracing/src/noop.rs | 23 +++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tracing/Cargo.toml create mode 100644 tracing/src/lib.rs create mode 100644 tracing/src/noop.rs diff --git a/Cargo.toml b/Cargo.toml index f2bf223a76..bae7ef373f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -76,6 +76,7 @@ members = [ "serde_keyvalue", "tpm2", "tpm2-sys", + "tracing", "usb_sys", "usb_util", "vfio_sys", diff --git a/tracing/Cargo.toml b/tracing/Cargo.toml new file mode 100644 index 0000000000..784508d510 --- /dev/null +++ b/tracing/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "tracing" +version = "0.1.0" +authors = ["The Chromium OS Authors"] +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] \ No newline at end of file diff --git a/tracing/src/lib.rs b/tracing/src/lib.rs new file mode 100644 index 0000000000..bdcf0b0f14 --- /dev/null +++ b/tracing/src/lib.rs @@ -0,0 +1,8 @@ +// Copyright 2022 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +/// A crate that provides noop tracing. +mod noop; + +pub use noop::*; diff --git a/tracing/src/noop.rs b/tracing/src/noop.rs new file mode 100644 index 0000000000..6a04d2f2c6 --- /dev/null +++ b/tracing/src/noop.rs @@ -0,0 +1,23 @@ +// Copyright 2022 The Chromium OS Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Empty macros for when the tracing feature isn't used. +#[macro_export] +macro_rules! trace_event { + ($category:ident, $name:expr) => { + None as Option + }; +} + +#[macro_export] +macro_rules! trace_event_begin { + ($category:ident, $name:expr) => {}; +} + +#[macro_export] +macro_rules! trace_event_end { + ($category:ident) => {}; +} + +pub fn init() {}