diff options
| author | bors <bors@rust-lang.org> | 2020-06-15 15:21:45 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-06-15 15:21:45 +0000 |
| commit | f315c35a77e40bd11ce81fedc0556be0f410bbf4 (patch) | |
| tree | b5cfdca90f9475d68f44b52f0df8b8d417733287 /src/tools/compiletest | |
| parent | ff4a2533a0720f9cdd86e02eafa3725f07aa7752 (diff) | |
| parent | 47c26e69a986d25ed9d26aebc2787334956a89ae (diff) | |
| download | rust-f315c35a77e40bd11ce81fedc0556be0f410bbf4.tar.gz rust-f315c35a77e40bd11ce81fedc0556be0f410bbf4.zip | |
Auto merge of #72357 - ortem:new-dbg-pretty-printers, r=pnkfelix
Implement new gdb/lldb pretty-printers Reopened #60826 This PR replaces current gdb and lldb pretty-printers with new ones that were originally written for [IntelliJ Rust](https://github.com/intellij-rust/intellij-rust/tree/master/prettyPrinters). The current state of lldb pretty-printers is poor, because [they don't use synthetic children](https://github.com/rust-lang/rust/issues/55586#issuecomment-436610063). When I started to reimplement lldb pretty-printers with synthetic children support, I've found current version strange and hard to support. I think `debugger_pretty_printers_common.py` is overkill, so I got rid of it. The new pretty-printers have to support all types supported by current pretty-printers, and also support `Rc`, `Arc`, `Cell`, `Ref`, `RefCell`, `RefMut`, `HashMap`, `HashSet`. Fixes #56252
Diffstat (limited to 'src/tools/compiletest')
| -rw-r--r-- | src/tools/compiletest/src/main.rs | 8 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 31 |
2 files changed, 32 insertions, 7 deletions
diff --git a/src/tools/compiletest/src/main.rs b/src/tools/compiletest/src/main.rs index 93a414ff6b9..93c53e779d5 100644 --- a/src/tools/compiletest/src/main.rs +++ b/src/tools/compiletest/src/main.rs @@ -464,11 +464,13 @@ fn common_inputs_stamp(config: &Config) -> Stamp { // Relevant pretty printer files let pretty_printer_files = [ - "src/etc/debugger_pretty_printers_common.py", + "src/etc/rust_types.py", "src/etc/gdb_load_rust_pretty_printers.py", - "src/etc/gdb_rust_pretty_printing.py", + "src/etc/gdb_lookup.py", + "src/etc/gdb_providers.py", "src/etc/lldb_batchmode.py", - "src/etc/lldb_rust_formatters.py", + "src/etc/lldb_lookup.py", + "src/etc/lldb_providers.py", ]; for file in &pretty_printer_files { let path = rust_src_dir.join(file); diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index 4f8cf92b869..18f00db3d8e 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -1079,15 +1079,38 @@ 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_rust_formatters.py"); + 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$", + "^&str$", + "^&\\[.+\\]$", + "^(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<.+>$", + ]; + script_str .push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[..])[..]); - script_str.push_str("type summary add --no-value "); - script_str.push_str("--python-function lldb_rust_formatters.print_val "); - script_str.push_str("-x \".*\" --category Rust\n"); + 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"); // Set breakpoints on every line that contains the string "#break" |
