2009-06-18 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
2016-08-01 00:00:08 +03:00
|
|
|
* Copyright 2011-2016, Rene Gollent, rene@gollent.com.
|
2009-06-18 23:57:46 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef ARCHITECTURE_H
|
|
|
|
#define ARCHITECTURE_H
|
|
|
|
|
2009-07-13 22:45:49 +04:00
|
|
|
|
2009-07-19 03:18:06 +04:00
|
|
|
#include <ByteOrder.h>
|
2009-06-18 23:57:46 +04:00
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
#include <Referenceable.h>
|
2009-07-13 22:45:49 +04:00
|
|
|
#include <Variant.h>
|
2009-06-18 23:57:46 +04:00
|
|
|
|
2013-03-28 07:21:42 +04:00
|
|
|
#include "ReturnValueInfo.h"
|
2009-06-30 02:38:15 +04:00
|
|
|
#include "Types.h"
|
2009-06-26 03:51:09 +04:00
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
|
2010-12-11 22:05:54 +03:00
|
|
|
class CfaContext;
|
2009-06-18 23:57:46 +04:00
|
|
|
class CpuState;
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
class DisassembledCode;
|
2009-06-20 21:20:49 +04:00
|
|
|
class FunctionDebugInfo;
|
|
|
|
class Image;
|
|
|
|
class ImageDebugInfoProvider;
|
2009-06-26 03:51:09 +04:00
|
|
|
class InstructionInfo;
|
2009-06-19 04:05:45 +04:00
|
|
|
class Register;
|
2009-07-13 22:45:49 +04:00
|
|
|
class RegisterMap;
|
2009-06-20 21:20:49 +04:00
|
|
|
class StackFrame;
|
2009-06-20 02:13:32 +04:00
|
|
|
class StackTrace;
|
2009-06-26 03:51:09 +04:00
|
|
|
class Statement;
|
2009-06-20 02:13:32 +04:00
|
|
|
class Team;
|
2009-06-26 04:39:23 +04:00
|
|
|
class TeamMemory;
|
2012-12-29 07:27:30 +04:00
|
|
|
class ValueLocation;
|
2009-06-18 23:57:46 +04:00
|
|
|
|
|
|
|
|
2011-12-12 17:40:49 +04:00
|
|
|
enum {
|
|
|
|
STACK_GROWTH_DIRECTION_POSITIVE = 0,
|
|
|
|
STACK_GROWTH_DIRECTION_NEGATIVE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2012-11-11 20:32:30 +04:00
|
|
|
enum {
|
|
|
|
WATCHPOINT_CAPABILITY_FLAG_READ = 1,
|
2012-11-11 21:03:28 +04:00
|
|
|
WATCHPOINT_CAPABILITY_FLAG_WRITE = 2,
|
|
|
|
WATCHPOINT_CAPABILITY_FLAG_READ_WRITE = 4
|
2012-11-11 20:32:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2010-12-16 16:50:30 +03:00
|
|
|
class Architecture : public BReferenceable {
|
2009-06-18 23:57:46 +04:00
|
|
|
public:
|
2009-07-19 03:18:06 +04:00
|
|
|
Architecture(TeamMemory* teamMemory,
|
2016-08-01 00:00:08 +03:00
|
|
|
uint8 addressSize,
|
|
|
|
size_t debugCpuStateSize,
|
|
|
|
bool bigEndian);
|
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
virtual ~Architecture();
|
|
|
|
|
2009-06-19 04:05:45 +04:00
|
|
|
virtual status_t Init();
|
|
|
|
|
2009-07-19 03:18:06 +04:00
|
|
|
inline uint8 AddressSize() const { return fAddressSize; }
|
2016-08-01 00:00:08 +03:00
|
|
|
inline size_t DebugCpuStateSize() const
|
|
|
|
{ return fDebugCpuStateSize; }
|
2009-07-19 03:18:06 +04:00
|
|
|
|
|
|
|
inline bool IsBigEndian() const { return fBigEndian; }
|
|
|
|
inline bool IsHostEndian() const;
|
|
|
|
|
2011-12-12 17:40:49 +04:00
|
|
|
virtual int32 StackGrowthDirection() const = 0;
|
|
|
|
|
2009-06-19 04:05:45 +04:00
|
|
|
virtual int32 CountRegisters() const = 0;
|
|
|
|
virtual const Register* Registers() const = 0;
|
2010-12-11 22:05:54 +03:00
|
|
|
virtual status_t InitRegisterRules(CfaContext& context) const;
|
2009-06-19 04:05:45 +04:00
|
|
|
|
2009-07-13 22:45:49 +04:00
|
|
|
virtual status_t GetDwarfRegisterMaps(RegisterMap** _toDwarf,
|
|
|
|
RegisterMap** _fromDwarf) const = 0;
|
|
|
|
// returns references
|
|
|
|
|
2015-04-15 00:44:12 +03:00
|
|
|
virtual status_t GetCpuFeatures(uint32& flags) = 0;
|
|
|
|
|
2009-07-13 22:45:49 +04:00
|
|
|
virtual status_t CreateCpuState(CpuState*& _state) = 0;
|
2009-06-18 23:57:46 +04:00
|
|
|
virtual status_t CreateCpuState(const void* cpuStateData,
|
|
|
|
size_t size, CpuState*& _state) = 0;
|
2009-06-20 21:20:49 +04:00
|
|
|
virtual status_t CreateStackFrame(Image* image,
|
|
|
|
FunctionDebugInfo* function,
|
2009-06-24 20:37:11 +04:00
|
|
|
CpuState* cpuState, bool isTopFrame,
|
2011-12-16 07:43:38 +04:00
|
|
|
StackFrame*& _frame,
|
2009-06-20 21:20:49 +04:00
|
|
|
CpuState*& _previousCpuState) = 0;
|
|
|
|
// returns reference to previous frame
|
|
|
|
// and CPU state; returned CPU state
|
|
|
|
// can be NULL
|
2009-06-25 02:10:07 +04:00
|
|
|
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.
|
2009-06-26 03:51:09 +04:00
|
|
|
|
2009-07-13 22:45:49 +04:00
|
|
|
virtual status_t ReadValueFromMemory(target_addr_t address,
|
|
|
|
uint32 valueType, BVariant& _value) const
|
|
|
|
= 0;
|
2009-07-15 06:07:42 +04:00
|
|
|
virtual status_t ReadValueFromMemory(target_addr_t addressSpace,
|
|
|
|
target_addr_t address, uint32 valueType,
|
|
|
|
BVariant& _value) const = 0;
|
2009-07-13 22:45:49 +04:00
|
|
|
|
2009-06-21 17:17:21 +04:00
|
|
|
virtual status_t DisassembleCode(FunctionDebugInfo* function,
|
|
|
|
const void* buffer, size_t bufferSize,
|
* Since disassembled code is actually function instance specific,
FunctionInstance does now also have a (DisassembledCode) source code
attribute. Function keeps its attribute, but it explicitly is a
FileSourceCode now.
* SourceCode:
- Removed GetStatementAtLocation(). Instead DisassembledCode has a
StatementAtLocation() now. As well as a StatementAtAddress() and
StatementAddressRange(). Rather cast to the subclass (in two instances)
instead of having those methods in the base class. In most cases we already
have the subclasses now, anyway.
- Added Lock()/Unlock(), which are implemented in FileSourceCode. The
statement ranges are no longer immutable, so we have to lock.
* TeamDebugModel:
- Revived GetBreakpointsInAddressRange().
- GetBreakpointsForSourceCode(): Optimized for DisassembledCode and fixed
in the FileSourceCode case. We need to compare with the functions' source
file instead of their source code, since they might not have the source
code set yet. Fixed two instances of the same problem in SourceView. Setting
breakpoints in functions that have no associated source code yet, works now.
* Team:
- GetStatementAtAddress(): Optimized by using the DisassembledCode, if
available.
- GetStatementAtSourceLocation(): If the supplied source code is
DisassembledCode, we have to get the statement from it directly, since
we can't get that information from the image debug info.
* TeamDebugInfo: Added LoadSourceCode() and DisassembleFunction(), the new way
to get FileSourceCode respectively DisassembledCode. SpecificTeamDebugInfo
has lost LoadSourceCode() and gained service methods AddSourceCodeInfo() and
ReadCode(). This avoids unnecessary code duplication in the subclasses.
Moreover it allows for joining source location info source files from
different images (and compilation units) -- interesting for inline functions
in headers.
* Adjusted LoadSourceCodeJob and TeamDebugger::FunctionSourceCodeRequested()
accordingly.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@31514 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-07-11 04:05:26 +04:00
|
|
|
DisassembledCode*& _sourceCode) = 0;
|
2009-06-26 03:51:09 +04:00
|
|
|
virtual status_t GetStatement(FunctionDebugInfo* function,
|
|
|
|
target_addr_t address,
|
|
|
|
Statement*& _statement) = 0;
|
|
|
|
virtual status_t GetInstructionInfo(target_addr_t address,
|
2013-01-01 07:54:39 +04:00
|
|
|
InstructionInfo& _info,
|
|
|
|
CpuState* state) = 0;
|
2013-07-29 01:30:49 +04:00
|
|
|
virtual status_t ResolvePICFunctionAddress(target_addr_t
|
|
|
|
instructionAddress,
|
|
|
|
CpuState* state,
|
|
|
|
target_addr_t& _targetAddress) = 0;
|
2009-06-20 21:20:49 +04:00
|
|
|
|
|
|
|
status_t CreateStackTrace(Team* team,
|
|
|
|
ImageDebugInfoProvider* imageInfoProvider,
|
|
|
|
CpuState* cpuState,
|
2011-12-15 07:00:17 +04:00
|
|
|
StackTrace*& _stackTrace,
|
2013-03-28 07:21:42 +04:00
|
|
|
ReturnValueInfoList* returnValueInfos,
|
2011-12-15 07:00:17 +04:00
|
|
|
int32 maxStackDepth = -1,
|
2012-12-26 09:17:09 +04:00
|
|
|
bool useExistingTrace = false,
|
|
|
|
bool getFullFrameInfo = true);
|
2009-06-20 02:13:32 +04:00
|
|
|
// team is not locked
|
2009-06-18 23:57:46 +04:00
|
|
|
|
2012-11-11 20:32:30 +04:00
|
|
|
virtual status_t GetWatchpointDebugCapabilities(
|
|
|
|
int32& _maxRegisterCount,
|
2012-11-13 05:22:15 +04:00
|
|
|
int32& _maxBytesPerRegister,
|
2012-11-11 20:32:30 +04:00
|
|
|
uint8& _watchpointCapabilityFlags) = 0;
|
|
|
|
|
2012-12-29 07:27:30 +04:00
|
|
|
virtual status_t GetReturnAddressLocation(
|
|
|
|
StackFrame* frame, target_size_t valueSize,
|
|
|
|
ValueLocation*& _location) = 0;
|
|
|
|
|
2012-11-11 20:32:30 +04:00
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
protected:
|
2009-06-26 04:39:23 +04:00
|
|
|
TeamMemory* fTeamMemory;
|
2009-07-19 03:18:06 +04:00
|
|
|
uint8 fAddressSize;
|
2016-08-01 00:00:08 +03:00
|
|
|
size_t fDebugCpuStateSize;
|
2009-07-19 03:18:06 +04:00
|
|
|
bool fBigEndian;
|
2009-06-18 23:57:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-07-19 03:18:06 +04:00
|
|
|
bool
|
|
|
|
Architecture::IsHostEndian() const
|
|
|
|
{
|
|
|
|
return fBigEndian == (B_HOST_IS_BENDIAN != 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
#endif // ARCHITECTURE_H
|