about summary refs log tree commit diff
path: root/src/test/debuginfo
diff options
context:
space:
mode:
authorPhilip Craig <philipjcraig@gmail.com>2019-08-25 13:01:46 +1000
committerPietro Albini <pietro@pietroalbini.org>2019-09-02 17:26:50 +0200
commit7014774fd014fb19d135f2f92dbaed46073d9c64 (patch)
treec6bf78bfd1577643dc78290137d89ba83a834212 /src/test/debuginfo
parenta06cba20cf55f9131bdfd8744d0bc6444ff1c4fe (diff)
debuginfo: give unique names to closure and generator types
Closure types have been moved to the namespace where they
are defined, and both closure and generator type names now
include the disambiguator.

This fixes an exception when lldb prints nested closures.

Fixes #57822
Diffstat (limited to 'src/test/debuginfo')
-rw-r--r--src/test/debuginfo/issue-57822.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/test/debuginfo/issue-57822.rs b/src/test/debuginfo/issue-57822.rs
new file mode 100644
index 00000000000..ba5e8e0f219
--- /dev/null
+++ b/src/test/debuginfo/issue-57822.rs
@@ -0,0 +1,55 @@
+// This test makes sure that the LLDB pretty printer does not throw an exception
+// for nested closures and generators.
+
+// Require LLVM with DW_TAG_variant_part and a gdb that can read it.
+// min-system-llvm-version: 8.0
+// min-gdb-version: 8.2
+// ignore-tidy-linelength
+
+// compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:run
+
+// gdb-command:print g
+// gdb-check:$1 = issue_57822::main::closure-1 (issue_57822::main::closure (1))
+
+// gdb-command:print b
+// gdb-check:$2 = issue_57822::main::generator-3 {__0: issue_57822::main::generator-2 {__0: 2, <<variant>>: {[...]}}, <<variant>>: {[...]}}
+
+// === LLDB TESTS ==================================================================================
+
+// lldb-command:run
+
+// lldb-command:print g
+// lldbg-check:(issue_57822::main::closure-1) $0 = closure-1(closure(1))
+
+// lldb-command:print b
+// lldbg-check:(issue_57822::main::generator-3) $1 = generator-3(generator-2(2))
+
+#![feature(omit_gdb_pretty_printer_section, generators, generator_trait)]
+#![omit_gdb_pretty_printer_section]
+
+use std::ops::Generator;
+use std::pin::Pin;
+
+fn main() {
+    let mut x = 1;
+    let f = move || x;
+    let g = move || f();
+
+    let mut y = 2;
+    let mut a = move || {
+        y += 1;
+        yield;
+    };
+    let mut b = move || {
+        Pin::new(&mut a).resume();
+        yield;
+    };
+
+    zzz(); // #break
+}
+
+fn zzz() { () }