1 //===-- SBLineEntry.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 //===----------------------------------------------------------------------===//
12 #include "lldb/API/SBLineEntry.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/Core/StreamString.h"
15 #include "lldb/Core/Log.h"
16 #include "lldb/Symbol/LineEntry.h"
19 using namespace lldb_private;
22 SBLineEntry::SBLineEntry () :
27 SBLineEntry::SBLineEntry (const SBLineEntry &rhs) :
34 SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
38 ref() = *lldb_object_ptr;
42 SBLineEntry::operator = (const SBLineEntry &rhs)
55 SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
57 ref() = lldb_object_ref;
61 SBLineEntry::~SBLineEntry ()
67 SBLineEntry::GetStartAddress () const
71 if (m_opaque_ap.get())
72 sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
74 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
78 const Address *addr = sb_address.get();
80 addr->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4);
81 log->Printf ("SBLineEntry(%p)::GetStartAddress () => SBAddress (%p): %s",
82 m_opaque_ap.get(), sb_address.get(), sstr.GetData());
89 SBLineEntry::GetEndAddress () const
92 if (m_opaque_ap.get())
94 sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
95 sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize());
97 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
101 const Address *addr = sb_address.get();
103 addr->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4);
104 log->Printf ("SBLineEntry(%p)::GetEndAddress () => SBAddress (%p): %s",
105 m_opaque_ap.get(), sb_address.get(), sstr.GetData());
111 SBLineEntry::IsValid () const
113 return m_opaque_ap.get() && m_opaque_ap->IsValid();
118 SBLineEntry::GetFileSpec () const
120 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
122 SBFileSpec sb_file_spec;
123 if (m_opaque_ap.get() && m_opaque_ap->file)
124 sb_file_spec.SetFileSpec(m_opaque_ap->file);
129 sb_file_spec.GetDescription (sstr);
130 log->Printf ("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s", m_opaque_ap.get(),
131 sb_file_spec.get(), sstr.GetData());
138 SBLineEntry::GetLine () const
140 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
143 if (m_opaque_ap.get())
144 line = m_opaque_ap->line;
147 log->Printf ("SBLineEntry(%p)::GetLine () => %u", m_opaque_ap.get(), line);
154 SBLineEntry::GetColumn () const
156 if (m_opaque_ap.get())
157 return m_opaque_ap->column;
162 SBLineEntry::SetFileSpec (lldb::SBFileSpec filespec)
164 if (filespec.IsValid())
165 ref().file = filespec.ref();
170 SBLineEntry::SetLine (uint32_t line)
176 SBLineEntry::SetColumn (uint32_t column)
184 SBLineEntry::operator == (const SBLineEntry &rhs) const
186 lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
187 lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
189 if (lhs_ptr && rhs_ptr)
190 return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0;
192 return lhs_ptr == rhs_ptr;
196 SBLineEntry::operator != (const SBLineEntry &rhs) const
198 lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
199 lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
201 if (lhs_ptr && rhs_ptr)
202 return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0;
204 return lhs_ptr != rhs_ptr;
207 const lldb_private::LineEntry *
208 SBLineEntry::operator->() const
210 return m_opaque_ap.get();
213 lldb_private::LineEntry &
216 if (m_opaque_ap.get() == NULL)
217 m_opaque_ap.reset (new lldb_private::LineEntry ());
221 const lldb_private::LineEntry &
222 SBLineEntry::ref() const
228 SBLineEntry::GetDescription (SBStream &description)
230 Stream &strm = description.ref();
232 if (m_opaque_ap.get())
234 char file_path[PATH_MAX*2];
235 m_opaque_ap->file.GetPath (file_path, sizeof (file_path));
236 strm.Printf ("%s:%u", file_path, GetLine());
238 strm.Printf (":%u", GetColumn());
241 strm.PutCString ("No value");
246 lldb_private::LineEntry *
249 return m_opaque_ap.get();