1/*
2 * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3 * Copyright 2010-2013, Rene Gollent, rene@gollent.com.
4 * Distributed under the terms of the MIT License.
5 */
6#ifndef IMAGE_DEBUG_INFO_H
7#define IMAGE_DEBUG_INFO_H
8
9
10#include <String.h>
11
12#include <ObjectList.h>
13#include <Referenceable.h>
14
15#include "AddressSectionTypes.h"
16#include "ImageInfo.h"
17#include "Types.h"
18
19
20class Architecture;
21class DebuggerInterface;
22class FileSourceCode;
23class FunctionDebugInfo;
24class FunctionInstance;
25class GlobalTypeCache;
26class LocatableFile;
27class SpecificImageDebugInfo;
28class SymbolInfo;
29class Type;
30class TypeLookupConstraints;
31
32
33class ImageDebugInfo : public BReferenceable {
34public:
35								ImageDebugInfo(const ImageInfo& imageInfo);
36								~ImageDebugInfo();
37
38			const ImageInfo&	GetImageInfo() const	{ return fImageInfo; }
39
40			bool				AddSpecificInfo(SpecificImageDebugInfo* info);
41			status_t			FinishInit(DebuggerInterface* interface);
42
43			status_t			GetType(GlobalTypeCache* cache,
44									const BString& name,
45									const TypeLookupConstraints& constraints,
46									Type*& _type);
47									// returns a reference
48
49			bool				HasType(const BString& name,
50									const TypeLookupConstraints& constraints)
51									const;
52
53			AddressSectionType	GetAddressSectionType(target_addr_t address)
54									const;
55
56			int32				CountFunctions() const;
57			FunctionInstance*	FunctionAt(int32 index) const;
58			FunctionInstance*	FunctionAtAddress(target_addr_t address) const;
59			FunctionInstance*	FunctionByName(const char* name) const;
60
61			FunctionInstance*	MainFunction() const
62									{ return fMainFunction; }
63
64			status_t			AddSourceCodeInfo(LocatableFile* file,
65									FileSourceCode* sourceCode) const;
66
67private:
68			typedef BObjectList<SpecificImageDebugInfo> SpecificInfoList;
69			typedef BObjectList<FunctionInstance> FunctionList;
70
71private:
72	static	int					_CompareFunctions(const FunctionInstance* a,
73									const FunctionInstance* b);
74	static	int					_CompareAddressFunction(
75									const target_addr_t* address,
76									const FunctionInstance* function);
77	static	int					_CompareSymbols(const SymbolInfo* a,
78									const SymbolInfo* b);
79
80private:
81			ImageInfo			fImageInfo;
82			SpecificInfoList	fSpecificInfos;
83			FunctionList		fFunctions;
84			FunctionInstance*	fMainFunction;
85};
86
87
88#endif	// IMAGE_DEBUG_INFO_H
89