From 36a8daeb44ebee51fb769a106e5aafbbb4a59ebb Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Sun, 10 Mar 2024 13:43:41 +0100 Subject: [PATCH] Deduplicate `lldb_commands`. --- src/tools/compiletest/src/runtest.rs | 42 ++++++---------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 386db1a64b8..e26e9df6f16 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1474,29 +1474,8 @@ impl<'test> TestCx<'test> { // Switch LLDB into "Rust mode" let rust_src_root = self.config.find_rust_src_root().expect("Could not find Rust source root"); - let rust_pp_module_rel_path = Path::new("./src/etc/lldb_lookup.py"); - let rust_pp_module_abs_path = - rust_src_root.join(rust_pp_module_rel_path).to_str().unwrap().to_owned(); - - let rust_type_regexes = vec![ - "^(alloc::([a-z_]+::)+)String$", - "^&(mut )?str$", - "^&(mut )?\\[.+\\]$", - "^(std::ffi::([a-z_]+::)+)OsString$", - "^(alloc::([a-z_]+::)+)Vec<.+>$", - "^(alloc::([a-z_]+::)+)VecDeque<.+>$", - "^(alloc::([a-z_]+::)+)BTreeSet<.+>$", - "^(alloc::([a-z_]+::)+)BTreeMap<.+>$", - "^(std::collections::([a-z_]+::)+)HashMap<.+>$", - "^(std::collections::([a-z_]+::)+)HashSet<.+>$", - "^(alloc::([a-z_]+::)+)Rc<.+>$", - "^(alloc::([a-z_]+::)+)Arc<.+>$", - "^(core::([a-z_]+::)+)Cell<.+>$", - "^(core::([a-z_]+::)+)Ref<.+>$", - "^(core::([a-z_]+::)+)RefMut<.+>$", - "^(core::([a-z_]+::)+)RefCell<.+>$", - "^(core::([a-z_]+::)+)NonZero<.+>$", - ]; + let rust_pp_module_rel_path = Path::new("./src/etc"); + let rust_pp_module_abs_path = rust_src_root.join(rust_pp_module_rel_path); // In newer versions of lldb, persistent results (the `$N =` part at the start of // expressions you have evaluated that let you re-use the result) aren't printed, but lots @@ -1507,16 +1486,13 @@ impl<'test> TestCx<'test> { script_str.push_str("command unalias p\n"); script_str.push_str("command alias p expr --\n"); - script_str - .push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[..])[..]); - script_str.push_str("type synthetic add -l lldb_lookup.synthetic_lookup -x '.*' "); - script_str.push_str("--category Rust\n"); - for type_regex in rust_type_regexes { - script_str.push_str("type summary add -F lldb_lookup.summary_lookup -e -x -h "); - script_str.push_str(&format!("'{}' ", type_regex)); - script_str.push_str("--category Rust\n"); - } - script_str.push_str("type category enable Rust\n"); + script_str.push_str(&format!( + "command script import {}/lldb_lookup.py\n", + rust_pp_module_abs_path.to_str().unwrap() + )); + File::open(rust_pp_module_abs_path.join("lldb_commands")) + .and_then(|mut file| file.read_to_string(&mut script_str)) + .expect("Failed to read lldb_commands"); // Set breakpoints on every line that contains the string "#break" let source_file_name = self.testpaths.file.file_name().unwrap().to_string_lossy();