1ac7ddfbfSEd Maste //===-- CompileUnit.cpp -----------------------------------------*- C++ -*-===// 2ac7ddfbfSEd Maste // 3ac7ddfbfSEd Maste // The LLVM Compiler Infrastructure 4ac7ddfbfSEd Maste // 5ac7ddfbfSEd Maste // This file is distributed under the University of Illinois Open Source 6ac7ddfbfSEd Maste // License. See LICENSE.TXT for details. 7ac7ddfbfSEd Maste // 8ac7ddfbfSEd Maste //===----------------------------------------------------------------------===// 9ac7ddfbfSEd Maste 10ac7ddfbfSEd Maste #include "lldb/Symbol/CompileUnit.h" 11ac7ddfbfSEd Maste #include "lldb/Core/Module.h" 12ac7ddfbfSEd Maste #include "lldb/Core/Language.h" 13ac7ddfbfSEd Maste #include "lldb/Symbol/LineTable.h" 14ac7ddfbfSEd Maste #include "lldb/Symbol/SymbolVendor.h" 15ac7ddfbfSEd Maste #include "lldb/Symbol/VariableList.h" 16ac7ddfbfSEd Maste 17ac7ddfbfSEd Maste using namespace lldb; 18ac7ddfbfSEd Maste using namespace lldb_private; 19ac7ddfbfSEd Maste 20ac7ddfbfSEd Maste CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const char *pathname, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) : 21ac7ddfbfSEd Maste ModuleChild(module_sp), 22ac7ddfbfSEd Maste FileSpec (pathname, false), 23ac7ddfbfSEd Maste UserID(cu_sym_id), 24ac7ddfbfSEd Maste m_user_data (user_data), 25ac7ddfbfSEd Maste m_language (language), 26ac7ddfbfSEd Maste m_flags (0), 27ac7ddfbfSEd Maste m_functions (), 28ac7ddfbfSEd Maste m_support_files (), 29ac7ddfbfSEd Maste m_line_table_ap (), 30ac7ddfbfSEd Maste m_variables() 31ac7ddfbfSEd Maste { 32ac7ddfbfSEd Maste if (language != eLanguageTypeUnknown) 33ac7ddfbfSEd Maste m_flags.Set(flagsParsedLanguage); 34ac7ddfbfSEd Maste assert(module_sp); 35ac7ddfbfSEd Maste } 36ac7ddfbfSEd Maste 37ac7ddfbfSEd Maste CompileUnit::CompileUnit (const lldb::ModuleSP &module_sp, void *user_data, const FileSpec &fspec, const lldb::user_id_t cu_sym_id, lldb::LanguageType language) : 38ac7ddfbfSEd Maste ModuleChild(module_sp), 39ac7ddfbfSEd Maste FileSpec (fspec), 40ac7ddfbfSEd Maste UserID(cu_sym_id), 41ac7ddfbfSEd Maste m_user_data (user_data), 42ac7ddfbfSEd Maste m_language (language), 43ac7ddfbfSEd Maste m_flags (0), 44ac7ddfbfSEd Maste m_functions (), 45ac7ddfbfSEd Maste m_support_files (), 46ac7ddfbfSEd Maste m_line_table_ap (), 47ac7ddfbfSEd Maste m_variables() 48ac7ddfbfSEd Maste { 49ac7ddfbfSEd Maste if (language != eLanguageTypeUnknown) 50ac7ddfbfSEd Maste m_flags.Set(flagsParsedLanguage); 51ac7ddfbfSEd Maste assert(module_sp); 52ac7ddfbfSEd Maste } 53ac7ddfbfSEd Maste 54ac7ddfbfSEd Maste CompileUnit::~CompileUnit () 55ac7ddfbfSEd Maste { 56ac7ddfbfSEd Maste } 57ac7ddfbfSEd Maste 58ac7ddfbfSEd Maste void 59ac7ddfbfSEd Maste CompileUnit::CalculateSymbolContext(SymbolContext* sc) 60ac7ddfbfSEd Maste { 61ac7ddfbfSEd Maste sc->comp_unit = this; 62ac7ddfbfSEd Maste GetModule()->CalculateSymbolContext(sc); 63ac7ddfbfSEd Maste } 64ac7ddfbfSEd Maste 65ac7ddfbfSEd Maste ModuleSP 66ac7ddfbfSEd Maste CompileUnit::CalculateSymbolContextModule () 67ac7ddfbfSEd Maste { 68ac7ddfbfSEd Maste return GetModule(); 69ac7ddfbfSEd Maste } 70ac7ddfbfSEd Maste 71ac7ddfbfSEd Maste CompileUnit * 72ac7ddfbfSEd Maste CompileUnit::CalculateSymbolContextCompileUnit () 73ac7ddfbfSEd Maste { 74ac7ddfbfSEd Maste return this; 75ac7ddfbfSEd Maste } 76ac7ddfbfSEd Maste 77ac7ddfbfSEd Maste void 78ac7ddfbfSEd Maste CompileUnit::DumpSymbolContext(Stream *s) 79ac7ddfbfSEd Maste { 80ac7ddfbfSEd Maste GetModule()->DumpSymbolContext(s); 81ac7ddfbfSEd Maste s->Printf(", CompileUnit{0x%8.8" PRIx64 "}", GetID()); 82ac7ddfbfSEd Maste } 83ac7ddfbfSEd Maste 84ac7ddfbfSEd Maste 85ac7ddfbfSEd Maste void 86ac7ddfbfSEd Maste CompileUnit::GetDescription(Stream *s, lldb::DescriptionLevel level) const 87ac7ddfbfSEd Maste { 88ac7ddfbfSEd Maste Language language(m_language); 89ac7ddfbfSEd Maste *s << "id = " << (const UserID&)*this << ", file = \"" << (const FileSpec&)*this << "\", language = \"" << language << '"'; 90ac7ddfbfSEd Maste } 91ac7ddfbfSEd Maste 92ac7ddfbfSEd Maste 93ac7ddfbfSEd Maste //---------------------------------------------------------------------- 94ac7ddfbfSEd Maste // Dump the current contents of this object. No functions that cause on 95ac7ddfbfSEd Maste // demand parsing of functions, globals, statics are called, so this 96ac7ddfbfSEd Maste // is a good function to call to get an idea of the current contents of 97ac7ddfbfSEd Maste // the CompileUnit object. 98ac7ddfbfSEd Maste //---------------------------------------------------------------------- 99ac7ddfbfSEd Maste void 100ac7ddfbfSEd Maste CompileUnit::Dump(Stream *s, bool show_context) const 101ac7ddfbfSEd Maste { 1020127ef0fSEd Maste s->Printf("%p: ", static_cast<const void*>(this)); 103ac7ddfbfSEd Maste s->Indent(); 1040127ef0fSEd Maste *s << "CompileUnit" << static_cast<const UserID&>(*this) 1050127ef0fSEd Maste << ", language = \"" << reinterpret_cast<const Language&>(*this) 1060127ef0fSEd Maste << "\", file = '" << static_cast<const FileSpec&>(*this) << "'\n"; 107ac7ddfbfSEd Maste 108ac7ddfbfSEd Maste // m_types.Dump(s); 109ac7ddfbfSEd Maste 110ac7ddfbfSEd Maste if (m_variables.get()) 111ac7ddfbfSEd Maste { 112ac7ddfbfSEd Maste s->IndentMore(); 113ac7ddfbfSEd Maste m_variables->Dump(s, show_context); 114ac7ddfbfSEd Maste s->IndentLess(); 115ac7ddfbfSEd Maste } 116ac7ddfbfSEd Maste 117ac7ddfbfSEd Maste if (!m_functions.empty()) 118ac7ddfbfSEd Maste { 119ac7ddfbfSEd Maste s->IndentMore(); 120ac7ddfbfSEd Maste std::vector<FunctionSP>::const_iterator pos; 121ac7ddfbfSEd Maste std::vector<FunctionSP>::const_iterator end = m_functions.end(); 122ac7ddfbfSEd Maste for (pos = m_functions.begin(); pos != end; ++pos) 123ac7ddfbfSEd Maste { 124ac7ddfbfSEd Maste (*pos)->Dump(s, show_context); 125ac7ddfbfSEd Maste } 126ac7ddfbfSEd Maste 127ac7ddfbfSEd Maste s->IndentLess(); 128ac7ddfbfSEd Maste s->EOL(); 129ac7ddfbfSEd Maste } 130ac7ddfbfSEd Maste } 131ac7ddfbfSEd Maste 132ac7ddfbfSEd Maste //---------------------------------------------------------------------- 133ac7ddfbfSEd Maste // Add a function to this compile unit 134ac7ddfbfSEd Maste //---------------------------------------------------------------------- 135ac7ddfbfSEd Maste void 136ac7ddfbfSEd Maste CompileUnit::AddFunction(FunctionSP& funcSP) 137ac7ddfbfSEd Maste { 138ac7ddfbfSEd Maste // TODO: order these by address 139ac7ddfbfSEd Maste m_functions.push_back(funcSP); 140ac7ddfbfSEd Maste } 141ac7ddfbfSEd Maste 142ac7ddfbfSEd Maste FunctionSP 143ac7ddfbfSEd Maste CompileUnit::GetFunctionAtIndex (size_t idx) 144ac7ddfbfSEd Maste { 145ac7ddfbfSEd Maste FunctionSP funcSP; 146ac7ddfbfSEd Maste if (idx < m_functions.size()) 147ac7ddfbfSEd Maste funcSP = m_functions[idx]; 148ac7ddfbfSEd Maste return funcSP; 149ac7ddfbfSEd Maste } 150ac7ddfbfSEd Maste 151ac7ddfbfSEd Maste //---------------------------------------------------------------------- 1521c3bbb01SEd Maste // Find functions using the Mangled::Tokens token list. This 1531c3bbb01SEd Maste // function currently implements an interactive approach designed to find 1541c3bbb01SEd Maste // all instances of certain functions. It isn't designed to the 155ac7ddfbfSEd Maste // quickest way to lookup functions as it will need to iterate through 156ac7ddfbfSEd Maste // all functions and see if they match, though it does provide a powerful 157ac7ddfbfSEd Maste // and context sensitive way to search for all functions with a certain 158ac7ddfbfSEd Maste // name, all functions in a namespace, or all functions of a template 159ac7ddfbfSEd Maste // type. See Mangled::Tokens::Parse() comments for more information. 160ac7ddfbfSEd Maste // 161ac7ddfbfSEd Maste // The function prototype will need to change to return a list of 162ac7ddfbfSEd Maste // results. It was originally used to help debug the Mangled class 163ac7ddfbfSEd Maste // and the Mangled::Tokens::MatchesQuery() function and it currently 164ac7ddfbfSEd Maste // will print out a list of matching results for the functions that 165ac7ddfbfSEd Maste // are currently in this compile unit. 166ac7ddfbfSEd Maste // 167ac7ddfbfSEd Maste // A FindFunctions method should be called prior to this that takes 168ac7ddfbfSEd Maste // a regular function name (const char * or ConstString as a parameter) 169ac7ddfbfSEd Maste // before resorting to this slower but more complete function. The 170ac7ddfbfSEd Maste // other FindFunctions method should be able to take advantage of any 171ac7ddfbfSEd Maste // accelerator tables available in the debug information (which is 172ac7ddfbfSEd Maste // parsed by the SymbolFile parser plug-ins and registered with each 173ac7ddfbfSEd Maste // Module). 174ac7ddfbfSEd Maste //---------------------------------------------------------------------- 175ac7ddfbfSEd Maste //void 176ac7ddfbfSEd Maste //CompileUnit::FindFunctions(const Mangled::Tokens& tokens) 177ac7ddfbfSEd Maste //{ 178ac7ddfbfSEd Maste // if (!m_functions.empty()) 179ac7ddfbfSEd Maste // { 180ac7ddfbfSEd Maste // Stream s(stdout); 181ac7ddfbfSEd Maste // std::vector<FunctionSP>::const_iterator pos; 182ac7ddfbfSEd Maste // std::vector<FunctionSP>::const_iterator end = m_functions.end(); 183ac7ddfbfSEd Maste // for (pos = m_functions.begin(); pos != end; ++pos) 184ac7ddfbfSEd Maste // { 185ac7ddfbfSEd Maste // const ConstString& demangled = (*pos)->Mangled().Demangled(); 186ac7ddfbfSEd Maste // if (demangled) 187ac7ddfbfSEd Maste // { 188ac7ddfbfSEd Maste // const Mangled::Tokens& func_tokens = (*pos)->Mangled().GetTokens(); 189ac7ddfbfSEd Maste // if (func_tokens.MatchesQuery (tokens)) 190ac7ddfbfSEd Maste // s << "demangled MATCH found: " << demangled << "\n"; 191ac7ddfbfSEd Maste // } 192ac7ddfbfSEd Maste // } 193ac7ddfbfSEd Maste // } 194ac7ddfbfSEd Maste //} 195ac7ddfbfSEd Maste 196ac7ddfbfSEd Maste FunctionSP 197ac7ddfbfSEd Maste CompileUnit::FindFunctionByUID (lldb::user_id_t func_uid) 198ac7ddfbfSEd Maste { 199ac7ddfbfSEd Maste FunctionSP funcSP; 200ac7ddfbfSEd Maste if (!m_functions.empty()) 201ac7ddfbfSEd Maste { 202ac7ddfbfSEd Maste std::vector<FunctionSP>::const_iterator pos; 203ac7ddfbfSEd Maste std::vector<FunctionSP>::const_iterator end = m_functions.end(); 204ac7ddfbfSEd Maste for (pos = m_functions.begin(); pos != end; ++pos) 205ac7ddfbfSEd Maste { 206ac7ddfbfSEd Maste if ((*pos)->GetID() == func_uid) 207ac7ddfbfSEd Maste { 208ac7ddfbfSEd Maste funcSP = *pos; 209ac7ddfbfSEd Maste break; 210ac7ddfbfSEd Maste } 211ac7ddfbfSEd Maste } 212ac7ddfbfSEd Maste } 213ac7ddfbfSEd Maste return funcSP; 214ac7ddfbfSEd Maste } 215ac7ddfbfSEd Maste 216ac7ddfbfSEd Maste 217ac7ddfbfSEd Maste lldb::LanguageType 218ac7ddfbfSEd Maste CompileUnit::GetLanguage() 219ac7ddfbfSEd Maste { 220ac7ddfbfSEd Maste if (m_language == eLanguageTypeUnknown) 221ac7ddfbfSEd Maste { 222ac7ddfbfSEd Maste if (m_flags.IsClear(flagsParsedLanguage)) 223ac7ddfbfSEd Maste { 224ac7ddfbfSEd Maste m_flags.Set(flagsParsedLanguage); 225ac7ddfbfSEd Maste SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor(); 226ac7ddfbfSEd Maste if (symbol_vendor) 227ac7ddfbfSEd Maste { 228ac7ddfbfSEd Maste SymbolContext sc; 229ac7ddfbfSEd Maste CalculateSymbolContext(&sc); 230ac7ddfbfSEd Maste m_language = symbol_vendor->ParseCompileUnitLanguage(sc); 231ac7ddfbfSEd Maste } 232ac7ddfbfSEd Maste } 233ac7ddfbfSEd Maste } 234ac7ddfbfSEd Maste return m_language; 235ac7ddfbfSEd Maste } 236ac7ddfbfSEd Maste 237ac7ddfbfSEd Maste LineTable* 238ac7ddfbfSEd Maste CompileUnit::GetLineTable() 239ac7ddfbfSEd Maste { 2400127ef0fSEd Maste if (m_line_table_ap.get() == nullptr) 241ac7ddfbfSEd Maste { 242ac7ddfbfSEd Maste if (m_flags.IsClear(flagsParsedLineTable)) 243ac7ddfbfSEd Maste { 244ac7ddfbfSEd Maste m_flags.Set(flagsParsedLineTable); 245ac7ddfbfSEd Maste SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor(); 246ac7ddfbfSEd Maste if (symbol_vendor) 247ac7ddfbfSEd Maste { 248ac7ddfbfSEd Maste SymbolContext sc; 249ac7ddfbfSEd Maste CalculateSymbolContext(&sc); 250ac7ddfbfSEd Maste symbol_vendor->ParseCompileUnitLineTable(sc); 251ac7ddfbfSEd Maste } 252ac7ddfbfSEd Maste } 253ac7ddfbfSEd Maste } 254ac7ddfbfSEd Maste return m_line_table_ap.get(); 255ac7ddfbfSEd Maste } 256ac7ddfbfSEd Maste 257ac7ddfbfSEd Maste void 258ac7ddfbfSEd Maste CompileUnit::SetLineTable(LineTable* line_table) 259ac7ddfbfSEd Maste { 2600127ef0fSEd Maste if (line_table == nullptr) 261ac7ddfbfSEd Maste m_flags.Clear(flagsParsedLineTable); 262ac7ddfbfSEd Maste else 263ac7ddfbfSEd Maste m_flags.Set(flagsParsedLineTable); 264ac7ddfbfSEd Maste m_line_table_ap.reset(line_table); 265ac7ddfbfSEd Maste } 266ac7ddfbfSEd Maste 267ac7ddfbfSEd Maste VariableListSP 268ac7ddfbfSEd Maste CompileUnit::GetVariableList(bool can_create) 269ac7ddfbfSEd Maste { 2700127ef0fSEd Maste if (m_variables.get() == nullptr && can_create) 271ac7ddfbfSEd Maste { 272ac7ddfbfSEd Maste SymbolContext sc; 273ac7ddfbfSEd Maste CalculateSymbolContext(&sc); 274ac7ddfbfSEd Maste assert(sc.module_sp); 275ac7ddfbfSEd Maste sc.module_sp->GetSymbolVendor()->ParseVariablesForContext(sc); 276ac7ddfbfSEd Maste } 277ac7ddfbfSEd Maste 278ac7ddfbfSEd Maste return m_variables; 279ac7ddfbfSEd Maste } 280ac7ddfbfSEd Maste 281ac7ddfbfSEd Maste uint32_t 282ac7ddfbfSEd Maste CompileUnit::FindLineEntry (uint32_t start_idx, uint32_t line, const FileSpec* file_spec_ptr, bool exact, LineEntry *line_entry_ptr) 283ac7ddfbfSEd Maste { 284ac7ddfbfSEd Maste uint32_t file_idx = 0; 285ac7ddfbfSEd Maste 286ac7ddfbfSEd Maste if (file_spec_ptr) 287ac7ddfbfSEd Maste { 288ac7ddfbfSEd Maste file_idx = GetSupportFiles().FindFileIndex (1, *file_spec_ptr, true); 289ac7ddfbfSEd Maste if (file_idx == UINT32_MAX) 290ac7ddfbfSEd Maste return UINT32_MAX; 291ac7ddfbfSEd Maste } 292ac7ddfbfSEd Maste else 293ac7ddfbfSEd Maste { 294ac7ddfbfSEd Maste // All the line table entries actually point to the version of the Compile 2951c3bbb01SEd Maste // Unit that is in the support files (the one at 0 was artificially added.) 296ac7ddfbfSEd Maste // So prefer the one further on in the support files if it exists... 297ac7ddfbfSEd Maste FileSpecList &support_files = GetSupportFiles(); 298ac7ddfbfSEd Maste const bool full = true; 299ac7ddfbfSEd Maste file_idx = support_files.FindFileIndex (1, support_files.GetFileSpecAtIndex(0), full); 300ac7ddfbfSEd Maste if (file_idx == UINT32_MAX) 301ac7ddfbfSEd Maste file_idx = 0; 302ac7ddfbfSEd Maste } 303ac7ddfbfSEd Maste LineTable *line_table = GetLineTable(); 304ac7ddfbfSEd Maste if (line_table) 305ac7ddfbfSEd Maste return line_table->FindLineEntryIndexByFileIndex (start_idx, file_idx, line, exact, line_entry_ptr); 306ac7ddfbfSEd Maste return UINT32_MAX; 307ac7ddfbfSEd Maste } 308ac7ddfbfSEd Maste 309ac7ddfbfSEd Maste 310ac7ddfbfSEd Maste 311ac7ddfbfSEd Maste 312ac7ddfbfSEd Maste uint32_t 313ac7ddfbfSEd Maste CompileUnit::ResolveSymbolContext 314ac7ddfbfSEd Maste ( 315ac7ddfbfSEd Maste const FileSpec& file_spec, 316ac7ddfbfSEd Maste uint32_t line, 317ac7ddfbfSEd Maste bool check_inlines, 318ac7ddfbfSEd Maste bool exact, 319ac7ddfbfSEd Maste uint32_t resolve_scope, 320ac7ddfbfSEd Maste SymbolContextList &sc_list 321ac7ddfbfSEd Maste ) 322ac7ddfbfSEd Maste { 323ac7ddfbfSEd Maste // First find all of the file indexes that match our "file_spec". If 324ac7ddfbfSEd Maste // "file_spec" has an empty directory, then only compare the basenames 325ac7ddfbfSEd Maste // when finding file indexes 326ac7ddfbfSEd Maste std::vector<uint32_t> file_indexes; 32735617911SEd Maste const bool full_match = (bool)file_spec.GetDirectory(); 3287aa51b79SEd Maste const bool remove_backup_dots = true; 3297aa51b79SEd Maste bool file_spec_matches_cu_file_spec = FileSpec::Equal(file_spec, *this, full_match, remove_backup_dots); 330ac7ddfbfSEd Maste 331ac7ddfbfSEd Maste // If we are not looking for inlined functions and our file spec doesn't 332ac7ddfbfSEd Maste // match then we are done... 333ac7ddfbfSEd Maste if (file_spec_matches_cu_file_spec == false && check_inlines == false) 334ac7ddfbfSEd Maste return 0; 335ac7ddfbfSEd Maste 3367aa51b79SEd Maste uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec, true, remove_backup_dots); 337ac7ddfbfSEd Maste while (file_idx != UINT32_MAX) 338ac7ddfbfSEd Maste { 339ac7ddfbfSEd Maste file_indexes.push_back (file_idx); 3407aa51b79SEd Maste file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec, true, remove_backup_dots); 341ac7ddfbfSEd Maste } 342ac7ddfbfSEd Maste 343ac7ddfbfSEd Maste const size_t num_file_indexes = file_indexes.size(); 344ac7ddfbfSEd Maste if (num_file_indexes == 0) 345ac7ddfbfSEd Maste return 0; 346ac7ddfbfSEd Maste 347ac7ddfbfSEd Maste const uint32_t prev_size = sc_list.GetSize(); 348ac7ddfbfSEd Maste 349ac7ddfbfSEd Maste SymbolContext sc(GetModule()); 350ac7ddfbfSEd Maste sc.comp_unit = this; 351ac7ddfbfSEd Maste 352ac7ddfbfSEd Maste 353ac7ddfbfSEd Maste if (line != 0) 354ac7ddfbfSEd Maste { 355ac7ddfbfSEd Maste LineTable *line_table = sc.comp_unit->GetLineTable(); 356ac7ddfbfSEd Maste 3570127ef0fSEd Maste if (line_table != nullptr) 358ac7ddfbfSEd Maste { 359ac7ddfbfSEd Maste uint32_t found_line; 360ac7ddfbfSEd Maste uint32_t line_idx; 361ac7ddfbfSEd Maste 362ac7ddfbfSEd Maste if (num_file_indexes == 1) 363ac7ddfbfSEd Maste { 364ac7ddfbfSEd Maste // We only have a single support file that matches, so use 365ac7ddfbfSEd Maste // the line table function that searches for a line entries 366ac7ddfbfSEd Maste // that match a single support file index 367ac7ddfbfSEd Maste LineEntry line_entry; 368ac7ddfbfSEd Maste line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes.front(), line, exact, &line_entry); 369ac7ddfbfSEd Maste 370ac7ddfbfSEd Maste // If "exact == true", then "found_line" will be the same 371ac7ddfbfSEd Maste // as "line". If "exact == false", the "found_line" will be the 372ac7ddfbfSEd Maste // closest line entry with a line number greater than "line" and 373ac7ddfbfSEd Maste // we will use this for our subsequent line exact matches below. 374ac7ddfbfSEd Maste found_line = line_entry.line; 375ac7ddfbfSEd Maste 376ac7ddfbfSEd Maste while (line_idx != UINT32_MAX) 377ac7ddfbfSEd Maste { 378ac7ddfbfSEd Maste // If they only asked for the line entry, then we're done, we can just copy that over. 379ac7ddfbfSEd Maste // But if they wanted more than just the line number, fill it in. 380ac7ddfbfSEd Maste if (resolve_scope == eSymbolContextLineEntry) 381ac7ddfbfSEd Maste { 382ac7ddfbfSEd Maste sc.line_entry = line_entry; 383ac7ddfbfSEd Maste } 384ac7ddfbfSEd Maste else 385ac7ddfbfSEd Maste { 386ac7ddfbfSEd Maste line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope); 387ac7ddfbfSEd Maste } 388ac7ddfbfSEd Maste 389ac7ddfbfSEd Maste sc_list.Append(sc); 390ac7ddfbfSEd Maste line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes.front(), found_line, true, &line_entry); 391ac7ddfbfSEd Maste } 392ac7ddfbfSEd Maste } 393ac7ddfbfSEd Maste else 394ac7ddfbfSEd Maste { 395ac7ddfbfSEd Maste // We found multiple support files that match "file_spec" so use 396ac7ddfbfSEd Maste // the line table function that searches for a line entries 397ac7ddfbfSEd Maste // that match a multiple support file indexes. 398ac7ddfbfSEd Maste LineEntry line_entry; 399ac7ddfbfSEd Maste line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes, line, exact, &line_entry); 400ac7ddfbfSEd Maste 401ac7ddfbfSEd Maste // If "exact == true", then "found_line" will be the same 402ac7ddfbfSEd Maste // as "line". If "exact == false", the "found_line" will be the 403ac7ddfbfSEd Maste // closest line entry with a line number greater than "line" and 404ac7ddfbfSEd Maste // we will use this for our subsequent line exact matches below. 405ac7ddfbfSEd Maste found_line = line_entry.line; 406ac7ddfbfSEd Maste 407ac7ddfbfSEd Maste while (line_idx != UINT32_MAX) 408ac7ddfbfSEd Maste { 409ac7ddfbfSEd Maste if (resolve_scope == eSymbolContextLineEntry) 410ac7ddfbfSEd Maste { 411ac7ddfbfSEd Maste sc.line_entry = line_entry; 412ac7ddfbfSEd Maste } 413ac7ddfbfSEd Maste else 414ac7ddfbfSEd Maste { 415ac7ddfbfSEd Maste line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope); 416ac7ddfbfSEd Maste } 417ac7ddfbfSEd Maste 418ac7ddfbfSEd Maste sc_list.Append(sc); 419ac7ddfbfSEd Maste line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes, found_line, true, &line_entry); 420ac7ddfbfSEd Maste } 421ac7ddfbfSEd Maste } 422ac7ddfbfSEd Maste } 423ac7ddfbfSEd Maste } 424ac7ddfbfSEd Maste else if (file_spec_matches_cu_file_spec && !check_inlines) 425ac7ddfbfSEd Maste { 426ac7ddfbfSEd Maste // only append the context if we aren't looking for inline call sites 427ac7ddfbfSEd Maste // by file and line and if the file spec matches that of the compile unit 428ac7ddfbfSEd Maste sc_list.Append(sc); 429ac7ddfbfSEd Maste } 430ac7ddfbfSEd Maste return sc_list.GetSize() - prev_size; 431ac7ddfbfSEd Maste } 432ac7ddfbfSEd Maste 433ac7ddfbfSEd Maste void 434ac7ddfbfSEd Maste CompileUnit::SetVariableList(VariableListSP &variables) 435ac7ddfbfSEd Maste { 436ac7ddfbfSEd Maste m_variables = variables; 437ac7ddfbfSEd Maste } 438ac7ddfbfSEd Maste 4391c3bbb01SEd Maste const std::vector<ConstString> & 4401c3bbb01SEd Maste CompileUnit::GetImportedModules () 4411c3bbb01SEd Maste { 4421c3bbb01SEd Maste if (m_imported_modules.empty() && 4431c3bbb01SEd Maste m_flags.IsClear(flagsParsedImportedModules)) 4441c3bbb01SEd Maste { 4451c3bbb01SEd Maste m_flags.Set(flagsParsedImportedModules); 4461c3bbb01SEd Maste if (SymbolVendor *symbol_vendor = GetModule()->GetSymbolVendor()) 4471c3bbb01SEd Maste { 4481c3bbb01SEd Maste SymbolContext sc; 4491c3bbb01SEd Maste CalculateSymbolContext(&sc); 4501c3bbb01SEd Maste symbol_vendor->ParseImportedModules(sc, m_imported_modules); 4511c3bbb01SEd Maste } 4521c3bbb01SEd Maste } 4531c3bbb01SEd Maste return m_imported_modules; 4541c3bbb01SEd Maste } 4551c3bbb01SEd Maste 456ac7ddfbfSEd Maste FileSpecList& 457ac7ddfbfSEd Maste CompileUnit::GetSupportFiles () 458ac7ddfbfSEd Maste { 459ac7ddfbfSEd Maste if (m_support_files.GetSize() == 0) 460ac7ddfbfSEd Maste { 461ac7ddfbfSEd Maste if (m_flags.IsClear(flagsParsedSupportFiles)) 462ac7ddfbfSEd Maste { 463ac7ddfbfSEd Maste m_flags.Set(flagsParsedSupportFiles); 464ac7ddfbfSEd Maste SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor(); 465ac7ddfbfSEd Maste if (symbol_vendor) 466ac7ddfbfSEd Maste { 467ac7ddfbfSEd Maste SymbolContext sc; 468ac7ddfbfSEd Maste CalculateSymbolContext(&sc); 469ac7ddfbfSEd Maste symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files); 470ac7ddfbfSEd Maste } 471ac7ddfbfSEd Maste } 472ac7ddfbfSEd Maste } 473ac7ddfbfSEd Maste return m_support_files; 474ac7ddfbfSEd Maste } 475ac7ddfbfSEd Maste 476ac7ddfbfSEd Maste void * 477ac7ddfbfSEd Maste CompileUnit::GetUserData () const 478ac7ddfbfSEd Maste { 479ac7ddfbfSEd Maste return m_user_data; 480ac7ddfbfSEd Maste } 481ac7ddfbfSEd Maste 482ac7ddfbfSEd Maste 483