Skip to content

Commit f68da5c

Browse files
Merge pull request #1043 from erikdesjardins/filt
Run cachegrind output through rustfilt
2 parents 6a3a3d4 + b7d6f78 commit f68da5c

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

collector/src/main.rs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,10 +510,22 @@ fn generate_cachegrind_diffs(
510510
let id_diff = format!("{}-{}", id1, id2);
511511
let cgout1 = out_dir.join(filename("cgout", id1));
512512
let cgout2 = out_dir.join(filename("cgout", id2));
513+
let cgfilt1 = out_dir.join(filename("cgfilt", id1));
514+
let cgfilt2 = out_dir.join(filename("cgfilt", id2));
513515
let cgdiff = out_dir.join(filename("cgdiff", &id_diff));
514516
let cgann = out_dir.join(filename("cgann", &id_diff));
515517

516-
if let Err(e) = cg_diff(&cgout1, &cgout2, &cgdiff) {
518+
if let Err(e) = rustfilt(&cgout1, &cgfilt1) {
519+
errors.incr();
520+
eprintln!("collector error: {:?}", e);
521+
continue;
522+
}
523+
if let Err(e) = rustfilt(&cgout2, &cgfilt2) {
524+
errors.incr();
525+
eprintln!("collector error: {:?}", e);
526+
continue;
527+
}
528+
if let Err(e) = cg_diff(&cgfilt1, &cgfilt2, &cgdiff) {
517529
errors.incr();
518530
eprintln!("collector error: {:?}", e);
519531
continue;
@@ -528,6 +540,24 @@ fn generate_cachegrind_diffs(
528540
}
529541
}
530542

543+
/// Demangles symbols in a file using rustfilt and writes result to path.
544+
fn rustfilt(cgout: &Path, path: &Path) -> anyhow::Result<()> {
545+
let output = Command::new("rustfilt")
546+
.arg("-i")
547+
.arg(cgout)
548+
.stderr(Stdio::inherit())
549+
.output()
550+
.context("failed to run `rustfilt`")?;
551+
552+
if !output.status.success() {
553+
anyhow::bail!("failed to process output with rustfilt");
554+
}
555+
556+
fs::write(path, output.stdout).context("failed to write `rustfilt` output")?;
557+
558+
Ok(())
559+
}
560+
531561
/// Compares two Cachegrind output files using cg_diff and writes result to path.
532562
fn cg_diff(cgout1: &Path, cgout2: &Path, path: &Path) -> anyhow::Result<()> {
533563
let output = Command::new("cg_diff")

0 commit comments

Comments
 (0)