Search in sources :

Example 46 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class CGraphDebugger method toggleBreakpoint.

/**
   * Sets or removes a breakpoint at a given line of a code node.
   *
   * @param debuggerProvider Debugger provider that contains all possible debuggers for the code
   *        node.
   * @param codeNode The code node where the breakpoint is set.
   * @param row The code node row where the breakpoint is set.
   */
public static void toggleBreakpoint(final BackEndDebuggerProvider debuggerProvider, final INaviCodeNode codeNode, final int row) {
    Preconditions.checkNotNull(debuggerProvider, "IE01719: Debugger provider argument can not be null");
    Preconditions.checkNotNull(codeNode, "IE01720: Code node argument can not be null");
    final INaviInstruction instruction = CCodeNodeHelpers.lineToInstruction(codeNode, row);
    if (instruction == null) {
        return;
    }
    final IDebugger debugger = getDebugger(debuggerProvider, instruction);
    if (debugger == null) {
        return;
    }
    toggleBreakpoint(debugger.getBreakpointManager(), instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
}
Also used : UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) IDebugger(com.google.security.zynamics.binnavi.debug.debugger.interfaces.IDebugger) INaviInstruction(com.google.security.zynamics.binnavi.disassembly.INaviInstruction)

Example 47 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class DebuggerHelpers method getBreakpointAddress.

/**
   * Converts a memory address into a breakpoint address.
   *
   * @param debugger The debugger which handles the breakpoint.
   * @param memoryAddress The memory address to convert.
   *
   * @return The breakpoint address.
   */
public static BreakpointAddress getBreakpointAddress(final IDebugger debugger, final RelocatedAddress memoryAddress) {
    Preconditions.checkNotNull(debugger, "IE00161: Debugger argument can not be null");
    Preconditions.checkNotNull(memoryAddress, "IE00163: Memory address argument can not be null");
    final INaviModule module = debugger.getModule(memoryAddress);
    return new BreakpointAddress(module, module == null ? new UnrelocatedAddress(memoryAddress.getAddress()) : debugger.memoryToFile(module, memoryAddress));
}
Also used : INaviModule(com.google.security.zynamics.binnavi.disassembly.INaviModule) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)

Example 48 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class BreakpointManagerTest method testSetBreakpoint.

@Test
public void testSetBreakpoint() {
    apiManager.addListener(mockListener);
    try {
        apiManager.setBreakpoint(null, null);
    } catch (final NullPointerException exception) {
    }
    apiManager.setBreakpoint(module, new Address(0x123));
    assertEquals("addedBreakpoint/123;", mockListener.events);
    try {
        apiManager.setBreakpoint(null, new Address(0x123));
    } catch (final NullPointerException exception) {
    }
    internalManager.addBreakpoints(BreakpointType.REGULAR, Sets.newHashSet(new BreakpointAddress(CommonTestObjects.MODULE, new UnrelocatedAddress(new CAddress(0x124)))));
    assertEquals("addedBreakpoint/123;addedBreakpoint/124;", mockListener.events);
    assertTrue(apiManager.hasBreakpoint(module, new Address(0x124)));
    apiManager.removeListener(mockListener);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 49 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class BreakpointManagerTest method testSetEchoBreakpoint.

@Test
public void testSetEchoBreakpoint() {
    apiManager.addListener(mockListener);
    try {
        apiManager.setEchoBreakpoint(null, null);
    } catch (final NullPointerException exception) {
    }
    apiManager.setEchoBreakpoint(module, new Address(0x123));
    assertEquals("addedEchoBreakpoint/123;", mockListener.events);
    try {
        apiManager.setEchoBreakpoint(null, new Address(0x123));
    } catch (final NullPointerException exception) {
    }
    internalManager.addBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(CommonTestObjects.MODULE, new UnrelocatedAddress(new CAddress(0x124)))));
    assertEquals("addedEchoBreakpoint/123;addedEchoBreakpoint/124;", mockListener.events);
    assertTrue(apiManager.hasEchoBreakpoint(module, new Address(0x124)));
    apiManager.removeListener(mockListener);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Example 50 with UnrelocatedAddress

use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.

the class BreakpointManagerTest method testRemoveEchoBreakpoint.

@Test
public void testRemoveEchoBreakpoint() {
    try {
        apiManager.removeEchoBreakpoint(null, null);
        fail();
    } catch (final NullPointerException exception) {
    }
    apiManager.setEchoBreakpoint(module, new Address(0x123));
    apiManager.setEchoBreakpoint(module, new Address(0x124));
    apiManager.addListener(mockListener);
    apiManager.removeEchoBreakpoint(module, new Address(0x123));
    internalManager.removeBreakpoints(BreakpointType.ECHO, Sets.newHashSet(new BreakpointAddress(CommonTestObjects.MODULE, new UnrelocatedAddress(new CAddress(0x124)))));
    assertEquals("removedEchoBreakpoint/123;removedEchoBreakpoint/124;", mockListener.events);
    assertEquals(0, apiManager.getBreakpoints().size());
    apiManager.removeListener(mockListener);
}
Also used : CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) Address(com.google.security.zynamics.binnavi.API.disassembly.Address) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) UnrelocatedAddress(com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress) BreakpointAddress(com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress) CAddress(com.google.security.zynamics.zylib.disassembly.CAddress) Test(org.junit.Test)

Aggregations

UnrelocatedAddress (com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress)81 BreakpointAddress (com.google.security.zynamics.binnavi.debug.models.breakpoints.BreakpointAddress)60 CAddress (com.google.security.zynamics.zylib.disassembly.CAddress)60 Test (org.junit.Test)49 INaviModule (com.google.security.zynamics.binnavi.disassembly.INaviModule)28 MockDebugger (com.google.security.zynamics.binnavi.Debug.Debugger.MockDebugger)15 ModuleTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.ModuleTargetSettings)15 MockModule (com.google.security.zynamics.binnavi.disassembly.Modules.MockModule)13 Address (com.google.security.zynamics.binnavi.API.disassembly.Address)12 ArrayList (java.util.ArrayList)11 TraceList (com.google.security.zynamics.binnavi.debug.models.trace.TraceList)10 INaviInstruction (com.google.security.zynamics.binnavi.disassembly.INaviInstruction)9 HashSet (java.util.HashSet)9 MockSqlProvider (com.google.security.zynamics.binnavi.Database.MockClasses.MockSqlProvider)8 DebugTargetSettings (com.google.security.zynamics.binnavi.debug.debugger.DebugTargetSettings)8 DebuggerProvider (com.google.security.zynamics.binnavi.debug.debugger.DebuggerProvider)8 Breakpoint (com.google.security.zynamics.binnavi.debug.models.breakpoints.Breakpoint)8 FilledList (com.google.security.zynamics.zylib.types.lists.FilledList)8 CBreakpointTableModel (com.google.security.zynamics.binnavi.Gui.Debug.BreakpointTable.CBreakpointTableModel)7 TraceLogger (com.google.security.zynamics.binnavi.debug.models.trace.TraceLogger)7