Source code for microprobe.exceptions

# Copyright 2011-2021 IBM Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
""":mod:`microprobe.exceptions` module

This module define the excpeption hierarchy used in Microprobe framework.
"""


# Constants

# Functions


# Classes
[docs] class MicroprobeException(Exception): """Base class for all Microprobe-defined Exceptions""" pass
[docs] class MicroprobeWarning(MicroprobeException, Warning): """Base class for all Microprobe-defined Warning Exceptions""" pass
[docs] class MicroprobeError(MicroprobeException, Exception): """Base class for all Microprobe-defined Error Exceptions""" pass
[docs] class MicroprobeValueError(MicroprobeError, ValueError): """MicroproveValueError Exception""" pass
# pylint: disable=too-many-ancestors
[docs] class MicroprobeDuplicatedValueError(MicroprobeValueError): """MicroprobeDuplicatedValueError Exception""" pass
# pylint: enable=too-many-ancestors
[docs] class MicroprobeCalledProcessError(Exception): """MicroprobeCalledProcessError Exception"""
[docs] def __init__(self, returncode, cmd, output): super(MicroprobeCalledProcessError, self).__init__() self.returncode = returncode self.cmd = cmd self.output = output
[docs] def __str__(self): return "Command '%s' returned non-zero exit status %d.\nOutput:%s" % ( self.cmd, self.returncode, self.output )
[docs] class MicroprobeAsmError(MicroprobeError): """MicroprobeAsmError Exception""" pass
[docs] class MicroprobeObjdumpError(MicroprobeError): """MicroprobeObjdumpError Exception""" pass
[docs] class MicroprobeRunCmdError(MicroprobeError): """MicroprobeRunCmdError Exception""" pass
[docs] class MicroprobeAddressTranslationError(MicroprobeError): """MicroprobeAddressTranslationError Exception""" pass
[docs] class MicroprobeBinaryError(MicroprobeError): """MicroprobeBinaryError Exception""" pass
[docs] class MicroprobePolicyError(MicroprobeError): """MicroprobePolicyError Exception""" pass
[docs] class MicroprobeUncheckableEnvironmentWarning(MicroprobeWarning): """MicroprobeUncheckableEnvironmentWarning Warning""" pass
[docs] class MicroprobeTypeError(MicroprobeError, TypeError): """MicroprobeTypeError Exception""" pass
[docs] class MicroprobeLookupError(MicroprobeError, LookupError): """MicroprobeLookupError Exception""" pass
[docs] class MicroprobeArchitectureDefinitionError(MicroprobeError): """MicroprobeArchitectureDefinitionError Exception""" pass
[docs] class MicroprobeArchitectureFormatError(MicroprobeArchitectureDefinitionError): """MicroprobeArchitectureFormatError Exception""" pass
[docs] class MicroprobeYamlFormatError(MicroprobeError): """MicroprobeYamlFormatError Exception""" pass
[docs] class MicroprobeCacheError(MicroprobeError): """MicroprobeCacheError Exception""" pass
[docs] class MicroprobeDMAFormatError(MicroprobeError): """MicroprobeDMAFormatError Exception""" pass
[docs] class MicroprobeMPTFormatError(MicroprobeError): """MicroprobeMPTFormatError Exception""" pass
[docs] class MicroprobeCodeGenerationError(MicroprobeError): """MicroprobeCodeGenerationError Exception""" pass
[docs] class MicroprobeTargetDefinitionError(MicroprobeError): """MicroprobeTargetDefinitionError Exception""" pass
[docs] class MicroprobeModelError(MicroprobeError): """MicroprobeModelError Exception""" pass
[docs] class MicroprobeImportDefinitionError(MicroprobeError): """MicroprobeImportDefinitionError Exception""" pass
[docs] class MicroprobeImportError(MicroprobeError): """MicroprobeImportError Exception""" pass
[docs] class MicroprobeNoComparatorError(MicroprobeCodeGenerationError): """Exception raised when there is no comparator suitable to perform a given action. :param val1: First value to compare. :type val1: :class:`~.int` or :class:`~.Register` :param val2: Second value to compare. :type val2: :class:`~.int` or :class:`~.Register` """
[docs] def __init__(self, val1, val2): """ :param val1: :param val2: """ super(MicroprobeNoComparatorError, self).__init__() self._val1 = val1 self._val2 = val2
[docs] def __str__(self): """ """ return "No comparator found to compare: '%s' and '%s'." % ( self._val1, self._val2 )
[docs] class MicroprobeBranchConditionError(MicroprobeCodeGenerationError): """Exception raised when the branch condition is not supported. :param string: cond: Condition """
[docs] def __init__(self, cond): """ :param cond: """ super(MicroprobeBranchConditionError, self).__init__() self._cond = cond
[docs] def __str__(self): """ """ return "Condition '%s' not supported." % (self._cond)
[docs] class MicroprobeConstantRegisterError(MicroprobeCodeGenerationError): """MicroprobeConstantRegisterError Exception""" pass
[docs] class MicroprobeNoGenerationPathError(MicroprobeCodeGenerationError): """Exception raised when there is not a path suitable to generate a given value using the available :class:`~.Generator` instances. :param target: Value to generate. :type target: :class:`~.int` :param origin: Starting value. :type origin: :class:`~.int` :param address: If value to generate is an address. :type address: :class:`~.bool` """
[docs] def __init__(self, target, origin, address): """ :param target: :param origin: :param address: """ super(MicroprobeNoGenerationPathError, self).__init__() self._target = target self._origin = origin self._address = address
[docs] def __str__(self): """ """ if self._address: return "It was not possible to generate the address '%d' " \ "from '%d' with the available Generators." else: return "It was not possible to generate the value '%d' from " \ "'%d' with the available Generators."