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 //----------------------------------------------------------------------
152ac7ddfbfSEd Maste // Find functions using the a Mangled::Tokens token list. This
153ac7ddfbfSEd Maste // function currently implements an interative approach designed to find
154ac7ddfbfSEd Maste // all instances of certain functions. It isn't designed to the 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
295ac7ddfbfSEd Maste         // Unit that is in the support files (the one at 0 was artifically 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();
328ac7ddfbfSEd Maste     bool file_spec_matches_cu_file_spec = FileSpec::Equal(file_spec, *this, full_match);
329ac7ddfbfSEd Maste 
330ac7ddfbfSEd Maste     // If we are not looking for inlined functions and our file spec doesn't
331ac7ddfbfSEd Maste     // match then we are done...
332ac7ddfbfSEd Maste     if (file_spec_matches_cu_file_spec == false && check_inlines == false)
333ac7ddfbfSEd Maste         return 0;
334ac7ddfbfSEd Maste 
335ac7ddfbfSEd Maste     uint32_t file_idx = GetSupportFiles().FindFileIndex (1, file_spec, true);
336ac7ddfbfSEd Maste     while (file_idx != UINT32_MAX)
337ac7ddfbfSEd Maste     {
338ac7ddfbfSEd Maste         file_indexes.push_back (file_idx);
339ac7ddfbfSEd Maste         file_idx = GetSupportFiles().FindFileIndex (file_idx + 1, file_spec, true);
340ac7ddfbfSEd Maste     }
341ac7ddfbfSEd Maste 
342ac7ddfbfSEd Maste     const size_t num_file_indexes = file_indexes.size();
343ac7ddfbfSEd Maste     if (num_file_indexes == 0)
344ac7ddfbfSEd Maste         return 0;
345ac7ddfbfSEd Maste 
346ac7ddfbfSEd Maste     const uint32_t prev_size = sc_list.GetSize();
347ac7ddfbfSEd Maste 
348ac7ddfbfSEd Maste     SymbolContext sc(GetModule());
349ac7ddfbfSEd Maste     sc.comp_unit = this;
350ac7ddfbfSEd Maste 
351ac7ddfbfSEd Maste 
352ac7ddfbfSEd Maste     if (line != 0)
353ac7ddfbfSEd Maste     {
354ac7ddfbfSEd Maste         LineTable *line_table = sc.comp_unit->GetLineTable();
355ac7ddfbfSEd Maste 
3560127ef0fSEd Maste         if (line_table != nullptr)
357ac7ddfbfSEd Maste         {
358ac7ddfbfSEd Maste             uint32_t found_line;
359ac7ddfbfSEd Maste             uint32_t line_idx;
360ac7ddfbfSEd Maste 
361ac7ddfbfSEd Maste             if (num_file_indexes == 1)
362ac7ddfbfSEd Maste             {
363ac7ddfbfSEd Maste                 // We only have a single support file that matches, so use
364ac7ddfbfSEd Maste                 // the line table function that searches for a line entries
365ac7ddfbfSEd Maste                 // that match a single support file index
366ac7ddfbfSEd Maste                 LineEntry line_entry;
367ac7ddfbfSEd Maste                 line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes.front(), line, exact, &line_entry);
368ac7ddfbfSEd Maste 
369ac7ddfbfSEd Maste                 // If "exact == true", then "found_line" will be the same
370ac7ddfbfSEd Maste                 // as "line". If "exact == false", the "found_line" will be the
371ac7ddfbfSEd Maste                 // closest line entry with a line number greater than "line" and
372ac7ddfbfSEd Maste                 // we will use this for our subsequent line exact matches below.
373ac7ddfbfSEd Maste                 found_line = line_entry.line;
374ac7ddfbfSEd Maste 
375ac7ddfbfSEd Maste                 while (line_idx != UINT32_MAX)
376ac7ddfbfSEd Maste                 {
377ac7ddfbfSEd Maste                     // If they only asked for the line entry, then we're done, we can just copy that over.
378ac7ddfbfSEd Maste                     // But if they wanted more than just the line number, fill it in.
379ac7ddfbfSEd Maste                     if (resolve_scope == eSymbolContextLineEntry)
380ac7ddfbfSEd Maste                     {
381ac7ddfbfSEd Maste                         sc.line_entry = line_entry;
382ac7ddfbfSEd Maste                     }
383ac7ddfbfSEd Maste                     else
384ac7ddfbfSEd Maste                     {
385ac7ddfbfSEd Maste                         line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);
386ac7ddfbfSEd Maste                     }
387ac7ddfbfSEd Maste 
388ac7ddfbfSEd Maste                     sc_list.Append(sc);
389ac7ddfbfSEd Maste                     line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes.front(), found_line, true, &line_entry);
390ac7ddfbfSEd Maste                 }
391ac7ddfbfSEd Maste             }
392ac7ddfbfSEd Maste             else
393ac7ddfbfSEd Maste             {
394ac7ddfbfSEd Maste                 // We found multiple support files that match "file_spec" so use
395ac7ddfbfSEd Maste                 // the line table function that searches for a line entries
396ac7ddfbfSEd Maste                 // that match a multiple support file indexes.
397ac7ddfbfSEd Maste                 LineEntry line_entry;
398ac7ddfbfSEd Maste                 line_idx = line_table->FindLineEntryIndexByFileIndex (0, file_indexes, line, exact, &line_entry);
399ac7ddfbfSEd Maste 
400ac7ddfbfSEd Maste                 // If "exact == true", then "found_line" will be the same
401ac7ddfbfSEd Maste                 // as "line". If "exact == false", the "found_line" will be the
402ac7ddfbfSEd Maste                 // closest line entry with a line number greater than "line" and
403ac7ddfbfSEd Maste                 // we will use this for our subsequent line exact matches below.
404ac7ddfbfSEd Maste                 found_line = line_entry.line;
405ac7ddfbfSEd Maste 
406ac7ddfbfSEd Maste                 while (line_idx != UINT32_MAX)
407ac7ddfbfSEd Maste                 {
408ac7ddfbfSEd Maste                     if (resolve_scope == eSymbolContextLineEntry)
409ac7ddfbfSEd Maste                     {
410ac7ddfbfSEd Maste                         sc.line_entry = line_entry;
411ac7ddfbfSEd Maste                     }
412ac7ddfbfSEd Maste                     else
413ac7ddfbfSEd Maste                     {
414ac7ddfbfSEd Maste                         line_entry.range.GetBaseAddress().CalculateSymbolContext(&sc, resolve_scope);
415ac7ddfbfSEd Maste                     }
416ac7ddfbfSEd Maste 
417ac7ddfbfSEd Maste                     sc_list.Append(sc);
418ac7ddfbfSEd Maste                     line_idx = line_table->FindLineEntryIndexByFileIndex (line_idx + 1, file_indexes, found_line, true, &line_entry);
419ac7ddfbfSEd Maste                 }
420ac7ddfbfSEd Maste             }
421ac7ddfbfSEd Maste         }
422ac7ddfbfSEd Maste     }
423ac7ddfbfSEd Maste     else if (file_spec_matches_cu_file_spec && !check_inlines)
424ac7ddfbfSEd Maste     {
425ac7ddfbfSEd Maste         // only append the context if we aren't looking for inline call sites
426ac7ddfbfSEd Maste         // by file and line and if the file spec matches that of the compile unit
427ac7ddfbfSEd Maste         sc_list.Append(sc);
428ac7ddfbfSEd Maste     }
429ac7ddfbfSEd Maste     return sc_list.GetSize() - prev_size;
430ac7ddfbfSEd Maste }
431ac7ddfbfSEd Maste 
432ac7ddfbfSEd Maste void
433ac7ddfbfSEd Maste CompileUnit::SetVariableList(VariableListSP &variables)
434ac7ddfbfSEd Maste {
435ac7ddfbfSEd Maste     m_variables = variables;
436ac7ddfbfSEd Maste }
437ac7ddfbfSEd Maste 
438ac7ddfbfSEd Maste FileSpecList&
439ac7ddfbfSEd Maste CompileUnit::GetSupportFiles ()
440ac7ddfbfSEd Maste {
441ac7ddfbfSEd Maste     if (m_support_files.GetSize() == 0)
442ac7ddfbfSEd Maste     {
443ac7ddfbfSEd Maste         if (m_flags.IsClear(flagsParsedSupportFiles))
444ac7ddfbfSEd Maste         {
445ac7ddfbfSEd Maste             m_flags.Set(flagsParsedSupportFiles);
446ac7ddfbfSEd Maste             SymbolVendor* symbol_vendor = GetModule()->GetSymbolVendor();
447ac7ddfbfSEd Maste             if (symbol_vendor)
448ac7ddfbfSEd Maste             {
449ac7ddfbfSEd Maste                 SymbolContext sc;
450ac7ddfbfSEd Maste                 CalculateSymbolContext(&sc);
451ac7ddfbfSEd Maste                 symbol_vendor->ParseCompileUnitSupportFiles(sc, m_support_files);
452ac7ddfbfSEd Maste             }
453ac7ddfbfSEd Maste         }
454ac7ddfbfSEd Maste     }
455ac7ddfbfSEd Maste     return m_support_files;
456ac7ddfbfSEd Maste }
457ac7ddfbfSEd Maste 
458ac7ddfbfSEd Maste void *
459ac7ddfbfSEd Maste CompileUnit::GetUserData () const
460ac7ddfbfSEd Maste {
461ac7ddfbfSEd Maste     return m_user_data;
462ac7ddfbfSEd Maste }
463ac7ddfbfSEd Maste 
464ac7ddfbfSEd Maste 
465