Skip to content

Remove the omit_gdb_pretty_printer_section attribute #144738

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,3 @@ impl<S: Stage> CombineAttributeParser<S> for TargetFeatureParser {
features
}
}

pub(crate) struct OmitGdbPrettyPrinterSectionParser;

impl<S: Stage> NoArgsAttributeParser<S> for OmitGdbPrettyPrinterSectionParser {
const PATH: &[Symbol] = &[sym::omit_gdb_pretty_printer_section];
const ON_DUPLICATE: OnDuplicate<S> = OnDuplicate::Error;
const CREATE: fn(Span) -> AttributeKind = |_| AttributeKind::OmitGdbPrettyPrinterSection;
}
6 changes: 2 additions & 4 deletions compiler/rustc_attr_parsing/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ use crate::attributes::allow_unstable::{
AllowConstFnUnstableParser, AllowInternalUnstableParser, UnstableFeatureBoundParser,
};
use crate::attributes::codegen_attrs::{
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser,
OmitGdbPrettyPrinterSectionParser, OptimizeParser, TargetFeatureParser, TrackCallerParser,
UsedParser,
ColdParser, CoverageParser, ExportNameParser, NakedParser, NoMangleParser, OptimizeParser,
TargetFeatureParser, TrackCallerParser, UsedParser,
};
use crate::attributes::confusables::ConfusablesParser;
use crate::attributes::deprecation::DeprecationParser;
Expand Down Expand Up @@ -187,7 +186,6 @@ attribute_parsers!(
Single<WithoutArgs<NoImplicitPreludeParser>>,
Single<WithoutArgs<NoMangleParser>>,
Single<WithoutArgs<NonExhaustiveParser>>,
Single<WithoutArgs<OmitGdbPrettyPrinterSectionParser>>,
Single<WithoutArgs<ParenSugarParser>>,
Single<WithoutArgs<PassByValueParser>>,
Single<WithoutArgs<PointeeParser>>,
Expand Down
8 changes: 1 addition & 7 deletions compiler/rustc_codegen_llvm/src/debuginfo/gdb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

use rustc_codegen_ssa::base::collect_debugger_visualizers_transitive;
use rustc_codegen_ssa::traits::*;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def_id::LOCAL_CRATE;
use rustc_hir::find_attr;
use rustc_middle::bug;
use rustc_middle::middle::debugger_visualizer::DebuggerVisualizerType;
use rustc_session::config::{CrateType, DebugInfo};
Expand Down Expand Up @@ -86,9 +84,6 @@ pub(crate) fn get_or_insert_gdb_debug_scripts_section_global<'ll>(
}

pub(crate) fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
let omit_gdb_pretty_printer_section =
find_attr!(cx.tcx.hir_krate_attrs(), AttributeKind::OmitGdbPrettyPrinterSection);

// To ensure the section `__rustc_debug_gdb_scripts_section__` will not create
// ODR violations at link time, this section will not be emitted for rlibs since
// each rlib could produce a different set of visualizers that would be embedded
Expand Down Expand Up @@ -117,8 +112,7 @@ pub(crate) fn needs_gdb_debug_scripts_section(cx: &CodegenCx<'_, '_>) -> bool {
}
});

!omit_gdb_pretty_printer_section
&& cx.sess().opts.debuginfo != DebugInfo::None
cx.sess().opts.debuginfo != DebugInfo::None
&& cx.sess().target.emit_debug_gdb_scripts
&& embed_visualizers
}
5 changes: 0 additions & 5 deletions compiler/rustc_feature/src/builtin_attrs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1257,11 +1257,6 @@ pub static BUILTIN_ATTRIBUTES: &[BuiltinAttribute] = &[
TEST, rustc_dummy, Normal, template!(Word /* doesn't matter*/),
DuplicatesOk, EncodeCrossCrate::No
),
gated!(
omit_gdb_pretty_printer_section, Normal, template!(Word),
WarnFollowing, EncodeCrossCrate::No,
"the `#[omit_gdb_pretty_printer_section]` attribute is just used for the Rust test suite",
),
rustc_attr!(
TEST, pattern_complexity_limit, CrateLevel, template!(NameValueStr: "N"),
ErrorFollowing, EncodeCrossCrate::No,
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_feature/src/removed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,8 @@ declare_features! (
/// Renamed to `dyn_compatible_for_dispatch`.
(removed, object_safe_for_dispatch, "1.83.0", Some(43561),
Some("renamed to `dyn_compatible_for_dispatch`"), 131511),
/// Allows using `#[omit_gdb_pretty_printer_section]`.
(removed, omit_gdb_pretty_printer_section, "CURRENT_RUSTC_VERSION", None, None, 144738),
/// Allows using `#[on_unimplemented(..)]` on traits.
/// (Moved to `rustc_attrs`.)
(removed, on_unimplemented, "1.40.0", None, None, 65794),
Expand Down
2 changes: 0 additions & 2 deletions compiler/rustc_feature/src/unstable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,6 @@ declare_features! (
(unstable, multiple_supertrait_upcastable, "1.69.0", None),
/// Allow negative trait bounds. This is an internal-only feature for testing the trait solver!
(internal, negative_bounds, "1.71.0", None),
/// Allows using `#[omit_gdb_pretty_printer_section]`.
(internal, omit_gdb_pretty_printer_section, "1.5.0", None),
/// Set the maximum pattern complexity allowed (not limited by default).
(internal, pattern_complexity_limit, "1.78.0", None),
/// Allows using pattern types.
Expand Down
3 changes: 0 additions & 3 deletions compiler/rustc_hir/src/attrs/data_structures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,6 @@ pub enum AttributeKind {
/// Represents `#[non_exhaustive]`
NonExhaustive(Span),

/// Represents `#[omit_gdb_pretty_printer_section]`
OmitGdbPrettyPrinterSection,

/// Represents `#[optimize(size|speed)]`
Optimize(OptimizeAttr, Span),

Expand Down
1 change: 0 additions & 1 deletion compiler/rustc_hir/src/attrs/encode_cross_crate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ impl AttributeKind {
NoImplicitPrelude(..) => No,
NoMangle(..) => Yes, // Needed for rustdoc
NonExhaustive(..) => Yes, // Needed for rustdoc
OmitGdbPrettyPrinterSection => No,
Optimize(..) => No,
ParenSugar(..) => No,
PassByValue(..) => Yes,
Expand Down
3 changes: 1 addition & 2 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
| AttributeKind::MacroTransparency(_)
| AttributeKind::Pointee(..)
| AttributeKind::Dummy
| AttributeKind::RustcBuiltinMacro { .. }
| AttributeKind::OmitGdbPrettyPrinterSection,
| AttributeKind::RustcBuiltinMacro { .. },
) => { /* do nothing */ }
Attribute::Parsed(AttributeKind::AsPtr(attr_span)) => {
self.check_applied_to_fn_or_method(hir_id, *attr_span, span, target)
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc-dev-guide/src/tests/directives.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,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

Expand Down
10 changes: 10 additions & 0 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -306,6 +309,7 @@ impl TestProps {
has_enzyme: false,
add_core_stubs: false,
dont_require_annotations: Default::default(),
disable_gdb_pretty_printers: false,
}
}

Expand Down Expand Up @@ -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,
);
},
);

Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives/directive_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/tools/compiletest/src/runtest/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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!(
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/associated-types.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================
// gdb-command:run
Expand Down Expand Up @@ -68,8 +69,6 @@

#![allow(unused_variables)]
#![allow(dead_code)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

trait TraitWithAssocType {
type Type;
Expand Down
2 changes: 0 additions & 2 deletions tests/debuginfo/auxiliary/cross_crate_spans.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![crate_type = "rlib"]

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

//@ no-prefer-dynamic
//@ compile-flags:-g
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/basic-types-globals-metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// gdb-command:run
// gdb-command:whatis basic_types_globals_metadata::B
Expand Down Expand Up @@ -35,8 +36,6 @@

#![allow(unused_variables)]
#![allow(dead_code)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

// N.B. These are `mut` only so they don't constant fold away.
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/basic-types-globals.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ revisions: lto no-lto

//@ compile-flags:-g
//@ disable-gdb-pretty-printers

//@ [lto] compile-flags:-C lto
//@ [lto] no-prefer-dynamic
Expand Down Expand Up @@ -39,8 +40,6 @@
// gdb-command:continue

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

// N.B. These are `mut` only so they don't constant fold away.
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/basic-types-metadata.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// gdb-command:run
// gdb-command:whatis unit
Expand Down Expand Up @@ -53,8 +54,6 @@
// gdb-command:continue

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/basic-types-mut-globals.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// its numerical value.

//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// gdb-command:run

Expand Down Expand Up @@ -74,8 +75,6 @@
// gdb-check:$30 = 9.25

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

static mut B: bool = false;
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/basic-types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// its numerical value.

//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -112,8 +113,6 @@
// cdb-check:s : [...] [Type: ref$<str$>]

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/borrowed-basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -96,8 +97,6 @@
// lldb-check:[...] 3.5

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/borrowed-c-style-enum.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -28,8 +29,6 @@
// lldb-check:[...] TheC

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

enum ABC { TheA, TheB, TheC }

Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/borrowed-enum.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//@ min-lldb-version: 1800

//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -28,8 +29,6 @@
// lldb-check:(borrowed_enum::Univariant) *univariant_ref = { value = { 0 = 4820353753753434 } }

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

// The first element is to ensure proper alignment, irrespective of the machines word size. Since
// the size of the discriminant value is machine dependent, this has be taken into account when
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/borrowed-struct.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -52,8 +53,6 @@
// lldb-check:[...] 26.5

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

struct SomeStruct {
x: isize,
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/borrowed-tuple.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -29,8 +30,6 @@


#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

fn main() {
let stack_val: (i16, f32) = (-14, -19f32);
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/borrowed-unique-basic.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand Down Expand Up @@ -100,8 +101,6 @@
// lldb-check:[...] 3.5

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]
#![feature(f16)]

fn main() {
Expand Down
3 changes: 1 addition & 2 deletions tests/debuginfo/box.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ compile-flags:-g
//@ disable-gdb-pretty-printers

// === GDB TESTS ===================================================================================

Expand All @@ -19,8 +20,6 @@
// lldb-check:[...] { 0 = 2 1 = 3.5 }

#![allow(unused_variables)]
#![feature(omit_gdb_pretty_printer_section)]
#![omit_gdb_pretty_printer_section]

fn main() {
let a = Box::new(1);
Expand Down
Loading
Loading