2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBLineEntry.cpp -----------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2011-04-08 21:36:44 +08:00
|
|
|
#include <limits.h>
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/API/SBLineEntry.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-10-31 11:01:06 +08:00
|
|
|
#include "lldb/Core/StreamString.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-10-31 11:01:06 +08:00
|
|
|
#include "lldb/Symbol/LineEntry.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-10-26 11:11:13 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
|
|
|
|
SBLineEntry::SBLineEntry () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBLineEntry::SBLineEntry (const SBLineEntry &rhs) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (rhs.IsValid())
|
2011-09-26 15:11:27 +08:00
|
|
|
ref() = rhs.ref();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBLineEntry::SBLineEntry (const lldb_private::LineEntry *lldb_object_ptr) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ap ()
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
if (lldb_object_ptr)
|
2011-09-26 15:11:27 +08:00
|
|
|
ref() = *lldb_object_ptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const SBLineEntry &
|
|
|
|
SBLineEntry::operator = (const SBLineEntry &rhs)
|
|
|
|
{
|
2011-09-26 15:11:27 +08:00
|
|
|
if (this != &rhs)
|
|
|
|
{
|
|
|
|
if (rhs.IsValid())
|
|
|
|
ref() = rhs.ref();
|
|
|
|
else
|
|
|
|
m_opaque_ap.reset();
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLineEntry::SetLineEntry (const lldb_private::LineEntry &lldb_object_ref)
|
|
|
|
{
|
2011-09-26 15:11:27 +08:00
|
|
|
ref() = lldb_object_ref;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBLineEntry::~SBLineEntry ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBAddress
|
|
|
|
SBLineEntry::GetStartAddress () const
|
|
|
|
{
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBAddress sb_address;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
|
|
|
{
|
2010-10-31 11:01:06 +08:00
|
|
|
StreamString sstr;
|
2012-04-05 04:36:48 +08:00
|
|
|
const Address *addr = sb_address.get();
|
|
|
|
if (addr)
|
|
|
|
addr->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4);
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBLineEntry(%p)::GetStartAddress () => SBAddress (%p): %s",
|
|
|
|
m_opaque_ap.get(), sb_address.get(), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBAddress
|
|
|
|
SBLineEntry::GetEndAddress () const
|
|
|
|
{
|
|
|
|
SBAddress sb_address;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
sb_address.SetAddress(&m_opaque_ap->range.GetBaseAddress());
|
|
|
|
sb_address.OffsetAddress(m_opaque_ap->range.GetByteSize());
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-31 11:01:06 +08:00
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
StreamString sstr;
|
2012-04-05 04:36:48 +08:00
|
|
|
const Address *addr = sb_address.get();
|
|
|
|
if (addr)
|
|
|
|
addr->Dump (&sstr, NULL, Address::DumpStyleModuleWithFileAddress, Address::DumpStyleInvalid, 4);
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBLineEntry(%p)::GetEndAddress () => SBAddress (%p): %s",
|
|
|
|
m_opaque_ap.get(), sb_address.get(), sstr.GetData());
|
|
|
|
}
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_address;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLineEntry::IsValid () const
|
|
|
|
{
|
2012-06-28 04:18:01 +08:00
|
|
|
return m_opaque_ap.get() && m_opaque_ap->IsValid();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SBFileSpec
|
|
|
|
SBLineEntry::GetFileSpec () const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBFileSpec sb_file_spec;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get() && m_opaque_ap->file)
|
|
|
|
sb_file_spec.SetFileSpec(m_opaque_ap->file);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
if (log)
|
|
|
|
{
|
|
|
|
SBStream sstr;
|
|
|
|
sb_file_spec.GetDescription (sstr);
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBLineEntry(%p)::GetFileSpec () => SBFileSpec(%p): %s", m_opaque_ap.get(),
|
2010-10-27 07:49:36 +08:00
|
|
|
sb_file_spec.get(), sstr.GetData());
|
2010-10-26 11:11:13 +08:00
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
return sb_file_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBLineEntry::GetLine () const
|
|
|
|
{
|
2013-03-28 07:08:40 +08:00
|
|
|
Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
uint32_t line = 0;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
2010-10-26 11:11:13 +08:00
|
|
|
line = m_opaque_ap->line;
|
|
|
|
|
|
|
|
if (log)
|
2010-10-31 11:01:06 +08:00
|
|
|
log->Printf ("SBLineEntry(%p)::GetLine () => %u", m_opaque_ap.get(), line);
|
2010-10-26 11:11:13 +08:00
|
|
|
|
|
|
|
return line;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBLineEntry::GetColumn () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
return m_opaque_ap->column;
|
2010-06-09 00:52:24 +08:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-09-26 15:11:27 +08:00
|
|
|
void
|
|
|
|
SBLineEntry::SetFileSpec (lldb::SBFileSpec filespec)
|
|
|
|
{
|
|
|
|
if (filespec.IsValid())
|
|
|
|
ref().file = filespec.ref();
|
|
|
|
else
|
|
|
|
ref().file.Clear();
|
|
|
|
}
|
|
|
|
void
|
|
|
|
SBLineEntry::SetLine (uint32_t line)
|
|
|
|
{
|
|
|
|
ref().line = line;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
SBLineEntry::SetColumn (uint32_t column)
|
|
|
|
{
|
|
|
|
ref().line = column;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
bool
|
|
|
|
SBLineEntry::operator == (const SBLineEntry &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
|
|
|
|
lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
|
|
return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) == 0;
|
|
|
|
|
|
|
|
return lhs_ptr == rhs_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBLineEntry::operator != (const SBLineEntry &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
lldb_private::LineEntry *lhs_ptr = m_opaque_ap.get();
|
|
|
|
lldb_private::LineEntry *rhs_ptr = rhs.m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
if (lhs_ptr && rhs_ptr)
|
|
|
|
return lldb_private::LineEntry::Compare (*lhs_ptr, *rhs_ptr) != 0;
|
|
|
|
|
|
|
|
return lhs_ptr != rhs_ptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::LineEntry *
|
|
|
|
SBLineEntry::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ap.get();
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2011-09-26 15:11:27 +08:00
|
|
|
lldb_private::LineEntry &
|
|
|
|
SBLineEntry::ref()
|
|
|
|
{
|
|
|
|
if (m_opaque_ap.get() == NULL)
|
|
|
|
m_opaque_ap.reset (new lldb_private::LineEntry ());
|
|
|
|
return *m_opaque_ap;
|
|
|
|
}
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
const lldb_private::LineEntry &
|
2011-09-26 15:11:27 +08:00
|
|
|
SBLineEntry::ref() const
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ap;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
bool
|
|
|
|
SBLineEntry::GetDescription (SBStream &description)
|
|
|
|
{
|
2011-11-13 14:57:31 +08:00
|
|
|
Stream &strm = description.ref();
|
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
if (m_opaque_ap.get())
|
|
|
|
{
|
|
|
|
char file_path[PATH_MAX*2];
|
|
|
|
m_opaque_ap->file.GetPath (file_path, sizeof (file_path));
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.Printf ("%s:%u", file_path, GetLine());
|
2010-09-20 13:20:02 +08:00
|
|
|
if (GetColumn() > 0)
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.Printf (":%u", GetColumn());
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
else
|
2011-11-13 14:57:31 +08:00
|
|
|
strm.PutCString ("No value");
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-09-20 13:20:02 +08:00
|
|
|
return true;
|
|
|
|
}
|
2010-10-27 07:49:36 +08:00
|
|
|
|
|
|
|
lldb_private::LineEntry *
|
|
|
|
SBLineEntry::get ()
|
|
|
|
{
|
|
|
|
return m_opaque_ap.get();
|
|
|
|
}
|