vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / debug_info / Function.h
blob7e8d9affbc7dd93715aa7bc6fdfb6374ebea4a89
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2010, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef FUNCTION_H
7 #define FUNCTION_H
9 #include <util/DoublyLinkedList.h>
10 #include <util/OpenHashTable.h>
12 #include "FunctionInstance.h"
13 #include "LocatableFile.h"
16 class FileSourceCode;
19 class Function : public BReferenceable, private LocatableFile::Listener {
20 public:
21 class Listener;
23 public:
24 Function();
25 ~Function();
27 // team must be locked to access the instances
28 FunctionInstance* FirstInstance() const
29 { return fInstances.Head(); }
30 FunctionInstance* LastInstance() const
31 { return fInstances.Tail(); }
32 const FunctionInstanceList& Instances() const
33 { return fInstances; }
35 const BString& Name() const
36 { return FirstInstance()->Name(); }
37 const BString& PrettyName() const
38 { return FirstInstance()->PrettyName(); }
39 LocatableFile* SourceFile() const
40 { return FirstInstance()->SourceFile(); }
41 SourceLocation GetSourceLocation() const
42 { return FirstInstance()
43 ->GetSourceLocation(); }
45 FunctionID* GetFunctionID() const
46 { return FirstInstance()->GetFunctionID(); }
47 // returns a reference
49 // mutable attributes follow (locking required)
50 FileSourceCode* GetSourceCode() const { return fSourceCode; }
51 function_source_state SourceCodeState() const
52 { return fSourceCodeState; }
53 void SetSourceCode(FileSourceCode* source,
54 function_source_state state);
56 void AddListener(Listener* listener);
57 void RemoveListener(Listener* listener);
59 // package private
60 void AddInstance(FunctionInstance* instance);
61 void RemoveInstance(FunctionInstance* instance);
63 void NotifySourceCodeChanged();
65 void LocatableFileChanged(LocatableFile* file);
67 private:
68 typedef DoublyLinkedList<Listener> ListenerList;
70 private:
71 FunctionInstanceList fInstances;
72 FileSourceCode* fSourceCode;
73 function_source_state fSourceCodeState;
74 ListenerList fListeners;
75 int32 fNotificationsDisabled;
77 public:
78 // BOpenHashTable support
79 Function* fNext;
83 class Function::Listener : public DoublyLinkedListLinkImpl<Listener> {
84 public:
85 virtual ~Listener();
87 virtual void FunctionSourceCodeChanged(Function* function);
88 // called with lock held
92 #endif // FUNCTION_H