summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2017-04-02 17:24:58 +0000
committerdim <dim@FreeBSD.org>2017-04-02 17:24:58 +0000
commit60b571e49a90d38697b3aca23020d9da42fc7d7f (patch)
tree99351324c24d6cb146b6285b6caffa4d26fce188 /contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp
parentbea1b22c7a9bce1dfdd73e6e5b65bc4752215180 (diff)
downloadFreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.zip
FreeBSD-src-60b571e49a90d38697b3aca23020d9da42fc7d7f.tar.gz
Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release:
MFC r309142 (by emaste): Add WITH_LLD_AS_LD build knob If set it installs LLD as /usr/bin/ld. LLD (as of version 3.9) is not capable of linking the world and kernel, but can self-host and link many substantial applications. GNU ld continues to be used for the world and kernel build, regardless of how this knob is set. It is on by default for arm64, and off for all other CPU architectures. Sponsored by: The FreeBSD Foundation MFC r310840: Reapply 310775, now it also builds correctly if lldb is disabled: Move llvm-objdump from CLANG_EXTRAS to installed by default We currently install three tools from binutils 2.17.50: as, ld, and objdump. Work is underway to migrate to a permissively-licensed tool-chain, with one goal being the retirement of binutils 2.17.50. LLVM's llvm-objdump is intended to be compatible with GNU objdump although it is currently missing some options and may have formatting differences. Enable it by default for testing and further investigation. It may later be changed to install as /usr/bin/objdump, it becomes a fully viable replacement. Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D8879 MFC r312855 (by emaste): Rename LLD_AS_LD to LLD_IS_LD, for consistency with CLANG_IS_CC Reported by: Dan McGregor <dan.mcgregor usask.ca> MFC r313559 | glebius | 2017-02-10 18:34:48 +0100 (Fri, 10 Feb 2017) | 5 lines Don't check struct rtentry on FreeBSD, it is an internal kernel structure. On other systems it may be API structure for SIOCADDRT/SIOCDELRT. Reviewed by: emaste, dim MFC r314152 (by jkim): Remove an assembler flag, which is redundant since r309124. The upstream took care of it by introducing a macro NO_EXEC_STACK_DIRECTIVE. http://llvm.org/viewvc/llvm-project?rev=273500&view=rev Reviewed by: dim MFC r314564: Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 (branches/release_40 296509). The release will follow soon. Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11 support to build; see UPDATING for more information. Also note that as of 4.0.0, lld should be able to link the base system on amd64 and aarch64. See the WITH_LLD_IS_LLD setting in src.conf(5). Though please be aware that this is work in progress. Release notes for llvm, clang and lld will be available here: <http://releases.llvm.org/4.0.0/docs/ReleaseNotes.html> <http://releases.llvm.org/4.0.0/tools/clang/docs/ReleaseNotes.html> <http://releases.llvm.org/4.0.0/tools/lld/docs/ReleaseNotes.html> Thanks to Ed Maste, Jan Beich, Antoine Brodin and Eric Fiselier for their help. Relnotes: yes Exp-run: antoine PR: 215969, 216008 MFC r314708: For now, revert r287232 from upstream llvm trunk (by Daniil Fukalov): [SCEV] limit recursion depth of CompareSCEVComplexity Summary: CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled loop) and runs almost infinite time. Added cache of "equal" SCEV pairs to earlier cutoff of further estimation. Recursion depth limit was also introduced as a parameter. Reviewers: sanjoy Subscribers: mzolotukhin, tstellarAMD, llvm-commits Differential Revision: https://reviews.llvm.org/D26389 This commit is the cause of excessive compile times on skein_block.c (and possibly other files) during kernel builds on amd64. We never saw the problematic behavior described in this upstream commit, so for now it is better to revert it. An upstream bug has been filed here: https://bugs.llvm.org/show_bug.cgi?id=32142 Reported by: mjg MFC r314795: Reapply r287232 from upstream llvm trunk (by Daniil Fukalov): [SCEV] limit recursion depth of CompareSCEVComplexity Summary: CompareSCEVComplexity goes too deep (50+ on a quite a big unrolled loop) and runs almost infinite time. Added cache of "equal" SCEV pairs to earlier cutoff of further estimation. Recursion depth limit was also introduced as a parameter. Reviewers: sanjoy Subscribers: mzolotukhin, tstellarAMD, llvm-commits Differential Revision: https://reviews.llvm.org/D26389 Pull in r296992 from upstream llvm trunk (by Sanjoy Das): [SCEV] Decrease the recursion threshold for CompareValueComplexity Fixes PR32142. r287232 accidentally increased the recursion threshold for CompareValueComplexity from 2 to 32. This change reverses that change by introducing a separate flag for CompareValueComplexity's threshold. The latter revision fixes the excessive compile times for skein_block.c. MFC r314907 | mmel | 2017-03-08 12:40:27 +0100 (Wed, 08 Mar 2017) | 7 lines Unbreak ARMv6 world. The new compiler_rt library imported with clang 4.0.0 have several fatal issues (non-functional __udivsi3 for example) with ARM specific instrict functions. As temporary workaround, until upstream solve these problems, disable all thumb[1][2] related feature. MFC r315016: Update clang, llvm, lld, lldb, compiler-rt and libc++ to 4.0.0 release. We were already very close to the last release candidate, so this is a pretty minor update. Relnotes: yes MFC r316005: Revert r314907, and pull in r298713 from upstream compiler-rt trunk (by Weiming Zhao): builtins: Select correct code fragments when compiling for Thumb1/Thum2/ARM ISA. Summary: Value of __ARM_ARCH_ISA_THUMB isn't based on the actual compilation mode (-mthumb, -marm), it reflect's capability of given CPU. Due to this: - use __tbumb__ and __thumb2__ insteand of __ARM_ARCH_ISA_THUMB - use '.thumb' directive consistently in all affected files - decorate all thumb functions using DEFINE_COMPILERRT_THUMB_FUNCTION() --------- Note: This patch doesn't fix broken Thumb1 variant of __udivsi3 ! Reviewers: weimingz, rengolin, compnerd Subscribers: aemerson, dim Differential Revision: https://reviews.llvm.org/D30938 Discussed with: mmel
Diffstat (limited to 'contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp')
-rw-r--r--contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp712
1 files changed, 304 insertions, 408 deletions
diff --git a/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp b/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp
index 259a450..8ba83d4 100644
--- a/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp
+++ b/contrib/llvm/tools/lldb/source/Symbol/CompileUnit.cpp
@@ -17,143 +17,104 @@
using namespace lldb;
using namespace lldb_private;
-CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const char *pathname,
- const lldb::user_id_t cu_sym_id, lldb::LanguageType language,
+CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
+ const char *pathname, const lldb::user_id_t cu_sym_id,
+ lldb::LanguageType language,
lldb_private::LazyBool is_optimized)
- : ModuleChild(module_sp),
- FileSpec(pathname, false),
- UserID(cu_sym_id),
- m_user_data(user_data),
- m_language(language),
- m_flags(0),
- m_functions(),
- m_support_files(),
- m_line_table_ap(),
- m_variables(),
- m_is_optimized(is_optimized)
-{
- if (language != eLanguageTypeUnknown)
- m_flags.Set(flagsParsedLanguage);
- assert(module_sp);
+ : ModuleChild(module_sp), FileSpec(pathname, false), UserID(cu_sym_id),
+ m_user_data(user_data), m_language(language), m_flags(0), m_functions(),
+ m_support_files(), m_line_table_ap(), m_variables(),
+ m_is_optimized(is_optimized) {
+ if (language != eLanguageTypeUnknown)
+ m_flags.Set(flagsParsedLanguage);
+ assert(module_sp);
}
-CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec,
- const lldb::user_id_t cu_sym_id, lldb::LanguageType language,
+CompileUnit::CompileUnit(const lldb::ModuleSP &module_sp, void *user_data,
+ const FileSpec &fspec, const lldb::user_id_t cu_sym_id,
+ lldb::LanguageType language,
lldb_private::LazyBool is_optimized)
- : ModuleChild(module_sp),
- FileSpec(fspec),
- UserID(cu_sym_id),
- m_user_data(user_data),
- m_language(language),
- m_flags(0),
- m_functions(),
- m_support_files(),
- m_line_table_ap(),
- m_variables(),
- m_is_optimized(is_optimized)
-{
- if (language != eLanguageTypeUnknown)
- m_flags.Set(flagsParsedLanguage);
- assert(module_sp);
+ : ModuleChild(module_sp), FileSpec(fspec), UserID(cu_sym_id),
+ m_user_data(user_data), m_language(language), m_flags(0), m_functions(),
+ m_support_files(), m_line_table_ap(), m_variables(),
+ m_is_optimized(is_optimized) {
+ if (language != eLanguageTypeUnknown)
+ m_flags.Set(flagsParsedLanguage);
+ assert(module_sp);
}
-CompileUnit::~CompileUnit ()
-{
-}
+CompileUnit::~CompileUnit() {}
-void
-CompileUnit::CalculateSymbolContext(SymbolContext* sc)
-{
- sc->comp_unit = this;
- GetModule()->CalculateSymbolContext(sc);
+void CompileUnit::CalculateSymbolContext(SymbolContext *sc) {
+ sc->comp_unit = this;
+ GetModule()->CalculateSymbolContext(sc);
}
-ModuleSP
-CompileUnit::CalculateSymbolContextModule ()
-{
- return GetModule();
-}
+ModuleSP CompileUnit::CalculateSymbolContextModule() { return GetModule(); }
-CompileUnit *
-CompileUnit::CalculateSymbolContextCompileUnit ()
-{
- return this;
-}
+CompileUnit *CompileUnit::CalculateSymbolContextCompileUnit() { return this; }
-void
-CompileUnit::DumpSymbolContext(Stream *s)
-{
- GetModule()->DumpSymbolContext(s);
- s->Printf(", CompileUnit{0x%8.8" PRIx64 "}", GetID());
+void CompileUnit::DumpSymbolContext(Stream *s) {
+ GetModule()->DumpSymbolContext(s);
+ s->Printf(", CompileUnit{0x%8.8" PRIx64 "}", GetID());
}
-
-void
-CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const
-{
- const char* language = Language::GetNameForLanguageType(m_language);
- *s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << language << '"';
+void CompileUnit::GetDescription(Stream *s,
+ lldb::DescriptionLevel level) const {
+ const char *language = Language::GetNameForLanguageType(m_language);
+ *s << "id = " << (const UserID &)*this << ", file = \""
+ << (const FileSpec &)*this << "\", language = \"" << language << '"';
}
-
//----------------------------------------------------------------------
// Dump the current contents of this object. No functions that cause on
// demand parsing of functions, globals, statics are called, so this
// is a good function to call to get an idea of the current contents of
// the CompileUnit object.
//----------------------------------------------------------------------
-void
-CompileUnit::Dump(Stream *s, bool show_context) const
-{
- const char* language = Language::GetNameForLanguageType(m_language);
-
- s->Printf("%p: ", static_cast<const void*>(this));
- s->Indent();
- *s << "CompileUnit" << static_cast<const UserID&>(*this)
- << ", language = \"" << language
- << "\", file = '" << static_cast<const FileSpec&>(*this) << "'\n";
-
-// m_types.Dump(s);
-
- if (m_variables.get())
- {
- s->IndentMore();
- m_variables->Dump(s, show_context);
- s->IndentLess();
+void CompileUnit::Dump(Stream *s, bool show_context) const {
+ const char *language = Language::GetNameForLanguageType(m_language);
+
+ s->Printf("%p: ", static_cast<const void *>(this));
+ s->Indent();
+ *s << "CompileUnit" << static_cast<const UserID &>(*this) << ", language = \""
+ << language << "\", file = '" << static_cast<const FileSpec &>(*this)
+ << "'\n";
+
+ // m_types.Dump(s);
+
+ if (m_variables.get()) {
+ s->IndentMore();
+ m_variables->Dump(s, show_context);
+ s->IndentLess();
+ }
+
+ if (!m_functions.empty()) {
+ s->IndentMore();
+ std::vector<FunctionSP>::const_iterator pos;
+ std::vector<FunctionSP>::const_iterator end = m_functions.end();
+ for (pos = m_functions.begin(); pos != end; ++pos) {
+ (*pos)->Dump(s, show_context);
}
- if (!m_functions.empty())
- {
- s->IndentMore();
- std::vector<FunctionSP>::const_iterator pos;
- std::vector<FunctionSP>::const_iterator end = m_functions.end();
- for (pos = m_functions.begin(); pos != end; ++pos)
- {
- (*pos)->Dump(s, show_context);
- }
-
- s->IndentLess();
- s->EOL();
- }
+ s->IndentLess();
+ s->EOL();
+ }
}
//----------------------------------------------------------------------
// Add a function to this compile unit
//----------------------------------------------------------------------
-void
-CompileUnit::AddFunction(FunctionSP& funcSP)
-{
- // TODO: order these by address
- m_functions.push_back(funcSP);
+void CompileUnit::AddFunction(FunctionSP &funcSP) {
+ // TODO: order these by address
+ m_functions.push_back(funcSP);
}
-FunctionSP
-CompileUnit::GetFunctionAtIndex (size_t idx)
-{
- FunctionSP funcSP;
- if (idx < m_functions.size())
- funcSP = m_functions[idx];
- return funcSP;
+FunctionSP CompileUnit::GetFunctionAtIndex(size_t idx) {
+ FunctionSP funcSP;
+ if (idx < m_functions.size())
+ funcSP = m_functions[idx];
+ return funcSP;
}
//----------------------------------------------------------------------
@@ -180,8 +141,8 @@ CompileUnit::GetFunctionAtIndex (size_t idx)
// parsed by the SymbolFile parser plug-ins and registered with each
// Module).
//----------------------------------------------------------------------
-//void
-//CompileUnit::FindFunctions(const Mangled::Tokens& tokens)
+// void
+// CompileUnit::FindFunctions(const Mangled::Tokens& tokens)
//{
// if (!m_functions.empty())
// {
@@ -193,7 +154,8 @@ CompileUnit::GetFunctionAtIndex (size_t idx)
// const ConstString& demangled = (*pos)->Mangled().Demangled();
// if (demangled)
// {
-// const Mangled::Tokens& func_tokens = (*pos)->Mangled().GetTokens();
+// const Mangled::Tokens& func_tokens =
+// (*pos)->Mangled().GetTokens();
// if (func_tokens.MatchesQuery (tokens))
// s << "demangled MATCH found: " << demangled << "\n";
// }
@@ -201,338 +163,272 @@ CompileUnit::GetFunctionAtIndex (size_t idx)
// }
//}
-FunctionSP
-CompileUnit::FindFunctionByUID (lldb::user_id_t func_uid)
-{
- FunctionSP funcSP;
- if (!m_functions.empty())
- {
- std::vector<FunctionSP>::const_iterator pos;
- std::vector<FunctionSP>::const_iterator end = m_functions.end();
- for (pos = m_functions.begin(); pos != end; ++pos)
- {
- if ((*pos)->GetID() == func_uid)
- {
- funcSP = *pos;
- break;
- }
- }
- }
- return funcSP;
-}
-
-
-lldb::LanguageType
-CompileUnit::GetLanguage()
-{
- if (m_language == eLanguageTypeUnknown)
- {
- if (m_flags.IsClear(flagsParsedLanguage))
- {
- m_flags.Set(flagsParsedLanguage);
- SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor)
- {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- m_language = symbol_vendor->ParseCompileUnitLanguage(sc);
- }
- }
+FunctionSP CompileUnit::FindFunctionByUID(lldb::user_id_t func_uid) {
+ FunctionSP funcSP;
+ if (!m_functions.empty()) {
+ std::vector<FunctionSP>::const_iterator pos;
+ std::vector<FunctionSP>::const_iterator end = m_functions.end();
+ for (pos = m_functions.begin(); pos != end; ++pos) {
+ if ((*pos)->GetID() == func_uid) {
+ funcSP = *pos;
+ break;
+ }
}
- return m_language;
+ }
+ return funcSP;
}
-LineTable*
-CompileUnit::GetLineTable()
-{
- if (m_line_table_ap.get() == nullptr)
- {
- if (m_flags.IsClear(flagsParsedLineTable))
- {
- m_flags.Set(flagsParsedLineTable);
- SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor)
- {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- symbol_vendor->ParseCompileUnitLineTable(sc);
- }
- }
+lldb::LanguageType CompileUnit::GetLanguage() {
+ if (m_language == eLanguageTypeUnknown) {
+ if (m_flags.IsClear(flagsParsedLanguage)) {
+ m_flags.Set(flagsParsedLanguage);
+ SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
+ if (symbol_vendor) {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ m_language = symbol_vendor->ParseCompileUnitLanguage(sc);
+ }
}
- return m_line_table_ap.get();
+ }
+ return m_language;
}
-void
-CompileUnit::SetLineTable(LineTable* line_table)
-{
- if (line_table == nullptr)
- m_flags.Clear(flagsParsedLineTable);
- else
- m_flags.Set(flagsParsedLineTable);
- m_line_table_ap.reset(line_table);
-}
-
-DebugMacros*
-CompileUnit::GetDebugMacros()
-{
- if (m_debug_macros_sp.get() == nullptr)
- {
- if (m_flags.IsClear(flagsParsedDebugMacros))
- {
- m_flags.Set(flagsParsedDebugMacros);
- SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor)
- {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- symbol_vendor->ParseCompileUnitDebugMacros(sc);
- }
- }
+LineTable *CompileUnit::GetLineTable() {
+ if (m_line_table_ap.get() == nullptr) {
+ if (m_flags.IsClear(flagsParsedLineTable)) {
+ m_flags.Set(flagsParsedLineTable);
+ SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
+ if (symbol_vendor) {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ symbol_vendor->ParseCompileUnitLineTable(sc);
+ }
}
-
- return m_debug_macros_sp.get();
+ }
+ return m_line_table_ap.get();
}
-void
-CompileUnit::SetDebugMacros(const DebugMacrosSP &debug_macros_sp)
-{
- if (debug_macros_sp.get() == nullptr)
- m_flags.Clear(flagsParsedDebugMacros);
- else
- m_flags.Set(flagsParsedDebugMacros);
- m_debug_macros_sp = debug_macros_sp;
+void CompileUnit::SetLineTable(LineTable *line_table) {
+ if (line_table == nullptr)
+ m_flags.Clear(flagsParsedLineTable);
+ else
+ m_flags.Set(flagsParsedLineTable);
+ m_line_table_ap.reset(line_table);
}
-VariableListSP
-CompileUnit::GetVariableList(bool can_create)
-{
- if (m_variables.get() == nullptr && can_create)
- {
+DebugMacros *CompileUnit::GetDebugMacros() {
+ if (m_debug_macros_sp.get() == nullptr) {
+ if (m_flags.IsClear(flagsParsedDebugMacros)) {
+ m_flags.Set(flagsParsedDebugMacros);
+ SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
+ if (symbol_vendor) {
SymbolContext sc;
CalculateSymbolContext(&sc);
- assert(sc.module_sp);
- sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
+ symbol_vendor->ParseCompileUnitDebugMacros(sc);
+ }
}
+ }
- return m_variables;
+ return m_debug_macros_sp.get();
}
-uint32_t
-CompileUnit::FindLineEntry (uint32_t start_idx, uint32_t line, const FileSpec* file_spec_ptr, bool exact, LineEntry *line_entry_ptr)
-{
- uint32_t file_idx = 0;
-
- if (file_spec_ptr)
- {
- file_idx = GetSupportFiles().FindFileIndex (1, *file_spec_ptr, true);
- if (file_idx == UINT32_MAX)
- return UINT32_MAX;
- }
- else
- {
- // All the line table entries actually point to the version of the Compile
- // Unit that is in the support files (the one at 0 was artificially added.)
- // So prefer the one further on in the support files if it exists...
- FileSpecList &support_files = GetSupportFiles();
- const bool full = true;
- file_idx = support_files.FindFileIndex (1, support_files.GetFileSpecAtIndex(0), full);
- if (file_idx == UINT32_MAX)
- file_idx = 0;
- }
- LineTable *line_table = GetLineTable();
- if (line_table)
- return line_table->FindLineEntryIndexByFileIndex (start_idx, file_idx, line, exact, line_entry_ptr);
- return UINT32_MAX;
+void CompileUnit::SetDebugMacros(const DebugMacrosSP &debug_macros_sp) {
+ if (debug_macros_sp.get() == nullptr)
+ m_flags.Clear(flagsParsedDebugMacros);
+ else
+ m_flags.Set(flagsParsedDebugMacros);
+ m_debug_macros_sp = debug_macros_sp;
}
+VariableListSP CompileUnit::GetVariableList(bool can_create) {
+ if (m_variables.get() == nullptr && can_create) {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ assert(sc.module_sp);
+ sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc);
+ }
+ return m_variables;
+}
+uint32_t CompileUnit::FindLineEntry(uint32_t start_idx, uint32_t line,
+ const FileSpec *file_spec_ptr, bool exact,
+ LineEntry *line_entry_ptr) {
+ uint32_t file_idx = 0;
+
+ if (file_spec_ptr) {
+ file_idx = GetSupportFiles().FindFileIndex(1, *file_spec_ptr, true);
+ if (file_idx == UINT32_MAX)
+ return UINT32_MAX;
+ } else {
+ // All the line table entries actually point to the version of the Compile
+ // Unit that is in the support files (the one at 0 was artificially added.)
+ // So prefer the one further on in the support files if it exists...
+ FileSpecList &support_files = GetSupportFiles();
+ const bool full = true;
+ file_idx = support_files.FindFileIndex(
+ 1, support_files.GetFileSpecAtIndex(0), full);
+ if (file_idx == UINT32_MAX)
+ file_idx = 0;
+ }
+ LineTable *line_table = GetLineTable();
+ if (line_table)
+ return line_table->FindLineEntryIndexByFileIndex(start_idx, file_idx, line,
+ exact, line_entry_ptr);
+ return UINT32_MAX;
+}
-uint32_t
-CompileUnit::ResolveSymbolContext
-(
- const FileSpec& file_spec,
- uint32_t line,
- bool check_inlines,
- bool exact,
- uint32_t resolve_scope,
- SymbolContextList &sc_list
-)
-{
- // First find all of the file indexes that match our "file_spec". If
- // "file_spec" has an empty directory, then only compare the basenames
- // when finding file indexes
- std::vector<uint32_t> file_indexes;
- const bool full_match = (bool)file_spec.GetDirectory();
- const bool remove_backup_dots = true;
- bool file_spec_matches_cu_file_spec = FileSpec::Equal(file_spec, *this, full_match, remove_backup_dots);
-
- // If we are not looking for inlined functions and our file spec doesn't
- // match then we are done...
- if (file_spec_matches_cu_file_spec == false && check_inlines == false)
- return 0;
-
- uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec, true, remove_backup_dots);
- while (file_idx != UINT32_MAX)
- {
- file_indexes.push_back (file_idx);
- file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec, true, remove_backup_dots);
- }
-
- const size_t num_file_indexes = file_indexes.size();
- if (num_file_indexes == 0)
- return 0;
-
- const uint32_t prev_size = sc_list.GetSize();
-
- SymbolContext sc(GetModule());
- sc.comp_unit = this;
-
-
- if (line != 0)
- {
- LineTable *line_table = sc.comp_unit->GetLineTable();
-
- if (line_table != nullptr)
- {
- uint32_t found_line;
- uint32_t line_idx;
-
- if (num_file_indexes == 1)
- {
- // We only have a single support file that matches, so use
- // the line table function that searches for a line entries
- // that match a single support file index
- LineEntry line_entry;
- line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes.front(), line, exact, &line_entry);
-
- // If "exact == true", then "found_line" will be the same
- // as "line". If "exact == false", the "found_line" will be the
- // closest line entry with a line number greater than "line" and
- // we will use this for our subsequent line exact matches below.
- found_line = line_entry.line;
-
- while (line_idx != UINT32_MAX)
- {
- // If they only asked for the line entry, then we're done, we can just copy that over.
- // But if they wanted more than just the line number, fill it in.
- if (resolve_scope == eSymbolContextLineEntry)
- {
- sc.line_entry = line_entry;
- }
- else
- {
- line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);
- }
-
- sc_list.Append(sc);
- line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes.front(), found_line, true, &line_entry);
- }
- }
- else
- {
- // We found multiple support files that match "file_spec" so use
- // the line table function that searches for a line entries
- // that match a multiple support file indexes.
- LineEntry line_entry;
- line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes, line, exact, &line_entry);
-
- // If "exact == true", then "found_line" will be the same
- // as "line". If "exact == false", the "found_line" will be the
- // closest line entry with a line number greater than "line" and
- // we will use this for our subsequent line exact matches below.
- found_line = line_entry.line;
-
- while (line_idx != UINT32_MAX)
- {
- if (resolve_scope == eSymbolContextLineEntry)
- {
- sc.line_entry = line_entry;
- }
- else
- {
- line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);
- }
-
- sc_list.Append(sc);
- line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes, found_line, true, &line_entry);
- }
- }
+uint32_t CompileUnit::ResolveSymbolContext(const FileSpec &file_spec,
+ uint32_t line, bool check_inlines,
+ bool exact, uint32_t resolve_scope,
+ SymbolContextList &sc_list) {
+ // First find all of the file indexes that match our "file_spec". If
+ // "file_spec" has an empty directory, then only compare the basenames
+ // when finding file indexes
+ std::vector<uint32_t> file_indexes;
+ const bool full_match = (bool)file_spec.GetDirectory();
+ const bool remove_backup_dots = true;
+ bool file_spec_matches_cu_file_spec =
+ FileSpec::Equal(file_spec, *this, full_match, remove_backup_dots);
+
+ // If we are not looking for inlined functions and our file spec doesn't
+ // match then we are done...
+ if (file_spec_matches_cu_file_spec == false && check_inlines == false)
+ return 0;
+
+ uint32_t file_idx =
+ GetSupportFiles().FindFileIndex(1, file_spec, true, remove_backup_dots);
+ while (file_idx != UINT32_MAX) {
+ file_indexes.push_back(file_idx);
+ file_idx = GetSupportFiles().FindFileIndex(file_idx + 1, file_spec, true,
+ remove_backup_dots);
+ }
+
+ const size_t num_file_indexes = file_indexes.size();
+ if (num_file_indexes == 0)
+ return 0;
+
+ const uint32_t prev_size = sc_list.GetSize();
+
+ SymbolContext sc(GetModule());
+ sc.comp_unit = this;
+
+ if (line != 0) {
+ LineTable *line_table = sc.comp_unit->GetLineTable();
+
+ if (line_table != nullptr) {
+ uint32_t found_line;
+ uint32_t line_idx;
+
+ if (num_file_indexes == 1) {
+ // We only have a single support file that matches, so use
+ // the line table function that searches for a line entries
+ // that match a single support file index
+ LineEntry line_entry;
+ line_idx = line_table->FindLineEntryIndexByFileIndex(
+ 0, file_indexes.front(), line, exact, &line_entry);
+
+ // If "exact == true", then "found_line" will be the same
+ // as "line". If "exact == false", the "found_line" will be the
+ // closest line entry with a line number greater than "line" and
+ // we will use this for our subsequent line exact matches below.
+ found_line = line_entry.line;
+
+ while (line_idx != UINT32_MAX) {
+ // If they only asked for the line entry, then we're done, we can just
+ // copy that over.
+ // But if they wanted more than just the line number, fill it in.
+ if (resolve_scope == eSymbolContextLineEntry) {
+ sc.line_entry = line_entry;
+ } else {
+ line_entry.range.GetBaseAddress().CalculateSymbolContext(
+ &sc, resolve_scope);
+ }
+
+ sc_list.Append(sc);
+ line_idx = line_table->FindLineEntryIndexByFileIndex(
+ line_idx + 1, file_indexes.front(), found_line, true,
+ &line_entry);
}
+ } else {
+ // We found multiple support files that match "file_spec" so use
+ // the line table function that searches for a line entries
+ // that match a multiple support file indexes.
+ LineEntry line_entry;
+ line_idx = line_table->FindLineEntryIndexByFileIndex(
+ 0, file_indexes, line, exact, &line_entry);
+
+ // If "exact == true", then "found_line" will be the same
+ // as "line". If "exact == false", the "found_line" will be the
+ // closest line entry with a line number greater than "line" and
+ // we will use this for our subsequent line exact matches below.
+ found_line = line_entry.line;
+
+ while (line_idx != UINT32_MAX) {
+ if (resolve_scope == eSymbolContextLineEntry) {
+ sc.line_entry = line_entry;
+ } else {
+ line_entry.range.GetBaseAddress().CalculateSymbolContext(
+ &sc, resolve_scope);
+ }
+
+ sc_list.Append(sc);
+ line_idx = line_table->FindLineEntryIndexByFileIndex(
+ line_idx + 1, file_indexes, found_line, true, &line_entry);
+ }
+ }
}
- else if (file_spec_matches_cu_file_spec && !check_inlines)
- {
- // only append the context if we aren't looking for inline call sites
- // by file and line and if the file spec matches that of the compile unit
- sc_list.Append(sc);
- }
- return sc_list.GetSize() - prev_size;
+ } else if (file_spec_matches_cu_file_spec && !check_inlines) {
+ // only append the context if we aren't looking for inline call sites
+ // by file and line and if the file spec matches that of the compile unit
+ sc_list.Append(sc);
+ }
+ return sc_list.GetSize() - prev_size;
}
-bool
-CompileUnit::GetIsOptimized ()
-{
- if (m_is_optimized == eLazyBoolCalculate)
- {
- m_is_optimized = eLazyBoolNo;
- if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor())
- {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- if (symbol_vendor->ParseCompileUnitIsOptimized(sc))
- m_is_optimized = eLazyBoolYes;
- }
+bool CompileUnit::GetIsOptimized() {
+ if (m_is_optimized == eLazyBoolCalculate) {
+ m_is_optimized = eLazyBoolNo;
+ if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ if (symbol_vendor->ParseCompileUnitIsOptimized(sc))
+ m_is_optimized = eLazyBoolYes;
}
- return m_is_optimized;
+ }
+ return m_is_optimized;
}
-void
-CompileUnit::SetVariableList(VariableListSP &variables)
-{
- m_variables = variables;
+void CompileUnit::SetVariableList(VariableListSP &variables) {
+ m_variables = variables;
}
-const std::vector<ConstString> &
-CompileUnit::GetImportedModules ()
-{
- if (m_imported_modules.empty() &&
- m_flags.IsClear(flagsParsedImportedModules))
- {
- m_flags.Set(flagsParsedImportedModules);
- if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor())
- {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- symbol_vendor->ParseImportedModules(sc, m_imported_modules);
- }
+const std::vector<ConstString> &CompileUnit::GetImportedModules() {
+ if (m_imported_modules.empty() &&
+ m_flags.IsClear(flagsParsedImportedModules)) {
+ m_flags.Set(flagsParsedImportedModules);
+ if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ symbol_vendor->ParseImportedModules(sc, m_imported_modules);
}
- return m_imported_modules;
+ }
+ return m_imported_modules;
}
-FileSpecList&
-CompileUnit::GetSupportFiles ()
-{
- if (m_support_files.GetSize() == 0)
- {
- if (m_flags.IsClear(flagsParsedSupportFiles))
- {
- m_flags.Set(flagsParsedSupportFiles);
- SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
- if (symbol_vendor)
- {
- SymbolContext sc;
- CalculateSymbolContext(&sc);
- symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files);
- }
- }
+FileSpecList &CompileUnit::GetSupportFiles() {
+ if (m_support_files.GetSize() == 0) {
+ if (m_flags.IsClear(flagsParsedSupportFiles)) {
+ m_flags.Set(flagsParsedSupportFiles);
+ SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor();
+ if (symbol_vendor) {
+ SymbolContext sc;
+ CalculateSymbolContext(&sc);
+ symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files);
+ }
}
- return m_support_files;
-}
-
-void *
-CompileUnit::GetUserData () const
-{
- return m_user_data;
+ }
+ return m_support_files;
}
-
+void *CompileUnit::GetUserData() const { return m_user_data; }
OpenPOWER on IntegriCloud