summaryrefslogtreecommitdiffstats
path: root/lldb/packages/Python/lldbsuite
diff options
context:
space:
mode:
authorPavel Labath <labath@google.com>2017-11-30 15:39:57 +0000
committerPavel Labath <labath@google.com>2017-11-30 15:39:57 +0000
commit6b75fab1fb16a505ffbfc59ef68b645e6c7c4fae (patch)
treee178a272608c66169f1c4df4a3a20037be52bfbe /lldb/packages/Python/lldbsuite
parent33031926b66b80a593856d89e3c05b509ae95c68 (diff)
downloadbcm5719-llvm-6b75fab1fb16a505ffbfc59ef68b645e6c7c4fae.tar.gz
bcm5719-llvm-6b75fab1fb16a505ffbfc59ef68b645e6c7c4fae.zip
Add a test case for open bug 35480
The test is about failing to hit breakpoints in global constructors in shared libraries. llvm-svn: 319443
Diffstat (limited to 'lldb/packages/Python/lldbsuite')
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile8
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py46
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp5
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h11
-rw-r--r--lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp12
5 files changed, 82 insertions, 0 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile
new file mode 100644
index 00000000000..801c1041bbe
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile
@@ -0,0 +1,8 @@
+LEVEL = ../../../make
+
+DYLIB_NAME := foo
+DYLIB_CXX_SOURCES := foo.cpp
+CXX_SOURCES := main.cpp
+CFLAGS_EXTRAS := -fPIC
+
+include $(LEVEL)/Makefile.rules
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
new file mode 100644
index 00000000000..4dfa03d5fab
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py
@@ -0,0 +1,46 @@
+"""
+Test that we can hit breakpoints in global constructors
+"""
+
+from __future__ import print_function
+
+
+import os
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+
+class TestBreakpointInGlobalConstructors(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+ NO_DEBUG_INFO_TESTCASE = True
+
+ def setUp(self):
+ TestBase.setUp(self)
+ self.line_foo = line_number('foo.cpp', '// !BR_foo')
+ self.line_main = line_number('main.cpp', '// !BR_main')
+
+ @expectedFailureAll(bugnumber="llvm.org/pr35480", oslist=["linux"])
+ def test(self):
+ self.build()
+ exe = os.path.join(os.getcwd(), "a.out")
+ self.runCmd("file %s" % exe)
+
+ bp_main = lldbutil.run_break_set_by_file_and_line(
+ self, 'main.cpp', self.line_main)
+ bp_foo = lldbutil.run_break_set_by_file_and_line(
+ self, 'foo.cpp', self.line_foo)
+
+ self.runCmd("run")
+
+ self.assertIsNotNone(
+ lldbutil.get_one_thread_stopped_at_breakpoint_id(
+ self.process(), bp_foo))
+
+ self.runCmd("continue")
+
+ self.assertIsNotNone(
+ lldbutil.get_one_thread_stopped_at_breakpoint_id(
+ self.process(), bp_main))
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp
new file mode 100644
index 00000000000..76950f20e5c
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp
@@ -0,0 +1,5 @@
+#include "foo.h"
+
+Foo::Foo() : x(42) {} // !BR_foo
+
+Foo FooObj;
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h
new file mode 100644
index 00000000000..3bc63fed755
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h
@@ -0,0 +1,11 @@
+#ifndef FOO_H
+#define FOO_H
+
+struct LLDB_TEST_API Foo {
+ Foo();
+ int x;
+};
+
+extern LLDB_TEST_API Foo FooObj;
+
+#endif
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp
new file mode 100644
index 00000000000..b0e39c1114c
--- /dev/null
+++ b/lldb/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp
@@ -0,0 +1,12 @@
+#include "foo.h"
+
+struct Main {
+ Main();
+ int x;
+};
+
+Main::Main() : x(47) {} // !BR_main
+
+Main MainObj;
+
+int main() { return MainObj.x + FooObj.x; }
OpenPOWER on IntegriCloud