Search in sources :

Example 1 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.

the class CModuleConfiguration method updateDebugger.

/**
   * Takes a debugger template and updates the debugger object of the module accordingly if
   * possible.
   * 
   * @param template The debugger template that provides the debugger information.
   */
private void updateDebugger(final DebuggerTemplate template) {
    if ((m_debugger == null) || !m_debugger.isConnected()) {
        if (template == null) {
            m_debugger = null;
        } else {
            m_debugger = new TcpDebugger(template, new ModuleTargetSettings(m_module));
            m_debugger.setAddressTranslator(m_module, m_fileBase, m_imageBase);
        }
        for (final IModuleListener listener : m_listeners) {
            try {
                listener.changedDebugger(m_module, m_debugger);
            } catch (final Exception exception) {
                CUtilityFunctions.logException(exception);
            }
        }
    }
}
Also used : TcpDebugger(com.google.security.zynamics.binnavi.debug.debugger.TcpDebugger) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException)

Example 2 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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);
}
Also used : MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) CTag(com.google.security.zynamics.binnavi.Tagging.CTag) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) SQLProvider(com.google.security.zynamics.binnavi.Database.Interfaces.SQLProvider) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) MockProject(com.google.security.zynamics.binnavi.disassembly.MockProject) Project(com.google.security.zynamics.binnavi.API.disassembly.Project) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) CTagManager(com.google.security.zynamics.binnavi.Tagging.CTagManager) TagManager(com.google.security.zynamics.binnavi.API.disassembly.TagManager) MockSqlProvider(com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider) TreeNode(com.google.security.zynamics.zylib.types.trees.TreeNode) ITreeNode(com.google.security.zynamics.zylib.types.trees.ITreeNode) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Database(com.google.security.zynamics.binnavi.API.disassembly.Database) IDatabase(com.google.security.zynamics.binnavi.Database.Interfaces.IDatabase) MockDatabase(com.google.security.zynamics.binnavi.Database.MockClasses.MockDatabase) Tree(com.google.security.zynamics.zylib.types.trees.Tree) MockModule(com.google.security.zynamics.binnavi.disassembly.Modules.MockModule) Module(com.google.security.zynamics.binnavi.API.disassembly.Module) Before(org.junit.Before)

Example 3 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings in project binnavi by google.

the class InstructionNode method toString.

@Override
public String toString() {
    final ZyGraphViewSettings settings = new ZyGraphViewSettings(new GraphSettingsConfigItem());
    final DebuggerProvider provider = new DebuggerProvider(new ModuleTargetSettings(instruction.getModule()));
    return ZyInstructionBuilder.buildInstructionLine(instruction, settings, new CDefaultModifier(settings, provider)).first();
}
Also used : GraphSettingsConfigItem(com.google.security.zynamics.binnavi.config.GraphSettingsConfigItem) ZyGraphViewSettings(com.google.security.zynamics.binnavi.ZyGraph.ZyGraphViewSettings) DebuggerProvider(com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CDefaultModifier(com.google.security.zynamics.binnavi.ZyGraph.Builders.Modifiers.CDefaultModifier)

Example 4 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 5 with ModuleTargetSettings

use of com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings 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();
}
Also used : MemoryMap(com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap) MockDebugger(com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger) TargetProcessThread(com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread) MemorySection(com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection) FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) MemoryMapReply(com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ModuleTargetSettings(com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)73 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)65 Test (org.junit.Test)63 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)51 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)21 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)20 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)20 ArrayList (java.util.ArrayList)19 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)18 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)18 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)17 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)17 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)17 TargetInformationReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.TargetInformationReply)16 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)15 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)15 UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)14 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)11 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)10