]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm/tools/lldb/source/API/SBModuleSpec.cpp
Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to
[FreeBSD/FreeBSD.git] / contrib / llvm / tools / lldb / source / API / SBModuleSpec.cpp
1 //===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 #include "lldb/API/SBModuleSpec.h"
11 #include "lldb/API/SBStream.h"
12 #include "lldb/Core/Module.h"
13 #include "lldb/Core/ModuleSpec.h"
14 #include "lldb/Host/Host.h"
15 #include "lldb/Symbol/ObjectFile.h"
16 #include "lldb/Utility/Stream.h"
17
18 using namespace lldb;
19 using namespace lldb_private;
20
21 SBModuleSpec::SBModuleSpec() : m_opaque_ap(new lldb_private::ModuleSpec()) {}
22
23 SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs)
24     : m_opaque_ap(new lldb_private::ModuleSpec(*rhs.m_opaque_ap)) {}
25
26 const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
27   if (this != &rhs)
28     *m_opaque_ap = *(rhs.m_opaque_ap);
29   return *this;
30 }
31
32 SBModuleSpec::~SBModuleSpec() {}
33
34 bool SBModuleSpec::IsValid() const { return m_opaque_ap->operator bool(); }
35
36 void SBModuleSpec::Clear() { m_opaque_ap->Clear(); }
37
38 SBFileSpec SBModuleSpec::GetFileSpec() {
39   SBFileSpec sb_spec(m_opaque_ap->GetFileSpec());
40   return sb_spec;
41 }
42
43 void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) {
44   m_opaque_ap->GetFileSpec() = *sb_spec;
45 }
46
47 lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() {
48   return SBFileSpec(m_opaque_ap->GetPlatformFileSpec());
49 }
50
51 void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) {
52   m_opaque_ap->GetPlatformFileSpec() = *sb_spec;
53 }
54
55 lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() {
56   return SBFileSpec(m_opaque_ap->GetSymbolFileSpec());
57 }
58
59 void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) {
60   m_opaque_ap->GetSymbolFileSpec() = *sb_spec;
61 }
62
63 const char *SBModuleSpec::GetObjectName() {
64   return m_opaque_ap->GetObjectName().GetCString();
65 }
66
67 void SBModuleSpec::SetObjectName(const char *name) {
68   m_opaque_ap->GetObjectName().SetCString(name);
69 }
70
71 const char *SBModuleSpec::GetTriple() {
72   std::string triple(m_opaque_ap->GetArchitecture().GetTriple().str());
73   // Unique the string so we don't run into ownership issues since the const
74   // strings put the string into the string pool once and the strings never
75   // comes out
76   ConstString const_triple(triple.c_str());
77   return const_triple.GetCString();
78 }
79
80 void SBModuleSpec::SetTriple(const char *triple) {
81   m_opaque_ap->GetArchitecture().SetTriple(triple);
82 }
83
84 const uint8_t *SBModuleSpec::GetUUIDBytes() {
85   return m_opaque_ap->GetUUID().GetBytes().data();
86 }
87
88 size_t SBModuleSpec::GetUUIDLength() {
89   return m_opaque_ap->GetUUID().GetBytes().size();
90 }
91
92 bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
93   m_opaque_ap->GetUUID() = UUID::fromOptionalData(uuid, uuid_len);
94   return m_opaque_ap->GetUUID().IsValid();
95 }
96
97 bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
98   m_opaque_ap->Dump(description.ref());
99   return true;
100 }
101
102 SBModuleSpecList::SBModuleSpecList() : m_opaque_ap(new ModuleSpecList()) {}
103
104 SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs)
105     : m_opaque_ap(new ModuleSpecList(*rhs.m_opaque_ap)) {}
106
107 SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
108   if (this != &rhs)
109     *m_opaque_ap = *rhs.m_opaque_ap;
110   return *this;
111 }
112
113 SBModuleSpecList::~SBModuleSpecList() {}
114
115 SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
116   SBModuleSpecList specs;
117   FileSpec file_spec(path, true);
118   Host::ResolveExecutableInBundle(file_spec);
119   ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap);
120   return specs;
121 }
122
123 void SBModuleSpecList::Append(const SBModuleSpec &spec) {
124   m_opaque_ap->Append(*spec.m_opaque_ap);
125 }
126
127 void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) {
128   m_opaque_ap->Append(*spec_list.m_opaque_ap);
129 }
130
131 size_t SBModuleSpecList::GetSize() { return m_opaque_ap->GetSize(); }
132
133 SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) {
134   SBModuleSpec sb_module_spec;
135   m_opaque_ap->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_ap);
136   return sb_module_spec;
137 }
138
139 SBModuleSpec
140 SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) {
141   SBModuleSpec sb_module_spec;
142   m_opaque_ap->FindMatchingModuleSpec(*match_spec.m_opaque_ap,
143                                       *sb_module_spec.m_opaque_ap);
144   return sb_module_spec;
145 }
146
147 SBModuleSpecList
148 SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) {
149   SBModuleSpecList specs;
150   m_opaque_ap->FindMatchingModuleSpecs(*match_spec.m_opaque_ap,
151                                        *specs.m_opaque_ap);
152   return specs;
153 }
154
155 bool SBModuleSpecList::GetDescription(lldb::SBStream &description) {
156   m_opaque_ap->Dump(description.ref());
157   return true;
158 }