Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[move] Unify debugging and tracing feature flags for tracing in the VM #20084

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions external-crates/move/crates/move-vm-runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ move-compiler.workspace = true
default = []
fuzzing = ["move-vm-types/fuzzing"]
failpoints = ["fail/failpoints"]
# Enable tracing and debugging also for release builds. By default, it is only enabled for debug builds.
debugging = []
testing = []
lazy_natives = []
tracing = [
Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-vm-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mod tracing;
mod tracing2;

// Only include debugging functionality in debug builds
#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
mod debug;

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion external-crates/move/crates/move-vm-runtime/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2203,7 +2203,7 @@ impl Function {
)
}

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
pub(crate) fn pretty_short_string(&self) -> String {
let id = &self.module;
format!(
Expand Down
24 changes: 12 additions & 12 deletions external-crates/move/crates/move-vm-runtime/src/tracing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Copyright (c) The Move Contributors
// SPDX-License-Identifier: Apache-2.0

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
use crate::debug::DebugContext;

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
use ::{
move_binary_format::file_format::Bytecode,
move_vm_types::values::Locals,
Expand All @@ -20,31 +20,31 @@ use ::{
},
};

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
use crate::{
interpreter::Interpreter,
loader::{Function, Loader},
};

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
const MOVE_VM_TRACING_ENV_VAR_NAME: &str = "MOVE_VM_TRACE";

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
const MOVE_VM_STEPPING_ENV_VAR_NAME: &str = "MOVE_VM_STEP";

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
static FILE_PATH: Lazy<String> = Lazy::new(|| {
env::var(MOVE_VM_TRACING_ENV_VAR_NAME).unwrap_or_else(|_| "move_vm_trace.trace".to_string())
});

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
static TRACING_ENABLED: Lazy<bool> = Lazy::new(|| env::var(MOVE_VM_TRACING_ENV_VAR_NAME).is_ok());

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
static DEBUGGING_ENABLED: Lazy<bool> =
Lazy::new(|| env::var(MOVE_VM_STEPPING_ENV_VAR_NAME).is_ok());

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
static LOGGING_FILE: Lazy<Mutex<File>> = Lazy::new(|| {
Mutex::new(
OpenOptions::new()
Expand All @@ -55,11 +55,11 @@ static LOGGING_FILE: Lazy<Mutex<File>> = Lazy::new(|| {
)
});

#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
static DEBUG_CONTEXT: Lazy<Mutex<DebugContext>> = Lazy::new(|| Mutex::new(DebugContext::new()));

// Only include in debug builds
#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
pub(crate) fn trace(
function_desc: &Function,
locals: &Locals,
Expand Down Expand Up @@ -93,7 +93,7 @@ pub(crate) fn trace(
macro_rules! trace {
($function_desc:expr, $locals:expr, $pc:expr, $instr:tt, $resolver:expr, $interp:expr) => {
// Only include this code in debug releases
#[cfg(any(debug_assertions, feature = "debugging"))]
#[cfg(any(debug_assertions, feature = "tracing"))]
$crate::tracing::trace(
&$function_desc,
$locals,
Expand Down
Loading