use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGlobalCodeNodeCommentParsingDeleteComment.
@Test
public void testGlobalCodeNodeCommentParsingDeleteComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_node_comments DELETE 1 4608");
final Collection<CommentNotification> result = PostgreSQLCommentNotificationParser.processNodeGlobalCommentNotification(notification, provider);
assertEquals(1, result.size());
final CodeNodeCommentNotificationContainer container = (CodeNodeCommentNotificationContainer) Iterables.getFirst(result, null);
final INaviCodeNode node = container.getNode();
assertEquals(1111, node.getId());
assertEquals(new CAddress(4608), node.getAddress());
assertEquals(CommentOperation.DELETE, container.getOperation());
assertNull(container.getCommentId());
assertEquals(CommentScope.GLOBAL, container.getScope());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class PostgreSQLNotificationParserTest method testGlobalCodeNodeCommentParsingAppendNewComment.
@Test
public void testGlobalCodeNodeCommentParsingAppendNewComment() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_global_node_comments UPDATE 1 4608 3333");
final Collection<CommentNotification> result = PostgreSQLCommentNotificationParser.processNodeGlobalCommentNotification(notification, provider);
assertEquals(1, result.size());
final CodeNodeCommentNotificationContainer container = (CodeNodeCommentNotificationContainer) Iterables.getFirst(result, null);
final INaviCodeNode node = container.getNode();
assertEquals(1111, node.getId());
assertEquals(new CAddress(4608), node.getAddress());
assertEquals(CommentOperation.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
assertEquals(CommentScope.GLOBAL, container.getScope());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class PostgreSQLNotificationParserTest method testLocalCodeNodeCommentParsingAppend.
@Test
public void testLocalCodeNodeCommentParsingAppend() {
new MockModule(provider, Lists.newArrayList(mockView), Lists.newArrayList(mockFunction));
MockPGNotification notification = new MockPGNotification("comment_changes", "bn_code_nodes UPDATE 1 1111 4608 3333");
CommentNotification result = PostgreSQLCommentNotificationParser.processNodeLocalNodeCommentNotification(notification, provider);
assertNotNull(result);
final CodeNodeCommentNotificationContainer container = (CodeNodeCommentNotificationContainer) result;
final INaviCodeNode node = container.getNode();
assertEquals(1111, node.getId());
assertEquals(new CAddress(4608), node.getAddress());
assertEquals(CommentOperation.APPEND, container.getOperation());
assertEquals(new Integer(3333), container.getCommentId());
assertEquals(CommentScope.LOCAL, container.getScope());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class CGraphSynchronizer method updateInstructionMap.
/**
* Updates the cached Address => Instruction map.
*/
private void updateInstructionMap() {
m_instructionMap.clear();
for (final INaviViewNode node : m_graph.getRawView().getGraph()) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) node;
for (final INaviInstruction instruction : cnode.getInstructions()) {
final IAddress address = instruction.getAddress();
m_instructionMap.put(address, instruction);
}
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviCodeNode in project binnavi by google.
the class CViewPruner method convertNodes.
/**
* Converts the nodes from the original view to the pruned view.
*
* @param view The original view.
* @param prunedView The pruned view.
* @param keptInstructions Instructions to add to the new view.
*
* @return A mapping between nodes of the original view and nodes of the pruned view.
*/
private static Map<INaviViewNode, INaviViewNode> convertNodes(final INaviView view, final INaviView prunedView, final List<INaviInstruction> keptInstructions) {
final Map<INaviViewNode, INaviViewNode> nodeMap = new HashMap<INaviViewNode, INaviViewNode>();
for (final INaviViewNode node : view.getGraph().getNodes()) {
if (node instanceof INaviCodeNode) {
final INaviCodeNode cnode = (INaviCodeNode) node;
final ArrayList<INaviInstruction> newInstructions = Lists.newArrayList(cnode.getInstructions());
newInstructions.retainAll(keptInstructions);
if (!newInstructions.isEmpty()) {
CCodeNode newNode;
try {
newNode = prunedView.getContent().createCodeNode(cnode.getParentFunction(), newInstructions);
} catch (final MaybeNullException e) {
newNode = prunedView.getContent().createCodeNode(null, newInstructions);
}
newNode.setBorderColor(node.getBorderColor());
newNode.setColor(node.getColor());
nodeMap.put(node, newNode);
}
} else if (node instanceof INaviFunctionNode) {
final INaviFunction function = ((INaviFunctionNode) node).getFunction();
final CFunctionNode newNode = prunedView.getContent().createFunctionNode(function);
nodeMap.put(node, newNode);
}
}
return nodeMap;
}
Aggregations