[Lldb-commits] [lldb] r255342 - Create test for llvm.org/pr25806
Tamas Berghammer via lldb-commits
lldb-commits at lists.llvm.org
Fri Dec 11 08:24:15 PST 2015
Author: tberghammer
Date: Fri Dec 11 10:24:14 2015
New Revision: 255342
URL: http://llvm.org/viewvc/llvm-project?rev=255342&view=rev
Log:
Create test for llvm.org/pr25806
LLDB don't detect the loading of a shared object file linked against the
main executable before the static initializers are executed for the
given module. Because of this it is not possible to get breakpoint hits
in these static initializers and to display proper debug info in case of
a crash in these codes.
Added:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp
- copied, changed from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp
- copied, changed from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp
- copied, changed from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp
- copied, changed from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp
- copied, changed from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp
- copied, changed from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c
Removed:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c
Modified:
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk
lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/Makefile Fri Dec 11 10:24:14 2015
@@ -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
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/TestLoadUnload.py Fri Dec 11 10:24:14 2015
@@ -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'])
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c?rev=255341&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c (removed)
@@ -1,15 +0,0 @@
-//===-- a.c -----------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-extern int b_function ();
-
-int
-a_function ()
-{
- return b_function ();
-}
Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp (from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c&r1=255341&r2=255342&rev=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.cpp Fri Dec 11 10:24:14 2015
@@ -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 ();
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/a.mk Fri Dec 11 10:24:14 2015
@@ -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:
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c?rev=255341&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c (removed)
@@ -1,13 +0,0 @@
-//===-- b.c -----------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-int
-b_function ()
-{
- return 500;
-}
Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp (from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c&r1=255341&r2=255342&rev=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.cpp Fri Dec 11 10:24:14 2015
@@ -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;
}
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/b.mk Fri Dec 11 10:24:14 2015
@@ -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
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c?rev=255341&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c (removed)
@@ -1,13 +0,0 @@
-//===-- c.c -----------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-int
-c_function ()
-{
- return 600;
-}
Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp (from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c&r1=255341&r2=255342&rev=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.cpp Fri Dec 11 10:24:14 2015
@@ -6,7 +6,7 @@
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
-int
+extern "C" int
c_function ()
{
return 600;
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/c.mk Fri Dec 11 10:24:14 2015
@@ -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
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c?rev=255341&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c (removed)
@@ -1,13 +0,0 @@
-//===-- c.c -----------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-int
-d_function ()
-{ // Find this line number within d_dunction().
- return 700;
-}
Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp (from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c&r1=255341&r2=255342&rev=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.cpp Fri Dec 11 10:24:14 2015
@@ -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().
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/d.mk Fri Dec 11 10:24:14 2015
@@ -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
Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile?rev=255342&r1=255341&r2=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/Makefile Fri Dec 11 10:24:14 2015
@@ -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
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c?rev=255341&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c (removed)
@@ -1,13 +0,0 @@
-//===-- c.c -----------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-int
-d_function ()
-{ // Find this line number within d_dunction().
- return 12345;
-}
Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp (from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c&r1=255341&r2=255342&rev=255342&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/hidden/d.cpp Fri Dec 11 10:24:14 2015
@@ -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().
Removed: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c?rev=255341&view=auto
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c (removed)
@@ -1,80 +0,0 @@
-//===-- main.c --------------------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-#include <stdio.h>
-#include <dlfcn.h>
-#include <limits.h>
-#include <string.h>
-#include <unistd.h>
-#include <libgen.h>
-#include <stdlib.h>
-
-int
-main (int argc, char const *argv[])
-{
-#if defined (__APPLE__)
- const char *a_name = "@executable_path/libloadunload_a.dylib";
- const char *c_name = "@executable_path/libloadunload_c.dylib";
-#else
- const char *a_name = "libloadunload_a.so";
- const char *c_name = "libloadunload_c.so";
-#endif
- void *a_dylib_handle = NULL;
- void *c_dylib_handle = NULL;
- int (*a_function) (void);
-
- a_dylib_handle = dlopen (a_name, RTLD_NOW); // Set break point at this line for test_lldb_process_load_and_unload_commands().
- if (a_dylib_handle == NULL)
- {
- fprintf (stderr, "%s\n", dlerror());
- exit (1);
- }
-
- a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function");
- if (a_function == NULL)
- {
- fprintf (stderr, "%s\n", dlerror());
- exit (2);
- }
- printf ("First time around, got: %d\n", a_function ());
- dlclose (a_dylib_handle);
-
- c_dylib_handle = dlopen (c_name, RTLD_NOW);
- if (c_dylib_handle == NULL)
- {
- fprintf (stderr, "%s\n", dlerror());
- exit (3);
- }
- a_function = (int (*) ()) dlsym (c_dylib_handle, "c_function");
- if (a_function == NULL)
- {
- fprintf (stderr, "%s\n", dlerror());
- exit (4);
- }
-
- a_dylib_handle = dlopen (a_name, RTLD_NOW);
- if (a_dylib_handle == NULL)
- {
- fprintf (stderr, "%s\n", dlerror());
- exit (5);
- }
-
- a_function = (int (*) ()) dlsym (a_dylib_handle, "a_function");
- if (a_function == NULL)
- {
- fprintf (stderr, "%s\n", dlerror());
- exit (6);
- }
- printf ("Second time around, got: %d\n", a_function ());
- dlclose (a_dylib_handle);
-
- int d_function(void);
- printf ("d_function returns: %d\n", d_function());
-
- return 0;
-}
Copied: lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp (from r255341, lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c)
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp?p2=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.cpp&p1=lldb/trunk/packages/Python/lldbsuite/test/functionalities/load_unload/main.c&r1=255341&r2=255342&rev=255342&view=diff
==============================================================================
(empty)
More information about the lldb-commits
mailing list