Skip to content

Commit c76e848

Browse files
committed
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.
1 parent cc0a5b7 commit c76e848

File tree

119 files changed

+218
-393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+218
-393
lines changed

compiler/rustc_attr_data_structures/src/attributes.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,9 +390,6 @@ pub enum AttributeKind {
390390
/// Represents `#[non_exhaustive]`
391391
NonExhaustive(Span),
392392

393-
/// Represents `#[omit_gdb_pretty_printer_section]`
394-
OmitGdbPrettyPrinterSection,
395-
396393
/// Represents `#[optimize(size|speed)]`
397394
Optimize(OptimizeAttr, Span),
398395

compiler/rustc_attr_data_structures/src/encode_cross_crate.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ impl AttributeKind {
5555
NoImplicitPrelude(..) => No,
5656
NoMangle(..) => Yes, // Needed for rustdoc
5757
NonExhaustive(..) => Yes, // Needed for rustdoc
58-
OmitGdbPrettyPrinterSection => No,
5958
Optimize(..) => No,
6059
ParenSugar(..) => No,
6160
PassByValue(..) => Yes,

compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -374,11 +374,3 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
374374
features
375375
}
376376
}
377-
378-
pub(crate) struct OmitGdbPrettyPrinterSectionParser;
379-
380-
impl<S: Stage> NoArgsAttributeParser<S> for OmitGdbPrettyPrinterSectionParser {
381-
const PATH: &[Symbol] = &[sym::omit_gdb_pretty_printer_section];
382-
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
383-
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::OmitGdbPrettyPrinterSection;
384-
}

compiler/rustc_attr_parsing/src/context.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,8 @@ use crate::attributes::allow_unstable::{
1717
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
1818
};
1919
use crate::attributes::codegen_attrs::{
20-
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser,
21-
OmitGdbPrettyPrinterSectionParser, OptimizeParser, TargetFeatureParser, TrackCallerParser,
22-
UsedParser,
20+
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser,
21+
TargetFeatureParser, TrackCallerParser, UsedParser,
2322
};
2423
use crate::attributes::confusables::ConfusablesParser;
2524
use crate::attributes::deprecation::DeprecationParser;
@@ -187,7 +186,6 @@ attribute_parsers!(
187186
Single<WithoutArgs<NoImplicitPreludeParser>>,
188187
Single<WithoutArgs<NoMangleParser>>,
189188
Single<WithoutArgs<NonExhaustiveParser>>,
190-
Single<WithoutArgs<OmitGdbPrettyPrinterSectionParser>>,
191189
Single<WithoutArgs<ParenSugarParser>>,
192190
Single<WithoutArgs<PassByValueParser>>,
193191
Single<WithoutArgs<PointeeParser>>,

compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// .debug_gdb_scripts binary section.
22

3-
use rustc_attr_data_structures::{AttributeKind, find_attr};
43
use rustc_codegen_ssa::base::collect_debugger_visualizers_transitive;
54
use rustc_codegen_ssa::traits::*;
65
use rustc_hir::def_id::LOCAL_CRATE;
@@ -85,9 +84,6 @@ pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
8584
}
8685

8786
pub(crate) fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
88-
let omit_gdb_pretty_printer_section =
89-
find_attr!(cx.tcx.hir_krate_attrs(), AttributeKind::OmitGdbPrettyPrinterSection);
90-
9187
// To ensure the section `__rustc_debug_gdb_scripts_section__` will not create
9288
// ODR violations at link time, this section will not be emitted for rlibs since
9389
// each rlib could produce a different set of visualizers that would be embedded
@@ -116,8 +112,7 @@ pub(crate) fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
116112
}
117113
});
118114

119-
!omit_gdb_pretty_printer_section
120-
&& cx.sess().opts.debuginfo != DebugInfo::None
115+
cx.sess().opts.debuginfo != DebugInfo::None
121116
&& cx.sess().target.emit_debug_gdb_scripts
122117
&& embed_visualizers
123118
}

