2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
11 #include <ObjectList.h>
12 #include <Referenceable.h>
13 #include <util/DoublyLinkedList.h>
18 enum stack_frame_type
{
19 STACK_FRAME_TYPE_SYSCALL
, // syscall frame
20 STACK_FRAME_TYPE_STANDARD
, // standard frame
21 STACK_FRAME_TYPE_SIGNAL
, // signal handler frame
22 STACK_FRAME_TYPE_FRAMELESS
// dummy frame for a frameless function
28 class FunctionInstance
;
29 class StackFrameDebugInfo
;
30 class StackFrameValueInfos
;
31 class StackFrameValues
;
32 class TypeComponentPath
;
36 class StackFrame
: public BReferenceable
{
41 StackFrame(stack_frame_type type
,
43 target_addr_t frameAddress
,
44 target_addr_t instructionPointer
,
45 StackFrameDebugInfo
* debugInfo
);
50 stack_frame_type
Type() const { return fType
; }
51 CpuState
* GetCpuState() const { return fCpuState
; }
52 target_addr_t
FrameAddress() const { return fFrameAddress
; }
53 StackFrameDebugInfo
* DebugInfo() const { return fDebugInfo
; }
55 target_addr_t
InstructionPointer() const
56 { return fInstructionPointer
; }
58 CpuState
* PreviousCpuState() const
59 { return fPreviousCpuState
; }
60 void SetPreviousCpuState(CpuState
* state
);
62 target_addr_t
ReturnAddress() const { return fReturnAddress
; }
63 void SetReturnAddress(target_addr_t address
);
65 Image
* GetImage() const { return fImage
; }
66 void SetImage(Image
* image
);
68 FunctionInstance
* Function() const { return fFunction
; }
69 void SetFunction(FunctionInstance
* function
);
71 int32
CountParameters() const;
72 Variable
* ParameterAt(int32 index
) const;
73 bool AddParameter(Variable
* parameter
);
75 int32
CountLocalVariables() const;
76 Variable
* LocalVariableAt(int32 index
) const;
77 bool AddLocalVariable(Variable
* variable
);
79 StackFrameValues
* Values() const { return fValues
; }
80 StackFrameValueInfos
* ValueInfos() const { return fValueInfos
; }
82 // team lock must be held
83 void AddListener(Listener
* listener
);
84 void RemoveListener(Listener
* listener
);
86 void NotifyValueRetrieved(Variable
* variable
,
87 TypeComponentPath
* path
);
90 typedef BObjectList
<Variable
> VariableList
;
91 typedef DoublyLinkedList
<Listener
> ListenerList
;
94 stack_frame_type fType
;
96 CpuState
* fPreviousCpuState
;
97 target_addr_t fFrameAddress
;
98 target_addr_t fInstructionPointer
;
99 target_addr_t fReturnAddress
;
100 StackFrameDebugInfo
* fDebugInfo
;
102 FunctionInstance
* fFunction
;
103 VariableList fParameters
;
104 VariableList fLocalVariables
;
105 StackFrameValues
* fValues
;
106 StackFrameValueInfos
* fValueInfos
;
107 ListenerList fListeners
;
111 class StackFrame::Listener
: public DoublyLinkedListLinkImpl
<Listener
> {
115 virtual void StackFrameValueRetrieved(StackFrame
* stackFrame
,
117 TypeComponentPath
* path
);
118 // called with lock held
122 #endif // STACK_FRAME_H