haiku/src/apps/debugger/arch/Architecture.h

79 lines
2.1 KiB
C
Raw Normal View History

/*
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
* Distributed under the terms of the MIT License.
*/
#ifndef ARCHITECTURE_H
#define ARCHITECTURE_H
#include <OS.h>
#include <Referenceable.h>
#include "Types.h"
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;
class FunctionDebugInfo;
class Image;
class ImageDebugInfoProvider;
class InstructionInfo;
class Register;
class StackFrame;
class StackTrace;
class Statement;
class Team;
class TeamMemory;
class Architecture : public Referenceable {
public:
Architecture(TeamMemory* teamMemory);
virtual ~Architecture();
virtual status_t Init();
virtual int32 CountRegisters() const = 0;
virtual const Register* Registers() const = 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*& _previousFrame,
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 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;
virtual status_t GetStatement(FunctionDebugInfo* function,
target_addr_t address,
Statement*& _statement) = 0;
virtual status_t GetInstructionInfo(target_addr_t address,
InstructionInfo& _info) = 0;
status_t CreateStackTrace(Team* team,
ImageDebugInfoProvider* imageInfoProvider,
CpuState* cpuState,
StackTrace*& _stackTrace);
// team is not locked
protected:
TeamMemory* fTeamMemory;
};
#endif // ARCHITECTURE_H