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

[natives] make move debug prints enabled by env variable #31

Merged
merged 5 commits into from
Jan 12, 2025
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: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- release
- ci-test
pull_request:
types: [opened, reopened]
types: [opened, reopened, synchronize]
branches:
- release

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- release
- ci-test
pull_request:
types: [opened, reopened]
types: [opened, reopened, synchronize]
branches:
- release

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ jobs:
file: target/cli/diem
tag: ${{ github.ref }}
overwrite: true
file_glob: true
file_glob: true
13 changes: 10 additions & 3 deletions diem-move/framework/src/natives/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ use move_vm_types::{
values::{Reference, Struct, Value},
};
use smallvec::{smallvec, SmallVec};
use std::{collections::VecDeque, sync::Arc};
use std::{collections::VecDeque, env, sync::Arc};
use once_cell::sync::Lazy;
// instead of compile time feature, we use environment variable to enable debug prints from the Move vm
// Note: downstream libra does not use compile time features.
const MOVE_DEBUG_ENV: Lazy<bool> = Lazy::new(|| match env::var("DIEM_MOVE_DEBUG") {
Ok(_) => true,
Err(_) => false,
});

/***************************************************************************************************
* native fun print
Expand All @@ -39,7 +46,7 @@ fn native_print(
debug_assert!(ty_args.is_empty());
debug_assert!(args.len() == 1);

if cfg!(feature = "testing") {
if *MOVE_DEBUG_ENV {
let val = safely_pop_arg!(args, Struct);
let bytes = val.unpack()?.next().unwrap();

Expand Down Expand Up @@ -69,7 +76,7 @@ fn native_stack_trace(

let mut s = String::new();

if cfg!(feature = "testing") {
if *MOVE_DEBUG_ENV{
context.print_stack_trace(&mut s)?;
}

Expand Down
2 changes: 1 addition & 1 deletion diem-move/framework/src/natives/transaction_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ fn native_generate_unique_address(
) -> SafeNativeResult<SmallVec<[Value; 1]>> {
context.charge(gas_params.base)?;

let mut transaction_context = context
let transaction_context = context
.extensions_mut()
.get_mut::<NativeTransactionContext>();
transaction_context.auid_counter += 1;
Expand Down
Loading