about summary refs log tree commit diff
path: root/src/test/codegen
diff options
context:
space:
mode:
authorTom Tromey <tom@tromey.com>2017-05-27 13:46:42 -0600
committerTom Tromey <tom@tromey.com>2017-11-15 01:48:14 -0700
commitae4cc6069626206b493caf6b1158d3d5d601bbc7 (patch)
treec3c653d637dd0b24ec1f2395d64b252c2b6eefcd /src/test/codegen
parenta5122281416e2c627c0610096ea3064a01bc2bb0 (diff)
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.
Diffstat (limited to 'src/test/codegen')
-rw-r--r--src/test/codegen/vtabletype.rs33
1 files changed, 33 insertions, 0 deletions
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 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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;
+}