Skip to content

Commit d5cfde0

Browse files
author
git apple-llvm automerger
committed
Merge commit '7b678fbd1304' from swift/release/6.0 into stable/20230725
2 parents 96c7e9b + 7b678fb commit d5cfde0

File tree

141 files changed

+543
-569
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+543
-569
lines changed

lldb/bindings/python/python.swig

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,6 @@ except ImportError:
5252
# Relative import should work if we are being loaded by Python.
5353
from . import $module"
5454
%enddef
55-
// These versions will not generate working python modules, so error out early.
56-
#if SWIG_VERSION >= 0x030009 && SWIG_VERSION < 0x030011
57-
#error Swig versions 3.0.9 and 3.0.10 are incompatible with lldb.
58-
#endif
5955

6056
// The name of the module to be created.
6157
%module(docstring=DOCSTRING, moduleimport=MODULEIMPORT) lldb

lldb/cmake/modules/FindLuaAndSwig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ else()
1515
LUA_INCLUDE_DIR)
1616
endif()
1717
else()
18-
message(STATUS "SWIG 3 or later is required for Lua support in LLDB but could not be found")
18+
message(STATUS "SWIG 4 or later is required for Lua support in LLDB but could not be found")
1919
endif()
2020

2121

lldb/cmake/modules/FindPythonAndSwig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ else()
4040
if (LLDB_ENABLE_SWIG OR LLDB_USE_STATIC_BINDINGS)
4141
FindPython3()
4242
else()
43-
message(STATUS "SWIG 3 or later is required for Python support in LLDB but could not be found")
43+
message(STATUS "SWIG 4 or later is required for Python support in LLDB but could not be found")
4444
endif()
4545

4646
get_property(MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)

lldb/cmake/modules/LLDBConfig.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ macro(add_optional_dependency variable description package found)
5656
message(STATUS "${description}: ${${variable}}")
5757
endmacro()
5858

59-
add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG SWIG_FOUND VERSION 3)
59+
add_optional_dependency(LLDB_ENABLE_SWIG "Enable SWIG to generate LLDB bindings" SWIG SWIG_FOUND VERSION 4)
6060

6161
# BEGIN SWIFT MOD
6262
if (LLDB_ENABLE_SWIG)

lldb/docs/resources/build.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ If you want to run the test suite, you'll need to build LLDB with Python
3434
scripting support.
3535

3636
* `Python <http://www.python.org/>`_
37-
* `SWIG <http://swig.org/>`_ 3 or later.
37+
* `SWIG <http://swig.org/>`_ 4 or later.
3838

3939
Optional Dependencies
4040
*********************

lldb/packages/Python/lldbsuite/test/decorators.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from __future__ import absolute_import
22

33
# System modules
4-
from distutils.version import LooseVersion
54
from functools import wraps
5+
from pkg_resources import packaging
66
import ctypes
77
import locale
88
import os
@@ -68,10 +68,10 @@ def fn_neq(x, y):
6868
">=": fn_geq,
6969
"<=": fn_leq,
7070
}
71-
expected_str = ".".join([str(x) for x in expected])
72-
actual_str = ".".join([str(x) for x in actual])
7371

74-
return op_lookup[comparison](LooseVersion(actual_str), LooseVersion(expected_str))
72+
return op_lookup[comparison](
73+
packaging.version.parse(actual), packaging.version.parse(expected)
74+
)
7575

7676

