diff options
Diffstat (limited to 'lldb/packages/Python/lldbsuite/test')
13 files changed, 100 insertions, 15 deletions
diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile index cbac629c7b5..779745c4d26 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile @@ -3,7 +3,7 @@ LEVEL := ../../make LIB_PREFIX := loadunload_ LD_EXTRAS := -L. -l$(LIB_PREFIX)d -ldl -C_SOURCES := main.c +CXX_SOURCES := main.cpp include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py index b42bc456c4d..481e7c887bd 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py @@ -24,9 +24,9 @@ class LoadUnloadTestCase(TestBase): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break for main.cpp. - self.line = line_number('main.c', + self.line = line_number('main.cpp', '// Set break point at this line for test_lldb_process_load_and_unload_commands().') - self.line_d_function = line_number('d.c', + self.line_d_function = line_number('d.cpp', '// Find this line number within d_dunction().') if not self.platformIsDarwin(): if not lldb.remote_platform and "LD_LIBRARY_PATH" in os.environ: @@ -164,7 +164,7 @@ class LoadUnloadTestCase(TestBase): substrs = [os.path.basename(old_dylib)], matching=True) - lldbutil.run_break_set_by_file_and_line (self, "d.c", self.line_d_function, num_expected_locations=1) + lldbutil.run_break_set_by_file_and_line (self, "d.cpp", self.line_d_function, num_expected_locations=1) # After run, make sure the non-hidden library is picked up. self.expect("run", substrs=["return", "700"]) @@ -194,10 +194,10 @@ class LoadUnloadTestCase(TestBase): exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) - # Break at main.c before the call to dlopen(). + # Break at main.cpp before the call to dlopen(). # Use lldb's process load command to load the dylib, instead. - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -296,7 +296,7 @@ class LoadUnloadTestCase(TestBase): self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) # Break by function name a_function (not yet loaded). - lldbutil.run_break_set_by_file_and_line (self, "main.c", self.line, num_expected_locations=1, loc_exact=True) + lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -311,3 +311,47 @@ class LoadUnloadTestCase(TestBase): self.expect("thread list", "step over succeeded.", substrs = ['stopped', 'stop reason = step over']) + + @skipIfFreeBSD # llvm.org/pr14424 - missing FreeBSD Makefiles/testcase support + @skipUnlessListedRemote(['android']) + @skipIfWindows # Windows doesn't have dlopen and friends, dynamic libraries work differently + @unittest2.expectedFailure("llvm.org/pr25806") + def test_static_init_during_load (self): + """Test that we can set breakpoints correctly in static initializers""" + + self.build() + self.copy_shlibs_to_remote() + + exe = os.path.join(os.getcwd(), "a.out") + self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) + + a_init_bp_num = lldbutil.run_break_set_by_symbol(self, "a_init", num_expected_locations=0) + b_init_bp_num = lldbutil.run_break_set_by_symbol(self, "b_init", num_expected_locations=0) + d_init_bp_num = lldbutil.run_break_set_by_symbol(self, "d_init", num_expected_locations=1) + + self.runCmd("run", RUN_SUCCEEDED) + + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'd_init', + 'stop reason = breakpoint %d' % d_init_bp_num]) + + self.runCmd("continue") + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'a_init', + 'stop reason = breakpoint %d' % a_init_bp_num]) + self.expect("thread backtrace", + substrs = ['a_init', + 'dlopen', + 'main']) + + self.runCmd("continue") + self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT, + substrs = ['stopped', + 'b_init', + 'stop reason = breakpoint %d' % b_init_bp_num]) + self.expect("thread backtrace", + substrs = ['b_init', + 'dlopen', + 'main']) diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp index 9d4711772dd..235749aef74 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp @@ -8,7 +8,14 @@ //===----------------------------------------------------------------------===// extern int b_function (); -int +int a_init() +{ + return 234; +} + +int a_global = a_init(); + +extern "C" int a_function () { return b_function (); diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk index a5c37561daa..e8ca3d57a3f 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk @@ -6,9 +6,11 @@ CFLAGS_EXTRAS := -fPIC LD_EXTRAS := -L. -l$(LIB_PREFIX)b DYLIB_NAME := $(LIB_PREFIX)a -DYLIB_C_SOURCES := a.c +DYLIB_CXX_SOURCES := a.cpp DYLIB_ONLY := YES +CXXFLAGS += -fPIC + include $(LEVEL)/Makefile.rules .PHONY: diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp index 6c629323655..4d383169b79 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp @@ -6,8 +6,16 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + +int b_init() +{ + return 345; +} + +int b_global = b_init(); + int b_function () { - return 500; + return 500; } diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk index 956dc37cb3f..c1b0877d72a 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk @@ -3,7 +3,9 @@ LEVEL := ../../make LIB_PREFIX := loadunload_ DYLIB_NAME := $(LIB_PREFIX)b -DYLIB_C_SOURCES := b.c +DYLIB_CXX_SOURCES := b.cpp DYLIB_ONLY := YES +CXXFLAGS += -fPIC + include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp index b1778b462d0..f0dfb4ec0d3 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp @@ -6,7 +6,7 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// -int +extern "C" int c_function () { return 600; diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk index ebb5ce15787..5b5691efeef 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk @@ -3,7 +3,9 @@ LEVEL := ../../make LIB_PREFIX := loadunload_ DYLIB_NAME := $(LIB_PREFIX)c -DYLIB_C_SOURCES := c.c +DYLIB_CXX_SOURCES := c.cpp DYLIB_ONLY := YES +CXXFLAGS += -fPIC + include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp index 6e5f0623101..55f2a6b404b 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp @@ -6,6 +6,14 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + +int d_init() +{ + return 123; +} + +int d_global = d_init(); + int d_function () { // Find this line number within d_dunction(). diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk index 437c1507e20..b6b6eeacba2 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk @@ -5,7 +5,9 @@ LIB_PREFIX := loadunload_ DYLIB_EXECUTABLE_PATH := $(CURDIR) DYLIB_NAME := $(LIB_PREFIX)d -DYLIB_C_SOURCES := d.c +DYLIB_CXX_SOURCES := d.cpp DYLIB_ONLY := YES +CXXFLAGS += -fPIC + include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile index 09aa39b378e..f84d8300843 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile @@ -3,7 +3,9 @@ LEVEL := ../../../make LIB_PREFIX := loadunload_ DYLIB_NAME := $(LIB_PREFIX)d -DYLIB_C_SOURCES := d.c +DYLIB_CXX_SOURCES := d.cpp DYLIB_ONLY := YES +CXXFLAGS += -fPIC + include $(LEVEL)/Makefile.rules diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp index f20aa095f2f..6a7642c08b9 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp @@ -6,6 +6,14 @@ // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// + +int d_init() +{ + return 456; +} + +int d_global = d_init(); + int d_function () { // Find this line number within d_dunction(). diff --git a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.c b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp index bff9a317606..bff9a317606 100644 --- a/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.c +++ b/lldb/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp |