Newer
Older
//===-- SymbolContext.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/Symbol/SymbolContext.h"
#include "lldb/Core/Log.h"
#include "lldb/Core/Module.h"
#include "lldb/Host/Host.h"
#include "lldb/Host/StringConvert.h"
#include "lldb/Symbol/Block.h"
#include "lldb/Symbol/ClangASTContext.h"
#include "lldb/Symbol/CompileUnit.h"
#include "lldb/Symbol/ObjectFile.h"
#include "lldb/Symbol/Symbol.h"
#include "lldb/Symbol/SymbolFile.h"
#include "lldb/Symbol/SymbolVendor.h"
#include "lldb/Symbol/Variable.h"
#include "lldb/Target/Target.h"
using namespace lldb;
using namespace lldb_private;
SymbolContext::SymbolContext() :
target_sp (),
module_sp (),
comp_unit (nullptr),
function (nullptr),
block (nullptr),
symbol (nullptr),
variable (nullptr)
{
}
SymbolContext::SymbolContext(const ModuleSP& m, CompileUnit *cu, Function *f, Block *b, LineEntry *le, Symbol *s) :
target_sp (),
module_sp (m),
comp_unit (cu),
function (f),
block (b),
line_entry (),
symbol (s),
variable (nullptr)
{
if (le)
line_entry = *le;
}
SymbolContext::SymbolContext(const TargetSP &t, const ModuleSP& m, CompileUnit *cu, Function *f, Block *b, LineEntry *le, Symbol *s) :
target_sp (t),
module_sp (m),
comp_unit (cu),
function (f),
block (b),
line_entry (),
symbol (s),
variable (nullptr)
{
if (le)
line_entry = *le;
}
SymbolContext::SymbolContext(const SymbolContext& rhs) :
target_sp (rhs.target_sp),
module_sp (rhs.module_sp),
comp_unit (rhs.comp_unit),
function (rhs.function),
block (rhs.block),
line_entry (rhs.line_entry),
symbol (rhs.symbol),
variable (rhs.variable)
{
}
SymbolContext::SymbolContext (SymbolContextScope *sc_scope) :
target_sp (),
module_sp (),
comp_unit (nullptr),
function (nullptr),
block (nullptr),
symbol (nullptr),
variable (nullptr)
{
sc_scope->CalculateSymbolContext (this);
}
SymbolContext::~SymbolContext ()
{
}
const SymbolContext&
SymbolContext::operator= (const SymbolContext& rhs)
{
if (this != &rhs)
{
target_sp = rhs.target_sp;
module_sp = rhs.module_sp;
comp_unit = rhs.comp_unit;
function = rhs.function;
block = rhs.block;
line_entry = rhs.line_entry;
symbol = rhs.symbol;
variable = rhs.variable;
}
return *this;
}
void
module_sp.reset();
comp_unit = nullptr;
function = nullptr;
block = nullptr;
line_entry.Clear();
symbol = nullptr;
variable = nullptr;
SymbolContext::DumpStopContext (
Stream *s,
ExecutionContextScope *exe_scope,
const Address &addr,
bool show_fullpaths,
Greg Clayton
committed
bool show_module,
bool show_inlined_frames,
bool show_function_arguments,
bool show_function_name
bool dumped_something = false;
if (show_module && module_sp)
{
if (show_fullpaths)
*s << module_sp->GetFileSpec();
else
*s << module_sp->GetFileSpec().GetFilename();
s->PutChar('`');
dumped_something = true;
if (function != nullptr)
SymbolContext inline_parent_sc;
Address inline_parent_addr;
if (show_function_name == false)
{
s->Printf("<");
dumped_something = true;
}
Greg Clayton
committed
else
Greg Clayton
committed
ConstString name;
if (show_function_arguments == false)
name = function->GetNameNoArguments();
if (!name)
name = function->GetName();
if (name)
name.Dump(s);
Greg Clayton
committed
if (addr.IsValid())
{
const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset();
if (show_function_name == false)
{
// Print +offset even if offset is 0
dumped_something = true;
s->Printf("+%" PRIu64 ">", function_offset);
}
else if (function_offset)
{
dumped_something = true;
s->Printf(" + %" PRIu64, function_offset);
Greg Clayton
committed
}
if (GetParentOfInlinedScope (addr, inline_parent_sc, inline_parent_addr))
dumped_something = true;
Block *inlined_block = block->GetContainingInlinedBlock();
const InlineFunctionInfo* inlined_block_info = inlined_block->GetInlinedFunctionInfo();
Greg Clayton
committed
s->Printf (" [inlined] %s", inlined_block_info->GetName(function->GetLanguage()).GetCString());
lldb_private::AddressRange block_range;
if (inlined_block->GetRangeContainingAddress(addr, block_range))
{
const addr_t inlined_function_offset = addr.GetOffset() - block_range.GetBaseAddress().GetOffset();
Loading
Loading full blame...