Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / tools / lldb-server / TestGdbRemoteAttach.py
blob38900353290bb38f4d5eaa901e10e426079541e1
1 import gdbremote_testcase
2 import lldbgdbserverutils
3 from lldbsuite.test.decorators import *
4 from lldbsuite.test.lldbtest import *
5 from lldbsuite.test import lldbutil
8 class TestGdbRemoteAttach(gdbremote_testcase.GdbRemoteTestCaseBase):
9 def test_attach_with_vAttach(self):
10 self.build()
11 self.set_inferior_startup_attach_manually()
13 # Start the inferior, start the debug monitor, nothing is attached yet.
14 procs = self.prep_debug_monitor_and_inferior(inferior_args=["sleep:60"])
15 self.assertIsNotNone(procs)
17 # Make sure the target process has been launched.
18 inferior = procs.get("inferior")
19 self.assertIsNotNone(inferior)
20 self.assertTrue(inferior.pid > 0)
21 self.assertTrue(lldbgdbserverutils.process_is_running(inferior.pid, True))
23 # Add attach packets.
24 self.test_sequence.add_log_lines(
26 # Do the attach.
27 "read packet: $vAttach;{:x}#00".format(inferior.pid),
28 # Expect a stop notification from the attach.
30 "direction": "send",
31 "regex": r"^\$T([0-9a-fA-F]{2})[^#]*#[0-9a-fA-F]{2}$",
32 "capture": {1: "stop_signal_hex"},
35 True,
37 self.add_process_info_collection_packets()
39 # Run the stream
40 context = self.expect_gdbremote_sequence()
41 self.assertIsNotNone(context)
43 # Gather process info response
44 process_info = self.parse_process_info_response(context)
45 self.assertIsNotNone(process_info)
47 # Ensure the process id matches what we expected.
48 pid_text = process_info.get("pid", None)
49 self.assertIsNotNone(pid_text)
50 reported_pid = int(pid_text, base=16)
51 self.assertEqual(reported_pid, inferior.pid)