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
14DwarfFunctionDebugInfo::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
36DwarfFunctionDebugInfo::~DwarfFunctionDebugInfo()
37{
38	if (fSourceFile != NULL)
39		fSourceFile->ReleaseReference();
40
41	fAddressRanges->ReleaseReference();
42	fImageDebugInfo->ReleaseReference();
43}
44
45
46SpecificImageDebugInfo*
47DwarfFunctionDebugInfo::GetSpecificImageDebugInfo() const
48{
49	return fImageDebugInfo;
50}
51
52
53target_addr_t
54DwarfFunctionDebugInfo::Address() const
55{
56	return fAddressRanges->LowestAddress() + fImageDebugInfo->RelocationDelta();
57}
58
59
60target_size_t
61DwarfFunctionDebugInfo::Size() const
62{
63	return fAddressRanges->CoveringRange().Size();
64}
65
66
67const BString&
68DwarfFunctionDebugInfo::Name() const
69{
70	return fName;
71}
72
73
74const BString&
75DwarfFunctionDebugInfo::PrettyName() const
76{
77	return fName;
78}
79
80
81bool
82DwarfFunctionDebugInfo::IsMain() const
83{
84	return fSubprogramEntry->IsMain();
85}
86
87
88LocatableFile*
89DwarfFunctionDebugInfo::SourceFile() const
90{
91	return fSourceFile;
92}
93
94
95SourceLocation
96DwarfFunctionDebugInfo::SourceStartLocation() const
97{
98	return fSourceLocation;
99}
100
101
102SourceLocation
103DwarfFunctionDebugInfo::SourceEndLocation() const
104{
105	return fSourceLocation;
106}
107