aboutsummaryrefslogtreecommitdiff
path: root/lldb/test
diff options
context:
space:
mode:
Diffstat (limited to 'lldb/test')
-rw-r--r--lldb/test/API/driver/stdio_closed/TestDriverWithClosedSTDIO.py6
-rw-r--r--lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py4
-rw-r--r--lldb/test/API/tools/lldb-dap/breakpoint-events/TestDAP_breakpointEvents.py30
-rw-r--r--lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py15
-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_console.py24
-rw-r--r--lldb/test/API/tools/lldb-dap/send-event/TestDAP_sendEvent.py2
-rw-r--r--lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp6
-rw-r--r--lldb/test/Shell/SymbolFile/PDB/function-nested-block.test6
-rw-r--r--lldb/test/Shell/SymbolFile/PDB/native-setting.cpp8
12 files changed, 113 insertions, 86 deletions
diff --git a/lldb/test/API/driver/stdio_closed/TestDriverWithClosedSTDIO.py b/lldb/test/API/driver/stdio_closed/TestDriverWithClosedSTDIO.py
index 751926b..a73322c 100644
--- a/lldb/test/API/driver/stdio_closed/TestDriverWithClosedSTDIO.py
+++ b/lldb/test/API/driver/stdio_closed/TestDriverWithClosedSTDIO.py
@@ -8,7 +8,9 @@ import lldb
import os
import sys
import socket
-import fcntl
+
+if os.name != "nt":
+ import fcntl
import lldbsuite.test.lldbutil as lldbutil
from lldbsuite.test.lldbtest import *
@@ -22,7 +24,7 @@ class TestDriverWithClosedSTDIO(TestBase):
# Windows doesn't have the fcntl module, so we can't run this
# test there.
- @skipIf(oslist=["windows"])
+ @skipIf(hostoslist=["windows"])
def test_run_lldb_and_wait(self):
"""This test forks, closes the stdio channels and exec's lldb.
Then it waits for it to exit and asserts it did that successfully"""
diff --git a/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py b/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
index 3d6b27f..7fd2ff4 100644
--- a/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
+++ b/lldb/test/API/functionalities/multiple-slides/TestMultipleSlides.py
@@ -12,6 +12,10 @@ 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()
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 beab4d6..7b78541 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,24 +81,20 @@ 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_breakpoints(dap_breakpoint_ids)
+ 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()
- 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)
+ bp_events = [e for e in self.dap_server.events if e["event"] == "breakpoint"]
- self.assertIn(main_bp_id, unverified_breakpoint_ids)
- self.assertIn(foo_bp_id, unverified_breakpoint_ids)
+ 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, verified_breakpoint_ids)
- self.assertIn(foo_bp_id, verified_breakpoint_ids)
+ self.assertTrue(main_bp_events)
+ self.assertTrue(foo_bp_events)
diff --git a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
index 1143cd9..d56a8a4 100644
--- a/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
+++ b/lldb/test/API/tools/lldb-dap/coreFile/TestDAP_coreFile.py
@@ -61,6 +61,21 @@ class TestDAP_coreFile(lldbdap_testcase.DAPTestCaseBase):
self.dap_server.request_next(threadId=32259)
self.assertEqual(self.get_stackFrames(), expected_frames)
+ def test_wrong_core_file(self):
+ exe_file = self.getSourcePath("linux-x86_64.out")
+ wrong_core_file = self.getSourcePath("main.c")
+
+ self.create_debug_adapter()
+ resp = self.attach(
+ program=exe_file, coreFile=wrong_core_file, expectFailure=True
+ )
+ self.assertIsNotNone(resp)
+ self.assertFalse(resp["success"], "Expected failure in response {resp!r}")
+ error_msg = resp["body"]["error"]["format"]
+
+ # attach may fail for mutilple reasons.
+ self.assertEqual(error_msg, "Failed to create the process")
+
@skipIfLLVMTargetMissing("X86")
def test_core_file_source_mapping_array(self):
"""Test that sourceMap property is correctly applied when loading a core"""
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 8db2316..dc6bf38 100644
--- a/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
+++ b/lldb/test/API/tools/lldb-dap/launch/TestDAP_launch.py
@@ -156,6 +156,7 @@ 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()
@@ -171,7 +172,6 @@ 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 1f4afab..9d1d17b 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 @@
-import dap_server
+"""
+Test 'module' events for dynamically loaded libraries.
+"""
+
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()
- source = "main.cpp"
- breakpoint1_line = line_number(source, "// breakpoint 1")
- breakpoint2_line = line_number(source, "// breakpoint 2")
- breakpoint3_line = line_number(source, "// breakpoint 3")
+ a_out_id = self.lookup_module_id("a.out")
+ a_out_events = self.module_events(id=a_out_id)
- breakpoint_ids = self.set_source_breakpoints(
- source, [breakpoint1_line, breakpoint2_line, breakpoint3_line]
+ self.assertIn(
+ "new",
+ self.module_reasons(a_out_events),
+ "Expected a.out to load during the debug session.",
)
- 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.")
- self.continue_to_exit()
+ 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.",
+ )
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 0ed53da..2d00c51 100644
--- a/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
+++ b/lldb/test/API/tools/lldb-dap/module/TestDAP_module.py
@@ -64,19 +64,18 @@ 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 = []
- module_event = self.dap_server.wait_for_event(["module"])
- while module_event is not None:
+ for module_event in self.dap_server.module_events:
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:
@@ -86,7 +85,6 @@ 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_console.py b/lldb/test/API/tools/lldb-dap/restart/TestDAP_restart_console.py
index e1ad142..fa62ec2 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
@@ -30,7 +30,11 @@ class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):
if reason == "entry":
seen_stopped_event += 1
- self.assertEqual(seen_stopped_event, 1, "expect only one stopped entry event.")
+ self.assertEqual(
+ seen_stopped_event,
+ 1,
+ f"expect only one stopped entry event in {stopped_events}",
+ )
@skipIfAsan
@skipIfWindows
@@ -92,11 +96,13 @@ class TestDAP_restart_console(lldbdap_testcase.DAPTestCaseBase):
self.build_and_launch(program, console="integratedTerminal", stopOnEntry=True)
[bp_main] = self.set_function_breakpoints(["main"])
- self.dap_server.request_continue() # sends configuration done
- stopped_events = self.dap_server.wait_for_stopped()
+ self.dap_server.request_configurationDone()
+ stopped_threads = list(self.dap_server.thread_stop_reasons.values())
# We should be stopped at the entry point.
- self.assertGreaterEqual(len(stopped_events), 0, "expect stopped events")
- self.verify_stopped_on_entry(stopped_events)
+ self.assertEqual(
+ len(stopped_threads), 1, "Expected the main thread to be stopped on entry."
+ )
+ self.assertEqual(stopped_threads[0]["reason"], "entry")
# Then, if we continue, we should hit the breakpoint at main.
self.dap_server.request_continue()
@@ -105,8 +111,12 @@ 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_events = self.dap_server.wait_for_stopped()
- self.verify_stopped_on_entry(stopped_events)
+ 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")
# 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 a018456..0184020 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.continue_to_next_stop()
+ self.do_continue()
custom_event = self.dap_server.wait_for_event(
filter=["my-custom-event-no-body"]
diff --git a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
index dc26ec8..91f451f 100644
--- a/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
+++ b/lldb/test/Shell/SymbolFile/NativePDB/native-setting.cpp
@@ -8,9 +8,9 @@
// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=-1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=-1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
diff --git a/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test b/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test
index 4a2355b..a18955b 100644
--- a/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test
+++ b/lldb/test/Shell/SymbolFile/PDB/function-nested-block.test
@@ -1,7 +1,9 @@
REQUIRES: system-windows, lld
RUN: %build --compiler=clang-cl --nodefaultlib --output=%t.exe %S/Inputs/FunctionNestedBlockTest.cpp
-RUN: lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s
-RUN: lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=0 lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -find=function -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-FUNCTION %s
+RUN: env LLDB_USE_NATIVE_PDB_READER=1 lldb-test symbols -find=block -file FunctionNestedBlockTest.cpp -line 4 %t.exe | FileCheck --check-prefix=CHECK-BLOCK %s
CHECK-FUNCTION: Found 1 functions:
CHECK-FUNCTION: name = "main"
diff --git a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
index f5e5459..54b7f28 100644
--- a/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
+++ b/lldb/test/Shell/SymbolFile/PDB/native-setting.cpp
@@ -8,9 +8,9 @@
// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
-// RUN: env LLDB_USE_NATIVE_PDB_READER=-1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV0 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=foo %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=42 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
+// RUN: env LLDB_USE_NATIVE_PDB_READER=-1 %lldb %t.exe -o 'target modules dump symfile' 2>&1 | FileCheck --check-prefix=ENV1 %s
// RUN: env LLDB_USE_NATIVE_PDB_READER=0 %lldb \
// RUN: -o 'settings set plugin.symbol-file.pdb.reader dia' \
@@ -36,7 +36,7 @@
// NO-ENV-NOT: warning:
// NO-ENV: (lldb) target modules dump symfile
// NO-ENV: Dumping debug symbols for 1 modules.
-// NO-ENV: SymbolFile pdb
+// NO-ENV: SymbolFile native-pdb
// ENV0-NOT: warning:
// ENV0: (lldb) target modules dump symfile