2010-06-09 00:52:24 +08:00
|
|
|
//===-- SBSymbol.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/SBSymbol.h"
|
2010-09-20 13:20:02 +08:00
|
|
|
#include "lldb/API/SBStream.h"
|
2010-10-06 11:09:58 +08:00
|
|
|
#include "lldb/Core/Disassembler.h"
|
2010-10-26 11:11:13 +08:00
|
|
|
#include "lldb/Core/Log.h"
|
2010-10-06 11:09:58 +08:00
|
|
|
#include "lldb/Core/Module.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
#include "lldb/Symbol/Symbol.h"
|
2010-10-06 11:09:58 +08:00
|
|
|
#include "lldb/Target/ExecutionContext.h"
|
|
|
|
#include "lldb/Target/Target.h"
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
using namespace lldb;
|
2010-10-06 11:09:58 +08:00
|
|
|
using namespace lldb_private;
|
2010-06-09 00:52:24 +08:00
|
|
|
|
|
|
|
SBSymbol::SBSymbol () :
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ptr (NULL)
|
2010-06-09 00:52:24 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SBSymbol::SBSymbol (lldb_private::Symbol *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
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-06 07:17:00 +08:00
|
|
|
SBSymbol::SBSymbol (const lldb::SBSymbol &rhs) :
|
|
|
|
m_opaque_ptr (rhs.m_opaque_ptr)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
const SBSymbol &
|
|
|
|
SBSymbol::operator = (const SBSymbol &rhs)
|
|
|
|
{
|
|
|
|
m_opaque_ptr = rhs.m_opaque_ptr;
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-09 00:52:24 +08:00
|
|
|
SBSymbol::~SBSymbol ()
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
m_opaque_ptr = NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBSymbol::IsValid () const
|
|
|
|
{
|
2010-06-23 09:19:29 +08:00
|
|
|
return m_opaque_ptr != NULL;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBSymbol::GetName() const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
const char *name = NULL;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ptr)
|
2010-10-30 12:51:46 +08:00
|
|
|
name = m_opaque_ptr->GetMangled().GetName().AsCString();
|
2010-10-27 07:49:36 +08:00
|
|
|
|
2010-10-30 12:51:46 +08:00
|
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
2010-10-26 11:11:13 +08:00
|
|
|
if (log)
|
2010-10-30 12:51:46 +08:00
|
|
|
log->Printf ("SBSymbol(%p)::GetName () => \"%s\"", m_opaque_ptr, name ? name : "");
|
|
|
|
return name;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
const char *
|
|
|
|
SBSymbol::GetMangledName () const
|
|
|
|
{
|
2010-10-30 12:51:46 +08:00
|
|
|
const char *name = NULL;
|
2010-06-23 09:19:29 +08:00
|
|
|
if (m_opaque_ptr)
|
2010-10-30 12:51:46 +08:00
|
|
|
name = m_opaque_ptr->GetMangled().GetMangledName().AsCString();
|
|
|
|
Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API);
|
|
|
|
if (log)
|
|
|
|
log->Printf ("SBSymbol(%p)::GetMangledName () => \"%s\"", m_opaque_ptr, name ? name : "");
|
|
|
|
|
|
|
|
return name;
|
2010-06-09 00:52:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
bool
|
|
|
|
SBSymbol::operator == (const SBSymbol &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
|
|
|
|
SBSymbol::operator != (const SBSymbol &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
|
|
|
}
|
2010-09-20 13:20:02 +08:00
|
|
|
|
|
|
|
bool
|
|
|
|
SBSymbol::GetDescription (SBStream &description)
|
|
|
|
{
|
|
|
|
if (m_opaque_ptr)
|
|
|
|
{
|
2010-09-23 07:01:29 +08:00
|
|
|
description.ref();
|
|
|
|
m_opaque_ptr->GetDescription (description.get(),
|
|
|
|
lldb::eDescriptionLevelFull, NULL);
|
2010-09-20 13:20:02 +08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
description.Printf ("No value");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-06 11:09:58 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SBInstructionList
|
|
|
|
SBSymbol::GetInstructions (SBTarget target)
|
|
|
|
{
|
|
|
|
SBInstructionList sb_instructions;
|
|
|
|
if (m_opaque_ptr)
|
|
|
|
{
|
|
|
|
ExecutionContext exe_ctx;
|
|
|
|
if (target.IsValid())
|
|
|
|
target->CalculateExecutionContext (exe_ctx);
|
|
|
|
const AddressRange *symbol_range = m_opaque_ptr->GetAddressRangePtr();
|
|
|
|
if (symbol_range)
|
|
|
|
{
|
|
|
|
Module *module = symbol_range->GetBaseAddress().GetModule();
|
|
|
|
if (module)
|
|
|
|
{
|
|
|
|
sb_instructions.SetDisassembler (Disassembler::DisassembleRange (module->GetArchitecture (),
|
|
|
|
exe_ctx,
|
|
|
|
*symbol_range));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sb_instructions;
|
|
|
|
}
|
|
|
|
|
2010-10-27 07:49:36 +08:00
|
|
|
lldb_private::Symbol *
|
|
|
|
SBSymbol::get ()
|
|
|
|
{
|
|
|
|
return m_opaque_ptr;
|
|
|
|
}
|