use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLInstructionFunctions method createOperandExpression.
/**
* Creates an operand expression tree in the database.
*
* @param provider The connection to the database.
* @param rootNode The root node of the operand tree to crate.
* @param parent ID of the parent node of the root node.
* @param nodes Output operand for all created nodes.
*
* @throws SQLException Thrown if the creation of the operand expression tree
* failed.
*/
private static void createOperandExpression(final SQLProvider provider, final INaviOperandTreeNode rootNode, final int parent, final Set<INaviOperandTreeNode> nodes) throws SQLException {
createOperandExpression(provider, rootNode, parent);
nodes.add(rootNode);
for (final INaviOperandTreeNode child : rootNode.getChildren()) {
createOperandExpression(provider, child, rootNode.getId(), nodes);
}
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLInstructionFunctions method createOperandTree.
/**
* Creates an operand expression tree in the database.
*
* @param provider The provider used to access the database.
* @param operand The operand to create.
* @param position The position of the operand in the instruction.
*
* @throws SQLException Thrown if the creation of the operand failed.
*/
private static void createOperandTree(final SQLProvider provider, final COperandTree operand, final int position) throws SQLException {
final Set<INaviOperandTreeNode> nodes = new HashSet<INaviOperandTreeNode>();
createOperandExpression(provider, operand.getRootNode(), 0, nodes);
final int expressionTreeId = createExpressionTree(provider, nodes, operand.getInstruction().getModule());
final BigInteger address = operand.getInstruction().getAddress().toBigInteger();
final int moduleId = operand.getInstruction().getModule().getConfiguration().getId();
createOperand(provider, moduleId, address, position, expressionTreeId);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsAddReference1.
@Test
public void testInstructionFunctionsAddReference1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
final IAddress address = instruction.getAddress();
final ReferenceType type = ReferenceType.DATA;
final int references = node.getReferences().size();
PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
final INaviModule module2 = getProvider().loadModules().get(1);
module2.load();
final INaviFunction function2 = module2.getContent().getFunctionContainer().getFunctions().get(1800);
function2.load();
final IBlockNode basicBlock2 = function2.getBasicBlocks().get(0);
final INaviInstruction instruction2 = Iterables.get(basicBlock2.getInstructions(), 1);
final COperandTree tree2 = instruction2.getOperands().get(0);
final INaviOperandTreeNode node2 = tree2.getRootNode();
assertEquals(references + 1, node2.getReferences().size());
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class PostgreSQLProviderTest method testInstructionFunctionsAddReference6.
@Test(expected = CouldntSaveDataException.class)
public void testInstructionFunctionsAddReference6() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviModule module = getProvider().loadModules().get(1);
module.load();
final INaviFunction function = module.getContent().getFunctionContainer().getFunctions().get(1800);
function.load();
final IBlockNode basicBlock = function.getBasicBlocks().get(0);
final INaviInstruction instruction = Iterables.get(basicBlock.getInstructions(), 1);
final COperandTree tree = instruction.getOperands().get(0);
final INaviOperandTreeNode node = tree.getRootNode();
final IAddress address = instruction.getAddress();
final ReferenceType type = ReferenceType.DATA;
PostgreSQLInstructionFunctions.addReference(getProvider(), node, address, type);
}
use of com.google.security.zynamics.binnavi.disassembly.INaviOperandTreeNode in project binnavi by google.
the class TypeManagerTest method testNotifySubstitutionDeleted.
@Test
public void testNotifySubstitutionDeleted() throws CouldntDeleteException, CouldntSaveDataException {
final CAddress address = new CAddress(0x1000);
final INaviOperandTreeNode node = new MockOperandTreeNode();
final TypeSubstitution substitution = typeManager.createTypeSubstitution(node, typeSystem.intType, 0, 0, address);
final TypeSubstitutionChangedEventCollector events = new TypeSubstitutionChangedEventCollector();
typeManager.addListener(events);
typeManager.deleteTypeSubstitution(node);
final TypeSubstitutionChangedEventCollector expectedEvents = new TypeSubstitutionChangedEventCollector();
expectedEvents.substitutionsDeleted(Sets.newHashSet(substitution));
Assert.assertEquals(expectedEvents, events);
}
Aggregations