brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.8 KiB · 8356ed7 Raw
56 lines · python
1# DExTer : Debugging Experience Tester2# ~~~~~~   ~         ~~         ~   ~~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-exception7 8 9from dex.command.CommandBase import CommandBase10from dex.dextIR import ValueIR11 12 13class DexUnreachable(CommandBase):14    """Expect the source line this is found on will never be stepped on to.15 16    DexUnreachable()17 18    See Commands.md for more info.19    """20 21    def __init__(self, *args, **kwargs):22        if len(args) != 0:23            raise TypeError("DexUnreachable takes no positional arguments")24        if "on_line" in kwargs:25            on_line = kwargs.pop("on_line")26            self._from_line = on_line27            self._to_line = on_line28        elif "from_line" in kwargs and "to_line" in kwargs:29            self._from_line = kwargs.pop("from_line")30            self._to_line = kwargs.pop("to_line")31        elif "from_line" in kwargs or "to_line" in kwargs:32            raise TypeError("Must provide both from_line and to_line to DexUnreachable")33 34        if len(kwargs) > 0:35            raise TypeError("Unexpected kwargs {}".format(kwargs.keys()))36        super(DexUnreachable, self).__init__()37        pass38 39    @staticmethod40    def get_name():41        return __class__.__name__42 43    def eval(self, step_info):44        # If we're ever called, at all, then we're evaluating a line that has45        # been marked as unreachable. Which means a failure.46        vir = ValueIR(47            expression="Unreachable",48            value="True",49            type_name=None,50            error_string=None,51            could_evaluate=True,52            is_optimized_away=True,53            is_irretrievable=False,54        )55        return {"DexUnreachable": vir}56