Skip to content

Commit 36a8dae

Browse files
committed
Deduplicate lldb_commands.
1 parent 4a79908 commit 36a8dae

File tree

1 file changed

+9
-33
lines changed

1 file changed

+9
-33
lines changed

src/tools/compiletest/src/runtest.rs

+9-33
Original file line numberDiff line numberDiff line change
@@ -1474,29 +1474,8 @@ impl<'test> TestCx<'test> {
14741474
// Switch LLDB into "Rust mode"
14751475
let rust_src_root =
14761476
self.config.find_rust_src_root().expect("Could not find Rust source root");
1477-
let rust_pp_module_rel_path = Path::new("./src/etc/lldb_lookup.py");
1478-
let rust_pp_module_abs_path =
1479-
rust_src_root.join(rust_pp_module_rel_path).to_str().unwrap().to_owned();
1480-
1481-
let rust_type_regexes = vec![
1482-
"^(alloc::([a-z_]+::)+)String$",
1483-
"^&(mut )?str$",
1484-
"^&(mut )?\\[.+\\]$",
1485-
"^(std::ffi::([a-z_]+::)+)OsString$",
1486-
"^(alloc::([a-z_]+::)+)Vec<.+>$",
1487-
"^(alloc::([a-z_]+::)+)VecDeque<.+>$",
1488-
"^(alloc::([a-z_]+::)+)BTreeSet<.+>$",
1489-
"^(alloc::([a-z_]+::)+)BTreeMap<.+>$",
1490-
"^(std::collections::([a-z_]+::)+)HashMap<.+>$",
1491-
"^(std::collections::([a-z_]+::)+)HashSet<.+>$",
1492-
"^(alloc::([a-z_]+::)+)Rc<.+>$",
1493-
"^(alloc::([a-z_]+::)+)Arc<.+>$",
1494-
"^(core::([a-z_]+::)+)Cell<.+>$",
1495-
"^(core::([a-z_]+::)+)Ref<.+>$",
1496-
"^(core::([a-z_]+::)+)RefMut<.+>$",
1497-
"^(core::([a-z_]+::)+)RefCell<.+>$",
1498-
"^(core::([a-z_]+::)+)NonZero<.+>$",
1499-
];
1477+
let rust_pp_module_rel_path = Path::new("./src/etc");
1478+
let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path);
15001479

15011480
// In newer versions of lldb, persistent results (the `$N =` part at the start of
15021481
// expressions you have evaluated that let you re-use the result) aren't printed, but lots
@@ -1507,16 +1486,13 @@ impl<'test> TestCx<'test> {
15071486
script_str.push_str("command unalias p\n");
15081487
script_str.push_str("command alias p expr --\n");
15091488

1510-
script_str
1511-
.push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[..])[..]);
1512-
script_str.push_str("type synthetic add -l lldb_lookup.synthetic_lookup -x '.*' ");
1513-
script_str.push_str("--category Rust\n");
1514-
for type_regex in rust_type_regexes {
1515-
script_str.push_str("type summary add -F lldb_lookup.summary_lookup -e -x -h ");
1516-
script_str.push_str(&format!("'{}' ", type_regex));
1517-
script_str.push_str("--category Rust\n");
1518-
}
1519-
script_str.push_str("type category enable Rust\n");
1489+
script_str.push_str(&format!(
1490+
"command script import {}/lldb_lookup.py\n",
1491+
rust_pp_module_abs_path.to_str().unwrap()
1492+
));
1493+
File::open(rust_pp_module_abs_path.join("lldb_commands"))
1494+
.and_then(|mut file| file.read_to_string(&mut script_str))
1495+
.expect("Failed to read lldb_commands");
15201496

15211497
// Set breakpoints on every line that contains the string "#break"
15221498
let source_file_name = self.testpaths.file.file_name().unwrap().to_string_lossy();

0 commit comments

Comments
 (0)