2009-06-18 23:57:46 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef STACK_FRAME_H
|
|
|
|
#define STACK_FRAME_H
|
|
|
|
|
2009-07-19 03:52:16 +04:00
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
#include <OS.h>
|
|
|
|
|
2009-07-17 05:54:43 +04:00
|
|
|
#include <ObjectList.h>
|
2009-06-18 23:57:46 +04:00
|
|
|
#include <Referenceable.h>
|
2009-07-19 03:52:16 +04:00
|
|
|
#include <util/DoublyLinkedList.h>
|
2009-06-18 23:57:46 +04:00
|
|
|
|
2009-06-30 02:38:15 +04:00
|
|
|
#include "Types.h"
|
2009-06-18 23:57:46 +04:00
|
|
|
|
|
|
|
|
2009-06-20 02:13:32 +04:00
|
|
|
enum stack_frame_type {
|
2009-06-25 02:10:07 +04:00
|
|
|
STACK_FRAME_TYPE_SYSCALL, // syscall frame
|
|
|
|
STACK_FRAME_TYPE_STANDARD, // standard frame
|
2009-06-20 02:13:32 +04:00
|
|
|
STACK_FRAME_TYPE_SIGNAL, // signal handler frame
|
|
|
|
STACK_FRAME_TYPE_FRAMELESS // dummy frame for a frameless function
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
class CpuState;
|
2009-06-20 21:20:49 +04:00
|
|
|
class Image;
|
2009-07-08 00:47:39 +04:00
|
|
|
class FunctionInstance;
|
2009-09-21 08:39:40 +04:00
|
|
|
class StackFrameDebugInfo;
|
|
|
|
class StackFrameValueInfos;
|
2009-07-19 03:52:16 +04:00
|
|
|
class StackFrameValues;
|
|
|
|
class TypeComponentPath;
|
2009-07-17 05:54:43 +04:00
|
|
|
class Variable;
|
2009-06-18 23:57:46 +04:00
|
|
|
|
|
|
|
|
2010-12-16 16:50:30 +03:00
|
|
|
class StackFrame : public BReferenceable {
|
2009-07-19 03:52:16 +04:00
|
|
|
public:
|
|
|
|
class Listener;
|
|
|
|
|
2009-06-18 23:57:46 +04:00
|
|
|
public:
|
2009-06-20 21:20:49 +04:00
|
|
|
StackFrame(stack_frame_type type,
|
|
|
|
CpuState* cpuState,
|
2009-06-25 02:10:07 +04:00
|
|
|
target_addr_t frameAddress,
|
2009-09-21 08:39:40 +04:00
|
|
|
target_addr_t instructionPointer,
|
|
|
|
StackFrameDebugInfo* debugInfo);
|
2009-06-20 21:20:49 +04:00
|
|
|
~StackFrame();
|
|
|
|
|
2009-07-19 03:52:16 +04:00
|
|
|
status_t Init();
|
|
|
|
|
2009-06-20 21:20:49 +04:00
|
|
|
stack_frame_type Type() const { return fType; }
|
|
|
|
CpuState* GetCpuState() const { return fCpuState; }
|
|
|
|
target_addr_t FrameAddress() const { return fFrameAddress; }
|
2009-09-21 08:39:40 +04:00
|
|
|
StackFrameDebugInfo* DebugInfo() const { return fDebugInfo; }
|
2009-06-20 21:20:49 +04:00
|
|
|
|
2009-06-25 02:10:07 +04:00
|
|
|
target_addr_t InstructionPointer() const
|
|
|
|
{ return fInstructionPointer; }
|
|
|
|
|
2011-12-16 07:40:32 +04:00
|
|
|
CpuState* GetPreviousCpuState() const
|
|
|
|
{ return fPreviousCpuState; }
|
|
|
|
void SetPreviousCpuState(CpuState* state);
|
|
|
|
|
2009-06-20 21:20:49 +04:00
|
|
|
target_addr_t ReturnAddress() const { return fReturnAddress; }
|
|
|
|
void SetReturnAddress(target_addr_t address);
|
|
|
|
|
|
|
|
Image* GetImage() const { return fImage; }
|
|
|
|
void SetImage(Image* image);
|
|
|
|
|
2009-07-08 00:47:39 +04:00
|
|
|
FunctionInstance* Function() const { return fFunction; }
|
|
|
|
void SetFunction(FunctionInstance* function);
|
2009-06-20 21:20:49 +04:00
|
|
|
|
2009-07-17 05:54:43 +04:00
|
|
|
int32 CountParameters() const;
|
|
|
|
Variable* ParameterAt(int32 index) const;
|
|
|
|
bool AddParameter(Variable* parameter);
|
|
|
|
|
|
|
|
int32 CountLocalVariables() const;
|
|
|
|
Variable* LocalVariableAt(int32 index) const;
|
|
|
|
bool AddLocalVariable(Variable* variable);
|
|
|
|
|
2009-09-21 08:39:40 +04:00
|
|
|
StackFrameValues* Values() const { return fValues; }
|
|
|
|
StackFrameValueInfos* ValueInfos() const { return fValueInfos; }
|
2009-07-19 03:52:16 +04:00
|
|
|
|
|
|
|
// team lock must be held
|
|
|
|
void AddListener(Listener* listener);
|
|
|
|
void RemoveListener(Listener* listener);
|
|
|
|
|
|
|
|
void NotifyValueRetrieved(Variable* variable,
|
|
|
|
TypeComponentPath* path);
|
|
|
|
|
2009-07-17 05:54:43 +04:00
|
|
|
private:
|
|
|
|
typedef BObjectList<Variable> VariableList;
|
2009-07-19 03:52:16 +04:00
|
|
|
typedef DoublyLinkedList<Listener> ListenerList;
|
2009-07-17 05:54:43 +04:00
|
|
|
|
2009-06-20 21:20:49 +04:00
|
|
|
private:
|
|
|
|
stack_frame_type fType;
|
|
|
|
CpuState* fCpuState;
|
2011-12-16 07:40:32 +04:00
|
|
|
CpuState* fPreviousCpuState;
|
2009-06-20 21:20:49 +04:00
|
|
|
target_addr_t fFrameAddress;
|
2009-06-25 02:10:07 +04:00
|
|
|
target_addr_t fInstructionPointer;
|
2009-06-20 21:20:49 +04:00
|
|
|
target_addr_t fReturnAddress;
|
2009-09-21 08:39:40 +04:00
|
|
|
StackFrameDebugInfo* fDebugInfo;
|
2009-06-20 21:20:49 +04:00
|
|
|
Image* fImage;
|
2009-07-08 00:47:39 +04:00
|
|
|
FunctionInstance* fFunction;
|
2009-07-17 05:54:43 +04:00
|
|
|
VariableList fParameters;
|
|
|
|
VariableList fLocalVariables;
|
2009-07-19 03:52:16 +04:00
|
|
|
StackFrameValues* fValues;
|
2009-09-21 08:39:40 +04:00
|
|
|
StackFrameValueInfos* fValueInfos;
|
2009-07-19 03:52:16 +04:00
|
|
|
ListenerList fListeners;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StackFrame::Listener : public DoublyLinkedListLinkImpl<Listener> {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
|
|
|
virtual void StackFrameValueRetrieved(StackFrame* stackFrame,
|
|
|
|
Variable* variable,
|
|
|
|
TypeComponentPath* path);
|
|
|
|
// called with lock held
|
2009-06-18 23:57:46 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // STACK_FRAME_H
|