コード例 #1
0
    def __init__(self, director, parent=None):
        super(CoverageModel, self).__init__(parent)
        self._blank_coverage = FunctionCoverage(idaapi.BADADDR)

        # local reference to the director
        self._director = director

        # mapping to correlate a given row in the table to its function coverage
        self.row2func = {}
        self._row_count = 0

        # internal mappings of the explicit data / coverage we render
        self._no_coverage = []
        self._visible_metadata = {}
        self._visible_coverage = {}

        # column headers of the table
        self._column_headers = \
        {
            COV_PERCENT:  "Coverage %",
            FUNC_NAME:    "Function Name",
            FUNC_ADDR:    "Address",
            BLOCKS_HIT:   "Blocks Hit",
            INST_HIT:     "Instructions Hit",
            FUNC_SIZE:    "Function Size",
            COMPLEXITY:   "Complexity",
            FINAL_COLUMN: ""            # NOTE: stretch section, left blank for now
        }

        # initialize a monospace font to use with our widget(s)
        self._font = MonospaceFont()
        self._font_metrics = QtGui.QFontMetricsF(self._font)

        #----------------------------------------------------------------------
        # Sorting
        #----------------------------------------------------------------------

        # members to enlighten the model to its last known sort state
        self._last_sort = FUNC_ADDR
        self._last_sort_order = QtCore.Qt.AscendingOrder

        #----------------------------------------------------------------------
        # Filters
        #----------------------------------------------------------------------

        # OPTION: display 0% coverage entries
        self._hide_zero = False

        # OPTION: display functions matching search_string (substring)
        self._search_string = ""

        #----------------------------------------------------------------------
        # Signals
        #----------------------------------------------------------------------

        # register for cues from the director
        self._director.coverage_switched(self._internal_refresh)
        self._director.coverage_modified(self._internal_refresh)
        self._director.metadata_modified(self._data_changed)
コード例 #2
0
    def __init__(self, director, parent=None):
        super(CoverageTableModel, self).__init__(parent)
        self._director = director

        # convenience mapping from row_number --> function_address
        self.row2func = {}
        self._row_count = 0

        # an internal mapping of the data / coverage to make visible
        self._no_coverage = []
        self._visible_metadata = {}
        self._visible_coverage = {}

        # a fallback coverage object for functions with no coverage
        self._blank_coverage = FunctionCoverage(BADADDR)
        self._blank_coverage.coverage_color = director._palette.coverage_none

        # set the default column text alignment for each column (centered)
        self._default_alignment = QtCore.Qt.AlignCenter
        self._column_alignment = [
            self._default_alignment for x in self.COLUMN_HEADERS
        ]

        # initialize a monospace font to use for table row / cell text
        self._entry_font = MonospaceFont()
        self._entry_font.setStyleStrategy(QtGui.QFont.ForceIntegerMetrics)
        self._entry_font.setPointSizeF(normalize_to_dpi(9))

        # use the default / system font for the column titles
        self._title_font = QtGui.QFont()
        self._title_font.setPointSizeF(normalize_to_dpi(9))

        #----------------------------------------------------------------------
        # Sorting
        #----------------------------------------------------------------------

        # attributes to track the model's last known (column) sort state
        self._last_sort = self.FUNC_ADDR
        self._last_sort_order = QtCore.Qt.AscendingOrder

        #----------------------------------------------------------------------
        # Filters
        #----------------------------------------------------------------------

        # OPTION: display 0% coverage entries
        self._hide_zero = False

        # OPTION: display functions matching search_string (substring)
        self._search_string = ""

        #----------------------------------------------------------------------
        # Signals
        #----------------------------------------------------------------------

        # register for cues from the director
        self._director.coverage_switched(self._internal_refresh)
        self._director.coverage_modified(self._internal_refresh)
        self._director.metadata_modified(self._data_changed)
コード例 #3
0
    def __init__(self, director, parent=None):
        super(CoverageModel, self).__init__(parent)
        self._blank_coverage = FunctionCoverage(idaapi.BADADDR)

        # the data source
        self._director = director

        # mapping to correlate a given row in the table to its function coverage
        self._rows = 0
        self.row2func = {}

        # internal mappings of the explicit data / coverage we render
        self._no_coverage = []
        self._visible_metadata = {}
        self._visible_coverage = {}

        # column headers of the table
        self._column_headers = \
        {
            COV_PERCENT:  "Coverage %",
            FUNC_NAME:    "Function Name",
            FUNC_ADDR:    "Address",
            BLOCKS_HIT:   "Blocks Hit",
            INST_HIT:     "Instructions Hit",
            FUNC_SIZE:    "Function Size",
            FINAL_COLUMN: ""            # NOTE: stretch section, left blank for now
        }

        # initialize a monospace font to use with our widget(s)
        self._font = MonospaceFont()
        self._font_metrics = QtGui.QFontMetricsF(self._font)

        # members to enlighten the model to its last known sort state
        self._last_sort = FUNC_ADDR
        self._last_sort_order = QtCore.Qt.AscendingOrder

        # used by the model to determine whether it should display 0% coverage entries
        self._hide_zero = False
コード例 #4
0
    def _priority_paint_functions(self, target_address, neighbors=1):
        """
        Paint functions in the immediate vicinity of the given address.

        This will paint both the instructions & graph nodes of defined functions.
        """
        db_metadata = self.director.metadata
        db_coverage = self.director.coverage
        blank_coverage = FunctionCoverage(BADADDR)

        # get the function metadata for the function closest to our cursor
        function_metadata = db_metadata.get_closest_function(target_address)
        if not function_metadata:
            return False

        # select the range of functions around us that we would like to paint
        func_num = db_metadata.get_function_index(function_metadata.address)
        func_num_start = max(func_num - neighbors, 0)
        func_num_end = min(func_num + neighbors + 1,
                           len(db_metadata.functions) - 1)

        # repaint the specified range of functions
        for current_num in xrange(func_num_start, func_num_end):

            # get the next function to paint
            function_metadata = db_metadata.get_function_by_index(current_num)
            if not function_metadata:
                continue

            # get the function coverage data for the target address
            function_address = function_metadata.address
            function_coverage = db_coverage.functions.get(
                function_address, blank_coverage)

            if not self._streaming_nodes:

                # clear nodes
                must_clear = sorted(
                    set(function_metadata.nodes) -
                    set(function_coverage.nodes))
                self._action_complete.clear()
                self._clear_nodes(must_clear)
                self._action_complete.wait()

                # paint nodes
                must_paint = sorted(function_coverage.nodes)
                self._action_complete.clear()
                self._paint_nodes(must_paint)
                self._action_complete.wait()

            if not self._streaming_instructions:

                # clear instructions
                must_clear = sorted(function_metadata.instructions -
                                    function_coverage.instructions)
                self._action_complete.clear()
                self._clear_instructions(must_clear)
                self._action_complete.wait()

                # paint instructions
                must_paint = sorted(function_coverage.instructions)
                self._action_complete.clear()
                self._paint_instructions(must_paint)
                self._action_complete.wait()

        # paint finished successfully
        return True