1 //===-- SBModuleSpec.cpp ----------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
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"
19 using namespace lldb_private;
21 SBModuleSpec::SBModuleSpec() : m_opaque_ap(new lldb_private::ModuleSpec()) {}
23 SBModuleSpec::SBModuleSpec(const SBModuleSpec &rhs)
24 : m_opaque_ap(new lldb_private::ModuleSpec(*rhs.m_opaque_ap)) {}
26 const SBModuleSpec &SBModuleSpec::operator=(const SBModuleSpec &rhs) {
28 *m_opaque_ap = *(rhs.m_opaque_ap);
32 SBModuleSpec::~SBModuleSpec() {}
34 bool SBModuleSpec::IsValid() const { return m_opaque_ap->operator bool(); }
36 void SBModuleSpec::Clear() { m_opaque_ap->Clear(); }
38 SBFileSpec SBModuleSpec::GetFileSpec() {
39 SBFileSpec sb_spec(m_opaque_ap->GetFileSpec());
43 void SBModuleSpec::SetFileSpec(const lldb::SBFileSpec &sb_spec) {
44 m_opaque_ap->GetFileSpec() = *sb_spec;
47 lldb::SBFileSpec SBModuleSpec::GetPlatformFileSpec() {
48 return SBFileSpec(m_opaque_ap->GetPlatformFileSpec());
51 void SBModuleSpec::SetPlatformFileSpec(const lldb::SBFileSpec &sb_spec) {
52 m_opaque_ap->GetPlatformFileSpec() = *sb_spec;
55 lldb::SBFileSpec SBModuleSpec::GetSymbolFileSpec() {
56 return SBFileSpec(m_opaque_ap->GetSymbolFileSpec());
59 void SBModuleSpec::SetSymbolFileSpec(const lldb::SBFileSpec &sb_spec) {
60 m_opaque_ap->GetSymbolFileSpec() = *sb_spec;
63 const char *SBModuleSpec::GetObjectName() {
64 return m_opaque_ap->GetObjectName().GetCString();
67 void SBModuleSpec::SetObjectName(const char *name) {
68 m_opaque_ap->GetObjectName().SetCString(name);
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
74 // the const strings put the string into the string pool once and
75 // the strings never comes out
76 ConstString const_triple(triple.c_str());
77 return const_triple.GetCString();
80 void SBModuleSpec::SetTriple(const char *triple) {
81 m_opaque_ap->GetArchitecture().SetTriple(triple);
84 const uint8_t *SBModuleSpec::GetUUIDBytes() {
85 return (const uint8_t *)m_opaque_ap->GetUUID().GetBytes();
88 size_t SBModuleSpec::GetUUIDLength() {
89 return m_opaque_ap->GetUUID().GetByteSize();
92 bool SBModuleSpec::SetUUIDBytes(const uint8_t *uuid, size_t uuid_len) {
93 return m_opaque_ap->GetUUID().SetBytes(uuid, uuid_len);
96 bool SBModuleSpec::GetDescription(lldb::SBStream &description) {
97 m_opaque_ap->Dump(description.ref());
101 SBModuleSpecList::SBModuleSpecList() : m_opaque_ap(new ModuleSpecList()) {}
103 SBModuleSpecList::SBModuleSpecList(const SBModuleSpecList &rhs)
104 : m_opaque_ap(new ModuleSpecList(*rhs.m_opaque_ap)) {}
106 SBModuleSpecList &SBModuleSpecList::operator=(const SBModuleSpecList &rhs) {
108 *m_opaque_ap = *rhs.m_opaque_ap;
112 SBModuleSpecList::~SBModuleSpecList() {}
114 SBModuleSpecList SBModuleSpecList::GetModuleSpecifications(const char *path) {
115 SBModuleSpecList specs;
116 FileSpec file_spec(path, true);
117 Host::ResolveExecutableInBundle(file_spec);
118 ObjectFile::GetModuleSpecifications(file_spec, 0, 0, *specs.m_opaque_ap);
122 void SBModuleSpecList::Append(const SBModuleSpec &spec) {
123 m_opaque_ap->Append(*spec.m_opaque_ap);
126 void SBModuleSpecList::Append(const SBModuleSpecList &spec_list) {
127 m_opaque_ap->Append(*spec_list.m_opaque_ap);
130 size_t SBModuleSpecList::GetSize() { return m_opaque_ap->GetSize(); }
132 SBModuleSpec SBModuleSpecList::GetSpecAtIndex(size_t i) {
133 SBModuleSpec sb_module_spec;
134 m_opaque_ap->GetModuleSpecAtIndex(i, *sb_module_spec.m_opaque_ap);
135 return sb_module_spec;
139 SBModuleSpecList::FindFirstMatchingSpec(const SBModuleSpec &match_spec) {
140 SBModuleSpec sb_module_spec;
141 m_opaque_ap->FindMatchingModuleSpec(*match_spec.m_opaque_ap,
142 *sb_module_spec.m_opaque_ap);
143 return sb_module_spec;
147 SBModuleSpecList::FindMatchingSpecs(const SBModuleSpec &match_spec) {
148 SBModuleSpecList specs;
149 m_opaque_ap->FindMatchingModuleSpecs(*match_spec.m_opaque_ap,
154 bool SBModuleSpecList::GetDescription(lldb::SBStream &description) {
155 m_opaque_ap->Dump(description.ref());