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);
}
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);
}
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();
}
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);
}
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();
}
Aggregations