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

Remove colored CLI output from wasmer-runtime-core lib #792

Merged
merged 4 commits into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from 3 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
69 changes: 0 additions & 69 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion lib/runtime-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ libc = "0.2.60"
hex = "0.3.2"
smallvec = "0.6.10"
bincode = "1.1"
colored = "1.8"

[dependencies.indexmap]
version = "1.2.0"
Expand Down
3 changes: 0 additions & 3 deletions lib/runtime-core/src/fault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,13 +283,10 @@ extern "C" fn signal_trap_handler(
let image = build_instance_image(ctx, es_image);
unwind_result = Box::new(image);
} else {
use colored::*;
if es_image.frames.len() > 0 {
eprintln!(
"\n{}",
"Wasmer encountered an error while running your WebAssembly program."
.bold()
.red()
);
es_image.print_backtrace_if_needed();
}
Expand Down
24 changes: 8 additions & 16 deletions lib/runtime-core/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,17 +303,15 @@ impl ExecutionStateImage {

if let Ok(x) = env::var("WASMER_BACKTRACE") {
if x == "1" {
eprintln!("{}", self.colored_output());
eprintln!("{}", self.output());
return;
}
}

eprintln!("Run with `WASMER_BACKTRACE=1` environment variable to display a backtrace.");
}

pub fn colored_output(&self) -> String {
use colored::*;

pub fn output(&self) -> String {
fn join_strings(x: impl Iterator<Item = String>, sep: &str) -> String {
let mut ret = String::new();
let mut first = true;
Expand Down Expand Up @@ -341,8 +339,6 @@ impl ExecutionStateImage {
i,
x.map(|x| format!("{}", x))
.unwrap_or_else(|| "?".to_string())
.bold()
.cyan()
)
}),
", ",
Expand All @@ -353,27 +349,23 @@ impl ExecutionStateImage {
let mut ret = String::new();

if self.frames.len() == 0 {
ret += &"Unknown fault address, cannot read stack.".yellow();
ret += &"Unknown fault address, cannot read stack.";
ret += "\n";
} else {
ret += &"Backtrace:".bold();
ret += &"Backtrace:";
ret += "\n";
for (i, f) in self.frames.iter().enumerate() {
ret += &format!("* Frame {} @ Local function {}", i, f.local_function_id).bold();
ret += &format!("* Frame {} @ Local function {}", i, f.local_function_id);
ret += "\n";
ret += &format!(" {} {}\n", "Offset:", format!("{}", f.wasm_inst_offset),);
ret += &format!(
" {} {}\n",
"Offset:".bold().yellow(),
format!("{}", f.wasm_inst_offset).bold().cyan(),
);
ret += &format!(
" {} {}\n",
"Locals:".bold().yellow(),
"Locals:",
format_optional_u64_sequence(&f.locals)
);
ret += &format!(
" {} {}\n\n",
"Stack:".bold().yellow(),
"Stack:",
format_optional_u64_sequence(&f.stack)
);
}
Expand Down
1 change: 0 additions & 1 deletion lib/singlepass-backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,3 @@ byteorder = "1.3.2"
nix = "0.15.0"
libc = "0.2.60"
smallvec = "0.6.10"
colored = "1.8"
2 changes: 1 addition & 1 deletion src/bin/wasmer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ fn interactive_shell(mut ctx: InteractiveShellContext) -> ShellExitOperation {
}
"backtrace" | "bt" => {
if let Some(ref image) = ctx.image {
println!("{}", image.execution_state.colored_output());
println!("{}", image.execution_state.output());
} else {
println!("State not available");
}
Expand Down