diff --git a/core/SAL/Register.hpp b/core/SAL/Register.hpp index 193af1cc..b42a05dc 100644 --- a/core/SAL/Register.hpp +++ b/core/SAL/Register.hpp @@ -1,9 +1,6 @@ #ifndef __REGISTER_HPP__ #define __REGISTER_HPP__ -// Author: Adrian Böckenkamp -// Date: 06.09.2011 - #include #include #include @@ -272,6 +269,14 @@ class RegisterManager * @return the base pointer */ virtual address_t getBasePointer() = 0; + /** + * Retrieves the textual description (mnemoric) for the current + * instruction. + * The format of the returned string is simulator-specific. + * @return the mnemoric of the current instruction whose address + * is given by \c getInstructionPointer(). + */ + virtual const std::string& getMnemoric() const = 0; }; } // end-of-namespace: sal diff --git a/core/SAL/bochs/BochsRegister.hpp b/core/SAL/bochs/BochsRegister.hpp index 60374dc8..01a77b37 100644 --- a/core/SAL/bochs/BochsRegister.hpp +++ b/core/SAL/bochs/BochsRegister.hpp @@ -4,7 +4,9 @@ #include "../Register.hpp" #include "../../../bochs/bochs.h" + #include +#include namespace sal { @@ -237,6 +239,27 @@ class BochsRegisterManager : public RegisterManager return (static_cast(getRegister(RID_EBP)->getData())); #endif } + /** + * Retrieves the textual description (mnemoric) for the current + * instruction. The format of the returned string is Bochs-specific. + * @return the mnemoric of the current instruction whose address + * is given by \c getInstructionPointer(). On errors, the + * returned string is empty + */ + const std::string& getMnemoric() const + { + static std::string str; + bxICacheEntry_c* pEntry = BX_CPU(0)->getICacheEntry(); + assert(pEntry != NULL && "FATAL ERROR: Bochs internal function returned NULL (not expected)!"); + bxInstruction_c* pInstr = pEntry->i; + assert(pInstr != NULL && "FATAL ERROR: Bochs internal member was NULL (not expected)!"); + const char* pszName = get_bx_opcode_name(pInstr->getIaOpcode()); + if (pszName != NULL) + str = pszName; + else + str.clear(); + return str; + } }; } // end-of-namespace: sal