Esempio n. 1
0
    def compare(self, other, source=None):
        # Disassemble with line numbers, but if the command is excluded or
        # fails, fallback to disassembly. If that is also excluded or failing,
        # only then fallback to a hexdump.
        diff = None
        error = None
        try:
            diff, excluded = Difference.from_operation_exc(
                ObjdumpDisassembleSection,
                self.path,
                other.path,
                operation_args=[self._name],
            )
        except subprocess.CalledProcessError as e:
            # eg. When failing to disassemble a different architecture.
            error = e
            logger.error(e)

        if not error and not excluded:
            return diff

        try:
            diff, excluded = Difference.from_operation_exc(
                ObjdumpDisassembleSectionNoLineNumbers,
                self.path,
                other.path,
                operation_args=[self._name],
            )
        except subprocess.CalledProcessError as e:
            error = e
            logger.error(e)

        if not error and not excluded:
            return diff

        return super().compare(other, source)