2009-06-18 19:57:46 +00: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
|
|
|
|
|
|
|
|
#include <OS.h>
|
|
|
|
|
|
|
|
#include <Referenceable.h>
|
2009-06-21 13:17:21 +00:00
|
|
|
#include <util/DoublyLinkedList.h>
|
2009-06-18 19:57:46 +00:00
|
|
|
|
|
|
|
#include "ArchitectureTypes.h"
|
|
|
|
|
|
|
|
|
2009-06-19 22:13:32 +00:00
|
|
|
enum stack_frame_type {
|
|
|
|
STACK_FRAME_TYPE_TOP, // top-most frame
|
|
|
|
STACK_FRAME_TYPE_STANDARD, // non-top-most standard frame
|
|
|
|
STACK_FRAME_TYPE_SIGNAL, // signal handler frame
|
|
|
|
STACK_FRAME_TYPE_FRAMELESS // dummy frame for a frameless function
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-21 13:17:21 +00:00
|
|
|
enum stack_frame_source_state {
|
|
|
|
STACK_SOURCE_NOT_LOADED,
|
|
|
|
STACK_SOURCE_LOADING,
|
|
|
|
STACK_SOURCE_LOADED,
|
|
|
|
STACK_SOURCE_UNAVAILABLE
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-06-18 19:57:46 +00:00
|
|
|
class CpuState;
|
2009-06-20 17:20:49 +00:00
|
|
|
class Image;
|
|
|
|
class FunctionDebugInfo;
|
2009-06-21 13:17:21 +00:00
|
|
|
class SourceCode;
|
2009-06-18 19:57:46 +00:00
|
|
|
|
|
|
|
|
2009-06-20 17:20:49 +00:00
|
|
|
class StackFrame : public Referenceable {
|
2009-06-21 13:17:21 +00:00
|
|
|
public:
|
|
|
|
class Listener;
|
|
|
|
|
2009-06-18 19:57:46 +00:00
|
|
|
public:
|
2009-06-20 17:20:49 +00:00
|
|
|
StackFrame(stack_frame_type type,
|
|
|
|
CpuState* cpuState,
|
|
|
|
target_addr_t frameAddress);
|
|
|
|
~StackFrame();
|
|
|
|
|
|
|
|
stack_frame_type Type() const { return fType; }
|
|
|
|
CpuState* GetCpuState() const { return fCpuState; }
|
|
|
|
target_addr_t InstructionPointer() const;
|
|
|
|
target_addr_t FrameAddress() const { return fFrameAddress; }
|
|
|
|
|
|
|
|
target_addr_t ReturnAddress() const { return fReturnAddress; }
|
|
|
|
void SetReturnAddress(target_addr_t address);
|
|
|
|
|
|
|
|
Image* GetImage() const { return fImage; }
|
|
|
|
void SetImage(Image* image);
|
|
|
|
|
|
|
|
FunctionDebugInfo* Function() const { return fFunction; }
|
|
|
|
void SetFunction(FunctionDebugInfo* function);
|
|
|
|
|
2009-06-21 13:17:21 +00:00
|
|
|
// mutable attributes follow (locking required)
|
|
|
|
SourceCode* GetSourceCode() const { return fSourceCode; }
|
|
|
|
stack_frame_source_state SourceCodeState() const
|
|
|
|
{ return fSourceCodeState; }
|
|
|
|
void SetSourceCode(SourceCode* source,
|
|
|
|
stack_frame_source_state state);
|
|
|
|
|
|
|
|
void AddListener(Listener* listener);
|
|
|
|
void RemoveListener(Listener* listener);
|
|
|
|
|
|
|
|
private:
|
|
|
|
typedef DoublyLinkedList<Listener> ListenerList;
|
|
|
|
|
2009-06-20 17:20:49 +00:00
|
|
|
private:
|
|
|
|
stack_frame_type fType;
|
|
|
|
CpuState* fCpuState;
|
|
|
|
target_addr_t fFrameAddress;
|
|
|
|
target_addr_t fReturnAddress;
|
|
|
|
Image* fImage;
|
|
|
|
FunctionDebugInfo* fFunction;
|
2009-06-21 13:17:21 +00:00
|
|
|
// mutable
|
|
|
|
SourceCode* fSourceCode;
|
|
|
|
stack_frame_source_state fSourceCodeState;
|
|
|
|
ListenerList fListeners;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
class StackFrame::Listener : public DoublyLinkedListLinkImpl<Listener> {
|
|
|
|
public:
|
|
|
|
virtual ~Listener();
|
|
|
|
|
|
|
|
virtual void StackFrameSourceCodeChanged(StackFrame* frame);
|
|
|
|
// called with lock held
|
2009-06-18 19:57:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // STACK_FRAME_H
|