From ae4cc6069626206b493caf6b1158d3d5d601bbc7 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Sat, 27 May 2017 13:46:42 -0600 Subject: Emit debug info for trait object pointer Emit better debugging information for a trait object pointer. In particular, now: * The fields are explicitly represented in the DWARF; * DWARF for the vtable itself is emitted; and * The DWARF for the vtable's type has a DW_AT_containing_type which points to the concrete type for which the vtable was emitted. This is a small DWARF extension, that allows debuggers to determine the real type of the object to which a trait object points. I'll submit the gdb patch to take advantage of this new debuginfo once this lands. The vtable type is not currently complete -- it doesn't include members for the pointers it contains. This information was not needed for this feature. This addresses part 1 of #1563. --- src/test/codegen/vtabletype.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/test/codegen/vtabletype.rs (limited to 'src/test/codegen') diff --git a/src/test/codegen/vtabletype.rs b/src/test/codegen/vtabletype.rs new file mode 100644 index 00000000000..b6466467548 --- /dev/null +++ b/src/test/codegen/vtabletype.rs @@ -0,0 +1,33 @@ +// Copyright 2017 The Rust Project Developers. See the COPYRIGHT +// file at the top-level directory of this distribution and at +// http://rust-lang.org/COPYRIGHT. +// +// Licensed under the Apache License, Version 2.0 or the MIT license +// , at your +// option. This file may not be copied, modified, or distributed +// except according to those terms. + +// This test depends on a patch that was committed to upstream LLVM +// after 5.0, then backported to the Rust LLVM fork. + +// ignore-tidy-linelength +// ignore-windows +// ignore-macos +// min-system-llvm-version 5.1 + +// compile-flags: -g -C no-prepopulate-passes + +// CHECK-LABEL: @main +// CHECK: {{.*}}DICompositeType{{.*}}name: "vtable",{{.*}}vtableHolder:{{.*}} + +pub trait T { +} + +impl T for f64 { +} + +pub fn main() { + let d = 23.0f64; + let td = &d as &T; +} -- cgit 1.4.1-3-g733a5