[Lldb-commits] [PATCH] D93895: Implement vAttachWait in lldb-server
labath added a comment. Thanks for picking this up. I'm not sure if this is the (only) reason for the failure, but I have a feeling you're encoding the packet incorrectly -- the application name should be hex-encoded. Try using `lldbgdbserverutils.gdbremote_hex_encode_string` instead. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93895/new/ https://reviews.llvm.org/D93895 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D93895: Implement vAttachWait in lldb-server
augusto2112 added a comment. Hi @labath. I see! I changed it to `lldbgdbserverutils.gdbremote_hex_encode_string`. Looking at the logs, I found that the checksum I inserted was wrong, so I've corrected that as well (is there a way I can calculate the checksum on the test, instead of hard-coding it in the string?). Despite these changes, I still get the same error (`ConnectionResetError: [Errno 104] Connection reset by peer` on line 46). I did test the `--waitfor` functionality on a program with an infinite loop, but could it be that the test executable is exiting too quickly? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93895/new/ https://reviews.llvm.org/D93895 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D93874: [process] fix exec support on Linux
labath added a comment. The new version seems ok-ish to me, but I'm leaving it open as I'd like Jim to weigh in here. The immediate cause of the crash is related to the (dangling?) m_thread pointer inside the completed "step instruction" plan. Normally, this pointer clears itself when the thread disappears but I guess this does not happen in the exec case. Jim should know what's the expected behavior here. Comment at: lldb/test/API/functionalities/exec/TestExec.py:91-93 +# Single step to create a thread plan. We have to make sure that after exec +# we clear all existing thread plans. +thread.StepInstruction(False) A separate test case would be better, as (even with the comment) a random future modification of the test could negate this. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93874/new/ https://reviews.llvm.org/D93874 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D93939: [elf-core] Improve reading memory from core file
labath added a comment. Have you by any chance learned why are we zero-filling this buffer in the first place? Seems like an odd thing to do... Maybe we should just stop zero-filling completely? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93939/new/ https://reviews.llvm.org/D93939 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
[Lldb-commits] [PATCH] D93895: Implement vAttachWait in lldb-server
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() 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. +
[Lldb-commits] [PATCH] D93895: Implement vAttachWait in lldb-server
augusto2112 updated this revision to Diff 314231. augusto2112 added a comment. Re-include deleted files. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93895/new/ https://reviews.llvm.org/D93895 Files: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py Index: lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py === --- /dev/null +++ lldb/test/API/tools/lldb-server/TestGdbRemoteAttachWait.py @@ -0,0 +1,69 @@ + +import os +from time import sleep + +import gdbremote_testcase +import lldbgdbserverutils +from lldbsuite.test.decorators import * +from lldbsuite.test.lldbtest import * +from lldbsuite.test import lldbutil + + +class TestGdbRemoteAttachWait(gdbremote_testcase.GdbRemoteTestCaseBase): + +mydir = TestBase.compute_mydir(__file__) + +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(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) + +# 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([ +{"direction": "send", + "regex": r"^\$T([0-9a-fA-F]{2})[^#]*#[0-9a-fA-F]{2}$", + "capture": {1: "stop_signal_hex"}}, +], True) +self.add_process_info_collection_packets() + + +# Run the stream sending the response.. +context = self.expect_gdbremote_sequence() +self.assertIsNotNone(context) + +# Gather process info response. +process_info = self.parse_process_info_response(context) +self.assertIsNotNone(process_info) + +# Ensure the process id matches what we expected. +pid_text = process_info.get('pid', None) +self.assertIsNotNone(pid_text) +reported_pid = int(pid_text, base=16) +self.assertEqual(reported_pid, inferior.pid) + Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.h @@ -59,6 +59,17 @@ /// attach operation. Status AttachToProcess(lldb::pid_t pid); + /// Wait to attach to a process with a given name. + /// + /// This method supports waiting for the next instance of a process + /// with a given name and attaching llgs to that via the configured + /// Platform. + /// + /// \return + /// An Status object indicating the success or failure of the + /// attach operation. + Status AttachWaitProcess(llvm::StringRef process_name); + // NativeProcessProtocol::NativeDelegate overrides void InitializeDelegate(NativeProcessProtocol *process) override; @@ -170,6 +181,8 @@ PacketResult Handle_vAttach(StringExtractorGDBRemote &packet); + PacketResult Handle_vAttachWait(StringExtractorGDBRemote &packet); + PacketResult Handle_D(StringExtractorGDBRemote &packet); PacketResult Handle_qThreadStopInfo(StringExtractorGDBRemote &packet); Index: lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp === --- lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -159,6 +159,9 @@ RegisterMemberFunctionHandler( StringExtractorGDBRemote::eServerPacketType_vAttach, &GDBRemoteCommunicationServerLLGS::Handle_vAttach); + RegisterMemberFunctionHandler( + StringExtractorGDBRemote::eServerPacketType_vAttachWait, + &GDBRemoteCommunicationServerLLGS::Handle_vAttachWait); RegisterMemberFunctionHandler( StringExtractorGDBRemote::eServe
[Lldb-commits] [PATCH] D93895: Implement vAttachWait in lldb-server
augusto2112 added a comment. Hi @labath. Ok, I believe the test is passing now. Thank you for all the help today! Question: the original author left a TODO: // TODO: Make the polling interval configurable std::chrono::milliseconds waitfor_interval = std::chrono::seconds(1); Is this a lot of work? Is it worth it to do this together in this patch? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D93895/new/ https://reviews.llvm.org/D93895 ___ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits