1/* 2 * Copyright 2009-2012, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2011, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6#ifndef CPU_STATE_X86_H 7#define CPU_STATE_X86_H 8 9#include <bitset> 10 11#include <debugger.h> 12 13#include "CpuState.h" 14 15 16enum { 17 X86_REGISTER_EIP = 0, 18 X86_REGISTER_ESP, 19 X86_REGISTER_EBP, 20 21 X86_REGISTER_EAX, 22 X86_REGISTER_EBX, 23 X86_REGISTER_ECX, 24 X86_REGISTER_EDX, 25 26 X86_REGISTER_ESI, 27 X86_REGISTER_EDI, 28 29 X86_REGISTER_CS, 30 X86_REGISTER_DS, 31 X86_REGISTER_ES, 32 X86_REGISTER_FS, 33 X86_REGISTER_GS, 34 X86_REGISTER_SS, 35 36 X86_INT_REGISTER_END, 37 X86_REGISTER_COUNT 38}; 39 40 41class CpuStateX86 : public CpuState { 42public: 43 CpuStateX86(); 44 CpuStateX86(const x86_debug_cpu_state& state); 45 virtual ~CpuStateX86(); 46 47 virtual target_addr_t InstructionPointer() const; 48 virtual target_addr_t StackFramePointer() const; 49 virtual target_addr_t StackPointer() const; 50 virtual bool GetRegisterValue(const Register* reg, 51 BVariant& _value) const; 52 virtual bool SetRegisterValue(const Register* reg, 53 const BVariant& value); 54 55 uint32 InterruptVector() const 56 { return fInterruptVector; } 57 58 bool IsRegisterSet(int32 index) const; 59 uint32 IntRegisterValue(int32 index) const; 60 void SetIntRegister(int32 index, uint32 value); 61 void UnsetRegister(int32 index); 62 63private: 64 typedef std::bitset<X86_REGISTER_COUNT> RegisterBitSet; 65 66private: 67 uint32 fIntRegisters[X86_REGISTER_COUNT]; 68 RegisterBitSet fSetRegisters; 69 uint32 fInterruptVector; 70}; 71 72 73#endif // CPU_STATE_X86_H 74