Search in sources :

Example 1 with DebuggerException

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException in project binnavi by google.

the class DebuggerTest method writeRegister3.

@Test
public void writeRegister3() throws DebugException {
    debugger.connect();
    debugger.getNative().getProcessManager().setTargetInformation(new TargetInformation(5, Lists.newArrayList(new RegisterDescription("eax", 4, true), new RegisterDescription("ebx", 4, false)), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
    debugger.writeRegister(0, "eax", 0);
}
Also used : RegisterDescription(com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription) 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) Test(org.junit.Test)

Example 2 with DebuggerException

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException in project binnavi by google.

the class ProcessTest method testGetTargetInformation.

@Test
public void testGetTargetInformation() {
    final MockProcessListener listener = new MockProcessListener();
    final ProcessManager manager = new ProcessManager();
    final Process process = new Process(manager);
    process.addListener(listener);
    assertNull(process.getTargetInformation());
    manager.setTargetInformation(new com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation(5, new FilledList<RegisterDescription>(), new DebuggerOptions(false, false, false, false, false, false, false, false, false, false, 12, 0, new ArrayList<DebuggerException>(), false, false, false)));
    final TargetInformation t1 = process.getTargetInformation();
    final TargetInformation t2 = process.getTargetInformation();
    assertNotNull(t1);
    assertEquals(t1, t2);
    assertEquals("changedTargetInformation;", listener.events);
    assertEquals(5, process.getTargetInformation().getAddressSize());
    assertEquals(false, process.getTargetInformation().canTerminate());
    process.removeListener(listener);
}
Also used : FilledList(com.google.security.zynamics.zylib.types.lists.FilledList) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) ProcessManager(com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager) Test(org.junit.Test)

Example 3 with DebuggerException

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException 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)

Example 4 with DebuggerException

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException in project binnavi by google.

the class CDebuggerFunctions method showDebuggerOptionsDialogAlways.

/**
   * Shows the debugger options dialog.
   *
   * @param parent Parent window of the dialog.
   * @param target Provides the debugger target.
   * @param debugger The debugger whose options are shown in the dialog.
   */
public static void showDebuggerOptionsDialogAlways(final JFrame parent, final DebugTargetSettings target, final IDebugger debugger) {
    Preconditions.checkNotNull(parent, "IE01559: Parent argument can not be null");
    Preconditions.checkNotNull(target, "IE01560: Target argument can not be null");
    Preconditions.checkNotNull(debugger, "IE01561: Debugger argument can not be null");
    final TargetInformation targetInformation = debugger.getProcessManager().getTargetInformation();
    if (targetInformation == null) {
        CMessageBox.showInformation(parent, "Debugger information can not be shown before the debugger is active.");
        return;
    }
    DebuggerOptions options = targetInformation.getDebuggerOptions();
    if (options == null) {
        CMessageBox.showInformation(parent, "Debugger information can not be shown before the debugger is active.");
        return;
    }
    if (!debugger.isConnected()) {
        CMessageBox.showInformation(parent, "Debugger information can not be shown since the debugger is not currently connected.");
        return;
    }
    try {
        options.setExceptions(new ArrayList<DebuggerException>(mergeExceptionsSettings(target, options.getExceptions(), debugger.getId())));
    } catch (final CouldntLoadDataException exception) {
        CUtilityFunctions.logException(exception);
        final String message = "Exception settings could not be loaded.";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not load the exception settings from the database."), new String[] { "Communication error while contacting the database" }, new String[] { "BinNavi is unable to show the debugger options dialog until the problem is resolved." + " The default debugger options will be used during this session." });
        NaviErrorDialog.show(parent, message, description, exception);
    }
    final DebuggerEventSettings eventSettings = readDebuggerEventSettings(parent, debugger, target);
    final COptionsDialog dlg = new COptionsDialog(parent, options, eventSettings);
    dlg.setVisible(true);
    options = dlg.getDebuggerOptions();
    try {
        writeDebuggerExceptionSettings(options, target, debugger.getId());
        writeDebuggerEventSettings(debugger, target, dlg.getDebuggerEventSettings());
    } catch (final CouldntSaveDataException exception) {
        CUtilityFunctions.logException(exception);
        CUtilityFunctions.logException(exception);
        final String message = "Exception settings could not be written.";
        final String description = CUtilityFunctions.createDescription(String.format("BinNavi could not write the debugger options to the database."), new String[] { "Communication error while contacting the database" }, new String[] { "BinNavi is unable to store the debugger options in the database.", "Nevertheless, the debugger options will be sent to the debugger." });
        NaviErrorDialog.show(parent, message, description, exception);
    }
    sendExceptionSettings(parent, debugger, options.getExceptions());
    sendDebuggerEventSettings(parent, debugger, target);
}
Also used : DebuggerEventSettings(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerEventSettings) CouldntSaveDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntSaveDataException) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException) CouldntLoadDataException(com.google.security.zynamics.binnavi.Database.Exceptions.CouldntLoadDataException) TargetInformation(com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation) DebuggerOptions(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions) COptionsDialog(com.google.security.zynamics.binnavi.Gui.Debug.OptionsDialog.COptionsDialog)

