1/* 2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. 3 * Copyright 2011-2012, Rene Gollent, rene@gollent.com. 4 * Distributed under the terms of the MIT License. 5 */ 6#ifndef ARCHITECTURE_X86_H 7#define ARCHITECTURE_X86_H 8 9 10#include <Array.h> 11 12#include "Architecture.h" 13#include "Register.h" 14 15 16class SourceLanguage; 17 18 19class ArchitectureX86 : public Architecture { 20public: 21 ArchitectureX86(TeamMemory* teamMemory); 22 virtual ~ArchitectureX86(); 23 24 virtual status_t Init(); 25 26 virtual int32 StackGrowthDirection() const; 27 28 virtual int32 CountRegisters() const; 29 virtual const Register* Registers() const; 30 virtual status_t InitRegisterRules(CfaContext& context) const; 31 32 virtual status_t GetDwarfRegisterMaps(RegisterMap** _toDwarf, 33 RegisterMap** _fromDwarf) const; 34 35 virtual status_t CreateCpuState(CpuState*& _state); 36 virtual status_t CreateCpuState(const void* cpuStateData, 37 size_t size, CpuState*& _state); 38 virtual status_t CreateStackFrame(Image* image, 39 FunctionDebugInfo* function, 40 CpuState* cpuState, bool isTopFrame, 41 StackFrame*& _previousFrame, 42 CpuState*& _previousCpuState); 43 virtual void UpdateStackFrameCpuState( 44 const StackFrame* frame, 45 Image* previousImage, 46 FunctionDebugInfo* previousFunction, 47 CpuState* previousCpuState); 48 49 virtual status_t ReadValueFromMemory(target_addr_t address, 50 uint32 valueType, BVariant& _value) const; 51 virtual status_t ReadValueFromMemory(target_addr_t addressSpace, 52 target_addr_t address, uint32 valueType, 53 BVariant& _value) const; 54 55 virtual status_t DisassembleCode(FunctionDebugInfo* function, 56 const void* buffer, size_t bufferSize, 57 DisassembledCode*& _sourceCode); 58 virtual status_t GetStatement(FunctionDebugInfo* function, 59 target_addr_t address, 60 Statement*& _statement); 61 virtual status_t GetInstructionInfo(target_addr_t address, 62 InstructionInfo& _info, CpuState* state); 63 64 virtual status_t GetWatchpointDebugCapabilities( 65 int32& _maxRegisterCount, 66 int32& _maxBytesPerRegister, 67 uint8& _watchpointCapabilityFlags); 68 69 virtual status_t GetReturnAddressLocation( 70 StackFrame* frame, target_size_t valueSize, 71 ValueLocation*& _location); 72 73 74private: 75 struct ToDwarfRegisterMap; 76 struct FromDwarfRegisterMap; 77 78private: 79 void _AddRegister(int32 index, const char* name, 80 uint32 bitSize, uint32 valueType, 81 register_type type, bool calleePreserved); 82 void _AddIntegerRegister(int32 index, 83 const char* name, uint32 valueType, 84 register_type type, bool calleePreserved); 85 86 bool _HasFunctionPrologue( 87 FunctionDebugInfo* function) const; 88 89private: 90 Array<Register> fRegisters; 91 SourceLanguage* fAssemblyLanguage; 92 ToDwarfRegisterMap* fToDwarfRegisterMap; 93 FromDwarfRegisterMap* fFromDwarfRegisterMap; 94}; 95 96 97#endif // ARCHITECTURE_X86_H 98