[TableGen] Fix validateOperandClass for non Phyical Reg (#118146)
[llvm-project.git] / lldb / test / API / functionalities / load_lazy / TestLoadUsingLazyBind.py
blob0fa7bc7edf995a48537dbe2db76159907f10a890
1 """
2 Test that SBProcess.LoadImageUsingPaths uses RTLD_LAZY
3 """
6 import os
7 import shutil
8 import lldb
9 from lldbsuite.test.decorators import *
10 from lldbsuite.test.lldbtest import *
11 from lldbsuite.test import lldbutil
14 class LoadUsingLazyBind(TestBase):
15 NO_DEBUG_INFO_TESTCASE = True
17 @skipIfRemote
18 @skipIfWindows # The Windows platform doesn't implement DoLoadImage.
19 @skipIf(oslist=["linux"], archs=["arm"]) # Fails on arm/linux
20 # Failing for unknown reasons on Linux, see
21 # https://bugs.llvm.org/show_bug.cgi?id=49656.
22 def test_load_using_lazy_bind(self):
23 """Test that we load using RTLD_LAZY"""
25 self.build()
26 wd = os.path.realpath(self.getBuildDir())
28 def make_lib_name(name):
29 return (
30 self.platformContext.shlib_prefix
31 + name
32 + "."
33 + self.platformContext.shlib_extension
36 def make_lib_path(name):
37 libpath = os.path.join(wd, make_lib_name(name))
38 self.assertTrue(os.path.exists(libpath))
39 return libpath
41 libt2_0 = make_lib_path("t2_0")
42 libt2_1 = make_lib_path("t2_1")
44 # Overwrite t2_0 with t2_1 to delete the definition of `use`.
45 shutil.copy(libt2_1, libt2_0)
47 # Launch a process and break
48 (target, process, thread, _) = lldbutil.run_to_source_breakpoint(
49 self, "break here", lldb.SBFileSpec("main.cpp"), extra_images=["t1"]
52 # Load libt1; should fail unless we use RTLD_LAZY
53 error = lldb.SBError()
54 lib_spec = lldb.SBFileSpec(make_lib_name("t1"))
55 paths = lldb.SBStringList()
56 paths.AppendString(wd)
57 out_spec = lldb.SBFileSpec()
58 token = process.LoadImageUsingPaths(lib_spec, paths, out_spec, error)
59 self.assertNotEqual(token, lldb.LLDB_INVALID_IMAGE_TOKEN, "Got a valid token")
61 # Calling `f1()` should return 5.
62 frame = thread.GetFrameAtIndex(0)
63 val = frame.EvaluateExpression("f1()")
64 self.assertTrue(val.IsValid())
65 self.assertEqual(val.GetValueAsSigned(-1), 5)