Example 5 with DebuggerException

use of com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException in project binnavi by google.

the class CDebuggerFunctions method mergeExceptionsSettings.

/**
   * Merge the exception settings from the database with the ones received from the debugger.
   *
   * @param target The debug target allowing us to access the per-module storage mechanism.
   * @param exceptions The list of exceptions received from the debugger.
   *
   * @return The collection of exceptions which have to be used during this session.
   *
   * @throws CouldntLoadDataException
   */
public static Collection<DebuggerException> mergeExceptionsSettings(final DebugTargetSettings target, final Collection<DebuggerException> exceptions, final int debuggerId) throws CouldntLoadDataException {
    final Map<Long, DebuggerException> exceptionsMap = getExceptionsMap(exceptions);
    for (final DebuggerException dbgException : exceptions) {
        final String setting = target.readSetting(DebuggerException.getSettingKey(dbgException, debuggerId));
        if (setting != null) {
            final DebuggerExceptionHandlingAction handlingAction = DebuggerExceptionHandlingAction.convertToHandlingAction(Integer.valueOf(setting));
            final DebuggerException newException = new DebuggerException(dbgException.getExceptionName(), dbgException.getExceptionCode(), handlingAction);
            exceptionsMap.put(dbgException.getExceptionCode(), newException);
        }
    }
    return exceptionsMap.values();
}
Also used : DebuggerExceptionHandlingAction(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerExceptionHandlingAction) DebuggerException(com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)

Aggregations

DebuggerException (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerException)15 DebuggerOptions (com.google.security.zynamics.binnavi.debug.models.targetinformation.DebuggerOptions)13 Test (org.junit.Test)12 TargetInformation (com.google.security.zynamics.binnavi.debug.models.targetinformation.TargetInformation)10 TargetProcessThread (com.google.security.zynamics.binnavi.debug.models.processmanager.TargetProcessThread)8 RegisterDescription (com.google.security.zynamics.binnavi.debug.models.targetinformation.RegisterDescription)8 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)7 MemoryModule (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryModule)5 RelocatedAddress (com.google.security.zynamics.binnavi.disassembly.RelocatedAddress)5 ModuleLoadedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleLoadedReply)4 ModuleUnloadedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ModuleUnloadedReply)4 MemoryMap (com.google.security.zynamics.binnavi.debug.models.processmanager.MemoryMap)4 MemorySection (com.google.security.zynamics.binnavi.debug.models.processmanager.MemorySection)4 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)4 MemoryMapReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.MemoryMapReply)3 ProcessManager (com.google.security.zynamics.binnavi.debug.models.processmanager.ProcessManager)3 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)2 EchoBreakpointSetReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointSetReply)2 EchoBreakpointsRemovedReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.EchoBreakpointsRemovedReply)2 ExceptionOccurredReply (com.google.security.zynamics.binnavi.debug.connection.packets.replies.ExceptionOccurredReply)2