diff options
Diffstat (limited to 'packages/Python/lldbsuite/test/lang/cpp/incomplete-types')
7 files changed, 156 insertions, 0 deletions
diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile new file mode 100644 index 000000000000..6595e33b7269 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/Makefile @@ -0,0 +1,35 @@ +LEVEL = ../../../make + +CXX_SOURCES = main.cpp length.cpp a.cpp + +CFLAGS_LIMIT = -c $(CXXFLAGS) +CFLAGS_NO_LIMIT = -c $(CXXFLAGS) + +ifneq (,$(findstring clang,$(CC))) + CFLAGS_LIMIT += -flimit-debug-info + CFLAGS_NO_LIMIT += -fno-limit-debug-info +endif + +all: limit nolimit + +limit: main.o length_limit.o a.o + $(CXX) $(LDFLAGS) main.o length_limit.o a.o -o limit + +nolimit: main.o length_nolimit.o a.o + $(CXX) $(LDFLAGS) main.o length_nolimit.o a.o -o nolimit + +main.o: main.cpp + $(CXX) $(CFLAGS_LIMIT) main.cpp -o main.o + +length_limit.o: length.cpp + $(CXX) $(CFLAGS_LIMIT) length.cpp -o length_limit.o + +length_nolimit.o: length.cpp + $(CXX) $(CFLAGS_NO_LIMIT) length.cpp -o length_nolimit.o + +a.o: a.cpp + $(CXX) $(CFLAGS_NO_DEBUG) -c a.cpp -o a.o + +clean: OBJECTS += limit nolimit length_limit.o length_nolimit.o length_limit.dwo length_nolimit.dwo + +include $(LEVEL)/Makefile.rules diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py new file mode 100644 index 000000000000..324f476efb9b --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py @@ -0,0 +1,66 @@ +import lldb +from lldbsuite.test.lldbtest import * +import lldbsuite.test.lldbutil as lldbutil + +class TestCppIncompleteTypes(TestBase): + + mydir = TestBase.compute_mydir(__file__) + + @expectedFailureFreeBSD("llvm.org/pr25626 test executable not built correctly on FreeBSD") + @skipIfGcc + def test_limit_debug_info(self): + self.build() + frame = self.get_test_frame('limit') + + value_f = frame.EvaluateExpression("f") + self.assertTrue(value_f.IsValid(), "'expr f' results in a valid SBValue object") + self.assertTrue(value_f.GetError().Success(), "'expr f' is successful") + + value_a = frame.EvaluateExpression("a") + self.assertTrue(value_a.IsValid(), "'expr a' results in a valid SBValue object") + self.assertTrue(value_a.GetError().Success(), "'expr a' is successful") + + @skipIfGcc + @skipIfWindows # Clang on Windows asserts in external record layout in this case. + def test_partial_limit_debug_info(self): + self.build() + frame = self.get_test_frame('nolimit') + + value_f = frame.EvaluateExpression("f") + self.assertTrue(value_f.IsValid(), "'expr f' results in a valid SBValue object") + self.assertTrue(value_f.GetError().Success(), "'expr f' is successful") + + value_a = frame.EvaluateExpression("a") + self.assertTrue(value_a.IsValid(), "'expr a' results in a valid SBValue object") + self.assertTrue(value_a.GetError().Success(), "'expr a' is successful") + + def get_test_frame(self, exe): + # Get main source file + src_file = "main.cpp" + src_file_spec = lldb.SBFileSpec(src_file) + self.assertTrue(src_file_spec.IsValid(), "Main source file") + + # Get the path of the executable + cwd = os.getcwd() + exe_path = os.path.join(cwd, exe) + + # Load the executable + target = self.dbg.CreateTarget(exe_path) + self.assertTrue(target.IsValid(), VALID_TARGET) + + # Break on main function + main_breakpoint = target.BreakpointCreateBySourceRegex("break here", src_file_spec) + self.assertTrue(main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1, VALID_BREAKPOINT) + + # Launch the process + args = None + env = None + process = target.LaunchSimple(args, env, self.get_process_working_directory()) + self.assertTrue(process.IsValid(), PROCESS_IS_VALID) + + # Get the thread of the process + self.assertTrue(process.GetState() == lldb.eStateStopped, PROCESS_STOPPED) + thread = lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint) + + # Get frame for current thread + return thread.GetSelectedFrame() diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/a.cpp b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/a.cpp new file mode 100644 index 000000000000..36b374be6f33 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/a.cpp @@ -0,0 +1,10 @@ + +#include "a.h" + +A::A () { } + +int +A::length () +{ + return 123; +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/a.h b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/a.h new file mode 100644 index 000000000000..13e9496e3fd7 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/a.h @@ -0,0 +1,11 @@ +#ifndef __A_H__ +#define __A_H__ + +class A +{ +public: + A(); + virtual int length(); +}; + +#endif diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/length.cpp b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/length.cpp new file mode 100644 index 000000000000..90a3b640f732 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/length.cpp @@ -0,0 +1,8 @@ + +#include "length.h" + +int +length (A &a) +{ + return a.length(); +} diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/length.h b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/length.h new file mode 100644 index 000000000000..96df4f021808 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/length.h @@ -0,0 +1,8 @@ +#ifndef __LENGTH_H__ +#define __LENGTH_H__ + +#include "a.h" + +int length (A &a); + +#endif diff --git a/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/main.cpp b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/main.cpp new file mode 100644 index 000000000000..ad324c905818 --- /dev/null +++ b/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/main.cpp @@ -0,0 +1,18 @@ + +#include "length.h" + +class Foo { +public: + A a; +}; + +class MyA : public A { +}; + +int main() +{ + Foo f; + MyA a; + + return length(a); // break here +} |