compiler/rustc_feature/src/builtin_attrs.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,11 +1257,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
12571257
TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/),
12581258
DuplicatesOk, EncodeCrossCrate::No
12591259
),
1260-
gated!(
1261-
omit_gdb_pretty_printer_section, Normal, template!(Word),
1262-
WarnFollowing, EncodeCrossCrate::No,
1263-
"the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite",
1264-
),
12651260
rustc_attr!(
12661261
TEST, pattern_complexity_limit, CrateLevel, template!(NameValueStr: "N"),
12671262
ErrorFollowing, EncodeCrossCrate::No,

compiler/rustc_feature/src/removed.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,8 @@ declare_features! (
199199
/// Renamed to `dyn_compatible_for_dispatch`.
200200
(removed, object_safe_for_dispatch, "1.83.0", Some(43561),
201201
Some("renamed to `dyn_compatible_for_dispatch`"), 131511),
202+
/// Allows using `#[omit_gdb_pretty_printer_section]`.
203+
(removed, omit_gdb_pretty_printer_section, "CURRENT_RUSTC_VERSION", None, None, 1/* TODO */),
202204
/// Allows using `#[on_unimplemented(..)]` on traits.
203205
/// (Moved to `rustc_attrs`.)
204206
(removed, on_unimplemented, "1.40.0", None, None, 65794),

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,8 +225,6 @@ declare_features! (
225225
(unstable, multiple_supertrait_upcastable, "1.69.0", None),
226226
/// Allow negative trait bounds. This is an internal-only feature for testing the trait solver!
227227
(internal, negative_bounds, "1.71.0", None),
228-
/// Allows using `#[omit_gdb_pretty_printer_section]`.
229-
(internal, omit_gdb_pretty_printer_section, "1.5.0", None),
230228
/// Set the maximum pattern complexity allowed (not limited by default).
231229
(internal, pattern_complexity_limit, "1.78.0", None),
232230
/// Allows using pattern types.

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,8 +291,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
291291
| AttributeKind::MacroTransparency(_)
292292
| AttributeKind::Pointee(..)
293293
| AttributeKind::Dummy
294-
| AttributeKind::RustcBuiltinMacro { .. }
295-
| AttributeKind::OmitGdbPrettyPrinterSection,
294+
| AttributeKind::RustcBuiltinMacro { .. },
296295
) => { /* do nothing */ }
297296
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
298297
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)

src/tools/compiletest/src/directives.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,8 @@ pub struct TestProps {
203203
pub add_core_stubs: bool,
204204
/// Whether line annotatins are required for the given error kind.
205205
pub dont_require_annotations: HashSet<ErrorKind>,
206+
/// Whether pretty printers should be enabled in the debugger.
207+
pub debug_pretty_printers: bool,
206208
}
207209

208210
mod directives {
@@ -251,6 +253,7 @@ mod directives {
251253
pub const ADD_CORE_STUBS: &'static str = "add-core-stubs";
252254
// This isn't a real directive, just one that is probably mistyped often
253255
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
256+
pub const DEBUG_PRETTY_PRINTERS: &'static str = "debug-pretty-printers";
254257
}
255258

256259
impl TestProps {
@@ -306,6 +309,7 @@ impl TestProps {
306309
has_enzyme: false,
307310
add_core_stubs: false,
308311
dont_require_annotations: Default::default(),
312+
debug_pretty_printers: true,
309313
}
310314
}
311315

@@ -654,6 +658,12 @@ impl TestProps {
654658
self.dont_require_annotations
655659
.insert(ErrorKind::expect_from_user_str(err_kind.trim()));
656660
}
661+
662+
config.set_name_directive(
663+
ln,
664+
DEBUG_PRETTY_PRINTERS,
665+
&mut self.debug_pretty_printers,
666+
);
657667
},
658668
);
659669

0 commit comments

Comments
 (0)