use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.
the class CFollowInDumpMenu method addFollowInDumpMenu.
/**
* Adds the menu that follow in dump menu for the clicked instruction.
*
* @param menu The code node menu that is extended.
* @param model The graph model that provides information about the graph.
* @param node The node whose menu is created.
* @param clickedObject The object that was clicked.
* @param y The y-coordinate of the click.
*/
public static void addFollowInDumpMenu(final JPopupMenu menu, final CGraphModel model, final NaviNode node, final Object clickedObject, final double y) {
Preconditions.checkNotNull(menu, "IE02371: menu argument can not be null");
Preconditions.checkNotNull(model, "IE02372: model argument can not be null");
Preconditions.checkNotNull(node, "IE02373: node argument can not be null");
final int line = node.positionToRow(y);
if (line == -1) {
return;
}
final INaviCodeNode codeNode = (INaviCodeNode) node.getRawNode();
final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, line);
if (instruction != null) {
final IDebugger debugger = CGraphDebugger.getDebugger(model.getDebuggerProvider(), instruction);
if ((debugger != null) && (clickedObject instanceof COperandTreeNode)) {
final TargetProcessThread activeThread = debugger.getProcessManager().getActiveThread();
if (activeThread != null) {
final CDebugPerspectiveModel viewModel = (CDebugPerspectiveModel) model.getGraphPanel().getViewModel().getModel(PerspectiveType.DebugPerspective);
final COperandTreeNode treeNode = (COperandTreeNode) clickedObject;
final boolean added = addFollowInDumpMenu(menu, viewModel, debugger, activeThread, instruction.getModule(), treeNode);
if (added) {
menu.addSeparator();
}
}
}
}
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.
the class CModulesPanelTest method testLifeCycle.
@Test
public void testLifeCycle() throws IllegalArgumentException, SecurityException, IllegalAccessException, NoSuchFieldException {
final MockDebugger debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
final CDebugPerspectiveModel model = new CDebugPerspectiveModel(new MockGraphModel());
model.setActiveDebugger(debugger);
final CModulesPanel panel = new CModulesPanel(model);
panel.dispose();
final LinkedHashSet<?> debuggerListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "synchronizer"), "listeners"), "m_listeners");
final LinkedHashSet<?> processListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(ReflectionHelpers.getField(AbstractDebugger.class, debugger, "processManager"), "listeners"), "m_listeners");
// The debugger only has one internal memory synchronizer
assertEquals(1, debuggerListeners.size());
// The process manager only has one thread state synchronizer
assertEquals(1, processListeners.size());
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.
the class CThreadInformationPanelTest method test2.
/**
* This test makes sure that going from no debugger to a debugger to no debugger works fine.
*/
@Test
public void test2() 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 TargetProcessThread thread = new TargetProcessThread(0, ThreadState.RUNNING);
debugger.getProcessManager().addThread(thread);
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");
final LinkedHashSet<?> threadListeners = (LinkedHashSet<?>) ReflectionHelpers.getField(ReflectionHelpers.getField(thread, "listeners"), "m_listeners");
assertEquals(1, perspectiveListeners.size());
assertEquals(1, debuggerListeners.size());
assertEquals(1, threadListeners.size());
model.setActiveDebugger(debugger);
assertEquals(2, threadListeners.size());
assertEquals(2, debuggerListeners.size());
model.setActiveDebugger(null);
assertEquals(1, threadListeners.size());
assertEquals(1, debuggerListeners.size());
assertEquals(1, perspectiveListeners.size());
panel.dispose();
assertEquals(1, threadListeners.size());
assertEquals(1, debuggerListeners.size());
assertEquals(0, perspectiveListeners.size());
}
use of com.google.security.zynamics.binnavi.Gui.GraphWindows.Panels.CDebugPerspectiveModel in project binnavi by google.
the class CMemoryViewerSynchronizerTest method setUp.
@Before
public void setUp() {
final IGraphModel graphModel = new MockGraphModel();
m_model = new CDebugPerspectiveModel(graphModel);
final CMemoryProvider provider = new CMemoryProvider();
m_hexView.setData(provider);
m_synchronizer = new CMemoryViewerSynchronizer(m_hexView, provider, m_model);
m_debugger = new MockDebugger(new ModuleTargetSettings(CommonTestObjects.MODULE));
m_model.setActiveDebugger(m_debugger);
}
Aggregations