Require type_map::stub
callers to supply file information
This change attaches file information (`DIFile` reference and line number) to struct debug info nodes. Before: ``` ; foo.ll ... !5 = !DIFile(filename: "<unknown>", directory: "") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !5, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "4cb373851db92e732c4cb5651b886dd0") ... ``` After: ``` ; foo.ll ... !3 = !DIFile(filename: "foo.rs", directory: "/home/matt/src/rust98678", checksumkind: CSK_SHA1, checksum: "bcb9f08512c8f3b8181ef4726012bc6807bc9be4") ... !16 = !DICompositeType(tag: DW_TAG_structure_type, name: "MyType", scope: !2, file: !3, line: 3, size: 32, align: 32, elements: !17, templateParams: !19, identifier: "9e5968c7af39c148acb253912b7f409f") ... ``` Fixes #98678
This commit is contained in:
parent
c07aa1e171
commit
2f00b6affd
5 changed files with 51 additions and 6 deletions
|
@ -204,6 +204,8 @@ fn build_pointer_or_reference_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&ptr_type_debuginfo_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(ptr_type),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
|
@ -371,6 +373,8 @@ fn build_dyn_type_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(dyn_type),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
|
@ -841,6 +845,8 @@ fn build_foreign_type_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&compute_debuginfo_type_name(cx.tcx, t, false),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(t),
|
||||
Some(get_namespace_for_item(cx, def_id)),
|
||||
DIFlags::FlagZero,
|
||||
|
@ -1044,6 +1050,15 @@ fn build_struct_type_di_node<'ll, 'tcx>(
|
|||
let struct_type_and_layout = cx.layout_of(struct_type);
|
||||
let variant_def = adt_def.non_enum_variant();
|
||||
|
||||
let tcx = cx.tcx;
|
||||
let struct_span = tcx.def_span(adt_def.did());
|
||||
let (file_metadata, line_number) = if !struct_span.is_dummy() {
|
||||
let loc = cx.lookup_debug_loc(struct_span.lo());
|
||||
(file_metadata(cx, &loc.file), loc.line)
|
||||
} else {
|
||||
(unknown_file_metadata(cx), UNKNOWN_LINE_NUMBER)
|
||||
};
|
||||
|
||||
type_map::build_type_with_children(
|
||||
cx,
|
||||
type_map::stub(
|
||||
|
@ -1051,6 +1066,8 @@ fn build_struct_type_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&compute_debuginfo_type_name(cx.tcx, struct_type, false),
|
||||
file_metadata,
|
||||
line_number,
|
||||
size_and_align_of(struct_type_and_layout),
|
||||
Some(containing_scope),
|
||||
visibility_di_flags(cx, adt_def.did(), adt_def.did()),
|
||||
|
@ -1154,6 +1171,8 @@ fn build_tuple_type_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(tuple_type_and_layout),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
|
@ -1200,6 +1219,8 @@ fn build_closure_env_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(closure_env_type),
|
||||
Some(containing_scope),
|
||||
DIFlags::FlagZero,
|
||||
|
@ -1231,6 +1252,8 @@ fn build_union_type_di_node<'ll, 'tcx>(
|
|||
Stub::Union,
|
||||
unique_type_id,
|
||||
&type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(union_ty_and_layout),
|
||||
Some(containing_scope),
|
||||
DIFlags::FlagZero,
|
||||
|
@ -1423,6 +1446,8 @@ fn build_vtable_type_di_node<'ll, 'tcx>(
|
|||
Stub::VTableTy { vtable_holder },
|
||||
unique_type_id,
|
||||
&vtable_type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
(size, pointer_align),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagArtificial,
|
||||
|
|
|
@ -199,6 +199,8 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
type_map::Stub::Union,
|
||||
unique_type_id,
|
||||
&enum_type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
cx.size_and_align_of(enum_type),
|
||||
NO_SCOPE_METADATA,
|
||||
visibility_di_flags(cx, enum_adt_def.did(), enum_adt_def.did()),
|
||||
|
@ -274,6 +276,8 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
|
|||
type_map::Stub::Union,
|
||||
unique_type_id,
|
||||
&coroutine_type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(coroutine_type_and_layout),
|
||||
NO_SCOPE_METADATA,
|
||||
DIFlags::FlagZero,
|
||||
|
@ -481,6 +485,8 @@ fn build_variant_struct_wrapper_type_di_node<'ll, 'tcx>(
|
|||
variant_index,
|
||||
),
|
||||
&variant_struct_wrapper_type_name(variant_index),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
// NOTE: We use size and align of enum_type, not from variant_layout:
|
||||
size_and_align_of(enum_or_coroutine_type_and_layout),
|
||||
Some(enum_or_coroutine_type_di_node),
|
||||
|
|
|
@ -204,6 +204,8 @@ fn build_enum_variant_struct_type_di_node<'ll, 'tcx>(
|
|||
variant_index,
|
||||
),
|
||||
variant_def.name.as_str(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
// NOTE: We use size and align of enum_type, not from variant_layout:
|
||||
size_and_align_of(enum_type_and_layout),
|
||||
Some(enum_type_di_node),
|
||||
|
@ -286,6 +288,8 @@ fn build_coroutine_variant_struct_type_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&variant_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(coroutine_type_and_layout),
|
||||
Some(coroutine_type_di_node),
|
||||
DIFlags::FlagZero,
|
||||
|
@ -351,7 +355,11 @@ enum DiscrResult {
|
|||
|
||||
impl DiscrResult {
|
||||
fn opt_single_val(&self) -> Option<u128> {
|
||||
if let Self::Value(d) = *self { Some(d) } else { None }
|
||||
if let Self::Value(d) = *self {
|
||||
Some(d)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,6 +62,8 @@ pub(super) fn build_enum_type_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&enum_type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(enum_type_and_layout),
|
||||
Some(containing_scope),
|
||||
visibility_flags,
|
||||
|
@ -141,6 +143,8 @@ pub(super) fn build_coroutine_di_node<'ll, 'tcx>(
|
|||
Stub::Struct,
|
||||
unique_type_id,
|
||||
&coroutine_type_name,
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
size_and_align_of(coroutine_type_and_layout),
|
||||
Some(containing_scope),
|
||||
DIFlags::FlagZero,
|
||||
|
|
|
@ -11,7 +11,7 @@ use rustc_middle::ty::{ParamEnv, PolyExistentialTraitRef, Ty, TyCtxt};
|
|||
use super::{SmallVec, UNKNOWN_LINE_NUMBER, unknown_file_metadata};
|
||||
use crate::common::{AsCCharPtr, CodegenCx};
|
||||
use crate::debuginfo::utils::{DIB, create_DIArray, debug_context};
|
||||
use crate::llvm::debuginfo::{DIFlags, DIScope, DIType};
|
||||
use crate::llvm::debuginfo::{DIFile, DIFlags, DIScope, DIType};
|
||||
use crate::llvm::{self};
|
||||
|
||||
mod private {
|
||||
|
@ -174,6 +174,8 @@ pub(super) fn stub<'ll, 'tcx>(
|
|||
kind: Stub<'ll>,
|
||||
unique_type_id: UniqueTypeId<'tcx>,
|
||||
name: &str,
|
||||
file_metadata: &'ll DIFile,
|
||||
line_number: u32,
|
||||
(size, align): (Size, Align),
|
||||
containing_scope: Option<&'ll DIScope>,
|
||||
flags: DIFlags,
|
||||
|
@ -193,8 +195,8 @@ pub(super) fn stub<'ll, 'tcx>(
|
|||
containing_scope,
|
||||
name.as_c_char_ptr(),
|
||||
name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
file_metadata,
|
||||
line_number,
|
||||
size.bits(),
|
||||
align.bits() as u32,
|
||||
flags,
|
||||
|
@ -213,8 +215,8 @@ pub(super) fn stub<'ll, 'tcx>(
|
|||
containing_scope,
|
||||
name.as_c_char_ptr(),
|
||||
name.len(),
|
||||
unknown_file_metadata(cx),
|
||||
UNKNOWN_LINE_NUMBER,
|
||||
file_metadata,
|
||||
line_number,
|
||||
size.bits(),
|
||||
align.bits() as u32,
|
||||
flags,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue