vfs: check userland buffers before reading them.
[haiku.git] / headers / private / debugger / debug_info / FunctionInstance.h
blob11d8f67cd9e4ce7c20caca605ab15c14e9db4435
1 /*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2016, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6 #ifndef FUNCTION_INSTANCE_H
7 #define FUNCTION_INSTANCE_H
9 #include <util/DoublyLinkedList.h>
11 #include "FunctionDebugInfo.h"
14 enum function_source_state {
15 FUNCTION_SOURCE_NOT_LOADED,
16 FUNCTION_SOURCE_LOADING,
17 FUNCTION_SOURCE_LOADED,
18 FUNCTION_SOURCE_UNAVAILABLE,
19 FUNCTION_SOURCE_SUPPRESSED
23 class DisassembledCode;
24 class Function;
25 class FunctionDebugInfo;
26 class FunctionID;
27 class ImageDebugInfo;
30 class FunctionInstance : public BReferenceable,
31 public DoublyLinkedListLinkImpl<FunctionInstance> {
32 public:
33 FunctionInstance(ImageDebugInfo* imageDebugInfo,
34 FunctionDebugInfo* functionDebugInfo);
35 ~FunctionInstance();
37 ImageDebugInfo* GetImageDebugInfo() const
38 { return fImageDebugInfo; }
39 Function* GetFunction() const
40 { return fFunction; }
41 FunctionDebugInfo* GetFunctionDebugInfo() const
42 { return fFunctionDebugInfo; }
44 target_addr_t Address() const
45 { return fFunctionDebugInfo->Address(); }
46 target_size_t Size() const
47 { return fFunctionDebugInfo->Size(); }
48 const BString& Name() const
49 { return fFunctionDebugInfo->Name(); }
50 const BString& PrettyName() const
51 { return fFunctionDebugInfo->PrettyName(); }
52 LocatableFile* SourceFile() const
53 { return fFunctionDebugInfo->SourceFile(); }
54 SourceLocation GetSourceLocation() const
55 { return fFunctionDebugInfo
56 ->SourceStartLocation(); }
58 FunctionID* GetFunctionID() const;
59 // returns a reference
61 void SetFunction(Function* function);
62 // package private
64 // mutable attributes follow (locking required)
65 DisassembledCode* GetSourceCode() const
66 { return fSourceCode; }
67 function_source_state SourceCodeState() const
68 { return fSourceCodeState; }
69 void SetSourceCode(DisassembledCode* source,
70 function_source_state state);
72 private:
73 ImageDebugInfo* fImageDebugInfo;
74 Function* fFunction;
75 FunctionDebugInfo* fFunctionDebugInfo;
76 DisassembledCode* fSourceCode;
77 function_source_state fSourceCodeState;
81 typedef DoublyLinkedList<FunctionInstance> FunctionInstanceList;
84 #endif // FUNCTION_INSTANCE_H