xref: /haiku/headers/private/debugger/debug_info/TeamDebugInfo.h (revision 3c08adef21129761f27ae654a1c5d1705786691a)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2014-2016, Rene Gollent, rene@gollent.com.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef TEAM_DEBUG_INFO_H
7 #define TEAM_DEBUG_INFO_H
8 
9 
10 #include <Locker.h>
11 
12 #include <ObjectList.h>
13 #include <Referenceable.h>
14 #include <util/OpenHashTable.h>
15 
16 #include "GlobalTypeLookup.h"
17 #include "ImageInfo.h"
18 #include "TeamFunctionSourceInformation.h"
19 #include "TeamTypeInformation.h"
20 
21 class Architecture;
22 class DebuggerInterface;
23 class DisassembledCode;
24 class FileManager;
25 class FileSourceCode;
26 class Function;
27 class FunctionID;
28 class FunctionInstance;
29 class ImageDebugInfo;
30 class ImageDebugInfoLoadingState;
31 class ImageInfo;
32 class LocatableFile;
33 class SourceCode;
34 class SourceLocation;
35 class SpecificTeamDebugInfo;
36 
37 
38 class TeamDebugInfo : public BReferenceable, public GlobalTypeLookup,
39 	public TeamTypeInformation, public TeamFunctionSourceInformation {
40 public:
41 								TeamDebugInfo(
42 									DebuggerInterface* debuggerInterface,
43 									Architecture* architecture,
44 									FileManager* fileManager);
45 								~TeamDebugInfo();
46 
47 			status_t			Init();
48 
49 	virtual	status_t			GetType(GlobalTypeCache* cache,
50 									const BString& name,
51 									const TypeLookupConstraints& constraints,
52 									Type*& _type);
53 	virtual	bool				HasType(GlobalTypeCache* cache,
54 									const BString& name,
55 									const TypeLookupConstraints& constraints);
56 
57 	virtual status_t			LookupTypeByName(const BString& name,
58 									const TypeLookupConstraints& constraints,
59 									Type*& _type);
60 	virtual	bool				TypeExistsByName(const BString& name,
61 									const TypeLookupConstraints& constraints);
62 
63 	virtual	status_t			GetActiveSourceCode(FunctionDebugInfo* info,
64 									SourceCode*& _code);
65 
66 			status_t			LoadImageDebugInfo(const ImageInfo& imageInfo,
67 									LocatableFile* imageFile,
68 									ImageDebugInfoLoadingState& state,
69 									ImageDebugInfo*& _imageDebugInfo);
70 
71 			status_t			LoadSourceCode(LocatableFile* file,
72 									FileSourceCode*& _sourceCode);
73 										// returns reference
74 			void				ClearSourceCode(LocatableFile* file);
75 
76 			status_t			DisassembleFunction(
77 									FunctionInstance* functionInstance,
78 									DisassembledCode*& _sourceCode);
79 										// returns reference
80 			FunctionInstance*	MainFunction() const
81 									{ return fMainFunction; }
82 
83 			// team is locked
84 			status_t			AddImageDebugInfo(
85 									ImageDebugInfo* imageDebugInfo);
86 			void				RemoveImageDebugInfo(
87 									ImageDebugInfo* imageDebugInfo);
88 			ImageDebugInfo*		ImageDebugInfoByName(const char* name) const;
89 
90 			Function*			FunctionAtSourceLocation(LocatableFile* file,
91 									const SourceLocation& location) const;
92 			Function*			FunctionByID(FunctionID* functionID) const;
93 
94 private:
95 			struct FunctionHashDefinition;
96 			struct SourceFileEntry;
97 			struct SourceFileHashDefinition;
98 
99 			typedef BObjectList<SpecificTeamDebugInfo> SpecificInfoList;
100 			typedef BObjectList<ImageDebugInfo> ImageList;
101 			typedef BOpenHashTable<FunctionHashDefinition> FunctionTable;
102 			typedef BOpenHashTable<SourceFileHashDefinition> SourceFileTable;
103 
104 private:
105 			status_t			_AddFunction(Function* function);
106 			void				_RemoveFunction(Function* function);
107 
108 private:
109 			BLocker				fLock;
110 			DebuggerInterface*	fDebuggerInterface;
111 			Architecture*		fArchitecture;
112 			FileManager*		fFileManager;
113 			SpecificInfoList	fSpecificInfos;
114 			ImageList			fImages;
115 			FunctionTable*		fFunctions;
116 			SourceFileTable*	fSourceFiles;
117 			GlobalTypeCache*	fTypeCache;
118 			FunctionInstance*	fMainFunction;
119 };
120 
121 
122 #endif	// TEAM_DEBUG_INFO_H
123