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 8 9 #include <util/DoublyLinkedList.h> 10 11 #include "FunctionDebugInfo.h" 12 13 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 20 }; 21 22 23 class DisassembledCode; 24 class Function; 25 class FunctionDebugInfo; 26 class FunctionID; 27 class ImageDebugInfo; 28 29 30 class FunctionInstance : public BReferenceable, 31 public DoublyLinkedListLinkImpl<FunctionInstance> { 32 public: 33 FunctionInstance(ImageDebugInfo* imageDebugInfo, 34 FunctionDebugInfo* functionDebugInfo); 35 ~FunctionInstance(); 36 GetImageDebugInfo()37 ImageDebugInfo* GetImageDebugInfo() const 38 { return fImageDebugInfo; } GetFunction()39 Function* GetFunction() const 40 { return fFunction; } GetFunctionDebugInfo()41 FunctionDebugInfo* GetFunctionDebugInfo() const 42 { return fFunctionDebugInfo; } 43 Address()44 target_addr_t Address() const 45 { return fFunctionDebugInfo->Address(); } Size()46 target_size_t Size() const 47 { return fFunctionDebugInfo->Size(); } Name()48 const BString& Name() const 49 { return fFunctionDebugInfo->Name(); } PrettyName()50 const BString& PrettyName() const 51 { return fFunctionDebugInfo->PrettyName(); } SourceFile()52 LocatableFile* SourceFile() const 53 { return fFunctionDebugInfo->SourceFile(); } GetSourceLocation()54 SourceLocation GetSourceLocation() const 55 { return fFunctionDebugInfo 56 ->SourceStartLocation(); } 57 58 FunctionID* GetFunctionID() const; 59 // returns a reference 60 61 void SetFunction(Function* function); 62 // package private 63 64 // mutable attributes follow (locking required) GetSourceCode()65 DisassembledCode* GetSourceCode() const 66 { return fSourceCode; } SourceCodeState()67 function_source_state SourceCodeState() const 68 { return fSourceCodeState; } 69 void SetSourceCode(DisassembledCode* source, 70 function_source_state state); 71 72 private: 73 ImageDebugInfo* fImageDebugInfo; 74 Function* fFunction; 75 FunctionDebugInfo* fFunctionDebugInfo; 76 DisassembledCode* fSourceCode; 77 function_source_state fSourceCodeState; 78 }; 79 80 81 typedef DoublyLinkedList<FunctionInstance> FunctionInstanceList; 82 83 84 #endif // FUNCTION_INSTANCE_H 85