예제 #1
0
    def configureValueTree(self, value_tree_node: ValueTreeNode,
                           **kwargs: Any) -> None:
        """Configure the source file"""
        source_file: binary.SourceFile = kwargs["source_file"]

        value_tree_node.path = source_file.path
        value_tree_node.path_wo_prefix = source_file.path_wo_prefix
        value_tree_node.id = source_file.id_
예제 #2
0
def _generateValueTree(
        node: Node,
        parent_value_tree_node: Optional[ValueTreeNode] = None
) -> ValueTreeNode:
    """Recursively attach a value tree to the meta tree"""
    value_tree_node = ValueTreeNode()
    value_tree_node.attachMetaTreeNode(node)

    for value in node._values.values():
        setattr(value_tree_node, value._name, None)

    if parent_value_tree_node is not None:
        parent_value_tree_node.addChild(node._name, value_tree_node)

    node.forEachChild(lambda parent, child, value_tree_node=value_tree_node:
                      _generateValueTree(child, value_tree_node))

    return value_tree_node
예제 #3
0
    def configureValueTree(self, value_tree_node: ValueTreeNode,
                           **kwargs: Any) -> None:
        """Configure the display info object's associated value tree node from one or two symbols"""
        symbol_class: str = kwargs["symbol_class"]
        symbol1: ElfSymbol = kwargs["symbol1"]
        symbol2: ElfSymbol = kwargs.get("symbol2", symbol1)
        if symbol2 is None:
            symbol2 = symbol1

        if ((symbol1.type_ == ElfSymbol.TYPE_DATA)
                or (not symbol1.hasInstructions())
                or (not symbol2.hasInstructions())):
            display_symbol_details = False
        else:
            display_symbol_details = True

        value_tree_node.symbol_class = symbol_class
        value_tree_node.anchor_id = str(symbol1.id_)
        value_tree_node.display_symbol_details = display_symbol_details
예제 #4
0
 def configureValueTree(self, value_tree_node: ValueTreeNode,
                        **kwargs: Any) -> None:
     """Configure the symbol meta tree node's value tree representation from an ElfSymbol"""
     symbol: ElfSymbol = kwargs["symbol"]
     value_tree_node.name = symbol.name
     value_tree_node.name_mangled = symbol.name_mangled
     value_tree_node.is_demangled = symbol.is_demangled
     value_tree_node.type = symbol.type_
     value_tree_node.id = symbol.id_
     value_tree_node.size = symbol.size
     value_tree_node.instructions = symbol.instructions
     value_tree_node.is_stored_in_program_memory = symbol.livesInProgramMemory(
     )
     value_tree_node.source.file_id = symbol.source_id
     value_tree_node.source.line = symbol.source_line
예제 #5
0
    def configureValueTree(self, value_tree_node: ValueTreeNode,
                           **kwargs: Any) -> None:
        """Configure the meta tree node's value tree representation from a pair of similar symbols"""
        settings: Settings = kwargs["settings"]
        similarity_pair: SimilarityPair = kwargs["similarity_pair"]
        id_: int = kwargs["id_"]
        instruction_similarity = 1.0
        if similarity_pair.instruction_similarity is not None:
            instruction_similarity = similarity_pair.instruction_similarity * 100.0

        _configureChildValueTreeNode(
            "display_info",
            value_tree_node,
            settings=settings,
            symbol_class="similar",
            symbol1=similarity_pair.old_symbol,
            symbol2=similarity_pair.new_symbol,
        )
        _configureChildValueTreeNode(
            "related_symbols",
            value_tree_node,
            old_symbol=similarity_pair.old_symbol,
            new_symbol=similarity_pair.new_symbol,
        )

        value_tree_node.id = id_
        value_tree_node.old.signature_tagged = string_diff.tagStringDiffSource(
            similarity_pair.old_symbol.name,
            similarity_pair.new_symbol.name,
        )
        value_tree_node.new.signature_tagged = string_diff.tagStringDiffTarget(
            similarity_pair.old_symbol.name,
            similarity_pair.new_symbol.name,
        )
        value_tree_node.similarities.signature = (
            similarity_pair.signature_similarity * 100.0)
        value_tree_node.similarities.instruction = instruction_similarity
예제 #6
0
def _configureChildValueTreeNode(name: str, value_tree_node: ValueTreeNode,
                                 **kwargs) -> None:
    """Configure a given child value tree node"""
    child_value_tree_node: ValueTreeNode = value_tree_node.getChild(name)
    child_value_tree_node.getMetaTreeNode().configureValueTree(
        child_value_tree_node, **kwargs)
예제 #7
0
 def configureValueTree(self, value_tree_node: ValueTreeNode,
                        **kwargs: Any) -> None:
     """Configures the related symbol node's associated value tree node"""
     old_symbol: ElfSymbol = kwargs["old_symbol"]
     new_symbol: ElfSymbol = kwargs["new_symbol"]
     value_tree_node.size_delta = new_symbol.size - old_symbol.size