| 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 |
|
| 8 |
|
| 9 |
from dex.command.CommandBase import CommandBase |
| 10 |
from dex.dextIR import ValueIR |
| 11 |
|
| 12 |
|
| 13 |
class 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_line |
| 27 |
self._to_line = on_line |
| 28 |
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 |
pass |
| 38 |
|
| 39 |
@staticmethod |
| 40 |
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 has |
| 45 |
# 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} |