aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test/API')
-rw-r--r--lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py7
-rw-r--r--lldb/test/API/lang/objc/real-definition/TestRealDefinition.py8
-rw-r--r--lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py30
-rw-r--r--lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py2
-rw-r--r--lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py88
-rw-r--r--lldb/test/API/tools/lldb-dap/module/TestDAP_module.py8
-rw-r--r--lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py28
-rw-r--r--lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py39
-rw-r--r--lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py2
9 files changed, 78 insertions, 134 deletions
diff --git a/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py b/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
index 7fd2ff4..5fd2b76 100644
--- a/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
+++ b/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
@@ -12,10 +12,6 @@ from lldbsuite.test import lldbutil
class MultipleSlidesTestCase(TestBase):
NO_DEBUG_INFO_TESTCASE = True
- # The intermediate object main.o is compiled without debug info, but
- # a.out is linked with `-gdwarf` on Windows. This creates a PDB.
- # However, in the native PDB plugin, the symbols don't have a size.
- @expectedFailureWindows
def test_mulitple_slides(self):
"""Test that a binary can be slid multiple times correctly."""
self.build()
@@ -33,10 +29,13 @@ class MultipleSlidesTestCase(TestBase):
first_sym.GetEndAddress().GetOffset()
- first_sym.GetStartAddress().GetOffset()
)
+ int_size = target.FindFirstType("int").GetByteSize()
+ self.assertGreaterEqual(first_size, 2048 * int_size)
second_size = (
second_sym.GetEndAddress().GetOffset()
- second_sym.GetStartAddress().GetOffset()
)
+ self.assertGreaterEqual(second_size, 2048 * int_size)
# View the first element of `first` and `second` while
# they have no load address set.
diff --git a/lldb/test/API/lang/objc/real-definition/TestRealDefinition.py b/lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
index 6cbb9dd..9fb2bea9 100644
--- a/lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
+++ b/lldb/test/API/lang/objc/real-definition/TestRealDefinition.py
@@ -27,13 +27,11 @@ class TestRealDefinition(TestBase):
# Run at stop at main
lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
- self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
-
# This should display correctly.
self.expect(
"frame variable foo->_bar->_hidden_ivar",
VARIABLES_DISPLAYED_CORRECTLY,
- substrs=["(NSString *)", "foo->_bar->_hidden_ivar = 0x"],
+ substrs=["foo->_bar->_hidden_ivar = 0x"],
)
def test_frame_var_after_stop_at_implementation(self):
@@ -54,11 +52,9 @@ class TestRealDefinition(TestBase):
# Run at stop at main
lldbutil.check_breakpoint(self, bpno=1, expected_hit_count=1)
- self.runCmd("settings set target.prefer-dynamic-value no-dynamic-values")
-
# This should display correctly.
self.expect(
"frame variable foo->_bar->_hidden_ivar",
VARIABLES_DISPLAYED_CORRECTLY,
- substrs=["(NSString *)", "foo->_bar->_hidden_ivar = 0x"],
+ substrs=["foo->_bar->_hidden_ivar = 0x"],
)
diff --git a/lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py b/lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py
index 7b78541..beab4d6 100644
--- a/lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py
+++ b/lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py
@@ -81,20 +81,24 @@ class TestDAP_breakpointEvents(lldbdap_testcase.DAPTestCaseBase):
breakpoint["verified"], "expect foo breakpoint to not be verified"
)
+ # Flush the breakpoint events.
+ self.dap_server.wait_for_breakpoint_events()
+
# Continue to the breakpoint
- self.continue_to_breakpoint(foo_bp_id)
- self.continue_to_next_stop() # foo_bp2
- self.continue_to_breakpoint(main_bp_id)
- self.continue_to_exit()
+ self.continue_to_breakpoints(dap_breakpoint_ids)
- bp_events = [e for e in self.dap_server.events if e["event"] == "breakpoint"]
+ verified_breakpoint_ids = []
+ unverified_breakpoint_ids = []
+ for breakpoint_event in self.dap_server.wait_for_breakpoint_events():
+ breakpoint = breakpoint_event["body"]["breakpoint"]
+ id = breakpoint["id"]
+ if breakpoint["verified"]:
+ verified_breakpoint_ids.append(id)
+ else:
+ unverified_breakpoint_ids.append(id)
- main_bp_events = [
- e for e in bp_events if e["body"]["breakpoint"]["id"] == main_bp_id
- ]
- foo_bp_events = [
- e for e in bp_events if e["body"]["breakpoint"]["id"] == foo_bp_id
- ]
+ self.assertIn(main_bp_id, unverified_breakpoint_ids)
+ self.assertIn(foo_bp_id, unverified_breakpoint_ids)
- self.assertTrue(main_bp_events)
- self.assertTrue(foo_bp_events)
+ self.assertIn(main_bp_id, verified_breakpoint_ids)
+ self.assertIn(foo_bp_id, verified_breakpoint_ids)
diff --git a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
index 09b1322..ca881f1 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -156,7 +156,6 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
self.build_and_launch(
program, debuggerRoot=program_parent_dir, initCommands=commands
)
- self.continue_to_exit()
output = self.get_console()
self.assertTrue(output and len(output) > 0, "expect console output")
lines = output.splitlines()
@@ -172,6 +171,7 @@ class TestDAP_launch(lldbdap_testcase.DAPTestCaseBase):
% (program_parent_dir, line[len(prefix) :]),
)
self.assertTrue(found, "verified lldb-dap working directory")
+ self.continue_to_exit()
def test_sourcePath(self):
"""
diff --git a/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py b/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
index 9d1d17b..1f4afab 100644
--- a/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
+++ b/lldb/test/API/tools/lldb-dap/module-event/TestDAP_module_event.py
@@ -1,58 +1,58 @@
-"""
-Test 'module' events for dynamically loaded libraries.
-"""
-
+import dap_server
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
import lldbdap_testcase
+import re
class TestDAP_module_event(lldbdap_testcase.DAPTestCaseBase):
- def lookup_module_id(self, name):
- """Returns the identifier for the first module event starting with the given name."""
- for event in self.dap_server.module_events:
- if self.get_dict_value(event, ["body", "module", "name"]).startswith(name):
- return self.get_dict_value(event, ["body", "module", "id"])
- self.fail(f"No module events matching name={name}")
-
- def module_events(self, id):
- """Finds all module events by identifier."""
- return [
- event
- for event in self.dap_server.module_events
- if self.get_dict_value(event, ["body", "module", "id"]) == id
- ]
-
- def module_reasons(self, events):
- """Returns the list of 'reason' values from the given events."""
- return [event["body"]["reason"] for event in events]
-
@skipIfWindows
def test_module_event(self):
- """
- Test that module events are fired on target load and when the list of
- dynamic libraries updates while running.
- """
program = self.getBuildArtifact("a.out")
self.build_and_launch(program)
- # We can analyze the order of events after the process exits.
- self.continue_to_exit()
- a_out_id = self.lookup_module_id("a.out")
- a_out_events = self.module_events(id=a_out_id)
+ source = "main.cpp"
+ breakpoint1_line = line_number(source, "// breakpoint 1")
+ breakpoint2_line = line_number(source, "// breakpoint 2")
+ breakpoint3_line = line_number(source, "// breakpoint 3")
- self.assertIn(
- "new",
- self.module_reasons(a_out_events),
- "Expected a.out to load during the debug session.",
+ breakpoint_ids = self.set_source_breakpoints(
+ source, [breakpoint1_line, breakpoint2_line, breakpoint3_line]
)
+ self.continue_to_breakpoints(breakpoint_ids)
+
+ # We're now stopped at breakpoint 1 before the dlopen. Flush all the module events.
+ event = self.dap_server.wait_for_event(["module"])
+ while event is not None:
+ event = self.dap_server.wait_for_event(["module"])
+
+ # Continue to the second breakpoint, before the dlclose.
+ self.continue_to_breakpoints(breakpoint_ids)
+
+ # Make sure we got a module event for libother.
+ event = self.dap_server.wait_for_event(["module"])
+ self.assertIsNotNone(event, "didn't get a module event")
+ module_name = event["body"]["module"]["name"]
+ module_id = event["body"]["module"]["id"]
+ self.assertEqual(event["body"]["reason"], "new")
+ self.assertIn("libother", module_name)
+
+ # Continue to the third breakpoint, after the dlclose.
+ self.continue_to_breakpoints(breakpoint_ids)
+
+ # Make sure we got a module event for libother.
+ event = self.dap_server.wait_for_event(["module"])
+ self.assertIsNotNone(event, "didn't get a module event")
+ reason = event["body"]["reason"]
+ self.assertEqual(reason, "removed")
+ self.assertEqual(event["body"]["module"]["id"], module_id)
+
+ # The removed module event should omit everything but the module id and name
+ # as they are required fields.
+ module_data = event["body"]["module"]
+ required_keys = ["id", "name"]
+ self.assertListEqual(list(module_data.keys()), required_keys)
+ self.assertEqual(module_data["name"], "", "expects empty name.")
- libother_id = self.lookup_module_id(
- "libother." # libother.so or libother.dylib based on OS.
- )
- libother_events = self.module_events(id=libother_id)
- self.assertEqual(
- self.module_reasons(libother_events),
- ["new", "removed"],
- "Expected libother to be loaded then unloaded during the debug session.",
- )
+ self.continue_to_exit()
diff --git a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
index 2d00c51..0ed53da 100644
--- a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
+++ b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
@@ -64,18 +64,19 @@ class TestDAP_module(lldbdap_testcase.DAPTestCaseBase):
self.assertEqual(program, program_module["path"])
self.assertIn("addressRange", program_module)
- self.continue_to_exit()
-
# Collect all the module names we saw as events.
module_new_names = []
module_changed_names = []
- for module_event in self.dap_server.module_events:
+ module_event = self.dap_server.wait_for_event(["module"])
+ while module_event is not None:
reason = module_event["body"]["reason"]
if reason == "new":
module_new_names.append(module_event["body"]["module"]["name"])
elif reason == "changed":
module_changed_names.append(module_event["body"]["module"]["name"])
+ module_event = self.dap_server.wait_for_event(["module"])
+
# Make sure we got an event for every active module.
self.assertNotEqual(len(module_new_names), 0)
for module in active_modules:
@@ -85,6 +86,7 @@ class TestDAP_module(lldbdap_testcase.DAPTestCaseBase):
# symbols got added.
self.assertNotEqual(len(module_changed_names), 0)
self.assertIn(program_module["name"], module_changed_names)
+ self.continue_to_exit()
@skipIfWindows
def test_modules(self):
diff --git a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py
index 83faf27..e8e07e1 100644
--- a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py
+++ b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart.py
@@ -51,20 +51,8 @@ class TestDAP_restart(lldbdap_testcase.DAPTestCaseBase):
self.build_and_launch(program, stopOnEntry=True)
[bp_main] = self.set_function_breakpoints(["main"])
- self.dap_server.request_configurationDone()
- self.dap_server.wait_for_stopped()
- # Once the "configuration done" event is sent, we should get a stopped
- # event immediately because of stopOnEntry.
- self.assertTrue(
- len(self.dap_server.thread_stop_reasons) > 0,
- "expected stopped event during launch",
- )
- for _, body in self.dap_server.thread_stop_reasons.items():
- if "reason" in body:
- reason = body["reason"]
- self.assertNotEqual(
- reason, "breakpoint", 'verify stop isn\'t "main" breakpoint'
- )
+ self.continue_to_next_stop()
+ self.verify_stop_on_entry()
# Then, if we continue, we should hit the breakpoint at main.
self.continue_to_breakpoints([bp_main])
@@ -73,17 +61,7 @@ class TestDAP_restart(lldbdap_testcase.DAPTestCaseBase):
# main.
resp = self.dap_server.request_restart()
self.assertTrue(resp["success"])
- stopped_events = self.dap_server.wait_for_stopped()
- for stopped_event in stopped_events:
- if "body" in stopped_event:
- body = stopped_event["body"]
- if "reason" in body:
- reason = body["reason"]
- self.assertNotEqual(
- reason,
- "breakpoint",
- 'verify stop after restart isn\'t "main" breakpoint',
- )
+ self.verify_stop_on_entry()
@skipIfWindows
def test_arguments(self):
diff --git a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py
index fa62ec2..7d49499 100644
--- a/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py
+++ b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py
@@ -11,31 +11,6 @@ from lldbsuite.test.lldbtest import line_number
@skipIfBuildType(["debug"])
class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):
- def verify_stopped_on_entry(self, stopped_events: List[Dict[str, Any]]):
- seen_stopped_event = 0
- for stopped_event in stopped_events:
- body = stopped_event.get("body")
- if body is None:
- continue
-
- reason = body.get("reason")
- if reason is None:
- continue
-
- self.assertNotEqual(
- reason,
- "breakpoint",
- 'verify stop after restart isn\'t "main" breakpoint',
- )
- if reason == "entry":
- seen_stopped_event += 1
-
- self.assertEqual(
- seen_stopped_event,
- 1,
- f"expect only one stopped entry event in {stopped_events}",
- )
-
@skipIfAsan
@skipIfWindows
@skipIf(oslist=["linux"], archs=["arm$"]) # Always times out on buildbot
@@ -97,12 +72,7 @@ class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):
[bp_main] = self.set_function_breakpoints(["main"])
self.dap_server.request_configurationDone()
- stopped_threads = list(self.dap_server.thread_stop_reasons.values())
- # We should be stopped at the entry point.
- self.assertEqual(
- len(stopped_threads), 1, "Expected the main thread to be stopped on entry."
- )
- self.assertEqual(stopped_threads[0]["reason"], "entry")
+ self.verify_stop_on_entry()
# Then, if we continue, we should hit the breakpoint at main.
self.dap_server.request_continue()
@@ -111,12 +81,7 @@ class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):
# Restart and check that we still get a stopped event before reaching
# main.
self.dap_server.request_restart()
- stopped_threads = list(self.dap_server.thread_stop_reasons.values())
- # We should be stopped at the entry point.
- self.assertEqual(
- len(stopped_threads), 1, "Expected the main thread to be stopped on entry."
- )
- self.assertEqual(stopped_threads[0]["reason"], "entry")
+ self.verify_stop_on_entry()
# continue to main
self.dap_server.request_continue()
diff --git a/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py b/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
index 0184020..a018456 100644
--- a/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
+++ b/lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py
@@ -32,7 +32,7 @@ class TestDAP_sendEvent(lldbdap_testcase.DAPTestCaseBase):
],
)
self.set_source_breakpoints(source, [breakpoint_line])
- self.do_continue()
+ self.continue_to_next_stop()
custom_event = self.dap_server.wait_for_event(
filter=["my-custom-event-no-body"]