7777
def _match_decorator_property(expected, actual):
@@ -227,7 +227,9 @@ def fn(self):
227227
)
228228
)
229229
skip_for_py_version = (py_version is None) or _check_expected_version(
230-
py_version[0], py_version[1], sys.version_info
230+
py_version[0],
231+
py_version[1],
232+
"{}.{}".format(sys.version_info.major, sys.version_info.minor),
231233
)
232234
skip_for_macos_version = (macos_version is None) or (
233235
(platform.mac_ver()[0] != "")

lldb/packages/Python/lldbsuite/test/lldbutil.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -710,24 +710,24 @@ def check_breakpoint(
710710
test.assertTrue(bkpt.IsValid(), "Breakpoint is not valid.")
711711

712712
if expected_locations is not None:
713-
test.assertEquals(expected_locations, bkpt.GetNumLocations())
713+
test.assertEqual(expected_locations, bkpt.GetNumLocations())
714714

715715
if expected_resolved_count is not None:
716-
test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
716+
test.assertEqual(expected_resolved_count, bkpt.GetNumResolvedLocations())
717717
else:
718718
expected_resolved_count = bkpt.GetNumLocations()
719719
if location_id is None:
720-
test.assertEquals(expected_resolved_count, bkpt.GetNumResolvedLocations())
720+
test.assertEqual(expected_resolved_count, bkpt.GetNumResolvedLocations())
721721

722722
if expected_hit_count is not None:
723-
test.assertEquals(expected_hit_count, bkpt.GetHitCount())
723+
test.assertEqual(expected_hit_count, bkpt.GetHitCount())
724724

725725
if location_id is not None:
726726
loc_bkpt = bkpt.FindLocationByID(location_id)
727727
test.assertTrue(loc_bkpt.IsValid(), "Breakpoint location is not valid.")
728-
test.assertEquals(loc_bkpt.IsResolved(), expected_location_resolved)
728+
test.assertEqual(loc_bkpt.IsResolved(), expected_location_resolved)
729729
if expected_location_hit_count is not None:
730-
test.assertEquals(expected_location_hit_count, loc_bkpt.GetHitCount())
730+
test.assertEqual(expected_location_hit_count, loc_bkpt.GetHitCount())
731731

732732

733733
# ==================================================

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/lldbdap_testcase.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,13 @@ def continue_to_exception_breakpoint(self, filter_label):
246246
def continue_to_exit(self, exitCode=0):
247247
self.dap_server.request_continue()
248248
stopped_events = self.dap_server.wait_for_stopped()
249-
self.assertEquals(
249+
self.assertEqual(
250250
len(stopped_events), 1, "stopped_events = {}".format(stopped_events)
251251
)
252-
self.assertEquals(
252+
self.assertEqual(
253253
stopped_events[0]["event"], "exited", "make sure program ran to completion"
254254
)
255-
self.assertEquals(
255+
self.assertEqual(
256256
stopped_events[0]["body"]["exitCode"],
257257
exitCode,
258258
"exitCode == %i" % (exitCode),

lldb/scripts/use_lldb_suite.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,12 @@ def find_lldb_root():
1616
return lldb_root
1717

1818
lldb_root = find_lldb_root()
19-
import imp
20-
fp, pathname, desc = imp.find_module("use_lldb_suite_root", [lldb_root])
21-
try:
22-
imp.load_module("use_lldb_suite_root", fp, pathname, desc)
23-
finally:
24-
if fp:
25-
fp.close()
19+
20+
import importlib.machinery
21+
import importlib.util
22+
23+
path = os.path.join(lldb_root, "use_lldb_suite_root.py")
24+
loader = importlib.machinery.SourceFileLoader("use_lldb_suite_root", path)
25+
spec = importlib.util.spec_from_loader("use_lldb_suite_root", loader=loader)
26+
module = importlib.util.module_from_spec(spec)
27+
loader.exec_module(module)

lldb/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -95,24 +95,28 @@ struct InitializePythonRAII {
9595
InitializePythonRAII() {
9696
InitializePythonHome();
9797

98+
// The table of built-in modules can only be extended before Python is
99+
// initialized.
100+
if (!Py_IsInitialized()) {
98101
#ifdef LLDB_USE_LIBEDIT_READLINE_COMPAT_MODULE
99-
// Python's readline is incompatible with libedit being linked into lldb.
100-
// Provide a patched version local to the embedded interpreter.
101-
bool ReadlinePatched = false;
102-
for (auto *p = PyImport_Inittab; p->name != nullptr; p++) {
103-
if (strcmp(p->name, "readline") == 0) {
104-
p->initfunc = initlldb_readline;
105-
break;
102+
// Python's readline is incompatible with libedit being linked into lldb.
103+
// Provide a patched version local to the embedded interpreter.
104+
bool ReadlinePatched = false;
105+
for (auto *p = PyImport_Inittab; p->name != nullptr; p++) {
106+
if (strcmp(p->name, "readline") == 0) {
107+
p->initfunc = initlldb_readline;
108+
break;
109+
}
110+
}
111+
if (!ReadlinePatched) {
112+
PyImport_AppendInittab("readline", initlldb_readline);
113+
ReadlinePatched = true;
106114
}
107-
}
108-
if (!ReadlinePatched) {
109-
PyImport_AppendInittab("readline", initlldb_readline);
110-
ReadlinePatched = true;
111-
}
112115
#endif
113116

114-
// Register _lldb as a built-in module.
115-
PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
117+
// Register _lldb as a built-in module.
118+
PyImport_AppendInittab("_lldb", LLDBSwigPyInit);
119+
}
116120

117121
// Python < 3.2 and Python >= 3.2 reversed the ordering requirements for
118122
// calling `Py_Initialize` and `PyEval_InitThreads`. < 3.2 requires that you

lldb/test/API/commands/disassemble/basic/TestFrameDisassemble.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def frame_disassemble_test(self):
4848
)
4949

5050
# The hit count for the breakpoint should be 1.
51-
self.assertEquals(breakpoint.GetHitCount(), 1)
51+
self.assertEqual(breakpoint.GetHitCount(), 1)
5252

5353
frame = threads[0].GetFrameAtIndex(0)
5454
disassembly = frame.Disassemble()

lldb/test/API/commands/expression/call-restarts/TestCallThatRestarts.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ def call_function(self):
7575
value = frame.EvaluateExpression("call_me (%d)" % (num_sigchld), options)
7676
self.assertTrue(value.IsValid())
7777
self.assertSuccess(value.GetError())
78-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
78+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
7979

8080
self.check_after_call(num_sigchld)
8181

@@ -92,7 +92,7 @@ def call_function(self):
9292

9393
self.assertTrue(value.IsValid())
9494
self.assertSuccess(value.GetError())
95-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
95+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
9696
self.check_after_call(num_sigchld)
9797

9898
# Now set the signal to print but not stop and make sure that calling
@@ -103,7 +103,7 @@ def call_function(self):
103103

104104
self.assertTrue(value.IsValid())
105105
self.assertSuccess(value.GetError())
106-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
106+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
107107
self.check_after_call(num_sigchld)
108108

109109
# Now set this unwind on error to false, and make sure that we still
@@ -113,7 +113,7 @@ def call_function(self):
113113

114114
self.assertTrue(value.IsValid())
115115
self.assertSuccess(value.GetError())
116-
self.assertEquals(value.GetValueAsSigned(-1), num_sigchld)
116+
self.assertEqual(value.GetValueAsSigned(-1), num_sigchld)
117117
self.check_after_call(num_sigchld)
118118

119119
# Okay, now set UnwindOnError to true, and then make the signal behavior to stop

lldb/test/API/commands/expression/call-throws/TestCallThatThrows.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def call_function(self):
4646

4747
value = frame.EvaluateExpression("[my_class callMeIThrow]", options)
4848
self.assertTrue(value.IsValid())
49-
self.assertEquals(value.GetError().Success(), False)
49+
self.assertEqual(value.GetError().Success(), False)
5050

5151
self.check_after_call()
5252

@@ -86,7 +86,7 @@ def call_function(self):
8686
value = frame.EvaluateExpression("[my_class iCatchMyself]", options)
8787
self.assertTrue(value.IsValid())
8888
self.assertSuccess(value.GetError())
89-
self.assertEquals(value.GetValueAsUnsigned(), 57)
89+
self.assertEqual(value.GetValueAsUnsigned(), 57)
9090
self.check_after_call()
9191
options.SetTrapExceptions(True)
9292

lldb/test/API/commands/expression/completion/TestExprCompletion.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ def assume_no_completions(self, str_input, cursor_pos=None):
310310
for m in match_strings:
311311
available_completions.append(m)
312312

313-
self.assertEquals(
313+
self.assertEqual(
314314
num_matches,
315315
0,
316316
"Got matches, but didn't expect any: " + str(available_completions),

lldb/test/API/commands/expression/fixits/TestFixIts.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test_with_target(self):
4646
value = frame.EvaluateExpression("my_pointer.first", options)
4747
self.assertTrue(value.IsValid())
4848
self.assertSuccess(value.GetError())
49-
self.assertEquals(value.GetValueAsUnsigned(), 10)
49+
self.assertEqual(value.GetValueAsUnsigned(), 10)
5050

5151
# Try with one error in a top-level expression.
5252
# The Fix-It changes "ptr.m" to "ptr->m".
@@ -56,22 +56,22 @@ def test_with_target(self):
5656
# unknown error . If a parsing error would have happened we
5757
# would get a different error kind, so let's check the error
5858
# kind here.
59-
self.assertEquals(value.GetError().GetCString(), "unknown error")
59+
self.assertEqual(value.GetError().GetCString(), "unknown error")
6060

6161
# Try with two errors:
6262
two_error_expression = "my_pointer.second->a"
6363
value = frame.EvaluateExpression(two_error_expression, options)
6464
self.assertTrue(value.IsValid())
6565
self.assertSuccess(value.GetError())
66-
self.assertEquals(value.GetValueAsUnsigned(), 20)
66+
self.assertEqual(value.GetValueAsUnsigned(), 20)
6767

6868
# Try a Fix-It that is stored in the 'note:' diagnostic of an error.
6969
# The Fix-It here is adding parantheses around the ToStr parameters.
7070
fixit_in_note_expr = "#define ToStr(x) #x\nToStr(0 {, })"
7171
value = frame.EvaluateExpression(fixit_in_note_expr, options)
7272
self.assertTrue(value.IsValid())
7373
self.assertSuccess(value.GetError())
74-
self.assertEquals(value.GetSummary(), '"(0 {, })"')
74+
self.assertEqual(value.GetSummary(), '"(0 {, })"')
7575

7676
# Now turn off the fixits, and the expression should fail:
7777
options.SetAutoApplyFixIts(False)
@@ -178,7 +178,7 @@ def test_with_multiple_retries(self):
178178
multiple_runs_options.SetRetriesWithFixIts(2)
179179
value = frame.EvaluateExpression(two_runs_expr, multiple_runs_options)
180180
# This error signals success for top level expressions.
181-
self.assertEquals(value.GetError().GetCString(), "unknown error")
181+
self.assertEqual(value.GetError().GetCString(), "unknown error")
182182

183183
# Test that the code above compiles to the right thing.
184184
self.expect_expr("test_X(1)", result_type="int", result_value="123")

lldb/test/API/commands/expression/save_jit_objects/TestSaveJITObjects.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def test_save_jit_objects(self):
3737

3838
self.cleanJITFiles()
3939
frame.EvaluateExpression("(void*)malloc(0x1)")
40-
self.assertEquals(
40+
self.assertEqual(
4141
self.countJITFiles(), 0, "No files emitted with save-jit-objects-dir empty"
4242
)
4343

lldb/test/API/commands/expression/test/TestExprs.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ def test_evaluate_expression_python(self):
123123
)
124124

125125
# We should be stopped on the breakpoint with a hit count of 1.
126-
self.assertEquals(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
126+
self.assertEqual(breakpoint.GetHitCount(), 1, BREAKPOINT_HIT_ONCE)
127127

128128
#
129129
# Use Python API to evaluate expressions while stopped in a stack frame.
@@ -168,15 +168,15 @@ def test_evaluate_expression_python(self):
168168
self.expect(
169169
"expression -i true -- a_function_to_call()", substrs=["(int) $", " 1"]
170170
)
171-
self.assertEquals(callee_break.GetHitCount(), 1)
171+
self.assertEqual(callee_break.GetHitCount(), 1)
172172

173173
# Now try ignoring breakpoints using the SB API's:
174174
options = lldb.SBExpressionOptions()
175175
options.SetIgnoreBreakpoints(True)
176176
value = frame.EvaluateExpression("a_function_to_call()", options)
177177
self.assertTrue(value.IsValid())
178-
self.assertEquals(value.GetValueAsSigned(0), 2)
179-
self.assertEquals(callee_break.GetHitCount(), 2)
178+
self.assertEqual(value.GetValueAsSigned(0), 2)
179+
self.assertEqual(callee_break.GetHitCount(), 2)
180180

181181
# rdar://problem/8686536
182182
# CommandInterpreter::HandleCommand is stripping \'s from input for

lldb/test/API/commands/expression/timeout/TestCallWithTimeout.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def test(self):
4646
return_value = interp.HandleCommand(
4747
"expr -t 100 -u true -- wait_a_while(1000000)", result
4848
)
49-
self.assertEquals(return_value, lldb.eReturnStatusFailed)
49+
self.assertEqual(return_value, lldb.eReturnStatusFailed)
5050

5151
# Okay, now do it again with long enough time outs:
5252

@@ -63,7 +63,7 @@ def test(self):
6363
return_value = interp.HandleCommand(
6464
"expr -t 1000000 -u true -- wait_a_while(1000)", result
6565
)
66-
self.assertEquals(return_value, lldb.eReturnStatusSuccessFinishResult)
66+
self.assertEqual(return_value, lldb.eReturnStatusSuccessFinishResult)
6767

6868
# Finally set the one thread timeout and make sure that doesn't change
6969
# things much:

lldb/test/API/commands/expression/unwind_expression/TestUnwindExpression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_conditional_bktp(self):
4242
main_frame = self.thread.GetFrameAtIndex(0)
4343
val = main_frame.EvaluateExpression("second_function(47)", options)
4444
self.assertSuccess(val.GetError(), "We did complete the execution.")
45-
self.assertEquals(47, val.GetValueAsSigned())
45+
self.assertEqual(47, val.GetValueAsSigned())
4646

4747
@add_test_categories(["pyapi"])
4848
@expectedFlakeyNetBSD

lldb/test/API/commands/frame/language/TestGuessLanguage.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def do_test(self):
5959
)
6060

6161
# The hit count for the breakpoint should be 1.
62-
self.assertEquals(breakpoint.GetHitCount(), 1)
62+
self.assertEqual(breakpoint.GetHitCount(), 1)
6363

6464
thread = threads[0]
6565

lldb/test/API/commands/frame/var/TestFrameVar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def do_test(self):
5252
)
5353

5454
# The hit count for the breakpoint should be 1.
55-
self.assertEquals(breakpoint.GetHitCount(), 1)
55+
self.assertEqual(breakpoint.GetHitCount(), 1)
5656

5757
frame = threads[0].GetFrameAtIndex(0)
5858
command_result = lldb.SBCommandReturnObject()

0 commit comments

Comments
 (0)