@Test public void testFilteredReturnInstructions() { ContextRegisterFilter cRegFilter = new ContextRegisterFilter(); cRegFilter.addRegAndValueToFilter("cReg2", new BigInteger("1")); cRegFilter.addRegAndValueToFilter("cReg3", new BigInteger("3")); cRegFilter.addRegAndValueToFilter("cReg4", new BigInteger("7")); List<InstructionSequence> seqs = InstructionSequence.getInstSeqs(fReader, PatternType.RETURN, cRegFilter); assertEquals(6, seqs.size()); }
public static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader, PatternType type, ContextRegisterFilter regFilter) { List<InstructionSequence> instSeqs = new ArrayList<InstructionSequence>(); for (FunctionBitPatternInfo fInfo : fsReader.getFInfoList()) { if (regFilter != null && !regFilter.allows(fInfo.getContextRegisters())) { continue; } switch (type) { case FIRST: InstructionSequence currentSeq = fInfo.getFirstInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getFirstBytes() != null)) { instSeqs.add(currentSeq); } break; case PRE: currentSeq = fInfo.getPreInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getPreBytes() != null)) { instSeqs.add(currentSeq); } break; case RETURN: List<InstructionSequence> currentSeqs = fInfo.getReturnInst(); List<String> currentBytes = fInfo.getReturnBytes(); if (currentSeqs.size() != currentBytes.size()) { continue; } for (int i = 0, numSeqs = currentSeqs.size(); i < numSeqs; ++i) { if (currentSeqs.get(i).getInstructions()[0] != null && currentBytes.get(i).getBytes() != null) { instSeqs.add(currentSeqs.get(i)); } } break; default: throw new IllegalArgumentException( "unsupported instruction type: " + type.name()); } } return instSeqs; }
InstructionSequence { public static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader, PatternType type, ContextRegisterFilter regFilter) { List<InstructionSequence> instSeqs = new ArrayList<InstructionSequence>(); for (FunctionBitPatternInfo fInfo : fsReader.getFInfoList()) { if (regFilter != null && !regFilter.allows(fInfo.getContextRegisters())) { continue; } switch (type) { case FIRST: InstructionSequence currentSeq = fInfo.getFirstInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getFirstBytes() != null)) { instSeqs.add(currentSeq); } break; case PRE: currentSeq = fInfo.getPreInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getPreBytes() != null)) { instSeqs.add(currentSeq); } break; case RETURN: List<InstructionSequence> currentSeqs = fInfo.getReturnInst(); List<String> currentBytes = fInfo.getReturnBytes(); if (currentSeqs.size() != currentBytes.size()) { continue; } for (int i = 0, numSeqs = currentSeqs.size(); i < numSeqs; ++i) { if (currentSeqs.get(i).getInstructions()[0] != null && currentBytes.get(i).getBytes() != null) { instSeqs.add(currentSeqs.get(i)); } } break; default: throw new IllegalArgumentException( "unsupported instruction type: " + type.name()); } } return instSeqs; } }
InstructionSequence { public static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader, PatternType type, ContextRegisterFilter regFilter) { List<InstructionSequence> instSeqs = new ArrayList<InstructionSequence>(); for (FunctionBitPatternInfo fInfo : fsReader.getFInfoList()) { if (regFilter != null && !regFilter.allows(fInfo.getContextRegisters())) { continue; } switch (type) { case FIRST: InstructionSequence currentSeq = fInfo.getFirstInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getFirstBytes() != null)) { instSeqs.add(currentSeq); } break; case PRE: currentSeq = fInfo.getPreInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getPreBytes() != null)) { instSeqs.add(currentSeq); } break; case RETURN: List<InstructionSequence> currentSeqs = fInfo.getReturnInst(); List<String> currentBytes = fInfo.getReturnBytes(); if (currentSeqs.size() != currentBytes.size()) { continue; } for (int i = 0, numSeqs = currentSeqs.size(); i < numSeqs; ++i) { if (currentSeqs.get(i).getInstructions()[0] != null && currentBytes.get(i).getBytes() != null) { instSeqs.add(currentSeqs.get(i)); } } break; default: throw new IllegalArgumentException( "unsupported instruction type: " + type.name()); } } return instSeqs; } InstructionSequence();  InstructionSequence(int length); }
InstructionSequence { public static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader, PatternType type, ContextRegisterFilter regFilter) { List<InstructionSequence> instSeqs = new ArrayList<InstructionSequence>(); for (FunctionBitPatternInfo fInfo : fsReader.getFInfoList()) { if (regFilter != null && !regFilter.allows(fInfo.getContextRegisters())) { continue; } switch (type) { case FIRST: InstructionSequence currentSeq = fInfo.getFirstInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getFirstBytes() != null)) { instSeqs.add(currentSeq); } break; case PRE: currentSeq = fInfo.getPreInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getPreBytes() != null)) { instSeqs.add(currentSeq); } break; case RETURN: List<InstructionSequence> currentSeqs = fInfo.getReturnInst(); List<String> currentBytes = fInfo.getReturnBytes(); if (currentSeqs.size() != currentBytes.size()) { continue; } for (int i = 0, numSeqs = currentSeqs.size(); i < numSeqs; ++i) { if (currentSeqs.get(i).getInstructions()[0] != null && currentBytes.get(i).getBytes() != null) { instSeqs.add(currentSeqs.get(i)); } } break; default: throw new IllegalArgumentException( "unsupported instruction type: " + type.name()); } } return instSeqs; } InstructionSequence();  InstructionSequence(int length); String getCompleteDisassembly(boolean inOrder); String getDisassembly(int numInstructions, boolean inOrder); String[] getInstructions(); void setInstructions(String[] instructions); Integer[] getSizes(); void setSizes(Integer[] sizes); String[] getCommaSeparatedOperands(); void setCommaSeparatedOperands(String[] commaSeparatedOperands); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader,
			PatternType type, ContextRegisterFilter regFilter); }
