xref: /haiku/src/kits/debugger/debug_info/DwarfFunctionDebugInfo.cpp (revision ed24eb5ff12640d052171c6a7feba37fab8a75d1)
1 /*
2  * Copyright 2009, Ingo Weinhold, ingo_weinhold@gmx.de.
3  * Distributed under the terms of the MIT License.
4  */
5 
6 #include "DwarfFunctionDebugInfo.h"
7 
8 #include "DebugInfoEntries.h"
9 #include "DwarfImageDebugInfo.h"
10 #include "LocatableFile.h"
11 #include "TargetAddressRangeList.h"
12 
13 
14 DwarfFunctionDebugInfo::DwarfFunctionDebugInfo(
15 	DwarfImageDebugInfo* imageDebugInfo, CompilationUnit* compilationUnit,
16 	DIESubprogram* subprogramEntry, TargetAddressRangeList* addressRanges,
17 	const BString& name, LocatableFile* sourceFile,
18 	const SourceLocation& sourceLocation)
19 	:
20 	fImageDebugInfo(imageDebugInfo),
21 	fCompilationUnit(compilationUnit),
22 	fSubprogramEntry(subprogramEntry),
23 	fAddressRanges(addressRanges),
24 	fName(name),
25 	fSourceFile(sourceFile),
26 	fSourceLocation(sourceLocation)
27 {
28 	fImageDebugInfo->AcquireReference();
29 	fAddressRanges->AcquireReference();
30 
31 	if (fSourceFile != NULL)
32 		fSourceFile->AcquireReference();
33 }
34 
35 
36 DwarfFunctionDebugInfo::~DwarfFunctionDebugInfo()
37 {
38 	if (fSourceFile != NULL)
39 		fSourceFile->ReleaseReference();
40 
41 	fAddressRanges->ReleaseReference();
42 	fImageDebugInfo->ReleaseReference();
43 }
44 
45 
46 SpecificImageDebugInfo*
47 DwarfFunctionDebugInfo::GetSpecificImageDebugInfo() const
48 {
49 	return fImageDebugInfo;
50 }
51 
52 
53 target_addr_t
54 DwarfFunctionDebugInfo::Address() const
55 {
56 	return fAddressRanges->LowestAddress() + fImageDebugInfo->RelocationDelta();
57 }
58 
59 
60 target_size_t
61 DwarfFunctionDebugInfo::Size() const
62 {
63 	return fAddressRanges->CoveringRange().Size();
64 }
65 
66 
67 const BString&
68 DwarfFunctionDebugInfo::Name() const
69 {
70 	return fName;
71 }
72 
73 
74 const BString&
75 DwarfFunctionDebugInfo::PrettyName() const
76 {
77 	return fName;
78 }
79 
80 
81 bool
82 DwarfFunctionDebugInfo::IsMain() const
83 {
84 	return fSubprogramEntry->IsMain();
85 }
86 
87 
88 LocatableFile*
89 DwarfFunctionDebugInfo::SourceFile() const
90 {
91 	return fSourceFile;
92 }
93 
94 
95 SourceLocation
96 DwarfFunctionDebugInfo::SourceStartLocation() const
97 {
98 	return fSourceLocation;
99 }
100 
101 
102 SourceLocation
103 DwarfFunctionDebugInfo::SourceEndLocation() const
104 {
105 	return fSourceLocation;
106 }
107