use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class TraceLoggerTest method setUp.
@Before
public void setUp() throws CouldntLoadDataException, InvalidDatabaseVersionException {
final SQLProvider mockProvider = new MockSqlProvider();
// CDatabase("", "", "", "", "", false,
final IDatabase internalDatabase = new MockDatabase();
// false);
final Database database = new Database(internalDatabase);
database.load();
final MockProject mockProject = new MockProject();
final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
final Module module = new Module(database, mockModule, nodeTagManager, viewTagManager);
final Project project = new Project(database, mockProject, nodeTagManager, viewTagManager);
m_mockModule = new Module(database, mockModule, viewTagManager, nodeTagManager);
m_debugSettings = new ModuleTargetSettings(m_mockModule.getNative());
m_mockDebugger = new MockDebugger(m_debugSettings);
m_mockDebugger.setAddressTranslator(mockModule, new CAddress(0), new CAddress(0x1000));
final Debugger debugger = new Debugger(m_mockDebugger);
m_logger = new TraceLogger(debugger, module);
m_projectLogger = new TraceLogger(debugger, project);
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class BreakpointHelpersTest method setUp.
@Before
public void setUp() throws DebugExceptionWrapper, CouldntLoadDataException, LoadCancelledException, FileReadException {
ConfigManager.instance().read();
final CDatabase database = new CDatabase("", "", "", "", "", "", "", false, false);
final Database apiDatabase = new Database(database);
final SQLProvider mockProvider = new MockSqlProvider();
final ITreeNode<CTag> nodeRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.NODE_TAG, mockProvider));
final Tree<CTag> nodeTagTree = new Tree<CTag>(nodeRootNode);
final TagManager nodeTagManager = new TagManager(new CTagManager(nodeTagTree, TagType.NODE_TAG, mockProvider));
final ITreeNode<CTag> viewRootNode = new TreeNode<CTag>(new CTag(0, "", "", TagType.VIEW_TAG, mockProvider));
final Tree<CTag> viewTagTree = new Tree<CTag>(viewRootNode);
final TagManager viewTagManager = new TagManager(new CTagManager(viewTagTree, TagType.VIEW_TAG, mockProvider));
m_module = new CModule(1, "", "", new Date(), new Date(), "00000000000000000000000000000000", "0000000000000000000000000000000000000000", 0, 0, new CAddress(0), new CAddress(0), null, null, Integer.MAX_VALUE, false, mockProvider);
m_module.load();
m_mockDebugger = new MockDebugger(m_moduleDebugSettings);
m_mockDebugger.connect();
m_debugger = new Debugger(m_mockDebugger);
final INaviFunction parentFunction = m_module.getContent().getFunctionContainer().getFunctions().get(0);
m_mockDebugger.setAddressTranslator(m_module, new CAddress(0), new CAddress(0x1000));
final ViewContainer viewContainer = new Module(apiDatabase, m_module, nodeTagManager, viewTagManager);
final INaviView naviView = new MockView(mockProvider);
final Function apiFunction = new Function(ModuleFactory.get(), parentFunction);
final COperandTreeNode rootNode1 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "eax", null, new ArrayList<IReference>(), mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final COperandTreeNode rootNode2 = new COperandTreeNode(1, IOperandTree.NODE_TYPE_REGISTER_ID, "ebx", null, new ArrayList<IReference>(), mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final COperandTree operand1 = new COperandTree(rootNode1, mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final COperandTree operand2 = new COperandTree(rootNode2, mockProvider, m_module.getTypeManager(), m_module.getContent().getTypeInstanceContainer());
final List<COperandTree> operands = Lists.newArrayList(operand1, operand2);
final CInstruction internalInstruction = new CInstruction(true, m_module, new CAddress(0x1234), "mov", operands, new byte[] { 1, 2, 3 }, "x86-32", mockProvider);
m_view = new View(viewContainer, naviView, nodeTagManager, viewTagManager);
m_node = m_view.createCodeNode(apiFunction, Lists.newArrayList(new Instruction(internalInstruction)));
setM_functionNode(m_view.createFunctionNode(apiFunction));
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testChangingAddress.
@Test
public void testChangingAddress() throws DebugExceptionWrapper {
// Makes sure to update the combo box when the active address changes
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
m_model.setActiveDebugger(debugger);
final MemorySection section1 = new MemorySection(new CAddress(0x1000), new CAddress(0x1FF0));
final MemorySection section2 = new MemorySection(new CAddress(0x3000), new CAddress(0x3FF0));
final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
assertEquals(2, m_sectionBox.getItemCount());
assertEquals(section1, m_sectionBox.getItemAt(0).getObject());
assertEquals(section2, m_sectionBox.getItemAt(1).getObject());
assertEquals(section1, m_sectionBox.getSelectedItem().getObject());
m_model.setActiveMemoryAddress(new CAddress(0x3000), false);
assertEquals(section2, m_sectionBox.getSelectedItem().getObject());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testReceiveTargetInformation.
@Test
public void testReceiveTargetInformation() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.SUSPENDED);
debugger.getProcessManager().addThread(thread);
debugger.getProcessManager().setActiveThread(thread);
final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
debugger.connect();
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setTargetInformation(new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertTrue(m_sectionBox.isEnabled());
debugger.getProcessManager().setTargetInformation(new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false)));
assertFalse(m_sectionBox.isEnabled());
m_synchronizer.dispose();
debugger.close();
}
use of com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger in project binnavi by google.
the class CMemorySectionPanelSynchronizerTest method testThreads.
@Test
public void testThreads() throws DebugExceptionWrapper {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
debugger.connect();
debugger.getProcessManager().setAttached(true);
debugger.connection.m_synchronizer.receivedEvent(new TargetInformationReply(0, 0, new TargetInformation(32, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, true, false, false, false, false, false, false, 1, 0, new ArrayList<DebuggerException>(), false, false, false))));
final MemorySection section1 = new MemorySection(new CAddress(0x100), new CAddress(0x1FF));
final MemorySection section2 = new MemorySection(new CAddress(0x300), new CAddress(0x3FF));
final MemoryMap memoryMap = new MemoryMap(Lists.newArrayList(section1, section2));
debugger.connection.m_synchronizer.receivedEvent(new MemoryMapReply(0, 0, memoryMap));
final TargetProcessThread thread = new TargetProcessThread(1, ThreadState.RUNNING);
m_model.setActiveDebugger(debugger);
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().addThread(thread);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().setActiveThread(thread);
assertTrue(m_sectionBox.isEnabled());
debugger.getProcessManager().setActiveThread(null);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().removeThread(thread);
assertFalse(m_sectionBox.isEnabled());
debugger.getProcessManager().setAttached(false);
m_synchronizer.dispose();
debugger.close();
}
Aggregations