From d9998269effa50ec4b83f3ad22ec52b90dfb0543 Mon Sep 17 00:00:00 2001 From: Stanislav Shwartsman Date: Tue, 24 Jul 2012 15:32:55 +0000 Subject: [PATCH] added branch_eip into near branch instructiontation callbacks --- bochs/cpu/cpu.h | 2 + bochs/cpu/ctrl_xfer16.cc | 104 ++++++++++++------------ bochs/cpu/ctrl_xfer32.cc | 104 ++++++++++++------------ bochs/cpu/ctrl_xfer64.cc | 104 ++++++++++++------------ bochs/instrument/example0/instrument.cc | 15 ++-- bochs/instrument/example0/instrument.h | 24 +++--- bochs/instrument/example1/instrument.cc | 15 ++-- bochs/instrument/example1/instrument.h | 24 +++--- bochs/instrument/example2/instrument.cc | 2 +- bochs/instrument/example2/instrument.h | 18 ++-- bochs/instrument/instrumentation.txt | 6 +- bochs/instrument/stubs/instrument.cc | 8 +- bochs/instrument/stubs/instrument.h | 24 +++--- 13 files changed, 225 insertions(+), 225 deletions(-) diff --git a/bochs/cpu/cpu.h b/bochs/cpu/cpu.h index d6cf86e49..03a930175 100644 --- a/bochs/cpu/cpu.h +++ b/bochs/cpu/cpu.h @@ -163,6 +163,8 @@ #define TMP64 (BX_CPU_THIS_PTR gen_reg[BX_TMP_REGISTER].rrx) +#define PREV_RIP (BX_CPU_THIS_PTR prev_rip) + // access to 64 bit MSR registers #define MSR_FSBASE (BX_CPU_THIS_PTR sregs[BX_SEG_REG_FS].cache.u.segment.base) #define MSR_GSBASE (BX_CPU_THIS_PTR sregs[BX_SEG_REG_GS].cache.u.segment.base) diff --git a/bochs/cpu/ctrl_xfer16.cc b/bochs/cpu/ctrl_xfer16.cc index 7d419b058..371d6160e 100644 --- a/bochs/cpu/ctrl_xfer16.cc +++ b/bochs/cpu/ctrl_xfer16.cc @@ -72,7 +72,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear16_Iw(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -99,7 +99,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear16(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -166,7 +166,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CALL_Jw(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -229,7 +229,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CALL_EwR(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL_INDIRECT, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL_INDIRECT, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -282,7 +282,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JMP_Jw(bxInstruction_c *i) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP, new_IP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } @@ -292,11 +292,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JO_Jw(bxInstruction_c *i) if (get_OF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -305,11 +305,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNO_Jw(bxInstruction_c *i) if (! get_OF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -318,11 +318,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JB_Jw(bxInstruction_c *i) if (get_CF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -331,11 +331,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNB_Jw(bxInstruction_c *i) if (! get_CF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -344,11 +344,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JZ_Jw(bxInstruction_c *i) if (get_ZF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -357,11 +357,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNZ_Jw(bxInstruction_c *i) if (! get_ZF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -370,11 +370,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JBE_Jw(bxInstruction_c *i) if (get_CF() || get_ZF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -383,11 +383,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNBE_Jw(bxInstruction_c *i) if (! (get_CF() || get_ZF())) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -396,11 +396,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JS_Jw(bxInstruction_c *i) if (get_SF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -409,11 +409,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNS_Jw(bxInstruction_c *i) if (! get_SF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -422,11 +422,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JP_Jw(bxInstruction_c *i) if (get_PF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -435,11 +435,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNP_Jw(bxInstruction_c *i) if (! get_PF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -448,11 +448,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JL_Jw(bxInstruction_c *i) if (getB_SF() != getB_OF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -461,11 +461,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNL_Jw(bxInstruction_c *i) if (getB_SF() == getB_OF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -474,11 +474,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JLE_Jw(bxInstruction_c *i) if (get_ZF() || (getB_SF() != getB_OF())) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -487,11 +487,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNLE_Jw(bxInstruction_c *i) if (! get_ZF() && (getB_SF() == getB_OF())) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -499,7 +499,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JMP_EwR(bxInstruction_c *i) { Bit16u new_IP = BX_READ_16BIT_REG(i->rm()); branch_near16(new_IP); - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP_INDIRECT, new_IP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP_INDIRECT, PREV_RIP, new_IP); BX_NEXT_TRACE(i); } @@ -605,11 +605,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JCXZ_Jb(bxInstruction_c *i) if (temp_ECX == 0) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -638,11 +638,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE16_Jb(bxInstruction_c *i) if (count != 0 && (get_ZF()==0)) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -655,11 +655,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE16_Jb(bxInstruction_c *i) if (count != 0 && (get_ZF()==0)) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -681,11 +681,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE16_Jb(bxInstruction_c *i) if (count != 0 && get_ZF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -698,11 +698,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE16_Jb(bxInstruction_c *i) if (count != 0 && get_ZF()) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -724,11 +724,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP16_Jb(bxInstruction_c *i) if (count != 0) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -741,11 +741,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP16_Jb(bxInstruction_c *i) if (count != 0) { Bit16u new_IP = IP + i->Iw(); branch_near16(new_IP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_IP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_IP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif diff --git a/bochs/cpu/ctrl_xfer32.cc b/bochs/cpu/ctrl_xfer32.cc index f85160724..f97f6aa16 100644 --- a/bochs/cpu/ctrl_xfer32.cc +++ b/bochs/cpu/ctrl_xfer32.cc @@ -71,7 +71,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear32_Iw(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -96,7 +96,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear32(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -164,7 +164,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CALL_Jd(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -230,7 +230,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CALL_EdR(bxInstruction_c *i) RSP_COMMIT; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL_INDIRECT, EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL_INDIRECT, PREV_RIP, EIP); BX_NEXT_TRACE(i); } @@ -284,7 +284,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JMP_Jd(bxInstruction_c *i) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP, new_EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } @@ -294,11 +294,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JO_Jd(bxInstruction_c *i) if (get_OF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -307,11 +307,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNO_Jd(bxInstruction_c *i) if (! get_OF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -320,11 +320,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JB_Jd(bxInstruction_c *i) if (get_CF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -333,11 +333,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNB_Jd(bxInstruction_c *i) if (! get_CF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -346,11 +346,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JZ_Jd(bxInstruction_c *i) if (get_ZF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -359,11 +359,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNZ_Jd(bxInstruction_c *i) if (! get_ZF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -372,11 +372,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JBE_Jd(bxInstruction_c *i) if (get_CF() || get_ZF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -385,11 +385,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNBE_Jd(bxInstruction_c *i) if (! (get_CF() || get_ZF())) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -398,11 +398,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JS_Jd(bxInstruction_c *i) if (get_SF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -411,11 +411,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNS_Jd(bxInstruction_c *i) if (! get_SF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -424,11 +424,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JP_Jd(bxInstruction_c *i) if (get_PF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -437,11 +437,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNP_Jd(bxInstruction_c *i) if (! get_PF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -450,11 +450,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JL_Jd(bxInstruction_c *i) if (getB_SF() != getB_OF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -463,11 +463,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNL_Jd(bxInstruction_c *i) if (getB_SF() == getB_OF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -476,11 +476,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JLE_Jd(bxInstruction_c *i) if (get_ZF() || (getB_SF() != getB_OF())) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -489,11 +489,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNLE_Jd(bxInstruction_c *i) if (! get_ZF() && (getB_SF() == getB_OF())) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -540,7 +540,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JMP_EdR(bxInstruction_c *i) { Bit32u new_EIP = BX_READ_32BIT_REG(i->rm()); branch_near32(new_EIP); - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP_INDIRECT, new_EIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP_INDIRECT, PREV_RIP, new_EIP); BX_NEXT_TRACE(i); } @@ -648,11 +648,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JECXZ_Jb(bxInstruction_c *i) if (temp_ECX == 0) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -681,11 +681,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE32_Jb(bxInstruction_c *i) if (count != 0 && (get_ZF()==0)) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -698,11 +698,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE32_Jb(bxInstruction_c *i) if (count != 0 && (get_ZF()==0)) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -724,11 +724,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE32_Jb(bxInstruction_c *i) if (count != 0 && get_ZF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -741,11 +741,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE32_Jb(bxInstruction_c *i) if (count != 0 && get_ZF()) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -767,11 +767,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP32_Jb(bxInstruction_c *i) if (count != 0) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -784,11 +784,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP32_Jb(bxInstruction_c *i) if (count != 0) { Bit32u new_EIP = EIP + (Bit32s) i->Id(); branch_near32(new_EIP); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, new_EIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, new_EIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif diff --git a/bochs/cpu/ctrl_xfer64.cc b/bochs/cpu/ctrl_xfer64.cc index 2d08716e8..15158bcdb 100644 --- a/bochs/cpu/ctrl_xfer64.cc +++ b/bochs/cpu/ctrl_xfer64.cc @@ -59,7 +59,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear64_Iw(bxInstruction_c *i) RIP = return_RIP; RSP += 8 + i->Iw(); - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, RIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, RIP); BX_NEXT_TRACE(i); } @@ -80,7 +80,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::RETnear64(bxInstruction_c *i) RIP = return_RIP; RSP += 8; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, RIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_RET, PREV_RIP, RIP); BX_NEXT_TRACE(i); } @@ -123,7 +123,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CALL_Jq(bxInstruction_c *i) RIP = new_RIP; RSP -= 8; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL, RIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL, PREV_RIP, RIP); BX_NEXT_TRACE(i); } @@ -148,7 +148,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::CALL_EqR(bxInstruction_c *i) RIP = new_RIP; RSP -= 8; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL_INDIRECT, RIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_CALL_INDIRECT, PREV_RIP, RIP); BX_NEXT_TRACE(i); } @@ -189,7 +189,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JMP_Jq(bxInstruction_c *i) RIP = new_RIP; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP, RIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP, PREV_RIP, RIP); BX_NEXT_TRACE(i); } @@ -198,11 +198,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JO_Jq(bxInstruction_c *i) { if (get_OF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -210,11 +210,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNO_Jq(bxInstruction_c *i) { if (! get_OF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -222,11 +222,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JB_Jq(bxInstruction_c *i) { if (get_CF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -234,11 +234,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNB_Jq(bxInstruction_c *i) { if (! get_CF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -246,11 +246,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JZ_Jq(bxInstruction_c *i) { if (get_ZF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -258,11 +258,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNZ_Jq(bxInstruction_c *i) { if (! get_ZF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -270,11 +270,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JBE_Jq(bxInstruction_c *i) { if (get_CF() || get_ZF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -282,11 +282,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNBE_Jq(bxInstruction_c *i) { if (! (get_CF() || get_ZF())) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -294,11 +294,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JS_Jq(bxInstruction_c *i) { if (get_SF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -306,11 +306,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNS_Jq(bxInstruction_c *i) { if (! get_SF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -318,11 +318,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JP_Jq(bxInstruction_c *i) { if (get_PF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -330,11 +330,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNP_Jq(bxInstruction_c *i) { if (! get_PF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -342,11 +342,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JL_Jq(bxInstruction_c *i) { if (getB_SF() != getB_OF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -354,11 +354,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNL_Jq(bxInstruction_c *i) { if (getB_SF() == getB_OF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -366,11 +366,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JLE_Jq(bxInstruction_c *i) { if (get_ZF() || (getB_SF() != getB_OF())) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -378,11 +378,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JNLE_Jq(bxInstruction_c *i) { if (! get_ZF() && (getB_SF() == getB_OF())) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); BX_NEXT_TRACE(i); } - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); BX_NEXT_INSTR(i); // trace can continue over non-taken branch } @@ -397,7 +397,7 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JMP_EqR(bxInstruction_c *i) RIP = op1_64; - BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP_INDIRECT, RIP); + BX_INSTR_UCNEAR_BRANCH(BX_CPU_ID, BX_INSTR_IS_JMP_INDIRECT, PREV_RIP, RIP); BX_NEXT_TRACE(i); } @@ -456,11 +456,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::JRCXZ_Jb(bxInstruction_c *i) if (temp_RCX == 0) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -484,11 +484,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE64_Jb(bxInstruction_c *i) if (((--count) != 0) && (get_ZF()==0)) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -499,11 +499,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPNE64_Jb(bxInstruction_c *i) if (((--count) != 0) && (get_ZF()==0)) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -520,11 +520,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE64_Jb(bxInstruction_c *i) if (((--count) != 0) && get_ZF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -535,11 +535,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOPE64_Jb(bxInstruction_c *i) if (((--count) != 0) && get_ZF()) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -556,11 +556,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP64_Jb(bxInstruction_c *i) if ((--count) != 0) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif @@ -571,11 +571,11 @@ BX_INSF_TYPE BX_CPP_AttrRegparmN(1) BX_CPU_C::LOOP64_Jb(bxInstruction_c *i) if ((--count) != 0) { branch_near64(i); - BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, RIP); + BX_INSTR_CNEAR_BRANCH_TAKEN(BX_CPU_ID, PREV_RIP, RIP); } #if BX_INSTRUMENTATION else { - BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID); + BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(BX_CPU_ID, PREV_RIP); } #endif diff --git a/bochs/instrument/example0/instrument.cc b/bochs/instrument/example0/instrument.cc index 10ba0c6e8..d87f975b7 100644 --- a/bochs/instrument/example0/instrument.cc +++ b/bochs/instrument/example0/instrument.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006-2009 Stanislav Shwartsman +// Copyright (c) 2006-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -147,20 +147,19 @@ static void branch_taken(unsigned cpu, bx_address new_eip) { if (!active || !instruction[cpu].ready) return; - // find linear address - bx_address laddr = BX_CPU(cpu)->get_laddr(BX_SEG_REG_CS, new_eip); - instruction[cpu].is_branch = 1; instruction[cpu].is_taken = 1; - instruction[cpu].target_linear = laddr; + + // find linear address + instruction[cpu].target_linear = BX_CPU(cpu)->get_laddr(BX_SEG_REG_CS, new_eip); } -void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip) +void bx_instr_cnear_branch_taken(unsigned cpu, bx_address branch_eip, bx_address new_eip) { branch_taken(cpu, new_eip); } -void bx_instr_cnear_branch_not_taken(unsigned cpu) +void bx_instr_cnear_branch_not_taken(unsigned cpu, bx_address branch_eip) { if (!active || !instruction[cpu].ready) return; @@ -168,7 +167,7 @@ void bx_instr_cnear_branch_not_taken(unsigned cpu) instruction[cpu].is_taken = 0; } -void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip) +void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address branch_eip, bx_address new_eip) { branch_taken(cpu, new_eip); } diff --git a/bochs/instrument/example0/instrument.h b/bochs/instrument/example0/instrument.h index f6cbf4388..59f24ca88 100644 --- a/bochs/instrument/example0/instrument.h +++ b/bochs/instrument/example0/instrument.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006-2009 Stanislav Shwartsman +// Copyright (c) 2006-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -34,9 +34,9 @@ void bx_instr_exit_env(void); void bx_instr_initialize(unsigned cpu); void bx_instr_reset(unsigned cpu, unsigned type); -void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip); -void bx_instr_cnear_branch_not_taken(unsigned cpu); -void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip); +void bx_instr_cnear_branch_taken(unsigned cpu, bx_address branch_eip, bx_address new_eip); +void bx_instr_cnear_branch_not_taken(unsigned cpu, bx_address branch_eip); +void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address branch_eip, bx_address new_eip); void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address new_eip); void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i); @@ -63,10 +63,10 @@ void bx_instr_lin_access(unsigned cpu, bx_address lin, bx_phy_address phy, unsig #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) bx_instr_cnear_branch_taken(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) bx_instr_cnear_branch_not_taken(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) bx_instr_ucnear_branch(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) bx_instr_cnear_branch_taken(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) bx_instr_cnear_branch_not_taken(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) bx_instr_ucnear_branch(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) bx_instr_far_branch(cpu_id, what, new_cs, new_eip) /* decoding completed */ @@ -121,10 +121,10 @@ void bx_instr_lin_access(unsigned cpu, bx_address lin, bx_phy_address phy, unsig #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) /* decoding completed */ diff --git a/bochs/instrument/example1/instrument.cc b/bochs/instrument/example1/instrument.cc index f1b3261c3..35912775a 100644 --- a/bochs/instrument/example1/instrument.cc +++ b/bochs/instrument/example1/instrument.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006-2009 Stanislav Shwartsman +// Copyright (c) 2006-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -117,20 +117,19 @@ void bxInstrumentation::branch_taken(bx_address new_eip) { if (!active || !ready) return; - // find linear address - bx_address laddr = BX_CPU(cpu_id)->get_laddr(BX_SEG_REG_CS, new_eip); - is_branch = 1; is_taken = 1; - target_linear = laddr; + + // find linear address + target_linear = BX_CPU(cpu_id)->get_laddr(BX_SEG_REG_CS, new_eip); } -void bxInstrumentation::bx_instr_cnear_branch_taken(bx_address new_eip) +void bxInstrumentation::bx_instr_cnear_branch_taken(bx_address branch_eip, bx_address new_eip) { branch_taken(new_eip); } -void bxInstrumentation::bx_instr_cnear_branch_not_taken() +void bxInstrumentation::bx_instr_cnear_branch_not_taken(bx_address branch_eip) { if (!active || !ready) return; @@ -138,7 +137,7 @@ void bxInstrumentation::bx_instr_cnear_branch_not_taken() is_taken = 0; } -void bxInstrumentation::bx_instr_ucnear_branch(unsigned what, bx_address new_eip) +void bxInstrumentation::bx_instr_ucnear_branch(unsigned what, bx_address branch_eip, bx_address new_eip) { branch_taken(new_eip); } diff --git a/bochs/instrument/example1/instrument.h b/bochs/instrument/example1/instrument.h index 5bde02f3e..0c97b3ba2 100644 --- a/bochs/instrument/example1/instrument.h +++ b/bochs/instrument/example1/instrument.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006-2009 Stanislav Shwartsman +// Copyright (c) 2006-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -75,9 +75,9 @@ public: void bx_instr_reset(unsigned type); - void bx_instr_cnear_branch_taken(bx_address new_eip); - void bx_instr_cnear_branch_not_taken(); - void bx_instr_ucnear_branch(unsigned what, bx_address new_eip); + void bx_instr_cnear_branch_taken(bx_address branch_eip, bx_address new_eip); + void bx_instr_cnear_branch_not_taken(bx_address branch_eip); + void bx_instr_ucnear_branch(unsigned what, bx_address branch_eip, bx_address new_eip); void bx_instr_far_branch(unsigned what, Bit16u new_cs, bx_address new_eip); void bx_instr_before_execution(bxInstruction_c *i); @@ -114,10 +114,10 @@ extern bxInstrumentation *icpu; #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) icpu[cpu_id].bx_instr_cnear_branch_taken(new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) icpu[cpu_id].bx_instr_cnear_branch_not_taken() -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) icpu[cpu_id].bx_instr_ucnear_branch(what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) icpu[cpu_id].bx_instr_cnear_branch_taken(branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) icpu[cpu_id].bx_instr_cnear_branch_not_taken(branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) icpu[cpu_id].bx_instr_ucnear_branch(what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) icpu[cpu_id].bx_instr_far_branch(what, new_cs, new_eip) /* decoding completed */ @@ -172,10 +172,10 @@ extern bxInstrumentation *icpu; #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) /* decoding completed */ diff --git a/bochs/instrument/example2/instrument.cc b/bochs/instrument/example2/instrument.cc index 7b5053e0c..6a3999b2c 100755 --- a/bochs/instrument/example2/instrument.cc +++ b/bochs/instrument/example2/instrument.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2009 Stanislav Shwartsman +// Copyright (c) 2009-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or diff --git a/bochs/instrument/example2/instrument.h b/bochs/instrument/example2/instrument.h index db22edcc8..c6666e9ee 100755 --- a/bochs/instrument/example2/instrument.h +++ b/bochs/instrument/example2/instrument.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2009 Stanislav Shwartsman +// Copyright (c) 2009-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -53,10 +53,10 @@ void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i); #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) /* decoding completed */ @@ -113,10 +113,10 @@ void bx_instr_before_execution(unsigned cpu, bxInstruction_c *i); #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) /* decoding completed */ diff --git a/bochs/instrument/instrumentation.txt b/bochs/instrument/instrumentation.txt index 74a9e6f09..a87c0dd03 100644 --- a/bochs/instrument/instrumentation.txt +++ b/bochs/instrument/instrumentation.txt @@ -66,19 +66,19 @@ state. The callback receives monitored memory range and MWAIT flags as a parameters. - void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip); + void bx_instr_cnear_branch_taken(unsigned cpu, bx_address branch_eip, bx_address new_eip); The callback is called each time, when currently executed instruction is a conditional near branch and it is taken. - void bx_instr_cnear_branch_not_taken(unsigned cpu); + void bx_instr_cnear_branch_not_taken(unsigned cpu, bx_address branch_eip); The callback is called each time, when currently executed instruction is a conditional near branch and it is not taken. - void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip); + void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address branch_eip, bx_address new_eip); The callback is called each time, when currently executed instruction is an unconditional near branch (always taken). diff --git a/bochs/instrument/stubs/instrument.cc b/bochs/instrument/stubs/instrument.cc index 2157362c1..050eb864d 100644 --- a/bochs/instrument/stubs/instrument.cc +++ b/bochs/instrument/stubs/instrument.cc @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006-2009 Stanislav Shwartsman +// Copyright (c) 2006-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -36,9 +36,9 @@ void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flag void bx_instr_debug_promt() {} void bx_instr_debug_cmd(const char *cmd) {} -void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip) {} -void bx_instr_cnear_branch_not_taken(unsigned cpu) {} -void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip) {} +void bx_instr_cnear_branch_taken(unsigned cpu, bx_address branch_eip, bx_address new_eip) {} +void bx_instr_cnear_branch_not_taken(unsigned cpu, bx_address branch_eip) {} +void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address branch_eip, bx_address new_eip) {} void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address new_eip) {} void bx_instr_opcode(unsigned cpu, const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64) {} diff --git a/bochs/instrument/stubs/instrument.h b/bochs/instrument/stubs/instrument.h index b4bb03a33..165912bb0 100644 --- a/bochs/instrument/stubs/instrument.h +++ b/bochs/instrument/stubs/instrument.h @@ -2,7 +2,7 @@ // $Id$ ///////////////////////////////////////////////////////////////////////// // -// Copyright (c) 2006-2009 Stanislav Shwartsman +// Copyright (c) 2006-2012 Stanislav Shwartsman // Written by Stanislav Shwartsman [sshwarts at sourceforge net] // // This library is free software; you can redistribute it and/or @@ -40,9 +40,9 @@ void bx_instr_mwait(unsigned cpu, bx_phy_address addr, unsigned len, Bit32u flag void bx_instr_debug_promt(); void bx_instr_debug_cmd(const char *cmd); -void bx_instr_cnear_branch_taken(unsigned cpu, bx_address new_eip); -void bx_instr_cnear_branch_not_taken(unsigned cpu); -void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address new_eip); +void bx_instr_cnear_branch_taken(unsigned cpu, bx_address branch_eip, bx_address new_eip); +void bx_instr_cnear_branch_not_taken(unsigned cpu, bx_address branch_eip); +void bx_instr_ucnear_branch(unsigned cpu, unsigned what, bx_address branch_eip, bx_address new_eip); void bx_instr_far_branch(unsigned cpu, unsigned what, Bit16u new_cs, bx_address new_eip); void bx_instr_opcode(unsigned cpu, bxInstruction_c *i, const Bit8u *opcode, unsigned len, bx_bool is32, bx_bool is64); @@ -86,10 +86,10 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); #define BX_INSTR_DEBUG_PROMPT() bx_instr_debug_promt() #define BX_INSTR_DEBUG_CMD(cmd) bx_instr_debug_cmd(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) bx_instr_cnear_branch_taken(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) bx_instr_cnear_branch_not_taken(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) bx_instr_ucnear_branch(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) bx_instr_cnear_branch_taken(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) bx_instr_cnear_branch_not_taken(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) bx_instr_ucnear_branch(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) bx_instr_far_branch(cpu_id, what, new_cs, new_eip) /* decoding completed */ @@ -146,10 +146,10 @@ void bx_instr_wrmsr(unsigned cpu, unsigned addr, Bit64u value); #define BX_INSTR_DEBUG_PROMPT() #define BX_INSTR_DEBUG_CMD(cmd) -/* branch resoultion */ -#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, new_eip) -#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id) -#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, new_eip) +/* branch resolution */ +#define BX_INSTR_CNEAR_BRANCH_TAKEN(cpu_id, branch_eip, new_eip) +#define BX_INSTR_CNEAR_BRANCH_NOT_TAKEN(cpu_id, branch_eip) +#define BX_INSTR_UCNEAR_BRANCH(cpu_id, what, branch_eip, new_eip) #define BX_INSTR_FAR_BRANCH(cpu_id, what, new_cs, new_eip) /* decoding completed */