use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.
the class CStepIntoAction method actionPerformed.
@Override
public void actionPerformed(final ActionEvent event) {
final IDebugger debugger = m_debugger.getCurrentSelectedDebugger();
final TargetProcessThread activeThread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
if ((debugger != null) && (activeThread != null)) {
CDebuggerFunctions.stepInto(m_parent, debugger);
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.
the class CDebuggerToolbar method updateGui.
/**
* Updates the GUI according to the currently available information about the target process.
*/
public void updateGui() {
// Note: There is a reason for why we have to update the toolbar
// from the outside. The toolbar can not update itself because
// the toolbar state depends on the state of the TID box in the
// debug panel.
final IDebugger debugger = m_debugger.getCurrentSelectedDebugger();
final TargetProcessThread activeThread = debugger == null ? null : debugger.getProcessManager().getActiveThread();
final boolean connected = (debugger != null) && debugger.isConnected();
final boolean suspended = connected && (activeThread != null);
m_startAction.setEnabled(!connected);
final boolean haltBeforeCommunicating = (debugger != null) && connected && (debugger.getProcessManager().getTargetInformation() != null) && debugger.getProcessManager().getTargetInformation().getDebuggerOptions().mustHaltBeforeCommunicating();
m_detachAction.setEnabled(connected && (!haltBeforeCommunicating || suspended));
m_terminateAction.setEnabled(connected);
m_stepIntoAction.setEnabled(connected && suspended);
m_stepIntoAction.setEnabled(connected && suspended);
m_stepOverAction.setEnabled(connected && suspended);
m_stepBlockAction.setEnabled(connected && suspended);
m_stepEndAction.setEnabled(connected && suspended);
m_resumeAction.setEnabled(connected && suspended);
m_haltAction.setEnabled(connected && !suspended);
final boolean tracing = (debugger != null) && m_debugger.getTraceLogger(debugger).hasEchoBreakpoints();
m_startTraceAction.setEnabled(connected && (!haltBeforeCommunicating || suspended));
m_stopTraceAction.setEnabled(connected && tracing && (!haltBeforeCommunicating || suspended));
}
use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.
the class CGraphDebugger method toggleBreakpoint.
/**
* Sets or removes a breakpoint from a function node.
*
* @param debuggerProvider Debugger provider that contains all possible debuggers for the function
* node.
* @param functionNode Function node object where the breakpoint is set or removed.
*/
public static void toggleBreakpoint(final BackEndDebuggerProvider debuggerProvider, final INaviFunctionNode functionNode) {
Preconditions.checkNotNull(debuggerProvider, "IE01721: Debugger provider argument can not be null");
Preconditions.checkNotNull(functionNode, "IE01722: Function node argument can not be null");
if (functionNode.getFunction().getType() == FunctionType.IMPORT) {
// We can not set breakpoints on imported functions
return;
}
final IDebugger debugger = getDebugger(debuggerProvider, functionNode);
if (debugger == null) {
return;
}
final INaviModule module = functionNode.getFunction().getModule();
CGraphDebugger.toggleBreakpoint(debugger.getBreakpointManager(), module, new UnrelocatedAddress(functionNode.getFunction().getAddress()));
}
use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.
the class CCodeNodeUpdater method initializeListeners.
/**
* Initializes the listeners that are responsible for updating the code node.
*/
private void initializeListeners() {
try {
codeNode.getParentFunction().addListener(functionUpdater);
codeNode.getParentFunction().getModule().addListener(moduleUpdater);
} catch (final MaybeNullException exception) {
// The code nodes does not have a parent function, therefore the information
// about the parent function is not shown in the code and does not have to
// be processed when updating.
}
final HashMap<INaviInstruction, INaviFunction> referenceMap = CReferenceFinder.getCodeReferenceMap(codeNode);
for (final INaviFunction functionReference : Sets.newHashSet(referenceMap.values())) {
functionReference.addListener(functionUpdater);
}
codeNode.addListener(codeNodeListener);
for (final INaviInstruction instruction : codeNode.getInstructions()) {
instruction.addListener(instructionUpdater);
for (final COperandTree tree : instruction.getOperands()) {
for (final INaviOperandTreeNode currentNode : tree.getNodes()) {
currentNode.addListener(operandTreeUpdater);
}
}
}
final Iterator<CTag> it = codeNode.getTagsIterator();
while (it.hasNext()) {
it.next().addListener(tagUpdater);
}
for (final IDebugger debugger : provider.getDebuggers()) {
debugger.getProcessManager().addListener(debuggerUpdater);
}
provider.addListener(debuggerProviderListener);
graph.getSettings().getDisplaySettings().addListener(settingsUpdater);
try {
codeNode.getParentFunction().getModule().getTypeManager().addListener(substitutionsUpdater);
} catch (final MaybeNullException exception) {
// If the code node doesn't have a a parent function, it is not in the database and therefore
// cannot receive type substitutions.
}
}
use of com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger in project binnavi by google.
the class CThreadInformationPanelTest method test3.
/**
* This test makes sure that going from no debugger to a debugger to more threads works fine.
*/
@Test
public void test3() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
// CGraphModelFactory.get(database,
final IGraphModel graphModel = new MockGraphModel();
// viewContainer);
final CDebugPerspectiveModel model = CDebugPerspectiveModelFactory.get(graphModel);
final CThreadInformationPanel panel = new CThreadInformationPanel(model);
final IDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
final LinkedHashSet<?> perspectiveListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(model, "m_listeners"), "m_listeners");
final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
assertEquals(1, perspectiveListeners.size());
assertEquals(1, debuggerListeners.size());
model.setActiveDebugger(debugger);
final TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
debugger.getProcessManager().addThread(thread);
final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
assertEquals(2, threadListeners.size());
assertEquals(2, threadListeners.size());
assertEquals(2, debuggerListeners.size());
debugger.getProcessManager().removeThread(thread);
assertEquals(0, threadListeners.size());
panel.dispose();
assertEquals(0, threadListeners.size());
assertEquals(1, debuggerListeners.size());
assertEquals(0, perspectiveListeners.size());
}
Aggregations