vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / model / StackFrame.h
blob69a12279727173d2908209bb26026d0fbafe99e6
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Distributed under the terms of the MIT License.
4 */
5 #ifndef STACK_FRAME_H
6 #define STACK_FRAME_H
9 #include <OS.h>
11 #include <ObjectList.h>
12 #include <Referenceable.h>
13 #include <util/DoublyLinkedList.h>
15 #include "Types.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
26 class CpuState;
27 class Image;
28 class FunctionInstance;
29 class StackFrameDebugInfo;
30 class StackFrameValueInfos;
31 class StackFrameValues;
32 class TypeComponentPath;
33 class Variable;
36 class StackFrame : public BReferenceable {
37 public:
38 class Listener;
40 public:
41 StackFrame(stack_frame_type type,
42 CpuState* cpuState,
43 target_addr_t frameAddress,
44 target_addr_t instructionPointer,
45 StackFrameDebugInfo* debugInfo);
46 ~StackFrame();
48 status_t Init();
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);
89 private:
90 typedef BObjectList<Variable> VariableList;
91 typedef DoublyLinkedList<Listener> ListenerList;
93 private:
94 stack_frame_type fType;
95 CpuState* fCpuState;
96 CpuState* fPreviousCpuState;
97 target_addr_t fFrameAddress;
98 target_addr_t fInstructionPointer;
99 target_addr_t fReturnAddress;
100 StackFrameDebugInfo* fDebugInfo;
101 Image* fImage;
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> {
112 public:
113 virtual ~Listener();
115 virtual void StackFrameValueRetrieved(StackFrame* stackFrame,
116 Variable* variable,
117 TypeComponentPath* path);
118 // called with lock held
122 #endif // STACK_FRAME_H