Пример #1
0
    def generateNewSymbolsTableHTML(self):

        new_binary = self.binary_pair.new_binary

        table_html = ""
        overal_symbol_size = 0

        for symbol_name in sorted(self.binary_pair.new_symbol_names, \
                                  key=lambda symbol_name: new_binary.symbols[symbol_name].size, \
                                  reverse = True):
            symbol_name_html = html.escapeString(symbol_name)
            symbol = new_binary.symbols[symbol_name]
            table_html += "<tr><td>%s</td><td>%s</td><td>%s</td></tr>\n" % ( \
                                 html.generateSymbolTableEntry(symbol_name_html), \
                                 symbol.type, \
                                 html.formatNumber(symbol.size))

            if symbol.livesInProgramMemory():
                overal_symbol_size += symbol.size

        if len(self.binary_pair.new_symbol_names) == 0:
            table_visible = "invisible"
        else:
            table_visible = True

        return [
            table_html, table_visible,
            html.highlightNumber(overal_symbol_size)
        ]
Пример #2
0
    def generatePersistingSymbolsTableHTML(self):

        old_binary = self.binary_pair.old_binary
        new_binary = self.binary_pair.new_binary

        table_html = ""

        import operator

        diff_by_symbol = {}
        for symbol_name in self.binary_pair.persisting_symbol_names:
            old_symbol = old_binary.symbols[symbol_name]
            new_symbol = new_binary.symbols[symbol_name]

            difference = new_symbol.size - old_symbol.size

            diff_by_symbol[symbol_name] = difference

        sorted_by_diff = sorted(diff_by_symbol.items(),
                                key=operator.itemgetter(1),
                                reverse=True)

        size_delta = 0

        changed_symbols = []

        for symbol_tuple in sorted_by_diff:

            symbol_name = symbol_tuple[0]

            old_symbol = old_binary.symbols[symbol_name]
            new_symbol = new_binary.symbols[symbol_name]

            if new_symbol.livesInProgramMemory():
                size_delta += new_symbol.size - old_symbol.size

            if old_symbol.size != new_symbol.size:
                symbol_name_html = html.escapeString(symbol_name)
                changed_symbols.append(symbol_name)
                table_html += "<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n" % ( \
                                  html.generateSymbolTableEntry(symbol_name_html), \
                                  new_symbol.type, \
                                  html.formatNumber(old_symbol.size), \
                                  html.formatNumber(new_symbol.size), \
                                  html.formatNumberDelta(old_symbol.size, new_symbol.size))

        if size_delta == 0:
            table_visible = False
        else:
            table_visible = True

        return [
            table_html, table_visible,
            html.highlightNumber(size_delta), changed_symbols
        ]