use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CBreakpointRemoveFunctions method deleteBreakpoints.
/**
* Deletes the breakpoints specified by the rows argument.
*
* @param debuggerProvider Provides the debuggers where breakpoints can be set.
* @param rows Rows that identify the breakpoints.
*/
public static void deleteBreakpoints(final BackEndDebuggerProvider debuggerProvider, final int[] rows) {
Preconditions.checkNotNull(debuggerProvider, "IE01886: Debugger provider argument can not be null");
Preconditions.checkNotNull(rows, "IE02253: Rows argument can't be null");
final ArrayList<Pair<IDebugger, BreakpointAddress>> addresses = new ArrayList<Pair<IDebugger, BreakpointAddress>>();
for (final int row : rows) {
final Pair<IDebugger, Integer> breakpoint = CBreakpointTableHelpers.findBreakpoint(debuggerProvider, row);
final BreakpointManager manager = breakpoint.first().getBreakpointManager();
final int breakpointIndex = breakpoint.second();
addresses.add(new Pair<IDebugger, BreakpointAddress>(breakpoint.first(), manager.getBreakpoint(BreakpointType.REGULAR, breakpointIndex).getAddress()));
}
for (final Pair<IDebugger, BreakpointAddress> p : addresses) {
final BreakpointManager manager = p.first().getBreakpointManager();
final BreakpointAddress address = p.second();
manager.setBreakpointStatus(Sets.newHashSet(address), BreakpointType.REGULAR, BreakpointStatus.BREAKPOINT_DELETING);
}
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CBreakpointTableHelpers method findBreakpoint.
/**
* Given a row of the breakpoint table, this function calculates to what breakpoint manager the
* breakpoint of that row belongs to and what index the breakpoint has within the breakpoint
* manager.
*
* @param debuggerProvider The debuggers that are used to fill the breakpoint table.
* @param row A row of the breakpoint table.
*
* @return A pair that contains the breakpoint manager and the breakpoint index of the breakpoint
* identified by the given row.
*
* @throws IllegalArgumentException Thrown if the debugger provider argument is null or the row
* argument is out of bounds.
*/
public static Pair<IDebugger, Integer> findBreakpoint(final BackEndDebuggerProvider debuggerProvider, final int row) {
Preconditions.checkNotNull(debuggerProvider, "IE01336: Debugger provider argument can't be null");
Preconditions.checkArgument(row >= 0, "IE01337: Row arguments can not be negative");
int breakpoints = 0;
for (final IDebugger debugger : debuggerProvider.getDebuggers()) {
if ((row >= breakpoints) && (row < breakpoints + debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR))) {
return new Pair<IDebugger, Integer>(debugger, row - breakpoints);
} else {
breakpoints += debugger.getBreakpointManager().getNumberOfBreakpoints(BreakpointType.REGULAR);
}
}
throw new IllegalArgumentException("IE01338: Invalid row number");
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CViewPruner method convertEdges.
/**
* Converts edges of the original view to the pruned view.
*
* @param view The original view.
* @param prunedView The pruned view.
* @param nodeMap A mapping between nodes of the original view and nodes of the pruned view.
*/
private static void convertEdges(final INaviView view, final INaviView prunedView, final Map<INaviViewNode, INaviViewNode> nodeMap) {
final Set<Pair<INaviViewNode, INaviViewNode>> createdEdges = new HashSet<Pair<INaviViewNode, INaviViewNode>>();
for (final INaviEdge edge : view.getGraph().getEdges()) {
final Set<EdgeResult> sources = getSources(edge, nodeMap, new HashSet<INaviEdge>());
final Set<EdgeResult> targets = getTargets(edge, nodeMap, new HashSet<INaviEdge>());
for (final EdgeResult source : sources) {
for (final EdgeResult target : targets) {
final Pair<INaviViewNode, INaviViewNode> edgePair = new Pair<INaviViewNode, INaviViewNode>(source.m_node, target.m_node);
if (createdEdges.contains(edgePair)) {
continue;
}
prunedView.getContent().createEdge(source.m_node, target.m_node, source.m_type);
createdEdges.add(edgePair);
}
}
}
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class CGlobalEdgeCommentSynchronizer method getModules.
/**
* Returns the modules the nodes of the edge belong to.
*
* @param edge The edge to check.
*
* @return Source module and target module of the edge.
*
* @throws MaybeNullException Thrown if the edge does not have source module or target module.
*/
private static Pair<INaviModule, INaviModule> getModules(final INaviEdge edge) throws MaybeNullException {
INaviModule srcModule = null;
INaviModule tarModule = null;
if (edge.getSource() instanceof INaviCodeNode) {
srcModule = ((INaviCodeNode) edge.getSource()).getParentFunction().getModule();
} else if (edge.getSource() instanceof INaviFunctionNode) {
srcModule = ((INaviFunctionNode) edge.getSource()).getFunction().getModule();
}
if (edge.getTarget() instanceof INaviCodeNode) {
tarModule = ((INaviCodeNode) edge.getTarget()).getParentFunction().getModule();
} else if (edge.getTarget() instanceof INaviFunctionNode) {
tarModule = ((INaviFunctionNode) edge.getTarget()).getFunction().getModule();
}
return new Pair<INaviModule, INaviModule>(srcModule, tarModule);
}
use of com.google.security.zynamics.zylib.general.Pair in project binnavi by google.
the class LocalInstructionCommentAccessor method getAllComments.
@Override
public ArrayList<Pair<INaviInstruction, IComment>> getAllComments() {
final ArrayList<Pair<INaviInstruction, IComment>> values = new ArrayList<>();
final CCodeNodeComments currentComments = m_codeNode.getComments();
for (final INaviInstruction instruction : m_codeNode.getInstructions()) {
final List<IComment> comments = currentComments.getLocalInstructionComment(instruction);
if ((comments == null) || comments.isEmpty()) {
values.add(new Pair<INaviInstruction, IComment>(instruction, new EmptyComment()));
continue;
} else {
for (final IComment comment : comments) {
values.add(new Pair<INaviInstruction, IComment>(instruction, comment));
}
values.add(new Pair<INaviInstruction, IComment>(instruction, new EmptyComment()));
}
}
return values;
}
Aggregations