Skip to content

[lldb-dap] Reimplement runInTerminal with signals #142374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import shutil
import json
from threading import Thread
import signal


class TestDAP_runInTerminal(lldbdap_testcase.DAPTestCaseBase):
Expand All @@ -30,6 +31,7 @@ def readErrorMessage(self, fifo_file):
return file.readline()

def isTestSupported(self):
return True
# For some strange reason, this test fails on python3.6
if not (sys.version_info.major == 3 and sys.version_info.minor >= 7):
return False
Expand Down Expand Up @@ -144,97 +146,21 @@ def test_missingArgInRunInTerminalLauncher(self):
)
self.assertNotEqual(proc.returncode, 0)
self.assertIn(
'"--launch-target" requires "--comm-file" to be specified', proc.stderr
'"--launch-target" requires "--debugger-pid" to be specified', proc.stderr
)

@skipIfWindows
@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
def test_FakeAttachedRunInTerminalLauncherWithInvalidProgram(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

proc = subprocess.Popen(
[
self.lldbDAPExec,
"--comm-file",
comm_file,
"--launch-target",
"INVALIDPROGRAM",
],
universal_newlines=True,
stderr=subprocess.PIPE,
)

self.readPidMessage(comm_file)
self.sendDidAttachMessage(comm_file)
self.assertIn("No such file or directory", self.readErrorMessage(comm_file))

_, stderr = proc.communicate()
self.assertIn("No such file or directory", stderr)

@skipIfWindows
@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
def test_FakeAttachedRunInTerminalLauncherWithValidProgram(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

proc = subprocess.Popen(
[
self.lldbDAPExec,
"--comm-file",
comm_file,
"--launch-target",
"echo",
"foo",
],
universal_newlines=True,
stdout=subprocess.PIPE,
)

self.readPidMessage(comm_file)
self.sendDidAttachMessage(comm_file)

stdout, _ = proc.communicate()
self.assertIn("foo", stdout)

@skipIfWindows
@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
def test_FakeAttachedRunInTerminalLauncherAndCheckEnvironment(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)

proc = subprocess.Popen(
[self.lldbDAPExec, "--comm-file", comm_file, "--launch-target", "env"],
universal_newlines=True,
stdout=subprocess.PIPE,
env={**os.environ, "FOO": "BAR"},
)

self.readPidMessage(comm_file)
self.sendDidAttachMessage(comm_file)

stdout, _ = proc.communicate()
self.assertIn("FOO=BAR", stdout)

@skipIfWindows
@skipIf(oslist=["linux"], archs=no_match(["x86_64"]))
def test_NonAttachedRunInTerminalLauncher(self):
if not self.isTestSupported():
return
comm_file = os.path.join(self.getBuildDir(), "comm-file")
os.mkfifo(comm_file)
signal.signal(signal.SIGUSR1, signal.SIG_IGN)

proc = subprocess.Popen(
[
self.lldbDAPExec,
"--comm-file",
comm_file,
"--debugger-pid",
str(os.getpid()),
"--launch-target",
"echo",
"foo",
Expand All @@ -244,7 +170,5 @@ def test_NonAttachedRunInTerminalLauncher(self):
env={**os.environ, "LLDB_DAP_RIT_TIMEOUT_IN_MS": "1000"},
)

self.readPidMessage(comm_file)

_, stderr = proc.communicate()
self.assertIn("Timed out trying to get messages from the debug adapter", stderr)
self.assertIn("runInTerminal target did not resume in time", stderr)
2 changes: 0 additions & 2 deletions lldb/tools/lldb-dap/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,13 @@ add_lldb_library(lldbDAP
DAPLog.cpp
EventHelper.cpp
ExceptionBreakpoint.cpp
FifoFiles.cpp
FunctionBreakpoint.cpp
InstructionBreakpoint.cpp
JSONUtils.cpp
LLDBUtils.cpp
OutputRedirector.cpp
ProgressEvent.cpp
ProtocolUtils.cpp
RunInTerminal.cpp
SourceBreakpoint.cpp
Transport.cpp
Variables.cpp
Expand Down
101 changes: 0 additions & 101 deletions lldb/tools/lldb-dap/FifoFiles.cpp

This file was deleted.

85 changes: 0 additions & 85 deletions lldb/tools/lldb-dap/FifoFiles.h

This file was deleted.

Loading
Loading