diff options
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp')
-rw-r--r-- | contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp | 141 |
1 files changed, 106 insertions, 35 deletions
diff --git a/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp b/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp index 129f4de..4fb0dbc 100644 --- a/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp +++ b/contrib/llvm/tools/lldb/source/Symbol/SymbolContext.cpp @@ -13,7 +13,7 @@ #include "lldb/Core/Module.h" #include "lldb/Core/ModuleSpec.h" #include "lldb/Host/Host.h" -#include "lldb/Interpreter/Args.h" +#include "lldb/Host/StringConvert.h" #include "lldb/Symbol/Block.h" #include "lldb/Symbol/ClangASTContext.h" #include "lldb/Symbol/CompileUnit.h" @@ -21,6 +21,7 @@ #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; @@ -33,7 +34,8 @@ SymbolContext::SymbolContext() : function (nullptr), block (nullptr), line_entry (), - symbol (nullptr) + symbol (nullptr), + variable (nullptr) { } @@ -44,7 +46,8 @@ SymbolContext::SymbolContext(const ModuleSP& m, CompileUnit *cu, Function *f, Bl function (f), block (b), line_entry (), - symbol (s) + symbol (s), + variable (nullptr) { if (le) line_entry = *le; @@ -57,7 +60,8 @@ SymbolContext::SymbolContext(const TargetSP &t, const ModuleSP& m, CompileUnit * function (f), block (b), line_entry (), - symbol (s) + symbol (s), + variable (nullptr) { if (le) line_entry = *le; @@ -70,7 +74,8 @@ SymbolContext::SymbolContext(const SymbolContext& rhs) : function (rhs.function), block (rhs.block), line_entry (rhs.line_entry), - symbol (rhs.symbol) + symbol (rhs.symbol), + variable (rhs.variable) { } @@ -82,7 +87,8 @@ SymbolContext::SymbolContext (SymbolContextScope *sc_scope) : function (nullptr), block (nullptr), line_entry (), - symbol (nullptr) + symbol (nullptr), + variable (nullptr) { sc_scope->CalculateSymbolContext (this); } @@ -103,6 +109,7 @@ SymbolContext::operator= (const SymbolContext& rhs) block = rhs.block; line_entry = rhs.line_entry; symbol = rhs.symbol; + variable = rhs.variable; } return *this; } @@ -118,18 +125,19 @@ SymbolContext::Clear(bool clear_target) block = nullptr; line_entry.Clear(); symbol = nullptr; + variable = nullptr; } bool -SymbolContext::DumpStopContext -( +SymbolContext::DumpStopContext ( Stream *s, ExecutionContextScope *exe_scope, const Address &addr, bool show_fullpaths, bool show_module, bool show_inlined_frames, - bool show_function_arguments + bool show_function_arguments, + bool show_function_name ) const { bool dumped_something = false; @@ -147,21 +155,32 @@ SymbolContext::DumpStopContext { SymbolContext inline_parent_sc; Address inline_parent_addr; - if (show_function_arguments == false && function->GetMangled().GetName(Mangled::ePreferDemangledWithoutArguments)) + if (show_function_name == false) { + s->Printf("<"); dumped_something = true; - function->GetMangled().GetName(Mangled::ePreferDemangledWithoutArguments).Dump(s); } - else if (function->GetMangled().GetName()) + else { - dumped_something = true; - function->GetMangled().GetName().Dump(s); + ConstString name; + if (show_function_arguments == false) + name = function->GetNameNoArguments(); + if (!name) + name = function->GetName(); + if (name) + name.Dump(s); } if (addr.IsValid()) { const addr_t function_offset = addr.GetOffset() - function->GetAddressRange().GetBaseAddress().GetOffset(); - if (function_offset) + 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); @@ -173,7 +192,7 @@ SymbolContext::DumpStopContext dumped_something = true; Block *inlined_block = block->GetContainingInlinedBlock(); const InlineFunctionInfo* inlined_block_info = inlined_block->GetInlinedFunctionInfo(); - s->Printf (" [inlined] %s", inlined_block_info->GetName().GetCString()); + s->Printf (" [inlined] %s", inlined_block_info->GetName(function->GetLanguage()).GetCString()); lldb_private::AddressRange block_range; if (inlined_block->GetRangeContainingAddress(addr, block_range)) @@ -194,7 +213,8 @@ SymbolContext::DumpStopContext { s->EOL(); s->Indent(); - return inline_parent_sc.DumpStopContext (s, exe_scope, inline_parent_addr, show_fullpaths, show_module, show_inlined_frames, show_function_arguments); + const bool show_function_name = true; + return inline_parent_sc.DumpStopContext (s, exe_scope, inline_parent_addr, show_fullpaths, show_module, show_inlined_frames, show_function_arguments, show_function_name); } } else @@ -210,18 +230,29 @@ SymbolContext::DumpStopContext } else if (symbol != nullptr) { - if (symbol->GetMangled().GetName()) + if (show_function_name == false) + { + s->Printf("<"); + dumped_something = true; + } + else if (symbol->GetName()) { dumped_something = true; if (symbol->GetType() == eSymbolTypeTrampoline) s->PutCString("symbol stub for: "); - symbol->GetMangled().GetName().Dump(s); + symbol->GetName().Dump(s); } if (addr.IsValid() && symbol->ValueIsAddress()) { - const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddress().GetOffset(); - if (symbol_offset) + const addr_t symbol_offset = addr.GetOffset() - symbol->GetAddressRef().GetOffset(); + if (show_function_name == false) + { + // Print +offset even if offset is 0 + dumped_something = true; + s->Printf("+%" PRIu64 ">", symbol_offset); + } + else if (symbol_offset) { dumped_something = true; s->Printf(" + %" PRIu64, symbol_offset); @@ -309,6 +340,37 @@ SymbolContext::GetDescription(Stream *s, lldb::DescriptionLevel level, Target *t symbol->GetDescription(s, level, target); s->EOL(); } + + if (variable != nullptr) + { + s->Indent(" Variable: "); + + s->Printf("id = {0x%8.8" PRIx64 "}, ", variable->GetID()); + + switch (variable->GetScope()) + { + case eValueTypeVariableGlobal: + s->PutCString("kind = global, "); + break; + + case eValueTypeVariableStatic: + s->PutCString("kind = static, "); + break; + + case eValueTypeVariableArgument: + s->PutCString("kind = argument, "); + break; + + case eValueTypeVariableLocal: + s->PutCString("kind = local, "); + break; + + default: + break; + } + + s->Printf ("name = \"%s\"\n", variable->GetName().GetCString()); + } } uint32_t @@ -322,6 +384,7 @@ SymbolContext::GetResolvedMask () const if (block) resolved_mask |= eSymbolContextBlock; if (line_entry.IsValid()) resolved_mask |= eSymbolContextLineEntry; if (symbol) resolved_mask |= eSymbolContextSymbol; + if (variable) resolved_mask |= eSymbolContextVariable; return resolved_mask; } @@ -375,8 +438,14 @@ SymbolContext::Dump(Stream *s, Target *target) const s->Indent(); *s << "Symbol = " << (void *)symbol; if (symbol != nullptr && symbol->GetMangled()) - *s << ' ' << symbol->GetMangled().GetName().AsCString(); + *s << ' ' << symbol->GetName().AsCString(); s->EOL(); + *s << "Variable = " << (void *)variable; + if (variable != nullptr) + { + *s << " {0x" << variable->GetID() << "} " << variable->GetType()->GetName(); + s->EOL(); + } s->IndentLess(); s->IndentLess(); } @@ -389,7 +458,8 @@ lldb_private::operator== (const SymbolContext& lhs, const SymbolContext& rhs) && lhs.module_sp.get() == rhs.module_sp.get() && lhs.comp_unit == rhs.comp_unit && lhs.target_sp.get() == rhs.target_sp.get() - && LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0; + && LineEntry::Compare(lhs.line_entry, rhs.line_entry) == 0 + && lhs.variable == rhs.variable; } bool @@ -400,7 +470,8 @@ lldb_private::operator!= (const SymbolContext& lhs, const SymbolContext& rhs) || lhs.module_sp.get() != rhs.module_sp.get() || lhs.comp_unit != rhs.comp_unit || lhs.target_sp.get() != rhs.target_sp.get() - || LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0; + || LineEntry::Compare(lhs.line_entry, rhs.line_entry) != 0 + || lhs.variable != rhs.variable; } bool @@ -444,7 +515,7 @@ SymbolContext::GetAddressRange (uint32_t scope, { if (symbol->ValueIsAddress()) { - range.GetBaseAddress() = symbol->GetAddress(); + range.GetBaseAddress() = symbol->GetAddressRef(); range.SetByteSize (symbol->GetByteSize()); return true; } @@ -610,14 +681,14 @@ SymbolContext::GetFunctionName (Mangled::NamePreference preference) const { const InlineFunctionInfo *inline_info = inlined_block->GetInlinedFunctionInfo(); if (inline_info) - return inline_info->GetName(); + return inline_info->GetName(function->GetLanguage()); } } - return function->GetMangled().GetName(preference); + return function->GetMangled().GetName(function->GetLanguage(), preference); } else if (symbol && symbol->ValueIsAddress()) { - return symbol->GetMangled().GetName(preference); + return symbol->GetMangled().GetName(symbol->GetLanguage(), preference); } else { @@ -730,12 +801,12 @@ SymbolContextSpecifier::AddSpecification (const char *spec_string, Specification m_type |= eFileSpecified; break; case eLineStartSpecified: - m_start_line = Args::StringToSInt32(spec_string, 0, 0, &return_value); + m_start_line = StringConvert::ToSInt32(spec_string, 0, 0, &return_value); if (return_value) m_type |= eLineStartSpecified; break; case eLineEndSpecified: - m_end_line = Args::StringToSInt32(spec_string, 0, 0, &return_value); + m_end_line = StringConvert::ToSInt32(spec_string, 0, 0, &return_value); if (return_value) m_type |= eLineEndSpecified; break; @@ -845,7 +916,7 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) { was_inlined = true; const Mangled &name = inline_info->GetMangled(); - if (!name.NameMatches (func_name)) + if (!name.NameMatches (func_name, sc.function->GetLanguage())) return false; } } @@ -854,12 +925,12 @@ SymbolContextSpecifier::SymbolContextMatches(SymbolContext &sc) { if (sc.function != nullptr) { - if (!sc.function->GetMangled().NameMatches(func_name)) + if (!sc.function->GetMangled().NameMatches(func_name, sc.function->GetLanguage())) return false; } else if (sc.symbol != nullptr) { - if (!sc.symbol->GetMangled().NameMatches(func_name)) + if (!sc.symbol->GetMangled().NameMatches(func_name, sc.function->GetLanguage())) return false; } } @@ -1035,7 +1106,7 @@ SymbolContextList::AppendIfUnique (const SymbolContext& sc, bool merge_symbol_in if (pos->function) { - if (pos->function->GetAddressRange().GetBaseAddress() == sc.symbol->GetAddress()) + if (pos->function->GetAddressRange().GetBaseAddress() == sc.symbol->GetAddressRef()) { // Do we already have a function with this symbol? if (pos->symbol == sc.symbol) @@ -1077,7 +1148,7 @@ SymbolContextList::MergeSymbolContextIntoFunctionContext (const SymbolContext& s if (function_sc.function) { - if (function_sc.function->GetAddressRange().GetBaseAddress() == symbol_sc.symbol->GetAddress()) + if (function_sc.function->GetAddressRange().GetBaseAddress() == symbol_sc.symbol->GetAddressRef()) { // Do we already have a function with this symbol? if (function_sc.symbol == symbol_sc.symbol) |