xref: /llvm-project/cross-project-tests/debuginfo-tests/dexter/dex/command/commands/DexWatch.py (revision f98ee40f4b5d7474fc67e82824bf6abbaedb7b1c)
1# DExTer : Debugging Experience Tester
2# ~~~~~~   ~         ~~         ~   ~~
3#
4# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5# See https://llvm.org/LICENSE.txt for license information.
6# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7"""Command to instruct the debugger to inspect the value of some set of
8expressions on the current source line.
9"""
10
11from dex.command.CommandBase import CommandBase
12
13
14class DexWatch(CommandBase):
15    """[Deprecated] Evaluate each given `expression` when the debugger steps onto the
16    line this command is found on
17
18    DexWatch(*expressions)
19
20    See Commands.md for more info.
21    """
22
23    def __init__(self, *args):
24        if not args:
25            raise TypeError("expected some arguments")
26
27        for arg in args:
28            if not isinstance(arg, str):
29                raise TypeError("invalid argument type")
30
31        self._args = args
32        super(DexWatch, self).__init__()
33
34    @staticmethod
35    def get_name():
36        return __class__.__name__
37
38    def eval(self, debugger):
39        return {arg: debugger.evaluate_expression(arg) for arg in self._args}
40