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