use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress 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.disassembly.UnrelocatedAddress in project binnavi by google.
the class CBreakpointPainter method paintBreakpoints.
/**
* Paints breakpoints into a function node.
*
* @param manager The breakpoint manager that provides breakpoint information.
* @param node The visible BinNavi node where the breakpoint is painted.
* @param functionNode The function node that contains the raw data for the BinNavi node.
*/
public static void paintBreakpoints(final BreakpointManager manager, final NaviNode node, final INaviFunctionNode functionNode) {
Preconditions.checkNotNull(manager, "IE02374: Manager argument can not be null");
Preconditions.checkNotNull(node, "IE02375: Node argument can not be null");
Preconditions.checkNotNull(functionNode, "IE02376: Code node argument can not be null");
final INaviFunction function = functionNode.getFunction();
final INaviModule module = function.getModule();
final int FUNCTION_BREAKPOINT_LINE = 1;
final BreakpointAddress address = new BreakpointAddress(module, new UnrelocatedAddress(function.getAddress()));
if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
node.setHighlighting(CHighlightLayers.BREAKPOINT_LAYER, FUNCTION_BREAKPOINT_LINE, BreakpointManager.getBreakpointColor(manager.getBreakpointStatus(address, BreakpointType.REGULAR)));
} else {
// If there is no breakpoint, clear potential older breakpoint line.
node.clearHighlighting(500, FUNCTION_BREAKPOINT_LINE);
}
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class CBreakpointPainter method paintBreakpoints.
/**
* Paints breakpoints into code nodes.
*
* @param manager The breakpoint manager that provides breakpoint information.
* @param node The visible BinNavi node where the breakpoint is painted.
* @param codeNode The code node that contains the raw data for the BinNavi node.
*/
public static void paintBreakpoints(final BreakpointManager manager, final NaviNode node, final INaviCodeNode codeNode) {
Preconditions.checkNotNull(manager, "IE02171: Manager argument can not be null");
Preconditions.checkNotNull(node, "IE02172: Node argument can not be null");
Preconditions.checkNotNull(codeNode, "IE02173: Code node argument can not be null");
for (final INaviInstruction instruction : codeNode.getInstructions()) {
final BreakpointAddress address = new BreakpointAddress(instruction.getModule(), new UnrelocatedAddress(instruction.getAddress()));
final int line = CCodeNodeHelpers.instructionToLine(codeNode, instruction);
if (manager.hasBreakpoint(BreakpointType.REGULAR, address)) {
// Only the address is highlighted when breakpoints are set on instructions
// visible in code nodes.
final int addressCharacters = address.getAddress().getAddress().toHexString().length();
node.setHighlighting(CHighlightLayers.BREAKPOINT_LAYER, line, 0, addressCharacters, BreakpointManager.getBreakpointColor(manager.getBreakpointStatus(address, BreakpointType.REGULAR)));
} else {
// If there is no breakpoint, clear potential older breakpoint line.
node.clearHighlighting(CHighlightLayers.BREAKPOINT_LAYER, line);
}
}
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class ZyCodeNodeBuilder method buildFunctionLine.
/**
* Builds the function line of a code node. This line gives information about the function from
* where the code node originally came from.
*
* @param node The node that provides the raw data.
* @param content The node content where the function line is added.
* @param modifier Calculates the address strings. This argument can be null.
*/
private static void buildFunctionLine(final INaviCodeNode node, final ZyLabelContent content, final INodeModifier modifier) {
try {
final INaviFunction parentFunction = node.getParentFunction();
final String address = modifier == null ? parentFunction.getAddress().toHexString() : modifier.getAddress(parentFunction.getModule(), new UnrelocatedAddress(parentFunction.getAddress()), true);
final String name = parentFunction.getName();
content.addLineContent(new ZyLineContent(address + PADDING_AFTER_FUNCTION_ADDRESS + parentFunction.getModule().getConfiguration().getName() + "::" + name, BOLD_FONT, Lists.newArrayList(new CStyleRunData(0, -1, Color.BLACK)), null));
} catch (final MaybeNullException exception) {
// If there is no parent function, the parent function is not shown in the code node.
}
}
use of com.google.security.zynamics.binnavi.disassembly.UnrelocatedAddress in project binnavi by google.
the class PostgreSQLProviderTest method testTraceFunctionsSave1.
@Test
public void testTraceFunctionsSave1() throws CouldntLoadDataException, LoadCancelledException, CouldntSaveDataException {
final INaviProject project = getProvider().createProject("SOME_PROJECT");
getProvider().createTrace(project, "SOME_TRACE", "SOME_TRACE_DESCRIPTION");
project.load();
final TraceList trace = project.getContent().getTraces().get(0);
final INaviModule module = getProvider().loadModules().get(0);
module.load();
final long tid = 0x1L;
final UnrelocatedAddress address2 = new UnrelocatedAddress(new CAddress(0x1234));
final BreakpointAddress address = new BreakpointAddress(module, address2);
final TraceEventType type = TraceEventType.ECHO_BREAKPOINT;
final List<TraceRegister> values = new ArrayList<>();
final ITraceEvent event = new TraceEvent(tid, address, type, values);
trace.addEvent(event);
trace.setDescription("burzelbarf");
PostgreSQLTraceFunctions.save((AbstractSQLProvider) getProvider(), trace);
project.close();
INaviProject project2 = null;
for (final INaviProject cProject : getProvider().loadProjects()) {
if (cProject.getConfiguration().getId() == project.getConfiguration().getId()) {
project2 = cProject;
}
}
getProvider().createTrace(project2, "SOME_TRACE_2", "SOME_TRACE_DESCRIPTION_2");
project2.load();
final TraceList trace2 = project2.getContent().getTraces().get(0);
assertEquals("burzelbarf", trace2.getDescription());
}
Aggregations