public void dump(CFG cfg, String name) { new IGVCFGVisitor(cfg, writer, name); }
protected void visitBasicBlocks(CFG cfg) { for (BasicBlock basicBlock: cfg.getBasicBlocks()) { BasicBlock(basicBlock); } }
public void CFG(CFG cfg, String name) { startTag(writer, "graph"); startTag(writer, "properties"); property(writer, "name", name); endTag(writer, "properties"); startTag(writer, "nodes"); visitBasicBlocks(cfg); endTag(writer, "nodes"); startTag(writer, "edges"); for (Tuple<Integer, Integer> edge: instrEdges) { emptyTag(writer, "edge", "from", edge.a, "to", edge.b); } for (Tuple<Integer, JumpTargetInstr> edge: extraInstrEdges) { emptyTag(writer, "edge", "from", edge.a, "to", indexOffsets.get(cfg.getBBForLabel(edge.b.getJumpTarget()))); } for (Tuple<Instr, Instr> edge: listener.getRemovedEdges()) { emptyTag(writer, "removedEdge", "from", System.identityHashCode(edge.a), "to", System.identityHashCode(edge.b)); } endTag(writer, "edges"); startTag(writer, "controlFlow"); visitEdges(cfg); endTag(writer, "controlFlow"); endTag(writer, "graph"); }
public IGVCFGVisitor(CFG cfg, PrintStream writer, String name) { this.writer = writer; listener = (IGVInstrListener) cfg.getScope().getManager().getInstructionsListener(); CFG(cfg, name); listener.reset(); }
public void BasicBlock(BasicBlock basicBlock) { // We have potentially empty entry and exit BBs if (!basicBlock.getInstrs().isEmpty()) { indexOffsets.put(basicBlock, System.identityHashCode(basicBlock.getInstrs().get(0))); } visitInstrs(basicBlock); }
protected void visitInstrs(BasicBlock basicBlock) { List<Instr> instrs = basicBlock.getInstrs(); int size = instrs.size(); if (size > 0) { int lastIPC = Instr(instrs.get(0)); // Last BB processed needs to hook up to first in next one if not a Jump (fallthrough) if (lastInstr != null && !(lastInstr instanceof JumpInstr)) { instrEdges.add(new Tuple(System.identityHashCode(lastInstr), lastIPC)); } for (int i = 1; i < size; i++) { int ipc = Instr(instrs.get(i)); instrEdges.add(new Tuple(lastIPC, ipc)); lastIPC = ipc; } lastInstr = instrs.get(size - 1); } }
public void CFG(CFG cfg, String name) { startTag(writer, "graph"); startTag(writer, "properties"); property(writer, "name", name); endTag(writer, "properties"); startTag(writer, "nodes"); visitBasicBlocks(cfg); endTag(writer, "nodes"); startTag(writer, "edges"); for (Tuple<Integer, Integer> edge: instrEdges) { emptyTag(writer, "edge", "from", edge.a, "to", edge.b); } for (Tuple<Integer, JumpTargetInstr> edge: extraInstrEdges) { emptyTag(writer, "edge", "from", edge.a, "to", indexOffsets.get(cfg.getBBForLabel(edge.b.getJumpTarget()))); } for (Tuple<Instr, Instr> edge: listener.getRemovedEdges()) { emptyTag(writer, "removedEdge", "from", System.identityHashCode(edge.a), "to", System.identityHashCode(edge.b)); } endTag(writer, "edges"); startTag(writer, "controlFlow"); visitEdges(cfg); endTag(writer, "controlFlow"); endTag(writer, "graph"); }
public IGVCFGVisitor(CFG cfg, PrintStream writer, String name) { this.writer = writer; listener = (IGVInstrListener) cfg.getScope().getManager().getInstructionsListener(); CFG(cfg, name); listener.reset(); }
public void BasicBlock(BasicBlock basicBlock) { // We have potentially empty entry and exit BBs if (!basicBlock.getInstrs().isEmpty()) { indexOffsets.put(basicBlock, System.identityHashCode(basicBlock.getInstrs().get(0))); } visitInstrs(basicBlock); }
protected void visitInstrs(BasicBlock basicBlock) { List<Instr> instrs = basicBlock.getInstrs(); int size = instrs.size(); if (size > 0) { int lastIPC = Instr(instrs.get(0)); // Last BB processed needs to hook up to first in next one if not a Jump (fallthrough) if (lastInstr != null && !(lastInstr instanceof JumpInstr)) { instrEdges.add(new Tuple(System.identityHashCode(lastInstr), lastIPC)); } for (int i = 1; i < size; i++) { int ipc = Instr(instrs.get(i)); instrEdges.add(new Tuple(lastIPC, ipc)); lastIPC = ipc; } lastInstr = instrs.get(size - 1); } }
protected void visitBasicBlocks(CFG cfg) { for (BasicBlock basicBlock: cfg.getBasicBlocks()) { BasicBlock(basicBlock); } }
public void dump(CFG cfg, String name) { new IGVCFGVisitor(cfg, writer, name); }