Modify debuginfo to deal with the difference between source and memory order

Fix gdb enum tests to ignore garbage variants, as we no longer actually know what the garbage is.
This commit is contained in:
Austin Hicks 2016-11-20 19:56:51 -05:00
parent 8e852e9902
commit 3d23dc7956
8 changed files with 47 additions and 36 deletions

View file

@ -881,25 +881,28 @@ impl<'tcx> MemberDescriptionFactory<'tcx> {
// Creates MemberDescriptions for the fields of a struct // Creates MemberDescriptions for the fields of a struct
struct StructMemberDescriptionFactory<'tcx> { struct StructMemberDescriptionFactory<'tcx> {
ty: Ty<'tcx>,
variant: &'tcx ty::VariantDef, variant: &'tcx ty::VariantDef,
substs: &'tcx Substs<'tcx>, substs: &'tcx Substs<'tcx>,
is_simd: bool,
span: Span, span: Span,
} }
impl<'tcx> StructMemberDescriptionFactory<'tcx> { impl<'tcx> StructMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>) fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
-> Vec<MemberDescription> { -> Vec<MemberDescription> {
let field_size = if self.is_simd { let layout = cx.layout_of(self.ty);
let fty = monomorphize::field_ty(cx.tcx(),
self.substs, // The following code is slightly convoluted as to allow us to avoid allocating in the Univariant case.
&self.variant.fields[0]); // tmp exists only so we can take a reference to it in the second match arm below.
Some(machine::llsize_of_alloc( let tmp;
cx, let offsets = match *layout {
type_of::type_of(cx, fty) layout::Univariant { ref variant, .. } => &variant.offsets,
) as usize) layout::Vector { element, count } => {
} else { let element_size = element.size(&cx.tcx().data_layout).bytes();
None tmp = (0..count).map(|i| layout::Size::from_bytes(i*element_size)).collect::<Vec<layout::Size>>();
&tmp
}
_ => bug!("{} is not a struct", self.ty)
}; };
self.variant.fields.iter().enumerate().map(|(i, f)| { self.variant.fields.iter().enumerate().map(|(i, f)| {
@ -910,11 +913,7 @@ impl<'tcx> StructMemberDescriptionFactory<'tcx> {
}; };
let fty = monomorphize::field_ty(cx.tcx(), self.substs, f); let fty = monomorphize::field_ty(cx.tcx(), self.substs, f);
let offset = if self.is_simd { let offset = FixedMemberOffset { bytes: offsets[i].bytes() as usize};
FixedMemberOffset { bytes: i * field_size.unwrap() }
} else {
ComputedMemberOffset
};
MemberDescription { MemberDescription {
name: name, name: name,
@ -956,9 +955,9 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
struct_metadata_stub, struct_metadata_stub,
struct_llvm_type, struct_llvm_type,
StructMDF(StructMemberDescriptionFactory { StructMDF(StructMemberDescriptionFactory {
ty: struct_type,
variant: variant, variant: variant,
substs: substs, substs: substs,
is_simd: struct_type.is_simd(),
span: span, span: span,
}) })
) )
@ -970,6 +969,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
// Creates MemberDescriptions for the fields of a tuple // Creates MemberDescriptions for the fields of a tuple
struct TupleMemberDescriptionFactory<'tcx> { struct TupleMemberDescriptionFactory<'tcx> {
ty: Ty<'tcx>,
component_types: Vec<Ty<'tcx>>, component_types: Vec<Ty<'tcx>>,
span: Span, span: Span,
} }
@ -977,6 +977,13 @@ struct TupleMemberDescriptionFactory<'tcx> {
impl<'tcx> TupleMemberDescriptionFactory<'tcx> { impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>) fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
-> Vec<MemberDescription> { -> Vec<MemberDescription> {
let layout = cx.layout_of(self.ty);
let offsets = if let layout::Univariant { ref variant, .. } = *layout {
&variant.offsets
} else {
bug!("{} is not a tuple", self.ty);
};
self.component_types self.component_types
.iter() .iter()
.enumerate() .enumerate()
@ -985,7 +992,7 @@ impl<'tcx> TupleMemberDescriptionFactory<'tcx> {
name: format!("__{}", i), name: format!("__{}", i),
llvm_type: type_of::type_of(cx, component_type), llvm_type: type_of::type_of(cx, component_type),
type_metadata: type_metadata(cx, component_type, self.span), type_metadata: type_metadata(cx, component_type, self.span),
offset: ComputedMemberOffset, offset: FixedMemberOffset { bytes: offsets[i].bytes() as usize },
flags: DIFlags::FlagZero, flags: DIFlags::FlagZero,
} }
}).collect() }).collect()
@ -1012,6 +1019,7 @@ fn prepare_tuple_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
NO_SCOPE_METADATA), NO_SCOPE_METADATA),
tuple_llvm_type, tuple_llvm_type,
TupleMDF(TupleMemberDescriptionFactory { TupleMDF(TupleMemberDescriptionFactory {
ty: tuple_type,
component_types: component_types.to_vec(), component_types: component_types.to_vec(),
span: span, span: span,
}) })
@ -1300,6 +1308,8 @@ impl<'tcx> EnumMemberDescriptionFactory<'tcx> {
// Creates MemberDescriptions for the fields of a single enum variant. // Creates MemberDescriptions for the fields of a single enum variant.
struct VariantMemberDescriptionFactory<'tcx> { struct VariantMemberDescriptionFactory<'tcx> {
// Cloned from the layout::Struct describing the variant.
offsets: Vec<layout::Size>,
args: Vec<(String, Ty<'tcx>)>, args: Vec<(String, Ty<'tcx>)>,
discriminant_type_metadata: Option<DIType>, discriminant_type_metadata: Option<DIType>,
span: Span, span: Span,
@ -1316,7 +1326,7 @@ impl<'tcx> VariantMemberDescriptionFactory<'tcx> {
Some(metadata) if i == 0 => metadata, Some(metadata) if i == 0 => metadata,
_ => type_metadata(cx, ty, self.span) _ => type_metadata(cx, ty, self.span)
}, },
offset: ComputedMemberOffset, offset: FixedMemberOffset { bytes: self.offsets[i].bytes() as usize },
flags: DIFlags::FlagZero flags: DIFlags::FlagZero
} }
}).collect() }).collect()
@ -1420,6 +1430,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let member_description_factory = let member_description_factory =
VariantMDF(VariantMemberDescriptionFactory { VariantMDF(VariantMemberDescriptionFactory {
offsets: struct_def.offsets.clone(),
args: args, args: args,
discriminant_type_metadata: match discriminant_info { discriminant_type_metadata: match discriminant_info {
RegularDiscriminant(discriminant_type_metadata) => { RegularDiscriminant(discriminant_type_metadata) => {

View file

@ -18,11 +18,11 @@
// gdb-command:run // gdb-command:run
// gdb-command:print *the_a_ref // gdb-command:print *the_a_ref
// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, __0 = 0, __1 = 2088533116, __2 = 2088533116}} // gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
// gdbr-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452} // gdbr-check:$1 = borrowed_enum::ABC::TheA{x: 0, y: 8970181431921507452}
// gdb-command:print *the_b_ref // gdb-command:print *the_b_ref
// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, x = 0, y = 1229782938247303441}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}} // gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
// gdbr-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153) // gdbr-check:$2 = borrowed_enum::ABC::TheB(0, 286331153, 286331153)
// gdb-command:print *univariant_ref // gdb-command:print *univariant_ref

View file

@ -42,7 +42,7 @@
// gdb-command:continue // gdb-command:continue
// gdb-command:print x // gdb-command:print x
// gdbg-check:$7 = {{RUST$ENUM$DISR = Case1, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = Case1, __0 = 0, __1 = 2088533116, __2 = 2088533116}} // gdbg-check:$7 = {{RUST$ENUM$DISR = Case1, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$7 = by_value_non_immediate_argument::Enum::Case1{x: 0, y: 8970181431921507452} // gdbr-check:$7 = by_value_non_immediate_argument::Enum::Case1{x: 0, y: 8970181431921507452}
// gdb-command:continue // gdb-command:continue

View file

@ -17,15 +17,15 @@
// gdb-command:run // gdb-command:run
// gdb-command:print case1 // gdb-command:print case1
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, a = 0, b = 2088533116, c = 2088533116}, {RUST$ENUM$DISR = Case1, a = 0, b = 8970181431921507452}} // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} // gdbr-check:$1 = generic_struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
// gdb-command:print case2 // gdb-command:print case2
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, a = 0, b = 4369, c = 4369, d = 4369, e = 4369}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, a = 0, b = 1229782938247303441}} // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
// gdbr-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} // gdbr-check:$2 = generic_struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153}
// gdb-command:print case3 // gdb-command:print case3
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, a = 0, b = 22873, c = 22873, d = 22873, e = 22873}, {RUST$ENUM$DISR = Case3, a = 0, b = 1499027801, c = 1499027801}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}} // gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
// gdbr-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} // gdbr-check:$3 = generic_struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897}
// gdb-command:print univariant // gdb-command:print univariant

