Test basic DWARF generation (#931)
* Add obj generation with debug info * Add simple transform check
This commit is contained in:
30
tests/debug/dump.rs
Normal file
30
tests/debug/dump.rs
Normal 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())
|
||||
}
|
||||
Reference in New Issue
Block a user