summaryrefslogtreecommitdiffstats
path: root/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this
diff options
context:
space:
mode:
authorpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
committerpatrick <patrick@openbsd.org>2020-08-03 14:33:06 +0000
commit061da546b983eb767bad15e67af1174fb0bcf31c (patch)
tree83c78b820819d70aa40c36d90447978b300078c5 /gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this
parentImport LLVM 10.0.0 release including clang, lld and lldb. (diff)
downloadwireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.tar.xz
wireguard-openbsd-061da546b983eb767bad15e67af1174fb0bcf31c.zip
Import LLVM 10.0.0 release including clang, lld and lldb.
ok hackroom tested by plenty
Diffstat (limited to 'gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this')
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/Makefile3
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py61
-rw-r--r--gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp52
3 files changed, 116 insertions, 0 deletions
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/Makefile b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/Makefile
new file mode 100644
index 00000000000..99998b20bcb
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/Makefile
@@ -0,0 +1,3 @@
+CXX_SOURCES := main.cpp
+
+include Makefile.rules
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py
new file mode 100644
index 00000000000..ab95627729d
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/TestCPPThis.py
@@ -0,0 +1,61 @@
+"""
+Tests that C++ member and static variables are available where they should be.
+"""
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class CPPThisTestCase(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ # rdar://problem/9962849
+ @expectedFailureAll(
+ compiler="gcc",
+ bugnumber="llvm.org/pr15439 The 'this' pointer isn't available during expression evaluation when stopped in an inlined member function")
+ @expectedFailureAll(
+ compiler="icc",
+ bugnumber="ICC doesn't emit correct DWARF inline debug info for inlined member functions.")
+ @expectedFailureAll(
+ oslist=["windows"],
+ bugnumber="llvm.org/pr24489: Name lookup not working correctly on Windows")
+ @expectedFailureNetBSD
+ def test_with_run_command(self):
+ """Test that the appropriate member variables are available when stopped in C++ static, inline, and const methods"""
+ self.build()
+ self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
+
+ self.set_breakpoint(line_number('main.cpp', '// breakpoint 1'))
+ self.set_breakpoint(line_number('main.cpp', '// breakpoint 2'))
+ self.set_breakpoint(line_number('main.cpp', '// breakpoint 3'))
+ self.set_breakpoint(line_number('main.cpp', '// breakpoint 4'))
+
+ self.runCmd("process launch", RUN_SUCCEEDED)
+
+ self.expect("expression -- m_a = 2",
+ startstr="(int) $0 = 2")
+
+ self.runCmd("process continue")
+
+ # This would be disallowed if we enforced const. But we don't.
+ self.expect("expression -- m_a = 2",
+ startstr="(int) $1 = 2")
+
+ self.expect("expression -- (int)getpid(); m_a",
+ startstr="(int) $2 = 2")
+
+ self.runCmd("process continue")
+
+ self.expect("expression -- s_a",
+ startstr="(int) $3 = 5")
+
+ self.runCmd("process continue")
+
+ self.expect("expression -- m_a",
+ startstr="(int) $4 = 2")
+
+ def set_breakpoint(self, line):
+ lldbutil.run_break_set_by_file_and_line(
+ self, "main.cpp", line, num_expected_locations=1, loc_exact=False)
diff --git a/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp
new file mode 100644
index 00000000000..4026de0222f
--- /dev/null
+++ b/gnu/llvm/lldb/packages/Python/lldbsuite/test/lang/cpp/this/main.cpp
@@ -0,0 +1,52 @@
+//===-- main.cpp ------------------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include <stdio.h>
+
+template <class T> class A
+{
+public:
+ void accessMember(T a);
+ T accessMemberConst() const;
+ static int accessStaticMember();
+
+ void accessMemberInline(T a) __attribute__ ((always_inline))
+ {
+ m_a = a; // breakpoint 4
+ }
+
+ T m_a;
+ static int s_a;
+};
+
+template <class T> int A<T>::s_a = 5;
+
+template <class T> void A<T>::accessMember(T a)
+{
+ m_a = a; // breakpoint 1
+}
+
+template <class T> T A<T>::accessMemberConst() const
+{
+ return m_a; // breakpoint 2
+}
+
+template <class T> int A<T>::accessStaticMember()
+{
+ return s_a; // breakpoint 3
+}
+
+int main()
+{
+ A<int> my_a;
+
+ my_a.accessMember(3);
+ my_a.accessMemberConst();
+ A<int>::accessStaticMember();
+ my_a.accessMemberInline(5);
+}