2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011-2016, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
10 #include <ByteOrder.h>
13 #include <Referenceable.h>
16 #include "ReturnValueInfo.h"
22 class DisassembledCode
;
23 class FunctionDebugInfo
;
25 class ImageDebugInfoProvider
;
26 class InstructionInfo
;
38 STACK_GROWTH_DIRECTION_POSITIVE
= 0,
39 STACK_GROWTH_DIRECTION_NEGATIVE
44 WATCHPOINT_CAPABILITY_FLAG_READ
= 1,
45 WATCHPOINT_CAPABILITY_FLAG_WRITE
= 2,
46 WATCHPOINT_CAPABILITY_FLAG_READ_WRITE
= 4
50 class Architecture
: public BReferenceable
{
52 Architecture(TeamMemory
* teamMemory
,
54 size_t debugCpuStateSize
,
57 virtual ~Architecture();
59 virtual status_t
Init();
61 inline uint8
AddressSize() const { return fAddressSize
; }
62 inline size_t DebugCpuStateSize() const
63 { return fDebugCpuStateSize
; }
65 inline bool IsBigEndian() const { return fBigEndian
; }
66 inline bool IsHostEndian() const;
68 virtual int32
StackGrowthDirection() const = 0;
70 virtual int32
CountRegisters() const = 0;
71 virtual const Register
* Registers() const = 0;
72 virtual status_t
InitRegisterRules(CfaContext
& context
) const;
74 virtual status_t
GetDwarfRegisterMaps(RegisterMap
** _toDwarf
,
75 RegisterMap
** _fromDwarf
) const = 0;
78 virtual status_t
GetCpuFeatures(uint32
& flags
) = 0;
80 virtual status_t
CreateCpuState(CpuState
*& _state
) = 0;
81 virtual status_t
CreateCpuState(const void* cpuStateData
,
82 size_t size
, CpuState
*& _state
) = 0;
83 virtual status_t
CreateStackFrame(Image
* image
,
84 FunctionDebugInfo
* function
,
85 CpuState
* cpuState
, bool isTopFrame
,
87 CpuState
*& _previousCpuState
) = 0;
88 // returns reference to previous frame
89 // and CPU state; returned CPU state
91 virtual void UpdateStackFrameCpuState(
92 const StackFrame
* frame
,
94 FunctionDebugInfo
* previousFunction
,
95 CpuState
* previousCpuState
) = 0;
96 // Called after a CreateStackFrame()
97 // with the image/function corresponding
100 virtual status_t
ReadValueFromMemory(target_addr_t address
,
101 uint32 valueType
, BVariant
& _value
) const
103 virtual status_t
ReadValueFromMemory(target_addr_t addressSpace
,
104 target_addr_t address
, uint32 valueType
,
105 BVariant
& _value
) const = 0;
107 virtual status_t
DisassembleCode(FunctionDebugInfo
* function
,
108 const void* buffer
, size_t bufferSize
,
109 DisassembledCode
*& _sourceCode
) = 0;
110 virtual status_t
GetStatement(FunctionDebugInfo
* function
,
111 target_addr_t address
,
112 Statement
*& _statement
) = 0;
113 virtual status_t
GetInstructionInfo(target_addr_t address
,
114 InstructionInfo
& _info
,
115 CpuState
* state
) = 0;
116 virtual status_t
ResolvePICFunctionAddress(target_addr_t
119 target_addr_t
& _targetAddress
) = 0;
121 status_t
CreateStackTrace(Team
* team
,
122 ImageDebugInfoProvider
* imageInfoProvider
,
124 StackTrace
*& _stackTrace
,
125 ReturnValueInfoList
* returnValueInfos
,
126 int32 maxStackDepth
= -1,
127 bool useExistingTrace
= false,
128 bool getFullFrameInfo
= true);
129 // team is not locked
131 virtual status_t
GetWatchpointDebugCapabilities(
132 int32
& _maxRegisterCount
,
133 int32
& _maxBytesPerRegister
,
134 uint8
& _watchpointCapabilityFlags
) = 0;
136 virtual status_t
GetReturnAddressLocation(
137 StackFrame
* frame
, target_size_t valueSize
,
138 ValueLocation
*& _location
) = 0;
142 TeamMemory
* fTeamMemory
;
144 size_t fDebugCpuStateSize
;
150 Architecture::IsHostEndian() const
152 return fBigEndian
== (B_HOST_IS_BENDIAN
!= 0);
156 #endif // ARCHITECTURE_H