diff --git a/SMPInstr.cpp b/SMPInstr.cpp index 4304cdaad19a4d0d6e807cf6047ba45e0c359c62..99ce1556fd41dbb1728914fa05b0c85b96095181 100644 --- a/SMPInstr.cpp +++ b/SMPInstr.cpp @@ -637,7 +637,8 @@ void SMPInstr::Analyze(void) { // Fill the Defs and Uses private data members. void SMPInstr::BuildSMPDefUseLists(void) { size_t OpNum; - + bool DebugFlag = (0x804837b == this->GetAddr()); + this->Defs.clear(); this->Uses.clear(); @@ -646,6 +647,11 @@ void SMPInstr::BuildSMPDefUseLists(void) { if (this->features & DefMacros[OpNum]) { // DEF op_t TempOp = this->SMPcmd.Operands[OpNum]; if (MDKnownOperandType(TempOp)) { + if (DebugFlag) { + msg("DEBUG: Setting DEF for: "); + PrintOperand(TempOp); + msg("\n"); + } if (o_reg == TempOp.type) { // We want to map AH, AL, and AX to EAX, etc. throughout our data flow // analysis and type inference systems. @@ -672,6 +678,11 @@ void SMPInstr::BuildSMPDefUseLists(void) { if (this->features & UseMacros[OpNum]) { // USE op_t TempOp = this->SMPcmd.Operands[OpNum]; if (MDKnownOperandType(TempOp)) { + if (DebugFlag) { + msg("DEBUG: Setting USE for: "); + PrintOperand(TempOp); + msg("\n"); + } if (o_reg == TempOp.type) { // We want to map AH, AL, and AX to EAX, etc. throughout our data flow // analysis and type inference systems. @@ -720,11 +731,19 @@ void SMPInstr::MDFixupDefUseLists(void) { // care whether we are dealing with a memory destination operand or source // operand, because register USEs, not DEFs, happen within the addressing expressions. size_t OpNum; - bool DebugFlag = (this->GetAddr() == 0x80482b8); + bool DebugFlag = (this->GetAddr() == 0x804837b); + if (DebugFlag) { + msg("DEBUG: Fixing up DEF-USE lists for debug location\n"); + this->Dump(); + } + for (OpNum = 0; OpNum < UA_MAXOP; ++OpNum) { op_t Opnd = SMPcmd.Operands[OpNum]; if ((Opnd.type == o_phrase) || (Opnd.type == o_displ) || (Opnd.type == o_mem)) { if (Opnd.hasSIB) { + if (DebugFlag) { + msg("DEBUG: hasSIB\n"); + } int BaseReg = sib_base(Opnd); short IndexReg = sib_index(Opnd); if (R_none != BaseReg) { @@ -769,11 +788,11 @@ void SMPInstr::MDFixupDefUseLists(void) { BaseOpnd.reg = BaseReg; BaseOpnd.hasSIB = 0; BaseOpnd.set_showed(); - if (BaseOpnd.is_reg(R_bp) && (Opnd.type == o_mem)) { - if (DebugFlag) msg("EBP base reg ignored at %x\n", this->GetAddr()); + if (Opnd.type == o_mem) { + if (!BaseOpnd.is_reg(0)) msg("base reg %d ignored at %x\n", + BaseOpnd.reg, this->GetAddr()); } else { - if (DebugFlag) msg("base reg %d not ignored at %x\n", BaseReg, this->GetAddr()); // We want to map AH, AL, and AX to EAX, etc. throughout our data flow // analysis and type inference systems. BaseOpnd.reg = MDCanonicalizeSubReg(BaseOpnd.reg); @@ -923,6 +942,10 @@ void SMPInstr::MDFixupDefUseLists(void) { } #endif + if (DebugFlag) { + msg("DEBUG after MDFixupDefuseLists:\n"); + this->Dump(); + } return; } // end of SMPInstr::MDFixupDefUseLists()