xref: /haiku/src/kits/debugger/arch/x86_64/ArchitectureX8664.h (revision fce4895d1884da5ae6fb299d23c735c598e690b1)
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 class SourceLanguage;
18 
19 
20 class ArchitectureX8664 : public Architecture {
21 public:
22 								ArchitectureX8664(TeamMemory* teamMemory);
23 	virtual						~ArchitectureX8664();
24 
25 	virtual	status_t			Init();
26 
27 	virtual int32				StackGrowthDirection() const;
28 
29 	virtual	int32				CountRegisters() const;
30 	virtual	const Register*		Registers() const;
31 	virtual status_t			InitRegisterRules(CfaContext& context) const;
32 
33 	virtual	status_t			GetDwarfRegisterMaps(RegisterMap** _toDwarf,
34 									RegisterMap** _fromDwarf) const;
35 
36 	virtual	status_t			GetCpuFeatures(uint32& flags);
37 
38 	virtual	status_t			CreateCpuState(CpuState*& _state);
39 	virtual	status_t			CreateCpuState(const void* cpuStateData,
40 									size_t size, CpuState*& _state);
41 	virtual	status_t			CreateStackFrame(Image* image,
42 									FunctionDebugInfo* function,
43 									CpuState* cpuState, bool isTopFrame,
44 									StackFrame*& _previousFrame,
45 									CpuState*& _previousCpuState);
46 	virtual	void				UpdateStackFrameCpuState(
47 									const StackFrame* frame,
48 									Image* previousImage,
49 									FunctionDebugInfo* previousFunction,
50 									CpuState* previousCpuState);
51 
52 	virtual	status_t			ReadValueFromMemory(target_addr_t address,
53 									uint32 valueType, BVariant& _value) const;
54 	virtual	status_t			ReadValueFromMemory(target_addr_t addressSpace,
55 									target_addr_t address, uint32 valueType,
56 									BVariant& _value) const;
57 
58 	virtual	status_t			DisassembleCode(FunctionDebugInfo* function,
59 									const void* buffer, size_t bufferSize,
60 									DisassembledCode*& _sourceCode);
61 	virtual	status_t			GetStatement(FunctionDebugInfo* function,
62 									target_addr_t address,
63 									Statement*& _statement);
64 	virtual	status_t			GetInstructionInfo(target_addr_t address,
65 									InstructionInfo& _info, CpuState* state);
66 	virtual	status_t			ResolvePICFunctionAddress(target_addr_t
67 									instructionAddress,
68 									CpuState* state,
69 									target_addr_t& _targetAddress);
70 
71 	virtual	status_t			GetWatchpointDebugCapabilities(
72 									int32& _maxRegisterCount,
73 									int32& _maxBytesPerRegister,
74 									uint8& _watchpointCapabilityFlags);
75 
76 	virtual	status_t			GetReturnAddressLocation(
77 									StackFrame* frame, target_size_t valueSize,
78 									ValueLocation*& _location);
79 
80 private:
81 			struct ToDwarfRegisterMap;
82 			struct FromDwarfRegisterMap;
83 
84 private:
85 			void				_AddRegister(int32 index, const char* name,
86 									uint32 bitSize, uint32 valueType,
87 									register_type type, bool calleePreserved);
88 			void				_AddIntegerRegister(int32 index,
89 									const char* name, uint32 valueType,
90 									register_type type, bool calleePreserved);
91 			void				_AddFPRegister(int32 index,
92 									const char* name);
93 			void				_AddSIMDRegister(int32 index,
94 									const char* name, uint32 byteSize);
95 			bool				_HasFunctionPrologue(
96 									FunctionDebugInfo* function) const;
97 private:
98 			Array<Register>		fRegisters;
99 			SourceLanguage*		fAssemblyLanguage;
100 			ToDwarfRegisterMap*	fToDwarfRegisterMap;
101 			FromDwarfRegisterMap* fFromDwarfRegisterMap;
102 };
103 
104 
105 #endif	// ARCHITECTURE_X86_64_H
106