Debugger: Add dedicated functions for global {un}init.
[haiku.git] / src / apps / debugger / arch / Architecture.h
blobf86bc8959090b873d5d3af3664432cd5de4f0f5b
1 /*
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.
5 */
6 #ifndef ARCHITECTURE_H
7 #define ARCHITECTURE_H
10 #include <ByteOrder.h>
11 #include <OS.h>
13 #include <Referenceable.h>
14 #include <Variant.h>
16 #include "ReturnValueInfo.h"
17 #include "Types.h"
20 class CfaContext;
21 class CpuState;
22 class DisassembledCode;
23 class FunctionDebugInfo;
24 class Image;
25 class ImageDebugInfoProvider;
26 class InstructionInfo;
27 class Register;
28 class RegisterMap;
29 class StackFrame;
30 class StackTrace;
31 class Statement;
32 class Team;
33 class TeamMemory;
34 class ValueLocation;
37 enum {
38 STACK_GROWTH_DIRECTION_POSITIVE = 0,
39 STACK_GROWTH_DIRECTION_NEGATIVE
43 enum {
44 WATCHPOINT_CAPABILITY_FLAG_READ = 1,
45 WATCHPOINT_CAPABILITY_FLAG_WRITE = 2,
46 WATCHPOINT_CAPABILITY_FLAG_READ_WRITE = 4
50 class Architecture : public BReferenceable {
51 public:
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;
71 // returns references
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,
81 StackFrame*& _frame,
82 CpuState*& _previousCpuState) = 0;
83 // returns reference to previous frame
84 // and CPU state; returned CPU state
85 // can be NULL
86 virtual void UpdateStackFrameCpuState(
87 const StackFrame* frame,
88 Image* previousImage,
89 FunctionDebugInfo* previousFunction,
90 CpuState* previousCpuState) = 0;
91 // Called after a CreateStackFrame()
92 // with the image/function corresponding
93 // to the CPU state.
95 virtual status_t ReadValueFromMemory(target_addr_t address,
96 uint32 valueType, BVariant& _value) const
97 = 0;
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
112 instructionAddress,
113 CpuState* state,
114 target_addr_t& _targetAddress) = 0;
116 status_t CreateStackTrace(Team* team,
117 ImageDebugInfoProvider* imageInfoProvider,
118 CpuState* cpuState,
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;
136 protected:
137 TeamMemory* fTeamMemory;
138 uint8 fAddressSize;
139 bool fBigEndian;
143 bool
144 Architecture::IsHostEndian() const
146 return fBigEndian == (B_HOST_IS_BENDIAN != 0);
150 #endif // ARCHITECTURE_H