xref: /haiku/src/kits/debugger/dwarf/CompilationUnit.h (revision 3634f142352af2428aed187781fc9d75075e9140)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Copyright 2013, Rene Gollent, rene@gollent.com.
4  * Distributed under the terms of the MIT License.
5  */
6 #ifndef COMPILATION_UNIT_H
7 #define COMPILATION_UNIT_H
8 
9 #include <ObjectList.h>
10 #include <String.h>
11 
12 #include "BaseUnit.h"
13 #include "LineNumberProgram.h"
14 #include "Types.h"
15 
16 
17 class DIECompileUnitBase;
18 class TargetAddressRangeList;
19 
20 
21 class CompilationUnit : public BaseUnit {
22 public:
23 								CompilationUnit(off_t headerOffset,
24 									off_t contentOffset,
25 									off_t totalSize,
26 									off_t abbreviationOffset,
27 									uint8 addressSize, bool isBigEndian,
28 									bool isDwarf64);
29 	virtual						~CompilationUnit();
30 
31 	inline	target_addr_t		MaxAddress() const;
32 
33 			DIECompileUnitBase*	UnitEntry() const	{ return fUnitEntry; }
34 			void				SetUnitEntry(DIECompileUnitBase* entry);
35 
36 			TargetAddressRangeList* AddressRanges() const
37 									{ return fAddressRanges; }
38 			void				SetAddressRanges(
39 									TargetAddressRangeList* ranges);
40 
41 			target_addr_t		AddressRangeBase() const;
42 
43 			LineNumberProgram&	GetLineNumberProgram()
44 									{ return fLineNumberProgram; }
45 
46 			bool				AddDirectory(const char* directory);
47 			int32				CountDirectories() const;
48 			const char*			DirectoryAt(int32 index) const;
49 
50 			bool				AddFile(const char* fileName, int32 dirIndex);
51 			int32				CountFiles() const;
52 			const char*			FileAt(int32 index,
53 									const char** _directory = NULL) const;
54 
55 	virtual	dwarf_unit_kind		Kind() const;
56 
57 private:
58 			struct File;
59 			typedef BObjectList<BString> DirectoryList;
60 			typedef BObjectList<File> FileList;
61 
62 private:
63 			DIECompileUnitBase*	fUnitEntry;
64 			TargetAddressRangeList* fAddressRanges;
65 			DirectoryList		fDirectories;
66 			FileList			fFiles;
67 			LineNumberProgram	fLineNumberProgram;
68 };
69 
70 
71 target_addr_t
72 CompilationUnit::MaxAddress() const
73 {
74 	return AddressSize() == 4 ? 0xffffffffULL : 0xffffffffffffffffULL;
75 }
76 
77 
78 #endif	// COMPILATION_UNIT_H
79