diff options
| author | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
|---|---|---|
| committer | Dimitry Andric <dim@FreeBSD.org> | 2017-12-18 20:12:36 +0000 |
| commit | ef5d0b5e97ec8e6fa395d377b09aa7755e345b4f (patch) | |
| tree | 27916256fdeeb57d10d2f3d6948be5d71a703215 /packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor | |
| parent | 76e0736e7fcfeb179779e49c05604464b1ccd704 (diff) | |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor')
5 files changed, 86 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/Makefile new file mode 100644 index 000000000000..801c1041bbe1 --- /dev/null +++ b/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/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/TestBreakpointInGlobalConstructor.py new file mode 100644 index 000000000000..4dfa03d5fab4 --- /dev/null +++ b/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/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp new file mode 100644 index 000000000000..f959a295467f --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.cpp @@ -0,0 +1,7 @@ +#include "foo.h" + +Foo::Foo() : x(42) { + bool some_code = x == 42; // !BR_foo +} + +Foo FooObj; diff --git a/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/foo.h new file mode 100644 index 000000000000..3bc63fed7555 --- /dev/null +++ b/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/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp new file mode 100644 index 000000000000..d1c8038dfadb --- /dev/null +++ b/packages/Python/lldbsuite/test/functionalities/breakpoint/global_constructor/main.cpp @@ -0,0 +1,14 @@ +#include "foo.h" + +struct Main { + Main(); + int x; +}; + +Main::Main() : x(47) { + bool some_code = x == 47; // !BR_main +} + +Main MainObj; + +int main() { return MainObj.x + FooObj.x; } |
