1
Fork 0

Rename option and add doc

This commit is contained in:
Matt Weber 2024-03-01 23:33:46 -05:00
parent 4692d46a46
commit 21c58b1b2c
11 changed files with 54 additions and 52 deletions

View file

@ -998,8 +998,8 @@ fn build_field_di_node<'ll, 'tcx>(
type_di_node: &'ll DIType,
def_id: Option<DefId>,
) -> &'ll DIType {
let (file_metadata, line_number) =
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
{
file_metadata_from_def_id(cx, def_id)
} else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
@ -1055,7 +1055,7 @@ fn build_struct_type_di_node<'ll, 'tcx>(
let containing_scope = get_namespace_for_item(cx, adt_def.did());
let struct_type_and_layout = cx.layout_of(struct_type);
let variant_def = adt_def.non_enum_variant();
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(adt_def.did())))
} else {
None
@ -1088,8 +1088,7 @@ fn build_struct_type_di_node<'ll, 'tcx>(
Cow::Borrowed(f.name.as_str())
};
let field_layout = struct_type_and_layout.field(cx, i);
let def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
{
let def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(f.did)
} else {
None
@ -1221,7 +1220,7 @@ fn build_closure_env_di_node<'ll, 'tcx>(
let containing_scope = get_namespace_for_item(cx, def_id);
let type_name = compute_debuginfo_type_name(cx.tcx, closure_env_type, false);
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(def_id)))
} else {
None
@ -1258,7 +1257,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
let containing_scope = get_namespace_for_item(cx, union_def_id);
let union_ty_and_layout = cx.layout_of(union_type);
let type_name = compute_debuginfo_type_name(cx.tcx, union_type, false);
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(union_def_id)))
} else {
None
@ -1284,8 +1283,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
.enumerate()
.map(|(i, f)| {
let field_layout = union_ty_and_layout.field(cx, i);
let def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
{
let def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(f.did)
} else {
None

View file

@ -192,7 +192,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
} else {
None
@ -269,7 +269,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> {
let coroutine_type = unique_type_id.expect_ty();
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
let &ty::Coroutine(coroutine_def_id, _) = coroutine_type.kind() else {
bug!("build_coroutine_di_node() called with non-coroutine type: `{:?}`", coroutine_type)
};
@ -337,7 +337,7 @@ fn build_single_variant_union_fields<'ll, 'tcx>(
let tag_base_type_di_node = type_di_node(cx, tag_base_type);
let tag_base_type_align = cx.align_of(tag_base_type);
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(enum_adt_def.did())
} else {
None
@ -408,7 +408,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
) -> SmallVec<&'ll DIType> {
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout);
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(enum_adt_def.did())
} else {
None
@ -721,7 +721,7 @@ fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>(
variant_range
.clone()
.map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))),
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(coroutine_def_id)
} else {
None
@ -818,7 +818,7 @@ fn build_union_fields_for_direct_tag_enum_or_coroutine<'ll, 'tcx>(
tag_base_type_di_node,
tag_base_type,
variant_member_info.discr,
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
variant_member_info.source_info
} else {
None

View file

@ -68,7 +68,7 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
enum_type_and_layout: TyAndLayout<'tcx>,
) -> DINodeCreationResult<'ll> {
let containing_scope = get_namespace_for_item(cx, enum_adt_def.did());
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(enum_adt_def.did())
} else {
None
@ -122,8 +122,8 @@ fn build_enumeration_type_di_node<'ll, 'tcx>(
})
.collect();
let (file_metadata, line_number) =
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
{
file_metadata_from_def_id(cx, def_id)
} else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
@ -207,7 +207,7 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
) -> &'ll DIType {
assert_eq!(variant_layout.ty, enum_type_and_layout.ty);
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(variant_def.def_id)))
} else {
None

View file

@ -56,7 +56,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
assert!(!wants_c_like_enum_debuginfo(cx.tcx, enum_type_and_layout));
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
} else {
None
@ -92,8 +92,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
enum_type_and_layout.for_variant(cx, variant_index),
visibility_flags,
),
source_info: if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
{
source_info: if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(
cx,
Some(enum_adt_def.variant(variant_index).def_id),
@ -104,8 +103,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
})
.collect();
let enum_adt_def_id = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo
{
let enum_adt_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(enum_adt_def.did())
} else {
None
@ -157,7 +155,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
let coroutine_type_name = compute_debuginfo_type_name(cx.tcx, coroutine_type, false);
let def_location = if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let def_location = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(file_metadata_from_def_id(cx, Some(coroutine_def_id)))
} else {
None
@ -227,9 +225,8 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
})
.collect();
let generator_def_id =
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
Some(generator_def_id)
let coroutine_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
Some(coroutine_def_id)
} else {
None
};
@ -274,8 +271,8 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
let variant_part_unique_type_id =
UniqueTypeId::for_enum_variant_part(cx.tcx, enum_type_and_layout.ty);
let (file_metadata, line_number) =
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo {
let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
{
file_metadata_from_def_id(cx, enum_type_def_id)
} else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)

