about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2024-06-13 16:04:31 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2024-06-13 16:04:31 +0200
commitb89a0a7838dc95362235a17d6f3d2cb90f466728 (patch)
tree3fdafa9c95e25670f9815bb926783e7f5999f438
parent9c25d4078463fea9a4b0ad6cab61b8f51b63bf6b (diff)
downloadrust-b89a0a7838dc95362235a17d6f3d2cb90f466728.tar.gz
rust-b89a0a7838dc95362235a17d6f3d2cb90f466728.zip
Add debuginfo tests for collapse_debuginfo for statics.
-rw-r--r--tests/debuginfo/collapse-debuginfo-static-external.rs24
-rw-r--r--tests/debuginfo/collapse-debuginfo-static.rs24
2 files changed, 48 insertions, 0 deletions
diff --git a/tests/debuginfo/collapse-debuginfo-static-external.rs b/tests/debuginfo/collapse-debuginfo-static-external.rs
new file mode 100644
index 00000000000..2209bb9bd94
--- /dev/null
+++ b/tests/debuginfo/collapse-debuginfo-static-external.rs
@@ -0,0 +1,24 @@
+//@ ignore-lldb
+
+// Test that static debug info is not collapsed with #[collapse_debuginfo(external)]
+
+//@ compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:info line collapse_debuginfo_static_external::FOO
+// gdb-check:[...]Line 15[...]
+
+#[collapse_debuginfo(external)]
+macro_rules! decl_foo {
+    () => {
+        static FOO: u32 = 0;
+    };
+}
+
+decl_foo!();
+
+fn main() {
+    // prevent FOO from getting optimized out
+    std::hint::black_box(&FOO);
+}
diff --git a/tests/debuginfo/collapse-debuginfo-static.rs b/tests/debuginfo/collapse-debuginfo-static.rs
new file mode 100644
index 00000000000..e6469da4785
--- /dev/null
+++ b/tests/debuginfo/collapse-debuginfo-static.rs
@@ -0,0 +1,24 @@
+//@ ignore-lldb
+
+// Test that static debug info is collapsed with #[collapse_debuginfo(yes)]
+
+//@ compile-flags:-g
+
+// === GDB TESTS ===================================================================================
+
+// gdb-command:info line collapse_debuginfo_static::FOO
+// gdb-check:[...]Line 19[...]
+
+#[collapse_debuginfo(yes)]
+macro_rules! decl_foo {
+    () => {
+        static FOO: u32 = 0;
+    };
+}
+
+decl_foo!();
+
+fn main() {
+    // prevent FOO from getting optimized out
+    std::hint::black_box(&FOO);
+}