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, type_di_node: &'ll DIType,
def_id: Option<DefId>, def_id: Option<DefId>,
) -> &'ll DIType { ) -> &'ll DIType {
let (file_metadata, line_number) = let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo { {
file_metadata_from_def_id(cx, def_id) file_metadata_from_def_id(cx, def_id)
} else { } else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER) (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 containing_scope = get_namespace_for_item(cx, adt_def.did());
let struct_type_and_layout = cx.layout_of(struct_type); let struct_type_and_layout = cx.layout_of(struct_type);
let variant_def = adt_def.non_enum_variant(); 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()))) Some(file_metadata_from_def_id(cx, Some(adt_def.did())))
} else { } else {
None None
@ -1088,8 +1088,7 @@ fn build_struct_type_di_node<'ll, 'tcx>(
Cow::Borrowed(f.name.as_str()) Cow::Borrowed(f.name.as_str())
}; };
let field_layout = struct_type_and_layout.field(cx, i); 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) Some(f.did)
} else { } else {
None None
@ -1221,7 +1220,7 @@ fn build_closure_env_di_node<'ll, 'tcx>(
let containing_scope = get_namespace_for_item(cx, def_id); let containing_scope = get_namespace_for_item(cx, def_id);
let type_name = compute_debuginfo_type_name(cx.tcx, closure_env_type, false); 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))) Some(file_metadata_from_def_id(cx, Some(def_id)))
} else { } else {
None 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 containing_scope = get_namespace_for_item(cx, union_def_id);
let union_ty_and_layout = cx.layout_of(union_type); let union_ty_and_layout = cx.layout_of(union_type);
let type_name = compute_debuginfo_type_name(cx.tcx, union_type, false); 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))) Some(file_metadata_from_def_id(cx, Some(union_def_id)))
} else { } else {
None None
@ -1284,8 +1283,7 @@ fn build_union_type_di_node<'ll, 'tcx>(
.enumerate() .enumerate()
.map(|(i, f)| { .map(|(i, f)| {
let field_layout = union_ty_and_layout.field(cx, i); 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) Some(f.did)
} else { } else {
None 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)); 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()))) Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
} else { } else {
None None
@ -269,7 +269,7 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
unique_type_id: UniqueTypeId<'tcx>, unique_type_id: UniqueTypeId<'tcx>,
) -> DINodeCreationResult<'ll> { ) -> DINodeCreationResult<'ll> {
let coroutine_type = unique_type_id.expect_ty(); 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 { let &ty::Coroutine(coroutine_def_id, _) = coroutine_type.kind() else {
bug!("build_coroutine_di_node() called with non-coroutine type: `{:?}`", coroutine_type) 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_di_node = type_di_node(cx, tag_base_type);
let tag_base_type_align = cx.align_of(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()) Some(enum_adt_def.did())
} else { } else {
None None
@ -408,7 +408,7 @@ fn build_union_fields_for_enum<'ll, 'tcx>(
) -> SmallVec<&'ll DIType> { ) -> SmallVec<&'ll DIType> {
let tag_base_type = tag_base_type(cx.tcx, enum_type_and_layout); 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()) Some(enum_adt_def.did())
} else { } else {
None None
@ -721,7 +721,7 @@ fn build_union_fields_for_direct_tag_coroutine<'ll, 'tcx>(
variant_range variant_range
.clone() .clone()
.map(|variant_index| (variant_index, CoroutineArgs::variant_name(variant_index))), .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) Some(coroutine_def_id)
} else { } else {
None 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_di_node,
tag_base_type, tag_base_type,
variant_member_info.discr, 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 variant_member_info.source_info
} else { } else {
None None

View file

@ -68,7 +68,7 @@ fn build_c_style_enum_di_node<'ll, 'tcx>(
enum_type_and_layout: TyAndLayout<'tcx>, enum_type_and_layout: TyAndLayout<'tcx>,
) -> DINodeCreationResult<'ll> { ) -> DINodeCreationResult<'ll> {
let containing_scope = get_namespace_for_item(cx, enum_adt_def.did()); 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()) Some(enum_adt_def.did())
} else { } else {
None None
@ -122,8 +122,8 @@ fn build_enumeration_type_di_node<'ll, 'tcx>(
}) })
.collect(); .collect();
let (file_metadata, line_number) = let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo { {
file_metadata_from_def_id(cx, def_id) file_metadata_from_def_id(cx, def_id)
} else { } else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER) (unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
@ -207,7 +207,7 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
) -> &'ll DIType { ) -> &'ll DIType {
assert_eq!(variant_layout.ty, enum_type_and_layout.ty); 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))) Some(file_metadata_from_def_id(cx, Some(variant_def.def_id)))
} else { } else {
None 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)); 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()))) Some(file_metadata_from_def_id(cx, Some(enum_adt_def.did())))
} else { } else {
None None
@ -92,8 +92,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
enum_type_and_layout.for_variant(cx, variant_index), enum_type_and_layout.for_variant(cx, variant_index),
visibility_flags, 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( Some(file_metadata_from_def_id(
cx, cx,
Some(enum_adt_def.variant(variant_index).def_id), Some(enum_adt_def.variant(variant_index).def_id),
@ -104,8 +103,7 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
}) })
.collect(); .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()) Some(enum_adt_def.did())
} else { } else {
None 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 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))) Some(file_metadata_from_def_id(cx, Some(coroutine_def_id)))
} else { } else {
None None
@ -227,9 +225,8 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
}) })
.collect(); .collect();
let generator_def_id = let coroutine_def_id = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers {
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo { Some(coroutine_def_id)
Some(generator_def_id)
} else { } else {
None None
}; };
@ -274,8 +271,8 @@ fn build_enum_variant_part_di_node<'ll, 'tcx>(
let variant_part_unique_type_id = let variant_part_unique_type_id =
UniqueTypeId::for_enum_variant_part(cx.tcx, enum_type_and_layout.ty); UniqueTypeId::for_enum_variant_part(cx.tcx, enum_type_and_layout.ty);
let (file_metadata, line_number) = let (file_metadata, line_number) = if cx.sess().opts.unstable_opts.debug_info_type_line_numbers
if cx.sess().opts.unstable_opts.more_source_locations_in_debuginfo { {
file_metadata_from_def_id(cx, enum_type_def_id) file_metadata_from_def_id(cx, enum_type_def_id)
} else { } else {
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER) (unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)

View file

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

View file

@ -1714,6 +1714,8 @@ options! {
"threshold to allow cross crate inlining of functions"), "threshold to allow cross crate inlining of functions"),
debug_info_for_profiling: bool = (false, parse_bool, [TRACKED], debug_info_for_profiling: bool = (false, parse_bool, [TRACKED],
"emit discriminators and other data necessary for AutoFDO"), "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], debuginfo_compression: DebugInfoCompression = (DebugInfoCompression::None, parse_debuginfo_compression, [TRACKED],
"compress debug info sections (none, zlib, zstd, default: none)"), "compress debug info sections (none, zlib, zstd, default: none)"),
deduplicate_diagnostics: bool = (true, parse_bool, [UNTRACKED], 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")] #[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_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)"), "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], move_size_limit: Option<usize> = (None, parse_opt_number, [TRACKED],
"the size at which the `large_assignments` lint starts to be emitted"), "the size at which the `large_assignments` lint starts to be emitted"),
mutable_noalias: bool = (true, parse_bool, [TRACKED], 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. // async functions.
// //
// edition: 2021 // 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"] #![crate_type = "lib"]
// ignore-tidy-linelength // ignore-tidy-linelength

View file

@ -1,7 +1,7 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for closures and // This test verifies the accuracy of emitted file and line debuginfo metadata for closures and
// generators. // 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"] #![crate_type = "lib"]
#![feature(generators, stmt_expr_attributes)] #![feature(generators, stmt_expr_attributes)]

View file

@ -1,6 +1,6 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata enums. // 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"] #![crate_type = "lib"]
// ignore-tidy-linelength // ignore-tidy-linelength

View file

@ -1,7 +1,7 @@
// This test verifies the accuracy of emitted file and line debuginfo metadata for structs and // This test verifies the accuracy of emitted file and line debuginfo metadata for structs and
// unions. // 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"] #![crate_type = "lib"]
// ignore-tidy-linelength // ignore-tidy-linelength