Test basic DWARF generation (#931)

* Add obj generation with debug info
* Add simple transform check
This commit is contained in:
Yury Delendik
2020-02-20 11:42:36 -06:00
committed by GitHub
parent 4460e569cf
commit b96b53eafb
17 changed files with 414 additions and 129 deletions

30
tests/debug/dump.rs Normal file
View File

@@ -0,0 +1,30 @@
use anyhow::{bail, Result};
use std::env;
use std::process::Command;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[allow(dead_code)]
pub enum DwarfDumpSection {
DebugInfo,
DebugLine,
}
pub fn get_dwarfdump(obj: &str, section: DwarfDumpSection) -> Result<String> {
let dwarfdump = env::var("DWARFDUMP").unwrap_or("llvm-dwarfdump".to_string());
let section_flag = match section {
DwarfDumpSection::DebugInfo => "-debug-info",
DwarfDumpSection::DebugLine => "-debug-line",
};
let output = Command::new(&dwarfdump)
.args(&[section_flag, obj])
.output()
.expect("success");
if !output.status.success() {
bail!(
"failed to execute {}: {}",
dwarfdump,
String::from_utf8_lossy(&output.stderr),
);
}
Ok(String::from_utf8_lossy(&output.stdout).to_string())
}