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

Report BOLT instrumentation errors and add more BOLT debug logging #7

Merged
merged 1 commit into from
Aug 8, 2022
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
22 changes: 10 additions & 12 deletions src/bolt/instrument.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use anyhow::anyhow;
use std::path::{Path, PathBuf};

use cargo_metadata::camino::Utf8PathBuf;
Expand Down Expand Up @@ -48,16 +49,8 @@ pub fn bolt_instrument(ctx: CargoContext, args: BoltInstrumentArgs) -> anyhow::R
"Binary {} built successfully. It will be now instrumented with BOLT.",
artifact.target.name.blue(),
);
let instrumented_path = instrument_binary(
&bolt_env, executable, &bolt_dir, &artifact,
)
.map_err(|error| {
anyhow::anyhow!(
"Cannot instrument binary {} with BOLT: {:?}.",
artifact.target.name,
error
)
})?;
let instrumented_path =
instrument_binary(&bolt_env, executable, &bolt_dir, &artifact)?;
log::info!(
"Binary {} instrumented successfully. Now run {} on your workload.",
artifact.target.name.blue(),
Expand Down Expand Up @@ -105,7 +98,7 @@ fn instrument_binary(

let profile_path = profile_dir.join("profile");

run_command(
let output = run_command(
&bolt_env.bolt,
&[
"-instrument",
Expand All @@ -119,7 +112,12 @@ fn instrument_binary(
"-o",
target_path.as_str(),
],
)?;
)?
.ok()
.map_err(|error| anyhow!("Cannot instrument binary with BOLT: {}.", error))?;

log::debug!("BOLT instrumentation stdout\n{}\n\n", output.stdout);
log::debug!("BOLT instrumentation stderr\n{}", output.stderr);

Ok(target_path.into_std_path_buf())
}
4 changes: 2 additions & 2 deletions src/bolt/optimize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,8 @@ fn optimize_binary(
.ok()
.map_err(|error| anyhow!("Cannot optimize binary with BOLT: {}.", error))?;

log::debug!("BOLT stdout\n{}\n\n", output.stdout);
log::debug!("BOLT stderr\n{}", output.stderr);
log::debug!("BOLT optimization stdout\n{}\n\n", output.stdout);
log::debug!("BOLT optimization stderr\n{}", output.stderr);

Ok(target_path.into_std_path_buf())
}
Expand Down
5 changes: 3 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ impl Utf8Output {
Ok(self)
} else {
Err(anyhow::anyhow!(
"Command ended with exit code {}\n{}",
"Command ended with {}\nStderr\n{}\nStdout\n{}",
self.status,
self.stderr
self.stderr,
self.stdout
))
}
}
Expand Down