| 8 | } |
| 9 | |
| 10 | pub fn get_dwarfdump(obj: &str, section: DwarfDumpSection) -> Result<String> { |
| 11 | let dwarfdump = env::var("DWARFDUMP").unwrap_or("llvm-dwarfdump".to_string()); |
| 12 | let section_flag = match section { |
| 13 | DwarfDumpSection::DebugInfo => "-debug-info", |
| 14 | }; |
| 15 | let output = Command::new(&dwarfdump) |
| 16 | .args(&[section_flag, obj]) |
| 17 | .output() |
| 18 | .with_context(|| format!("failed to spawn `{dwarfdump}`"))?; |
| 19 | if !output.status.success() { |
| 20 | bail!( |
| 21 | "failed to execute {}: {}", |
| 22 | dwarfdump, |
| 23 | String::from_utf8_lossy(&output.stderr), |
| 24 | ); |
| 25 | } |
| 26 | Ok(String::from_utf8_lossy(&output.stdout).to_string()) |
| 27 | } |