Debugger: Split into core library and application.
- Add subfolder src/kits/debugger which contains the debugger's core functionality and lower layers. Correspondingly add headers/private/debugger for shared headers to be used by clients such as the Debugger application and eventual remote_debug_server. Adjust various files to account for differences as a result of the split and moves. - Add libdebugger.so to minimal Jamfile.
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2011-2015, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef ARCHITECTURE_H
|
||||
#define ARCHITECTURE_H
|
||||
|
||||
|
||||
#include <ByteOrder.h>
|
||||
#include <OS.h>
|
||||
|
||||
#include <Referenceable.h>
|
||||
#include <Variant.h>
|
||||
|
||||
#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, bool bigEndian);
|
||||
virtual ~Architecture();
|
||||
|
||||
virtual status_t Init();
|
||||
|
||||
inline uint8 AddressSize() const { return fAddressSize; }
|
||||
|
||||
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;
|
||||
bool fBigEndian;
|
||||
};
|
||||
|
||||
|
||||
bool
|
||||
Architecture::IsHostEndian() const
|
||||
{
|
||||
return fBigEndian == (B_HOST_IS_BENDIAN != 0);
|
||||
}
|
||||
|
||||
|
||||
#endif // ARCHITECTURE_H
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2011, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef CPU_STATE_H
|
||||
#define CPU_STATE_H
|
||||
|
||||
#include <OS.h>
|
||||
|
||||
#include <Referenceable.h>
|
||||
#include <Variant.h>
|
||||
|
||||
#include "Types.h"
|
||||
|
||||
|
||||
class Register;
|
||||
|
||||
|
||||
class CpuState : public BReferenceable {
|
||||
public:
|
||||
virtual ~CpuState();
|
||||
|
||||
virtual status_t Clone(CpuState*& _clone) const = 0;
|
||||
|
||||
virtual status_t UpdateDebugState(void* state, size_t size)
|
||||
const = 0;
|
||||
|
||||
virtual target_addr_t InstructionPointer() const = 0;
|
||||
virtual void SetInstructionPointer(
|
||||
target_addr_t address) = 0;
|
||||
|
||||
virtual target_addr_t StackFramePointer() const = 0;
|
||||
virtual target_addr_t StackPointer() const = 0;
|
||||
virtual bool GetRegisterValue(const Register* reg,
|
||||
BVariant& _value) const = 0;
|
||||
virtual bool SetRegisterValue(const Register* reg,
|
||||
const BVariant& value) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // CPU_STATE_H
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2009, Ingo Weinhold, [email protected].
|
||||
* Copyright 2014, Rene Gollent, [email protected].
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef REGISTER_H
|
||||
#define REGISTER_H
|
||||
|
||||
|
||||
#include <SupportDefs.h>
|
||||
|
||||
|
||||
enum register_format {
|
||||
REGISTER_FORMAT_INTEGER,
|
||||
REGISTER_FORMAT_FLOAT,
|
||||
REGISTER_FORMAT_SIMD
|
||||
};
|
||||
|
||||
enum register_type {
|
||||
REGISTER_TYPE_INSTRUCTION_POINTER,
|
||||
REGISTER_TYPE_STACK_POINTER,
|
||||
REGISTER_TYPE_RETURN_ADDRESS,
|
||||
REGISTER_TYPE_GENERAL_PURPOSE,
|
||||
REGISTER_TYPE_SPECIAL_PURPOSE,
|
||||
REGISTER_TYPE_EXTENDED
|
||||
};
|
||||
|
||||
|
||||
class Register {
|
||||
public:
|
||||
Register(int32 index, const char* name,
|
||||
uint32 bitSize, uint32 valueType,
|
||||
register_type type, bool calleePreserved);
|
||||
// name will not be cloned
|
||||
Register(const Register& other);
|
||||
|
||||
int32 Index() const { return fIndex; }
|
||||
const char* Name() const { return fName; }
|
||||
uint32 ValueType() const { return fValueType; }
|
||||
register_format Format() const { return fFormat; }
|
||||
uint32 BitSize() const { return fBitSize; }
|
||||
register_type Type() const { return fType; }
|
||||
bool IsCalleePreserved() const
|
||||
{ return fCalleePreserved; }
|
||||
|
||||
private:
|
||||
int32 fIndex;
|
||||
const char* fName;
|
||||
uint32 fBitSize;
|
||||
uint32 fValueType;
|
||||
register_format fFormat;
|
||||
register_type fType;
|
||||
bool fCalleePreserved;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // REGISTER_H
|
||||
Reference in New Issue
Block a user