Bugfix for ALUInstr

git-svn-id: https://www4.informatik.uni-erlangen.de/i4svn/danceos/trunk/devel/fail@1743 8c4709b5-6ec9-48aa-a5cd-a96041d1645a
This commit is contained in:
unzner
2012-10-13 22:02:09 +00:00
parent c9f1a5dbb8
commit 111cf2dc97
4 changed files with 37 additions and 10 deletions

View File

@ -92,14 +92,14 @@ bool BochsALUInstructions::isALUInstruction(bxInstruction_c const *src) {
return false;
}
void BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
int BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
std::string &details) const {
// find a random member of the same equivalence class
X86AluClass equClassID = lastInstr.aluClass;
if (equClassID == ALU_UNDEF) {
// something went wrong - just return the original instruction
result = lastOrigInstr;
return;
return 10;
}
InstrList const &destList = equivalenceClasses.at(equClassID);
@ -108,7 +108,7 @@ void BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
do {
int index = rand() % destList.size();
dest = destList[index];
} while (memcmp(&dest, &lastInstr, sizeof(BochsALUInstr)) == 0);
} while (dest == lastInstr);
// alternative chosen -- now store the necessary details
std::ostringstream oss;
@ -136,6 +136,13 @@ void BochsALUInstructions::randomEquivalent(bxInstruction_c &result,
if (dest.opcodeRegisterOffset < BochsALUInstr::REG_COUNT) {
result.setRm(dest.opcodeRegisterOffset);
}
if (memcmp(&result, &lastOrigInstr, sizeof(bxInstruction_c)) == 0) {
fprintf(stderr,"randomEquivalent failed\n");
scanf("%*s");
}
return 0;
}
#ifdef DEBUG