CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
92 lines
2.9 KiB
Python
92 lines
2.9 KiB
Python
# DExTer : Debugging Experience Tester
|
|
# ~~~~~~ ~ ~~ ~ ~~
|
|
#
|
|
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
# See https://llvm.org/LICENSE.txt for license information.
|
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
"""Command for specifying a partial or complete state for the program to enter
|
|
during execution.
|
|
"""
|
|
|
|
from itertools import chain
|
|
|
|
from dex.command.CommandBase import CommandBase, StepExpectInfo
|
|
from dex.dextIR import ProgramState, SourceLocation, StackFrame, DextIR
|
|
|
|
|
|
def frame_from_dict(source: dict) -> StackFrame:
|
|
if "location" in source:
|
|
assert isinstance(source["location"], dict)
|
|
source["location"] = SourceLocation(**source["location"])
|
|
return StackFrame(**source)
|
|
|
|
|
|
def state_from_dict(source: dict) -> ProgramState:
|
|
if "frames" in source:
|
|
assert isinstance(source["frames"], list)
|
|
source["frames"] = list(map(frame_from_dict, source["frames"]))
|
|
return ProgramState(**source)
|
|
|
|
|
|
class DexExpectProgramState(CommandBase):
|
|
"""Expect to see a given program `state` a certain numer of `times`.
|
|
|
|
DexExpectProgramState(state [,**times])
|
|
|
|
See Commands.md for more info.
|
|
"""
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
if len(args) != 1:
|
|
raise TypeError("expected exactly one unnamed arg")
|
|
|
|
self.program_state_text = str(args[0])
|
|
|
|
self.expected_program_state = state_from_dict(args[0])
|
|
|
|
self.times = kwargs.pop("times", -1)
|
|
if kwargs:
|
|
raise TypeError("unexpected named args: {}".format(", ".join(kwargs)))
|
|
|
|
# Step indices at which the expected program state was encountered.
|
|
self.encounters = []
|
|
|
|
super(DexExpectProgramState, self).__init__()
|
|
|
|
@staticmethod
|
|
def get_name():
|
|
return __class__.__name__
|
|
|
|
def get_watches(self):
|
|
frame_expects = set()
|
|
for idx, frame in enumerate(self.expected_program_state.frames):
|
|
path = (
|
|
frame.location.path
|
|
if frame.location and frame.location.path
|
|
else self.path
|
|
)
|
|
line_range = (
|
|
range(frame.location.lineno, frame.location.lineno + 1)
|
|
if frame.location and frame.location.lineno
|
|
else None
|
|
)
|
|
for watch in frame.watches:
|
|
frame_expects.add(
|
|
StepExpectInfo(
|
|
expression=watch,
|
|
path=path,
|
|
frame_idx=idx,
|
|
line_range=line_range,
|
|
)
|
|
)
|
|
return frame_expects
|
|
|
|
def eval(self, step_collection: DextIR) -> bool:
|
|
for step in step_collection.steps:
|
|
if self.expected_program_state.match(step.program_state):
|
|
self.encounters.append(step.step_index)
|
|
|
|
return (
|
|
self.times < 0 < len(self.encounters) or len(self.encounters) == self.times
|
|
)
|