[Lldb-commits] [PATCH] D93895: Implement vAttachWait in lldb-server

Augusto Noronha via Phabricator via lldb-commits lldb-commits at lists.llvm.org
Fri Jan 1 13:26:22 PST 2021


augusto2112 updated this revision to Diff 314230.
augusto2112 added a comment.

Update test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93895/new/

https://reviews.llvm.org/D93895

Files:
  lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py


Index: lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py
===================================================================
--- lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py
+++ lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py
@@ -1,4 +1,6 @@
 
+import os
+from time import sleep
 
 import gdbremote_testcase
 import lldbgdbserverutils
@@ -11,30 +13,39 @@
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def attach_with_vAttachWait(self):
-        # Add attach packets.
+    def test_attach_with_vAttachWait(self):
+        exe = '%s_%d' % (self.testMethodName, os.getpid())
+        self.build(dictionary={'EXE': exe})
+        self.set_inferior_startup_attach_manually()
+
+        server = self.connect_to_debug_monitor()
+        self.assertIsNotNone(server)
+
+
+        self.add_no_ack_remote_stream()
         self.test_sequence.add_log_lines([
             # Do the attach.
-            "read packet: $vAttachWait;{}#00".format(''.join(str(ord(c)) for c in "a.out")),
+            "read packet: $vAttachWait;{}#00".format(lldbgdbserverutils.gdbremote_hex_encode_string(exe)),
         ], True)
+        # Run the stream until attachWait.
+        context = self.expect_gdbremote_sequence()
+        self.assertIsNotNone(context)
 
+        # Sleep so we're sure that the inferior is launched after we ask for the attach.
+        sleep(1)
 
-        # Start the inferior, start the debug monitor, nothing is attached yet.
-        procs = self.prep_debug_monitor_and_inferior(
-            inferior_args=["sleep:60"])
-        self.assertIsNotNone(procs)
-
-        # Make sure the target process has been launched.
-        inferior = procs.get("inferior")
+        # Launch the inferior.
+        inferior = self.launch_process_for_attach(
+            inferior_args=["sleep:60"],
+            exe_path=self.getBuildArtifact(exe))
         self.assertIsNotNone(inferior)
         self.assertTrue(inferior.pid > 0)
         self.assertTrue(
             lldbgdbserverutils.process_is_running(
                 inferior.pid, True))
 
-
+        # Make sure the attach succeeded.
         self.test_sequence.add_log_lines([
-            # Expect a stop notification from the attach.
             {"direction": "send",
              "regex": r"^\$T([0-9a-fA-F]{2})[^#]*#[0-9a-fA-F]{2}$",
              "capture": {1: "stop_signal_hex"}},
@@ -42,11 +53,11 @@
         self.add_process_info_collection_packets()
 
 
-        # Run the stream
+        # Run the stream sending the response..
         context = self.expect_gdbremote_sequence()
         self.assertIsNotNone(context)
 
-        # Gather process info response
+        # Gather process info response.
         process_info = self.parse_process_info_response(context)
         self.assertIsNotNone(process_info)
 
@@ -56,14 +67,3 @@
         reported_pid = int(pid_text, base=16)
         self.assertEqual(reported_pid, inferior.pid)
 
-    @debugserver_test
-    def test_attach_with_vAttach_debugserver(self):
-        self.build()
-        self.set_inferior_startup_attach_manually()
-        self.attach_with_vAttachWait()
-
-    @llgs_test
-    def test_attach_with_vAttach_llgs(self):
-        self.build()
-        self.set_inferior_startup_attach_manually()
-        self.attach_with_vAttachWait()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93895.314230.patch
Type: text/x-patch
Size: 3313 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20210101/fb7a44df/attachment.bin>


More information about the lldb-commits mailing list