def get_variables(self, *varnames, **kwargs): """Fetches the specified variables from the frame specified by frame_id, or from the topmost frame in the last "stackTrace" response if frame_id is not specified. If varnames is empty, then all variables in the frame are returned. The result is an OrderedDict, in which every entry has variable name as the key, and a DAP Variable object as the value. The original order of variables as reported by the debugger is preserved. If varnames is not empty, then only the specified variables are returned. The result is a tuple, in which every entry is a DAP Variable object; those entries are in the same order as varnames. """ assert self.timeline.is_frozen frame_id = kwargs.pop("frame_id", None) if frame_id is None: stackTrace_responses = self.all_occurrences_of( timeline.Response(timeline.Request("stackTrace"))) assert stackTrace_responses, ( "get_variables() without frame_id requires at least one response " 'to a "stackTrace" request in the timeline.') stack_trace = stackTrace_responses[-1] frame_id = stack_trace.body.get("stackFrames", json.array())[0]("id", int) scopes = self.request("scopes", {"frameId": frame_id})("scopes", json.array()) assert len(scopes) > 0 variables = self.request( "variables", {"variablesReference": scopes[0]("variablesReference", int)})( "variables", json.array()) variables = collections.OrderedDict( ((v("name", unicode), v) for v in variables)) if varnames: assert set(varnames) <= set(variables.keys()) return tuple((variables[name] for name in varnames)) else: return variables
def _request_start(self, method): self.config.normalize() start_request = self.send_request(method, self.config) # Depending on whether it's "noDebug" or not, we either get the "initialized" # event, or an immediate response to our request. self.timeline.wait_until_realized( timeline.Event("initialized") | timeline.Response(start_request), freeze=True, ) if start_request.response is not None: # It was an immediate response - configuration is not possible. Just get # the "process" event, and return to caller. return self.wait_for_process() # We got "initialized" - now we need to yield to the caller, so that it can # configure the session before it starts running. return self._ConfigurationContextManager(self)