def generateSimilarSymbolsTableHTML(self): table_html = "" index = 0 for symbol_pair in self.binary_pair.similar_symbols: index = index + 1 old_symbol = symbol_pair[0] new_symbol = symbol_pair[1] old_symbol_name_html = html.escapeString(old_symbol.name) new_symbol_name_html = html.escapeString(new_symbol.name) table_html += "<tr><td>%s</td><td><p>%s</p><p>%s</p></td><td><p>%s</p><p>%s</p></td><td><p>%s</p><p>%s</p></td><td>%s</td></tr>\n" % ( \ html.generateSimilarSymbolTableEntry(str(index)), \ html.generateSymbolTableEntryLight(old_symbol_name_html), \ html.generateSymbolTableEntryLight(new_symbol_name_html), \ old_symbol.type, \ new_symbol.type, \ html.formatNumber(old_symbol.size), \ html.formatNumber(new_symbol.size), \ html.formatNumberDelta(old_symbol.size, new_symbol.size)) if len(self.binary_pair.similar_symbols) == 0: table_visible = "invisible" else: table_visible = True return [ table_html, table_visible, len(self.binary_pair.similar_symbols) ]
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 ]
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) ]