def _load_analysis(self, analysis, processor):
        """
        @brief  Function to import and instantiate one analysis.
        @param[in] self Pointer to the current object
        @param[in] analysis Analysis name
        @param[in] processor processor number.

        Raises:
            ImportError: When the given analysis name is invalid.
        """
        class_name = ANALYSES.get(analysis)
        if class_name is None:
            raise ImportError('Invalid {} analysis'.format(analysis))

        current_proc = self.processors[processor]
        kwargs = {
            "chipdata": current_proc.chipdata,
            "debuginfo": current_proc.debuginfo,
            "formatter": current_proc.formatter,
            "interpreter": self
        }
        # All analyses depend on module Analysis.
        # Python 3 demands that it is imported first.
        importlib.import_module("ACAT.Analysis")
        extensions = ["", "Old1", "Old2", "Old3"]
        for ext in extensions:
            try:
                # Import the analyses.
                imported_analysis = importlib.import_module(
                    '.' + class_name + ext, "ACAT.Analysis")
                # Get the analysis class from the module.
                class_obj = getattr(imported_analysis, class_name)
                # create the analyses object
                analysis_obj = class_obj(**kwargs)
                current_proc.available_analyses[analysis] = analysis_obj
                setattr(current_proc, analysis, analysis_obj)

                if cu.global_options.dependency_check:
                    # check if the analyses loaded are compatible with the debug
                    # information.
                    check_dependencies(current_proc, class_name,
                                       imported_analysis)
                # exit from the loop
                return
            except ImportError:
                # If the standard (the one with no extension) analyses is not
                # available it means no other will so bail out.
                if ext == "":
                    raise ImportError()
                continue
            except OutdatedFwAnalysisError:
                # continue to look for compatible analyses
                continue

        # Couldn't find anything. If we are here it is because outdated Kymera.
        raise OutdatedFwAnalysisError()
    def _check_kymera_version(self):
        """Checks if the Kymera version is compatible with this analysis.

        For outdated Kymera OutdatedFwAnalysisError will be raised.
        """
        try:
            self.debuginfo.get_var_strict("$_processor_heap_info_list")
        except DebugInfoNoVariableError:
            # fallback to the old implementation
            raise OutdatedFwAnalysisError()
Esempio n. 3
0
    def _check_kymera_version(self):
        """Checks if the Kymera version is compatible with this analysis.

        Raises:
            OutdatedFwAnalysisError: When the kymera version is outdated.
        """
        try:
            self.debuginfo.get_var_strict("L_pool_block_counts")
        except DebugInfoNoVariableError:
            # fallback to the old implementation
            raise OutdatedFwAnalysisError()
Esempio n. 4
0
    def _check_kymera_version(self):
        """Checks if the Kymera version is compatible with this analysis.

        Raises:
            OutdatedFwAnalysisError: For an outdated Kymera.
        """
        try:
            self.debuginfo.get_var_strict("L_heap_single_mode")
        except DebugInfoNoVariableError:
            # fallback to the old implementation
            raise OutdatedFwAnalysisError()
Esempio n. 5
0
    def _check_kymera_version(self):
        """Checks if the Kymera version is compatible with this analysis.

        Raises:
            OutdatedFwAnalysisError: For outdated Kymera.
        """
        # There is an older version of PM heap that had fixed sizes for P0
        # and P1 heap. If newer variables are not present, raise the outdated
        #  firmware exception.
        try:
            self.debuginfo.get_var_strict("L_heap_pm_start")
        except DebugInfoNoVariableError:
            # fallback to the old implementation
            raise OutdatedFwAnalysisError()
Esempio n. 6
0
    def __init__(self, **kwarg):
        # Call the base class constructor.
        Analysis.Analysis.__init__(self, **kwarg)

        # set the values of type and incr depending on the current architecture
        if Arch.chip_arch == "Hydra":
            self.native_word_size = 4
            self.null = 0xFFFFFFFF
        elif Arch.chip_arch == "Bluecore":
            self.native_word_size = 1
            self.null = 0xFFFFFF

        try:
            self.buffer_types = dict_to_ordered_dict(
                self.debuginfo.get_enum("cbops_buffer_type", None)
            )

        except InvalidDebuginfoEnumError:
            # fallback to the old implementation
            raise OutdatedFwAnalysisError()

        self.buffers_indexes = []