bootstrap/core/debuggers/
lldb.rs

1use std::path::PathBuf;
2
3use crate::core::builder::Builder;
4use crate::utils::exec::command;
5
6pub(crate) struct Lldb {
7    pub(crate) lldb_exe: PathBuf,
8    pub(crate) lldb_version: String,
9}
10
11pub(crate) fn discover_lldb(builder: &Builder<'_>) -> Option<Lldb> {
12    // FIXME(#148361): We probably should not be picking up whatever arbitrary
13    // lldb happens to be in the user's path, and instead require some kind of
14    // explicit opt-in or configuration.
15    let lldb_exe = builder.config.lldb.clone().unwrap_or_else(|| PathBuf::from("lldb"));
16
17    let lldb_version = command(&lldb_exe)
18        .allow_failure()
19        .arg("--version")
20        .run_capture(builder)
21        .stdout_if_ok()
22        .and_then(|v| if v.trim().is_empty() { None } else { Some(v) })?;
23
24    Some(Lldb { lldb_exe, lldb_version })
25}