View file

@ -19,15 +19,15 @@
// gdb-command:run // gdb-command:run
// gdb-command:print case1 // gdb-command:print case1
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, __0 = 0, __1 = 2088533116, __2 = 2088533116}, {RUST$ENUM$DISR = Case1, __0 = 0, __1 = 8970181431921507452}} // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) // gdbr-check:$1 = generic_tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868)
// gdb-command:print case2 // gdb-command:print case2
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, __0 = 0, __1 = 4369, __2 = 4369, __3 = 4369, __4 = 4369}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 1229782938247303441}} // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
// gdbr-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153) // gdbr-check:$2 = generic_tuple_style_enum::Regular::Case2(0, 286331153, 286331153)
// gdb-command:print case3 // gdb-command:print case3
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, __0 = 0, __1 = 22873, __2 = 22873, __3 = 22873, __4 = 22873}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 1499027801, __2 = 1499027801}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}} // gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
// gdbr-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897) // gdbr-check:$3 = generic_tuple_style_enum::Regular::Case3(0, 6438275382588823897)
// gdb-command:print univariant // gdb-command:print univariant

View file

@ -19,15 +19,15 @@
// gdb-command:run // gdb-command:run
// gdb-command:print case1 // gdb-command:print case1
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, a = 0, b = 2088533116, c = 2088533116}, {RUST$ENUM$DISR = Case1, a = 0, b = 8970181431921507452}} // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, a = 0, b = 31868, c = 31868, d = 31868, e = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$1 = struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868} // gdbr-check:$1 = struct_style_enum::Regular::Case1{a: 0, b: 31868, c: 31868, d: 31868, e: 31868}
// gdb-command:print case2 // gdb-command:print case2
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, a = 0, b = 4369, c = 4369, d = 4369, e = 4369}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, a = 0, b = 1229782938247303441}} // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, a = 0, b = 286331153, c = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
// gdbr-check:$2 = struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153} // gdbr-check:$2 = struct_style_enum::Regular::Case2{a: 0, b: 286331153, c: 286331153}
// gdb-command:print case3 // gdb-command:print case3
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, a = 0, b = 22873, c = 22873, d = 22873, e = 22873}, {RUST$ENUM$DISR = Case3, a = 0, b = 1499027801, c = 1499027801}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}} // gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, a = 0, b = 6438275382588823897}}
// gdbr-check:$3 = struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897} // gdbr-check:$3 = struct_style_enum::Regular::Case3{a: 0, b: 6438275382588823897}
// gdb-command:print univariant // gdb-command:print univariant