View file

@ -709,7 +709,6 @@ fn test_unstable_options_tracking_hash() {
untracked!(macro_backtrace, true);
untracked!(meta_stats, true);
untracked!(mir_include_spans, MirIncludeSpans::On);
untracked!(more_source_locations_in_debuginfo, true);
untracked!(nll_facts, true);
untracked!(no_analysis, true);
untracked!(no_leak_check, true);
@ -773,6 +772,7 @@ fn test_unstable_options_tracking_hash() {
tracked!(crate_attr, vec!["abc".to_string()]);
tracked!(cross_crate_inline_threshold, InliningThreshold::Always);
tracked!(debug_info_for_profiling, true);
tracked!(debug_info_type_line_numbers, true);
tracked!(default_visibility, Some(rustc_target::spec::SymbolVisibility::Hidden));
tracked!(dep_info_omit_d_target, true);
tracked!(direct_access_external_data, Some(true));

View file

@ -1714,6 +1714,8 @@ options! {
"threshold to allow cross crate inlining of functions"),
debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
"emit discriminators and other data necessary for AutoFDO"),
debug_info_type_line_numbers: bool = (false, parse_bool, [TRACKED],
"emit type and line information for additional data types (default: no)"),
debuginfo_compression: DebugInfoCompression = (DebugInfoCompression::None, parse_debuginfo_compression, [TRACKED],
"compress debug info sections (none, zlib, zstd, default: none)"),
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED],
@ -1907,8 +1909,6 @@ options! {
#[rustc_lint_opt_deny_field_access("use `Session::mir_opt_level` instead of this field")]
mir_opt_level: Option<usize> = (None, parse_opt_number, [TRACKED],
"MIR optimization level (0-4; default: 1 in non optimized builds and 2 in optimized builds)"),
more_source_locations_in_debuginfo: bool = (false, parse_bool, [UNTRACKED],
"include additional source file and line number information in debuginfo (default: no)"),
move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
"the size at which the `large_assignments` lint starts to be emitted"),
mutable_noalias: bool = (true, parse_bool, [TRACKED],

View file

@ -0,0 +1,7 @@
# `debug-info-type-line-numbers`
---
This option causes additional type and line information to be emitted in debug
info to provide richer information to debuggers. This is currently off by
default as it causes some compilation scenarios to be noticeably slower.

View file

@ -2,7 +2,7 @@
// async functions.
//
// edition: 2021
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo=true
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
#![crate_type = "lib"]
// ignore-tidy-linelength

View file

@ -1,7 +1,7 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for closures and
// generators.
//
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
#![crate_type = "lib"]
#![feature(generators, stmt_expr_attributes)]

View file

@ -1,6 +1,6 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata enums.
//
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
#![crate_type = "lib"]
// ignore-tidy-linelength

View file

@ -1,7 +1,7 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for structs and
// unions.
//
// compile-flags: -C debuginfo=2 -Z more-source-locations-in-debuginfo
// compile-flags: -C debuginfo=2 -Z debug-info-type-line-numbers=true
#![crate_type = "lib"]
// ignore-tidy-linelength