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
70 if (m_opaque_ap.get())
71 sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
73 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
77 const Address *addr = sb_address.get();
79 addr->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4);
80 log->Printf ("SBLineEntry(%p)::GetStartAddress () => SBAddress (%p): %s",
81 static_cast<void*>(m_opaque_ap.get()),
82 static_cast<void*>(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 static_cast<void*>(m_opaque_ap.get()),
106 static_cast<void*>(sb_address.get()), sstr.GetData());
112 SBLineEntry::IsValid () const
114 return m_opaque_ap.get() && m_opaque_ap->IsValid();
119 SBLineEntry::GetFileSpec () const
121 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
123 SBFileSpec sb_file_spec;
124 if (m_opaque_ap.get() && m_opaque_ap->file)
125 sb_file_spec.SetFileSpec(m_opaque_ap->file);
130 sb_file_spec.GetDescription (sstr);
131 log->Printf ("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s",
132 static_cast<void*>(m_opaque_ap.get()),
133 static_cast<const void*>(sb_file_spec.get()),
141 SBLineEntry::GetLine () const
143 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
146 if (m_opaque_ap.get())
147 line = m_opaque_ap->line;
150 log->Printf ("SBLineEntry(%p)::GetLine () => %u",
151 static_cast<void*>(m_opaque_ap.get()), line);
158 SBLineEntry::GetColumn () const
160 if (m_opaque_ap.get())
161 return m_opaque_ap->column;
166 SBLineEntry::SetFileSpec (lldb::SBFileSpec filespec)
168 if (filespec.IsValid())
169 ref().file = filespec.ref();
174 SBLineEntry::SetLine (uint32_t line)
180 SBLineEntry::SetColumn (uint32_t column)
188 SBLineEntry::operator == (const SBLineEntry &rhs) const
190 lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
191 lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
193 if (lhs_ptr && rhs_ptr)
194 return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0;
196 return lhs_ptr == rhs_ptr;
200 SBLineEntry::operator != (const SBLineEntry &rhs) const
202 lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
203 lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
205 if (lhs_ptr && rhs_ptr)
206 return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0;
208 return lhs_ptr != rhs_ptr;
211 const lldb_private::LineEntry *
212 SBLineEntry::operator->() const
214 return m_opaque_ap.get();
217 lldb_private::LineEntry &
220 if (m_opaque_ap.get() == NULL)
221 m_opaque_ap.reset (new lldb_private::LineEntry ());
225 const lldb_private::LineEntry &
226 SBLineEntry::ref() const
232 SBLineEntry::GetDescription (SBStream &description)
234 Stream &strm = description.ref();
236 if (m_opaque_ap.get())
238 char file_path[PATH_MAX*2];
239 m_opaque_ap->file.GetPath (file_path, sizeof (file_path));
240 strm.Printf ("%s:%u", file_path, GetLine());
242 strm.Printf (":%u", GetColumn());
245 strm.PutCString ("No value");
250 lldb_private::LineEntry *
253 return m_opaque_ap.get();