2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2011-2015, 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
,
53 uint8 addressSize
, bool bigEndian
);
54 virtual ~Architecture();
56 virtual status_t
Init();
58 inline uint8
AddressSize() const { return fAddressSize
; }
60 inline bool IsBigEndian() const { return fBigEndian
; }
61 inline bool IsHostEndian() const;
63 virtual int32
StackGrowthDirection() const = 0;
65 virtual int32
CountRegisters() const = 0;
66 virtual const Register
* Registers() const = 0;
67 virtual status_t
InitRegisterRules(CfaContext
& context
) const;
69 virtual status_t
GetDwarfRegisterMaps(RegisterMap
** _toDwarf
,
70 RegisterMap
** _fromDwarf
) const = 0;
73 virtual status_t
GetCpuFeatures(uint32
& flags
) = 0;
75 virtual status_t
CreateCpuState(CpuState
*& _state
) = 0;
76 virtual status_t
CreateCpuState(const void* cpuStateData
,
77 size_t size
, CpuState
*& _state
) = 0;
78 virtual status_t
CreateStackFrame(Image
* image
,
79 FunctionDebugInfo
* function
,
80 CpuState
* cpuState
, bool isTopFrame
,
82 CpuState
*& _previousCpuState
) = 0;
83 // returns reference to previous frame
84 // and CPU state; returned CPU state
86 virtual void UpdateStackFrameCpuState(
87 const StackFrame
* frame
,
89 FunctionDebugInfo
* previousFunction
,
90 CpuState
* previousCpuState
) = 0;
91 // Called after a CreateStackFrame()
92 // with the image/function corresponding
95 virtual status_t
ReadValueFromMemory(target_addr_t address
,
96 uint32 valueType
, BVariant
& _value
) const
98 virtual status_t
ReadValueFromMemory(target_addr_t addressSpace
,
99 target_addr_t address
, uint32 valueType
,
100 BVariant
& _value
) const = 0;
102 virtual status_t
DisassembleCode(FunctionDebugInfo
* function
,
103 const void* buffer
, size_t bufferSize
,
104 DisassembledCode
*& _sourceCode
) = 0;
105 virtual status_t
GetStatement(FunctionDebugInfo
* function
,
106 target_addr_t address
,
107 Statement
*& _statement
) = 0;
108 virtual status_t
GetInstructionInfo(target_addr_t address
,
109 InstructionInfo
& _info
,
110 CpuState
* state
) = 0;
111 virtual status_t
ResolvePICFunctionAddress(target_addr_t
114 target_addr_t
& _targetAddress
) = 0;
116 status_t
CreateStackTrace(Team
* team
,
117 ImageDebugInfoProvider
* imageInfoProvider
,
119 StackTrace
*& _stackTrace
,
120 ReturnValueInfoList
* returnValueInfos
,
121 int32 maxStackDepth
= -1,
122 bool useExistingTrace
= false,
123 bool getFullFrameInfo
= true);
124 // team is not locked
126 virtual status_t
GetWatchpointDebugCapabilities(
127 int32
& _maxRegisterCount
,
128 int32
& _maxBytesPerRegister
,
129 uint8
& _watchpointCapabilityFlags
) = 0;
131 virtual status_t
GetReturnAddressLocation(
132 StackFrame
* frame
, target_size_t valueSize
,
133 ValueLocation
*& _location
) = 0;
137 TeamMemory
* fTeamMemory
;
144 Architecture::IsHostEndian() const
146 return fBigEndian
== (B_HOST_IS_BENDIAN
!= 0);
150 #endif // ARCHITECTURE_H