Skip to content

Commit aa17add

Browse files
committed
[Dexter] Track DAP capabilities
1 parent 2d33b79 commit aa17add

File tree

1 file changed

+41
-0
lines changed
  • cross-project-tests/debuginfo-tests/dexter/dex/debugger

1 file changed

+41
-0
lines changed

cross-project-tests/debuginfo-tests/dexter/dex/debugger/DAP.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,35 @@ def write_message(self, message: dict, incoming: bool):
100100
)
101101

102102

103+
# Debuggers communicate optional feature support.
104+
class DAPDebuggerCapabilities:
105+
def __init__(self):
106+
self.supportsConfigurationDoneRequest: bool = False
107+
self.supportsFunctionBreakpoints: bool = False
108+
self.supportsConditionalBreakpoints: bool = False
109+
self.supportsHitConditionalBreakpoints: bool = False
110+
self.supportsEvaluateForHovers: bool = False
111+
self.supportsSetVariable: bool = False
112+
self.supportsStepInTargetsRequest: bool = False
113+
self.supportsModulesRequest: bool = False
114+
self.supportsValueFormattingOptions: bool = False
115+
self.supportsLogPoints: bool = False
116+
self.supportsSetExpression: bool = False
117+
self.supportsDataBreakpoints: bool = False
118+
self.supportsReadMemoryRequest: bool = False
119+
self.supportsWriteMemoryRequest: bool = False
120+
self.supportsDisassembleRequest: bool = False
121+
self.supportsCancelRequest: bool = False
122+
self.supportsSteppingGranularity: bool = False
123+
self.supportsInstructionBreakpoints: bool = False
124+
125+
def update(self, logger: Logger, feature_dict: dict):
126+
for k, v in feature_dict.items():
127+
if hasattr(self, k):
128+
setattr(self, k, v)
129+
else:
130+
logger.warning(f"DAP: Unknown support flag: {k}")
131+
103132
# As DAP does not give us a trivially query-able process, we are responsible for maintaining our own state information,
104133
# including what breakpoints are currently set, and whether the debugger is running or stopped.
105134
# This class holds all state that is set based on events sent by the debug adapter; most responses are forwarded through
@@ -142,6 +171,9 @@ def __init__(self):
142171
# Map of DAP breakpoint IDs to resolved instruction addresses.
143172
self.bp_addr_map = {}
144173

174+
# DAP features supported by the debugger.
175+
self.capabilities = DAPDebuggerCapabilities()
176+
145177
def set_response(self, req_id: int, response: dict):
146178
if len(self.responses) > req_id:
147179
self.responses[req_id] = response
@@ -315,6 +347,9 @@ def _handle_message(
315347
and debugger_state.thread is None
316348
):
317349
debugger_state.thread = event_details["threadId"]
350+
elif event_type == "capabilities":
351+
# Unchanged capabilites may not be included.
352+
debugger_state.capabilities.update(logger, event_details)
318353
# There are many events we do not care about, just skip processing them.
319354
else:
320355
pass
@@ -338,6 +373,12 @@ def _handle_message(
338373
debugger_state.frame_map = [
339374
stackframe["id"] for stackframe in message["body"]["stackFrames"]
340375
]
376+
# The debugger communicates which optional DAP features are
377+
# supported in its initalize response.
378+
if message["command"] == "initialize" and message["success"] == True:
379+
body = message.get("body")
380+
if body:
381+
debugger_state.capabilities.update(logger, body)
341382

342383
def _colorize_dap_message(message: dict) -> dict:
343384
colorized_message = copy.deepcopy(message)

0 commit comments

Comments
 (0)