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.
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
;
25 class FunctionDebugInfo
;
30 class FunctionInstance
: public BReferenceable
,
31 public DoublyLinkedListLinkImpl
<FunctionInstance
> {
33 FunctionInstance(ImageDebugInfo
* imageDebugInfo
,
34 FunctionDebugInfo
* functionDebugInfo
);
37 ImageDebugInfo
* GetImageDebugInfo() const
38 { return fImageDebugInfo
; }
39 Function
* GetFunction() const
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
);
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
);
73 ImageDebugInfo
* fImageDebugInfo
;
75 FunctionDebugInfo
* fFunctionDebugInfo
;
76 DisassembledCode
* fSourceCode
;
77 function_source_state fSourceCodeState
;
81 typedef DoublyLinkedList
<FunctionInstance
> FunctionInstanceList
;
84 #endif // FUNCTION_INSTANCE_H