about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2025-08-03 21:56:56 +0200
committerGitHub <noreply@github.com>2025-08-03 21:56:56 +0200
commit3823f0bc078c90eb0df74fa08fcae52b2c269330 (patch)
tree50529238b372a92b9eaa9a04fdfd1d9414d70b72 /src
parent116619fb81ee1e53f9e71914949049fdb2b39282 (diff)
parentae2f8d921654f01e008824385fb1e1d7b36ce705 (diff)
downloadrust-3823f0bc078c90eb0df74fa08fcae52b2c269330.tar.gz
rust-3823f0bc078c90eb0df74fa08fcae52b2c269330.zip
Rollup merge of #144738 - bjorn3:remove_omit_gdb_pretty_printer_section, r=jieyouxu
Remove the omit_gdb_pretty_printer_section attribute

Disabling loading of pretty printers in the debugger itself is more reliable. Before this commit the .gdb_debug_scripts section couldn't be included in dylibs or rlibs as otherwise there is no way to disable the section anymore without recompiling the entire standard library.
Diffstat (limited to 'src')
-rw-r--r--src/doc/rustc-dev-guide/src/tests/directives.md1
-rw-r--r--src/tools/compiletest/src/directives.rs10
-rw-r--r--src/tools/compiletest/src/directives/directive_names.rs1
-rw-r--r--src/tools/compiletest/src/runtest/debuginfo.rs4
4 files changed, 15 insertions, 1 deletions
diff --git a/src/doc/rustc-dev-guide/src/tests/directives.md b/src/doc/rustc-dev-guide/src/tests/directives.md
index 6fff021b0b1..6eac8109e05 100644
--- a/src/doc/rustc-dev-guide/src/tests/directives.md
+++ b/src/doc/rustc-dev-guide/src/tests/directives.md
@@ -299,6 +299,7 @@ See [Pretty-printer](compiletest.md#pretty-printer-tests).
 - [`should-ice`](compiletest.md#incremental-tests) — incremental cfail should
       ICE
 - [`reference`] — an annotation linking to a rule in the reference
+- `disable-gdb-pretty-printers` — disable gdb pretty printers for debuginfo tests
 
 [`reference`]: https://github.com/rust-lang/reference/blob/master/docs/authoring.md#test-rule-annotations
 
diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs
index 54511f4fd08..13e694b7f03 100644
--- a/src/tools/compiletest/src/directives.rs
+++ b/src/tools/compiletest/src/directives.rs
@@ -203,6 +203,8 @@ pub struct TestProps {
     pub add_core_stubs: bool,
     /// Whether line annotatins are required for the given error kind.
     pub dont_require_annotations: HashSet<ErrorKind>,
+    /// Whether pretty printers should be disabled in gdb.
+    pub disable_gdb_pretty_printers: bool,
 }
 
 mod directives {
@@ -251,6 +253,7 @@ mod directives {
     pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
     // This isn't a real directive, just one that is probably mistyped often
     pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
+    pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers";
 }
 
 impl TestProps {
@@ -306,6 +309,7 @@ impl TestProps {
             has_enzyme: false,
             add_core_stubs: false,
             dont_require_annotations: Default::default(),
+            disable_gdb_pretty_printers: false,
         }
     }
 
@@ -654,6 +658,12 @@ impl TestProps {
                         self.dont_require_annotations
                             .insert(ErrorKind::expect_from_user_str(err_kind.trim()));
                     }
+
+                    config.set_name_directive(
+                        ln,
+                        DISABLE_GDB_PRETTY_PRINTERS,
+                        &mut self.disable_gdb_pretty_printers,
+                    );
                 },
             );
 
diff --git a/src/tools/compiletest/src/directives/directive_names.rs b/src/tools/compiletest/src/directives/directive_names.rs
index 7fc76a42e0c..f7955429d83 100644
--- a/src/tools/compiletest/src/directives/directive_names.rs
+++ b/src/tools/compiletest/src/directives/directive_names.rs
@@ -18,6 +18,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
     "check-stdout",
     "check-test-line-numbers-match",
     "compile-flags",
+    "disable-gdb-pretty-printers",
     "doc-flags",
     "dont-check-compiler-stderr",
     "dont-check-compiler-stdout",
diff --git a/src/tools/compiletest/src/runtest/debuginfo.rs b/src/tools/compiletest/src/runtest/debuginfo.rs
index 471e4a4c819..6114afdc9df 100644
--- a/src/tools/compiletest/src/runtest/debuginfo.rs
+++ b/src/tools/compiletest/src/runtest/debuginfo.rs
@@ -259,7 +259,9 @@ impl TestCx<'_> {
                 Some(version) => {
                     println!("NOTE: compiletest thinks it is using GDB version {}", version);
 
-                    if version > extract_gdb_version("7.4").unwrap() {
+                    if !self.props.disable_gdb_pretty_printers
+                        && version > extract_gdb_version("7.4").unwrap()
+                    {
                         // Add the directory containing the pretty printers to
                         // GDB's script auto loading safe path
                         script_str.push_str(&format!(