/* * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Copyright 2011-2016, Rene Gollent, rene@gollent.com. * Distributed under the terms of the MIT License. */ #ifndef ARCHITECTURE_H #define ARCHITECTURE_H #include #include #include #include #include "ReturnValueInfo.h" #include "Types.h" class CfaContext; class CpuState; class DisassembledCode; class FunctionDebugInfo; class Image; class ImageDebugInfoProvider; class InstructionInfo; class Register; class RegisterMap; class StackFrame; class StackTrace; class Statement; class Team; class TeamMemory; class ValueLocation; enum { STACK_GROWTH_DIRECTION_POSITIVE = 0, STACK_GROWTH_DIRECTION_NEGATIVE }; enum { WATCHPOINT_CAPABILITY_FLAG_READ = 1, WATCHPOINT_CAPABILITY_FLAG_WRITE = 2, WATCHPOINT_CAPABILITY_FLAG_READ_WRITE = 4 }; class Architecture : public BReferenceable { public: Architecture(TeamMemory* teamMemory, uint8 addressSize, size_t debugCpuStateSize, bool bigEndian); virtual ~Architecture(); virtual status_t Init(); inline uint8 AddressSize() const { return fAddressSize; } inline size_t DebugCpuStateSize() const { return fDebugCpuStateSize; } inline bool IsBigEndian() const { return fBigEndian; } inline bool IsHostEndian() const; virtual int32 StackGrowthDirection() const = 0; virtual int32 CountRegisters() const = 0; virtual const Register* Registers() const = 0; virtual status_t InitRegisterRules(CfaContext& context) const; virtual status_t GetDwarfRegisterMaps(RegisterMap** _toDwarf, RegisterMap** _fromDwarf) const = 0; // returns references virtual status_t GetCpuFeatures(uint32& flags) = 0; virtual status_t CreateCpuState(CpuState*& _state) = 0; virtual status_t CreateCpuState(const void* cpuStateData, size_t size, CpuState*& _state) = 0; virtual status_t CreateStackFrame(Image* image, FunctionDebugInfo* function, CpuState* cpuState, bool isTopFrame, StackFrame*& _frame, CpuState*& _previousCpuState) = 0; // returns reference to previous frame // and CPU state; returned CPU state // can be NULL virtual void UpdateStackFrameCpuState( const StackFrame* frame, Image* previousImage, FunctionDebugInfo* previousFunction, CpuState* previousCpuState) = 0; // Called after a CreateStackFrame() // with the image/function corresponding // to the CPU state. virtual status_t ReadValueFromMemory(target_addr_t address, uint32 valueType, BVariant& _value) const = 0; virtual status_t ReadValueFromMemory(target_addr_t addressSpace, target_addr_t address, uint32 valueType, BVariant& _value) const = 0; virtual status_t DisassembleCode(FunctionDebugInfo* function, const void* buffer, size_t bufferSize, DisassembledCode*& _sourceCode) = 0; virtual status_t GetStatement(FunctionDebugInfo* function, target_addr_t address, Statement*& _statement) = 0; virtual status_t GetInstructionInfo(target_addr_t address, InstructionInfo& _info, CpuState* state) = 0; virtual status_t ResolvePICFunctionAddress(target_addr_t instructionAddress, CpuState* state, target_addr_t& _targetAddress) = 0; status_t CreateStackTrace(Team* team, ImageDebugInfoProvider* imageInfoProvider, CpuState* cpuState, StackTrace*& _stackTrace, ReturnValueInfoList* returnValueInfos, int32 maxStackDepth = -1, bool useExistingTrace = false, bool getFullFrameInfo = true); // team is not locked virtual status_t GetWatchpointDebugCapabilities( int32& _maxRegisterCount, int32& _maxBytesPerRegister, uint8& _watchpointCapabilityFlags) = 0; virtual status_t GetReturnAddressLocation( StackFrame* frame, target_size_t valueSize, ValueLocation*& _location) = 0; protected: TeamMemory* fTeamMemory; uint8 fAddressSize; size_t fDebugCpuStateSize; bool fBigEndian; }; bool Architecture::IsHostEndian() const { return fBigEndian == (B_HOST_IS_BENDIAN != 0); } #endif // ARCHITECTURE_H