use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class FunctionBlockTest method testConstructor.
@Test
public void testConstructor() {
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final Function function = new Function(ModuleFactory.get(), parentFunction);
final FunctionBlock block = new FunctionBlock(function);
assertEquals(function, block.getFunction());
assertEquals("Function Block ['123 Mock Function']", block.toString());
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class FunctionEdgeTest method testConstructor.
@Test
public void testConstructor() {
final MockSqlProvider provider = new MockSqlProvider();
final CModule internalModule = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, provider);
final CFunction parentFunction = new CFunction(internalModule, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, provider);
final Function function = new Function(ModuleFactory.get(), parentFunction);
final FunctionBlock block = new FunctionBlock(function);
final FunctionBlock childBlock = new FunctionBlock(function);
final FunctionEdge edge = new FunctionEdge(block, childBlock);
assertEquals("Function Edge [Mock Function -> Mock Function]", edge.toString());
assertEquals(block, edge.getSource());
assertEquals(childBlock, edge.getTarget());
assertEquals(0, block.getParents().size());
assertEquals(1, block.getChildren().size());
assertEquals(childBlock, block.getChildren().get(0));
assertEquals(0, childBlock.getChildren().size());
assertEquals(1, childBlock.getParents().size());
assertEquals(block, childBlock.getParents().get(0));
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class PostgreSQLProviderTest method testSetDescription1.
@Test
public void testSetDescription1() throws CouldntSaveDataException, CouldntLoadDataException, LoadCancelledException {
final INaviProject project = getProvider().loadProjects().get(0);
final CAddressSpace addressSpace = getProvider().createAddressSpace(project, "SOME_OTHER_ADDRESS_SPACE");
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final CFunction function = (CFunction) module.getContent().getFunctionContainer().getFunctions().get(0);
final CView view = (CView) module.getContent().getViewContainer().getViews().get(0);
final CTagManager tagManager = getProvider().loadTagManager(TagType.VIEW_TAG);
final ITreeNode<CTag> tag = tagManager.getRootTag().getChildren().get(0);
getProvider().setDescription(addressSpace, "New Description");
getProvider().setDescription(function, "New Description");
getProvider().setDescription(module, "New Description");
getProvider().setDescription(project, "New Description");
getProvider().setDescription(tag.getObject(), "New Description");
getProvider().setDescription(module.getContent().getTraceContainer().getTraces().get(0), "New Description");
getProvider().setDescription(view, "New Description");
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class GraphSearcherTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, CPartialLoadException, LoadCancelledException {
final Graph2D g = new Graph2D();
m_ynode = g.createNode();
final MockSqlProvider sql = new MockSqlProvider();
final CModule module = MockCreator.createModule(sql);
module.load();
final CFunction function = MockCreator.createFunction(module, sql);
final CView m_view = MockCreator.createView(sql, module);
final CInstruction instruction1 = MockCreator.createInstruction(module, sql);
final CInstruction instruction2 = MockCreator.createInstruction(module, sql);
final CInstruction instruction3 = MockCreator.createInstruction(module, sql);
m_view.load();
m_codeNode1 = m_view.getContent().createCodeNode(function, Lists.newArrayList(instruction1, instruction2, instruction3));
m_content = new ZyLabelContent(null);
}
use of com.google.security.zynamics.binnavi.disassembly.CFunction in project binnavi by google.
the class CGraphDebuggerTest method testToggleBreakpoint3.
@Test
public void testToggleBreakpoint3() {
final MockModule module = new MockModule();
module.getConfiguration().setDebugger(m_debugger);
m_debugger.setAddressTranslator(module, m_fileBase, m_imageBase);
final DebugTargetSettings target = new ModuleTargetSettings(module);
final DebuggerProvider debuggerProvider = new DebuggerProvider(target);
debuggerProvider.addDebugger(m_debugger);
final CFunction function = new CFunction(module, new MockView(), new CAddress(0x123), "Mock Function", "Mock Function", "Mock Description", 0, 0, 0, 0, FunctionType.NORMAL, "", 0, null, null, null, m_provider);
final ArrayList<IComment> comments = Lists.<IComment>newArrayList(new CComment(null, CommonTestObjects.TEST_USER_1, null, "Mock Comment"));
final INaviCodeNode codeNode = new CCodeNode(0, 0, 0, 0, 0, Color.RED, Color.RED, false, false, comments, function, new HashSet<CTag>(), new MockSqlProvider());
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x123), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
codeNode.addInstruction(new CInstruction(true, module, new CAddress(0x124), "nop", new ArrayList<COperandTree>(), new byte[] { (byte) 0x90 }, "x86-32", m_provider), null);
CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
assertEquals(1, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
assertEquals(0x124, m_debugger.getBreakpointManager().getBreakpoint(BreakpointType.REGULAR, 0).getAddress().getAddress().getAddress().toLong());
assertEquals(BreakpointStatus.BREAKPOINT_INACTIVE, m_debugger.getBreakpointManager().getBreakpointStatus(BreakpointType.REGULAR, 0));
CGraphDebugger.toggleBreakpoint(debuggerProvider, codeNode, 2);
assertEquals(0, m_debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR));
}
Aggregations