Skip to content

Commit 671b912

Browse files
committed
[lldb-dap] Refactoring IO handling for the SBDebugger.
This refactors the IO handling of lldb-dap and its SBDebugger. This adjusts the SBDebugger instance to have a pty associated with in/out/err. Using a pty allows us to handle commands with raw input modes, such as `script` or `breakpoint command add`. Additionally, to better handle output produced by the debugger and evaluate command I added a print helper. This new print helper will inspect the SBCommandReturnObject and store any associated variables in the variable store. This lets users more easily inspect variables directly in the Debug Console in VSCode.
1 parent 4aee501 commit 671b912

27 files changed

+716
-328
lines changed

lldb/packages/Python/lldbsuite/test/tools/lldb-dap/dap_server.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -987,17 +987,23 @@ def request_writeMemory(self, memoryReference, data, offset=0, allowPartial=Fals
987987
}
988988
return self._send_recv(command_dict)
989989

990-
def request_evaluate(self, expression, frameIndex=0, threadId=None, context=None):
990+
def request_evaluate(
991+
self,
992+
expression: str,
993+
frameIndex=0,
994+
threadId: Optional[int] = None,
995+
context: Optional[
996+
Literal["watch", "repl", "hover", "clipboard", "variables"]
997+
] = None,
998+
) -> Optional[Response]:
991999
stackFrame = self.get_stackFrame(frameIndex=frameIndex, threadId=threadId)
992-
if stackFrame is None:
993-
return []
9941000
args_dict = {
9951001
"expression": expression,
9961002
"frameId": stackFrame["id"],
9971003
}
9981004
if context:
9991005
args_dict["context"] = context
1000-
command_dict = {
1006+
command_dict: Request = {
10011007
"command": "evaluate",
10021008
"type": "request",
10031009
"arguments": args_dict,

lldb/test/API/tools/lldb-dap/cancel/TestDAP_cancel.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
Test lldb-dap cancel request
33
"""
44

5-
import time
6-
75
from lldbsuite.test.decorators import *
86
from lldbsuite.test.lldbtest import *
97
import lldbdap_testcase

lldb/test/API/tools/lldb-dap/evaluate/TestDAP_evaluate.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ def run_test_evaluate_expressions(
125125
self.assertEvaluate("var1", "20", want_type="int")
126126
# Empty expression should equate to the previous expression.
127127
if context == "repl":
128+
self.assertEvaluate("p var1", "20")
128129
self.assertEvaluate("", "20")
129130
else:
130131
self.assertEvaluateFailure("")

0 commit comments

Comments
 (0)