Skip to content

Commit 89f6778

Browse files
[debuginfo] Fix and unify handling of fat pointers in debuginfo: address review comments.
1 parent 756a70c commit 89f6778

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -555,8 +555,8 @@ fn subroutine_type_metadata<'ll, 'tcx>(
555555
)
556556
}
557557

558-
// Create debuginfo for `dyn SomeTrait` types. Currently these are empty structs
559-
// we with the correct type name (e.g. "dyn SomeTrait<Foo, Item=u32> + Sync").
558+
/// Create debuginfo for `dyn SomeTrait` types. Currently these are empty structs
559+
/// we with the correct type name (e.g. "dyn SomeTrait<Foo, Item=u32> + Sync").
560560
fn dyn_type_metadata<'ll, 'tcx>(
561561
cx: &CodegenCx<'ll, 'tcx>,
562562
dyn_type: Ty<'tcx>,
@@ -570,23 +570,23 @@ fn dyn_type_metadata<'ll, 'tcx>(
570570
}
571571
}
572572

573-
// Create debuginfo for `[T]` and `str`. These are unsized.
574-
//
575-
// Note: We currently emit just emit the debuginfo for the element type here
576-
// (i.e. `T` for slices and `u8` for `str`), so that we end up with
577-
// `*const T` for the `data_ptr` field of the corresponding fat-pointer
578-
// debuginfo of `&[T]`.
579-
//
580-
// It would be preferable and more accurate if we emitted a DIArray of T
581-
// without an upper bound instead. That is, LLVM already supports emitting
582-
// debuginfo of arrays of unknown size. But GDB currently seems to end up
583-
// in an infinite loop when confronted with such a type.
584-
//
585-
// As a side effect of the current encoding every instance of a type like
586-
// `struct Foo { unsized_field: [u8] }` will look like
587-
// `struct Foo { unsized_field: u8 }` in debuginfo. If the length of the
588-
// slice is zero, then accessing `unsized_field` in the debugger would
589-
// result in an out-of-bounds access.
573+
/// Create debuginfo for `[T]` and `str`. These are unsized.
574+
///
575+
/// Note: We currently emit just emit the debuginfo for the element type here
576+
/// (i.e. `T` for slices and `u8` for `str`), so that we end up with
577+
/// `*const T` for the `data_ptr` field of the corresponding fat-pointer
578+
/// debuginfo of `&[T]`.
579+
///
580+
/// It would be preferable and more accurate if we emitted a DIArray of T
581+
/// without an upper bound instead. That is, LLVM already supports emitting
582+
/// debuginfo of arrays of unknown size. But GDB currently seems to end up
583+
/// in an infinite loop when confronted with such a type.
584+
///
585+
/// As a side effect of the current encoding every instance of a type like
586+
/// `struct Foo { unsized_field: [u8] }` will look like
587+
/// `struct Foo { unsized_field: u8 }` in debuginfo. If the length of the
588+
/// slice is zero, then accessing `unsized_field` in the debugger would
589+
/// result in an out-of-bounds access.
590590
fn slice_type_metadata<'ll, 'tcx>(
591591
cx: &CodegenCx<'ll, 'tcx>,
592592
slice_type: Ty<'tcx>,

0 commit comments

Comments
 (0)