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
(self, *varnames, **kwargs)
| 852 | return breakpoints |
| 853 | |
| 854 | def get_variables(self, *varnames, **kwargs): |
| 855 | """Fetches the specified variables from the frame specified by frame_id, or |
| 856 | from the topmost frame in the last "stackTrace" response if frame_id is not |
| 857 | specified. |
| 858 | |
| 859 | If varnames is empty, then all variables in the frame are returned. The result |
| 860 | is an OrderedDict, in which every entry has variable name as the key, and a |
| 861 | DAP Variable object as the value. The original order of variables as reported |
| 862 | by the debugger is preserved. |
| 863 | |
| 864 | If varnames is not empty, then only the specified variables are returned. |
| 865 | The result is a tuple, in which every entry is a DAP Variable object; those |
| 866 | entries are in the same order as varnames. |
| 867 | """ |
| 868 | |
| 869 | assert self.timeline.is_frozen |
| 870 | |
| 871 | frame_id = kwargs.pop("frame_id", None) |
| 872 | if frame_id is None: |
| 873 | stackTrace_responses = self.all_occurrences_of( |
| 874 | timeline.Response(timeline.Request("stackTrace")) |
| 875 | ) |
| 876 | assert stackTrace_responses, ( |
| 877 | "get_variables() without frame_id requires at least one response " |
| 878 | 'to a "stackTrace" request in the timeline.' |
| 879 | ) |
| 880 | stack_trace = stackTrace_responses[-1] |
| 881 | frame_id = stack_trace.body.get("stackFrames", json.array())[0]("id", int) |
| 882 | |
| 883 | scopes = self.request("scopes", {"frameId": frame_id})("scopes", json.array()) |
| 884 | assert len(scopes) > 0 |
| 885 | |
| 886 | variables = self.request( |
| 887 | "variables", {"variablesReference": scopes[0]("variablesReference", int)} |
| 888 | )("variables", json.array()) |
| 889 | |
| 890 | variables = collections.OrderedDict(((v("name", str), v) for v in variables)) |
| 891 | if varnames: |
| 892 | assert set(varnames) <= set(variables.keys()) |
| 893 | return tuple((variables[name] for name in varnames)) |
| 894 | else: |
| 895 | return variables |
| 896 | |
| 897 | def get_variable(self, varname, frame_id=None): |
| 898 | """Same as get_variables(...)[0].""" |
no test coverage detected