Skip to content

Commit

Permalink
feature flag added
Browse files Browse the repository at this point in the history
  • Loading branch information
apoorvsadana committed Jun 19, 2023
1 parent 5fca394 commit 7e2e51d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
26 changes: 13 additions & 13 deletions cairo-vm-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
use bincode::enc::write::Writer;
use cairo_vm::cairo_run::{self, EncodeTraceError};
use cairo_vm::hint_processor::builtin_hint_processor::builtin_hint_processor_definition::BuiltinHintProcessor;
#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
use cairo_vm::serde::deserialize_program::DebugInfo;
use cairo_vm::vm::errors::cairo_run_errors::CairoRunError;
use cairo_vm::vm::errors::trace_errors::TraceError;
use cairo_vm::vm::errors::vm_errors::VirtualMachineError;
#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
use cairo_vm::vm::runners::cairo_runner::CairoRunner;
#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
use cairo_vm::vm::vm_core::VirtualMachine;
#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
use cairo_vm_tracer::error::trace_data_errors::TraceDataError;
#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
use cairo_vm_tracer::tracer::run_tracer;
use clap::{Parser, ValueHint};
use std::io::{self, Write};
Expand Down Expand Up @@ -47,8 +47,8 @@ struct Args {
proof_mode: bool,
#[structopt(long = "--secure_run")]
secure_run: Option<bool>,
#[cfg(feature = "tracer")]
#[structopt(long = "--tracer")]
#[cfg(feature = "with_tracer")]
tracer: Option<bool>,
}

Expand Down Expand Up @@ -82,7 +82,7 @@ enum Error {
#[error(transparent)]
Trace(#[from] TraceError),
#[error(transparent)]
#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
TraceDataErroe(#[from] TraceDataError),
}

Expand Down Expand Up @@ -119,7 +119,7 @@ impl FileWriter {
}
}

#[cfg(feature = "tracer")]
#[cfg(feature = "with_tracer")]
fn start_tracer(cairo_runner: &CairoRunner, vm: &VirtualMachine) -> Result<(), TraceDataError> {
let instruction_locations = cairo_runner
.get_program()
Expand Down Expand Up @@ -173,11 +173,6 @@ fn run(args: impl Iterator<Item = String>) -> Result<(), Error> {
}
};

#[cfg(feature = "tracer")]
if args.tracer.is_some() && args.tracer.unwrap() {
start_tracer(&cairo_runner, &vm)?;
}

if args.print_output {
let mut output_buffer = "Program Output:\n".to_string();
vm.write_output(&mut output_buffer)?;
Expand All @@ -204,6 +199,11 @@ fn run(args: impl Iterator<Item = String>) -> Result<(), Error> {
memory_writer.flush()?;
}

#[cfg(feature = "with_tracer")]
if args.tracer.is_some() && args.tracer.unwrap() {
start_tracer(&cairo_runner, &vm)?;
}

Ok(())
}

Expand Down
Binary file added mem_sum
Binary file not shown.
Binary file added trace_sum
Binary file not shown.
1 change: 0 additions & 1 deletion vm/src/vm/vm_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,7 +911,6 @@ impl VirtualMachine {
}

// TODO: add test cases
#[cfg(feature = "tracer")]
pub fn get_relocation_table(&self) -> Result<Vec<usize>, MemoryError> {
self.segments.relocate_segments()
}
Expand Down

0 comments on commit 7e2e51d

Please sign in to comment.