2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBCompileUnit.cpp ---------------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "lldb/API/SBCompileUnit.h"
|
|
|
|
#include "lldb/API/SBLineEntry.h"
|
|
|
|
#include "lldb/Symbol/CompileUnit.h"
|
|
|
|
#include "lldb/Symbol/LineEntry.h"
|
|
|
|
#include "lldb/Symbol/LineTable.h"
|
|
|
|
|
|
|
|
using namespace lldb;
|
|
|
|
using namespace lldb_private;
|
|
|
|
|
|
|
|
|
|
|
|
SBCompileUnit::SBCompileUnit () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ptr (NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBCompileUnit::SBCompileUnit (lldb_private::CompileUnit *lldb_object_ptr) :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ptr (lldb_object_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBCompileUnit::~SBCompileUnit ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ptr = NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
SBFileSpec
|
|
|
|
SBCompileUnit::GetFileSpec () const
|
|
|
|
{
|
|
|
|
SBFileSpec file_spec;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ptr)
|
|
|
|
file_spec.SetFileSpec(*m_opaque_ptr);
|
2010-06-09 00:52:24 +08:00
|
|
|
return file_spec;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBCompileUnit::GetNumLineEntries () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
LineTable *line_table = m_opaque_ptr->GetLineTable ();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (line_table)
|
|
|
|
return line_table->GetSize();
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
SBLineEntry
|
|
|
|
SBCompileUnit::GetLineEntryAtIndex (uint32_t idx) const
|
|
|
|
{
|
|
|
|
SBLineEntry sb_line_entry;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
LineTable *line_table = m_opaque_ptr->GetLineTable ();
|
2010-06-09 00:52:24 +08:00
|
|
|
if (line_table)
|
|
|
|
{
|
|
|
|
LineEntry line_entry;
|
|
|
|
if (line_table->GetLineEntryAtIndex(idx, line_entry))
|
|
|
|
sb_line_entry.SetLineEntry(line_entry);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_line_entry;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
SBCompileUnit::FindLineEntryIndex (uint32_t start_idx, uint32_t line, SBFileSpec *inline_file_spec) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ptr)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
FileSpec file_spec;
|
|
|
|
if (inline_file_spec && inline_file_spec->IsValid())
|
|
|
|
file_spec = inline_file_spec->ref();
|
|
|
|
else
|
2010-06-23 09:19:29 +08:00
|
|
|
file_spec = *m_opaque_ptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ptr->FindLineEntry (start_idx,
|
2010-06-09 00:52:24 +08:00
|
|
|
line,
|
|
|
|
inline_file_spec ? inline_file_spec->get() : NULL,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
return UINT32_MAX;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBCompileUnit::IsValid () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ptr != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBCompileUnit::operator == (const SBCompileUnit &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ptr == rhs.m_opaque_ptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBCompileUnit::operator != (const SBCompileUnit &rhs) const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ptr != rhs.m_opaque_ptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::CompileUnit *
|
|
|
|
SBCompileUnit::operator->() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const lldb_private::CompileUnit &
|
|
|
|
SBCompileUnit::operator*() const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return *m_opaque_ptr;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|