View file

@ -19,15 +19,15 @@
// gdb-command:run // gdb-command:run
// gdb-command:print case1 // gdb-command:print case1
// gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, __0 = 0, __1 = 2088533116, __2 = 2088533116}, {RUST$ENUM$DISR = Case1, __0 = 0, __1 = 8970181431921507452}} // gdbg-check:$1 = {{RUST$ENUM$DISR = Case1, __0 = 0, __1 = 31868, __2 = 31868, __3 = 31868, __4 = 31868}, {RUST$ENUM$DISR = Case1, [...]}, {RUST$ENUM$DISR = Case1, [...]}}
// gdbr-check:$1 = tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868) // gdbr-check:$1 = tuple_style_enum::Regular::Case1(0, 31868, 31868, 31868, 31868)
// gdb-command:print case2 // gdb-command:print case2
// gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, __0 = 0, __1 = 4369, __2 = 4369, __3 = 4369, __4 = 4369}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 1229782938247303441}} // gdbg-check:$2 = {{RUST$ENUM$DISR = Case2, [...]}, {RUST$ENUM$DISR = Case2, __0 = 0, __1 = 286331153, __2 = 286331153}, {RUST$ENUM$DISR = Case2, [...]}}
// gdbr-check:$2 = tuple_style_enum::Regular::Case2(0, 286331153, 286331153) // gdbr-check:$2 = tuple_style_enum::Regular::Case2(0, 286331153, 286331153)
// gdb-command:print case3 // gdb-command:print case3
// gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, __0 = 0, __1 = 22873, __2 = 22873, __3 = 22873, __4 = 22873}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 1499027801, __2 = 1499027801}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}} // gdbg-check:$3 = {{RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, [...]}, {RUST$ENUM$DISR = Case3, __0 = 0, __1 = 6438275382588823897}}
// gdbr-check:$3 = tuple_style_enum::Regular::Case3(0, 6438275382588823897) // gdbr-check:$3 = tuple_style_enum::Regular::Case3(0, 6438275382588823897)
// gdb-command:print univariant // gdb-command:print univariant

View file

@ -18,11 +18,11 @@
// gdb-command:run // gdb-command:run
// gdb-command:print *the_a // gdb-command:print *the_a
// gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, __0 = 0, __1 = 2088533116, __2 = 2088533116}} // gdbg-check:$1 = {{RUST$ENUM$DISR = TheA, x = 0, y = 8970181431921507452}, {RUST$ENUM$DISR = TheA, [...]}}
// gdbr-check:$1 = unique_enum::ABC::TheA{x: 0, y: 8970181431921507452} // gdbr-check:$1 = unique_enum::ABC::TheA{x: 0, y: 8970181431921507452}
// gdb-command:print *the_b // gdb-command:print *the_b
// gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, x = 0, y = 1229782938247303441}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}} // gdbg-check:$2 = {{RUST$ENUM$DISR = TheB, [...]}, {RUST$ENUM$DISR = TheB, __0 = 0, __1 = 286331153, __2 = 286331153}}
// gdbr-check:$2 = unique_enum::ABC::TheB(0, 286331153, 286331153) // gdbr-check:$2 = unique_enum::ABC::TheB(0, 286331153, 286331153)
// gdb-command:print *univariant // gdb-command:print *univariant