InstructionSequence { public static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader, PatternType type, ContextRegisterFilter regFilter) { List<InstructionSequence> instSeqs = new ArrayList<InstructionSequence>(); for (FunctionBitPatternInfo fInfo : fsReader.getFInfoList()) { if (regFilter != null && !regFilter.allows(fInfo.getContextRegisters())) { continue; } switch (type) { case FIRST: InstructionSequence currentSeq = fInfo.getFirstInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getFirstBytes() != null)) { instSeqs.add(currentSeq); } break; case PRE: currentSeq = fInfo.getPreInst(); if (currentSeq.getInstructions()[0] != null && (fInfo.getPreBytes() != null)) { instSeqs.add(currentSeq); } break; case RETURN: List<InstructionSequence> currentSeqs = fInfo.getReturnInst(); List<String> currentBytes = fInfo.getReturnBytes(); if (currentSeqs.size() != currentBytes.size()) { continue; } for (int i = 0, numSeqs = currentSeqs.size(); i < numSeqs; ++i) { if (currentSeqs.get(i).getInstructions()[0] != null && currentBytes.get(i).getBytes() != null) { instSeqs.add(currentSeqs.get(i)); } } break; default: throw new IllegalArgumentException( "unsupported instruction type: " + type.name()); } } return instSeqs; } InstructionSequence();  InstructionSequence(int length); String getCompleteDisassembly(boolean inOrder); String getDisassembly(int numInstructions, boolean inOrder); String[] getInstructions(); void setInstructions(String[] instructions); Integer[] getSizes(); void setSizes(Integer[] sizes); String[] getCommaSeparatedOperands(); void setCommaSeparatedOperands(String[] commaSeparatedOperands); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); static List<InstructionSequence> getInstSeqs(FileBitPatternInfoReader fsReader,
			PatternType type, ContextRegisterFilter regFilter);  }