Module.h revision 327952
155714Skris//===-- Module.h ------------------------------------------------*- C++ -*-===//
259191Skris//
355714Skris//                     The LLVM Compiler Infrastructure
455714Skris//
555714Skris// This file is distributed under the University of Illinois Open Source
655714Skris// License. See LICENSE.TXT for details.
755714Skris//
855714Skris//===----------------------------------------------------------------------===//
9280304Sjkim
1055714Skris#ifndef liblldb_Module_h_
1155714Skris#define liblldb_Module_h_
1255714Skris
1355714Skris#include "lldb/Core/Address.h"    // for Address
1455714Skris#include "lldb/Core/ModuleSpec.h" // for ModuleSpec
1555714Skris#include "lldb/Symbol/SymbolContextScope.h"
16280304Sjkim#include "lldb/Symbol/TypeSystem.h"
1755714Skris#include "lldb/Target/PathMappingList.h"
1855714Skris#include "lldb/Utility/ArchSpec.h"
1955714Skris#include "lldb/Utility/ConstString.h" // for ConstString
2055714Skris#include "lldb/Utility/FileSpec.h"
2155714Skris#include "lldb/Utility/Status.h" // for Status
2255714Skris#include "lldb/Utility/UUID.h"
23280304Sjkim#include "lldb/lldb-defines.h"      // for DISALLOW_COPY_AND_ASSIGN
2455714Skris#include "lldb/lldb-enumerations.h" // for LanguageType, SymbolType
2555714Skris#include "lldb/lldb-forward.h"
2655714Skris#include "lldb/lldb-types.h" // for addr_t, offset_t
2755714Skris
2855714Skris#include "llvm/ADT/DenseSet.h"
2955714Skris#include "llvm/ADT/StringRef.h"
3055714Skris#include "llvm/Support/Chrono.h"
3155714Skris
3255714Skris#include <atomic>
3355714Skris#include <memory> // for enable_shared_from_this
3455714Skris#include <mutex>
3555714Skris#include <stddef.h> // for size_t
3655714Skris#include <stdint.h> // for uint32_t, uint64_t
3755714Skris#include <string>
38280304Sjkim#include <vector>
3955714Skris
4055714Skrisnamespace lldb_private {
41280304Sjkimclass CompilerDeclContext;
4255714Skris}
4355714Skrisnamespace lldb_private {
4455714Skrisclass Function;
4555714Skris}
4655714Skrisnamespace lldb_private {
4755714Skrisclass Log;
4855714Skris}
4955714Skrisnamespace lldb_private {
5055714Skrisclass ObjectFile;
5155714Skris}
5255714Skrisnamespace lldb_private {
53280304Sjkimclass RegularExpression;
5455714Skris}
5555714Skrisnamespace lldb_private {
5655714Skrisclass SectionList;
5755714Skris}
5855714Skrisnamespace lldb_private {
5955714Skrisclass Stream;
60280304Sjkim}
61109998Smarkmnamespace lldb_private {
62280304Sjkimclass Symbol;
63280304Sjkim}
64280304Sjkimnamespace lldb_private {
65280304Sjkimclass SymbolContext;
66280304Sjkim}
67280304Sjkimnamespace lldb_private {
68280304Sjkimclass SymbolContextList;
69280304Sjkim}
70280304Sjkimnamespace lldb_private {
71280304Sjkimclass SymbolFile;
72280304Sjkim}
7355714Skrisnamespace lldb_private {
74280304Sjkimclass SymbolVendor;
75280304Sjkim}
7655714Skrisnamespace lldb_private {
77280304Sjkimclass Symtab;
78280304Sjkim}
7955714Skrisnamespace lldb_private {
80280304Sjkimclass Target;
81280304Sjkim}
82280304Sjkimnamespace lldb_private {
8355714Skrisclass TypeList;
8455714Skris}
8555714Skrisnamespace lldb_private {
8655714Skrisclass TypeMap;
8755714Skris}
8859191Skrisnamespace lldb_private {
8959191Skrisclass VariableList;
9055714Skris}
91280304Sjkim
92280304Sjkimnamespace lldb_private {
93280304Sjkim
94280304Sjkim//----------------------------------------------------------------------
95280304Sjkim/// @class Module Module.h "lldb/Core/Module.h"
96280304Sjkim/// @brief A class that describes an executable image and its associated
97280304Sjkim///        object and symbol files.
98280304Sjkim///
99280304Sjkim/// The module is designed to be able to select a single slice of an
10055714Skris/// executable image as it would appear on disk and during program
101280304Sjkim/// execution.
10255714Skris///
103280304Sjkim/// Modules control when and if information is parsed according to which
104280304Sjkim/// accessors are called. For example the object file (ObjectFile)
105280304Sjkim/// representation will only be parsed if the object file is requested
10655714Skris/// using the Module::GetObjectFile() is called. The debug symbols
107280304Sjkim/// will only be parsed if the symbol vendor (SymbolVendor) is
108280304Sjkim/// requested using the Module::GetSymbolVendor() is called.
109109998Smarkm///
110280304Sjkim/// The module will parse more detailed information as more queries are
111280304Sjkim/// made.
112280304Sjkim//----------------------------------------------------------------------
113280304Sjkimclass Module : public std::enable_shared_from_this<Module>,
114280304Sjkim               public SymbolContextScope {
115280304Sjkimpublic:
116280304Sjkim  // Static functions that can track the lifetime of module objects.
11755714Skris  // This is handy because we might have Module objects that are in
118280304Sjkim  // shared pointers that aren't in the global module list (from
119280304Sjkim  // ModuleList). If this is the case we need to know about it.
120280304Sjkim  // The modules in the global list maintained by these functions
121280304Sjkim  // can be viewed using the "target modules list" command using the
122280304Sjkim  // "--global" (-g for short).
123280304Sjkim  static size_t GetNumberAllocatedModules();
124280304Sjkim
125280304Sjkim  static Module *GetAllocatedModuleAtIndex(size_t idx);
126280304Sjkim
127280304Sjkim  static std::recursive_mutex &GetAllocationModuleCollectionMutex();
128280304Sjkim
129280304Sjkim  //------------------------------------------------------------------
130280304Sjkim  /// Construct with file specification and architecture.
131280304Sjkim  ///
132280304Sjkim  /// Clients that wish to share modules with other targets should
133280304Sjkim  /// use ModuleList::GetSharedModule().
134280304Sjkim  ///
135280304Sjkim  /// @param[in] file_spec
136280304Sjkim  ///     The file specification for the on disk representation of
137280304Sjkim  ///     this executable image.
138280304Sjkim  ///
139280304Sjkim  /// @param[in] arch
140280304Sjkim  ///     The architecture to set as the current architecture in
141280304Sjkim  ///     this module.
142280304Sjkim  ///
143280304Sjkim  /// @param[in] object_name
144280304Sjkim  ///     The name of an object in a module used to extract a module
145280304Sjkim  ///     within a module (.a files and modules that contain multiple
146280304Sjkim  ///     architectures).
147280304Sjkim  ///
148280304Sjkim  /// @param[in] object_offset
149280304Sjkim  ///     The offset within an existing module used to extract a
150280304Sjkim  ///     module within a module (.a files and modules that contain
151280304Sjkim  ///     multiple architectures).
152280304Sjkim  //------------------------------------------------------------------
153280304Sjkim  Module(
154280304Sjkim      const FileSpec &file_spec, const ArchSpec &arch,
155280304Sjkim      const ConstString *object_name = nullptr,
156280304Sjkim      lldb::offset_t object_offset = 0,
157280304Sjkim      const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>());
158280304Sjkim
159280304Sjkim  Module(const ModuleSpec &module_spec);
160280304Sjkim
161280304Sjkim  static lldb::ModuleSP
16255714Skris  CreateJITModule(const lldb::ObjectFileJITDelegateSP &delegate_sp);
163280304Sjkim
164280304Sjkim  //------------------------------------------------------------------
165280304Sjkim  /// Destructor.
166280304Sjkim  //------------------------------------------------------------------
167280304Sjkim  ~Module() override;
168280304Sjkim
169280304Sjkim  bool MatchesModuleSpec(const ModuleSpec &module_ref);
170280304Sjkim
171280304Sjkim  //------------------------------------------------------------------
172280304Sjkim  /// Set the load address for all sections in a module to be the
173280304Sjkim  /// file address plus \a slide.
174280304Sjkim  ///
175280304Sjkim  /// Many times a module will be loaded in a target with a constant
176280304Sjkim  /// offset applied to all top level sections. This function can
177280304Sjkim  /// set the load address for all top level sections to be the
178280304Sjkim  /// section file address + offset.
179280304Sjkim  ///
180280304Sjkim  /// @param[in] target
181280304Sjkim  ///     The target in which to apply the section load addresses.
182280304Sjkim  ///
18355714Skris  /// @param[in] value
184280304Sjkim  ///     if \a value_is_offset is true, then value is the offset to
18555714Skris  ///     apply to all file addresses for all top level sections in
186280304Sjkim  ///     the object file as each section load address is being set.
187280304Sjkim  ///     If \a value_is_offset is false, then "value" is the new
188280304Sjkim  ///     absolute base address for the image.
189109998Smarkm  ///
190280304Sjkim  /// @param[in] value_is_offset
191280304Sjkim  ///     If \b true, then \a value is an offset to apply to each
192280304Sjkim  ///     file address of each top level section.
193280304Sjkim  ///     If \b false, then \a value is the image base address that
194280304Sjkim  ///     will be used to rigidly slide all loadable sections.
195280304Sjkim  ///
19655714Skris  /// @param[out] changed
197280304Sjkim  ///     If any section load addresses were changed in \a target,
198280304Sjkim  ///     then \a changed will be set to \b true. Else \a changed
199280304Sjkim  ///     will be set to false. This allows this function to be
200280304Sjkim  ///     called multiple times on the same module for the same
201280304Sjkim  ///     target. If the module hasn't moved, then \a changed will
202280304Sjkim  ///     be false and no module updated notification will need to
203280304Sjkim  ///     be sent out.
204280304Sjkim  ///
205280304Sjkim  /// @return
206280304Sjkim  ///     /b True if any sections were successfully loaded in \a target,
207280304Sjkim  ///     /b false otherwise.
208280304Sjkim  //------------------------------------------------------------------
209280304Sjkim  bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset,
210280304Sjkim                      bool &changed);
211280304Sjkim
212280304Sjkim  //------------------------------------------------------------------
213280304Sjkim  /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
214280304Sjkim  ///
215280304Sjkim  /// @see SymbolContextScope
216280304Sjkim  //------------------------------------------------------------------
217280304Sjkim  void CalculateSymbolContext(SymbolContext *sc) override;
218280304Sjkim
21955714Skris  lldb::ModuleSP CalculateSymbolContextModule() override;
220280304Sjkim
221280304Sjkim  void
222280304Sjkim  GetDescription(Stream *s,
223280304Sjkim                 lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
224280304Sjkim
225280304Sjkim  //------------------------------------------------------------------
226280304Sjkim  /// Get the module path and object name.
227280304Sjkim  ///
228280304Sjkim  /// Modules can refer to object files. In this case the specification
229280304Sjkim  /// is simple and would return the path to the file:
230280304Sjkim  ///
231280304Sjkim  ///     "/usr/lib/foo.dylib"
232280304Sjkim  ///
23355714Skris  /// Modules can be .o files inside of a BSD archive (.a file). In
234280304Sjkim  /// this case, the object specification will look like:
235280304Sjkim  ///
236280304Sjkim  ///     "/usr/lib/foo.a(bar.o)"
237280304Sjkim  ///
238280304Sjkim  /// There are many places where logging wants to log this fully
239280304Sjkim  /// qualified specification, so we centralize this functionality
240280304Sjkim  /// here.
241280304Sjkim  ///
242280304Sjkim  /// @return
243280304Sjkim  ///     The object path + object name if there is one.
244280304Sjkim  //------------------------------------------------------------------
245280304Sjkim  std::string GetSpecificationDescription() const;
24655714Skris
247280304Sjkim  //------------------------------------------------------------------
248280304Sjkim  /// Dump a description of this object to a Stream.
249280304Sjkim  ///
250280304Sjkim  /// Dump a description of the contents of this object to the
251280304Sjkim  /// supplied stream \a s. The dumped content will be only what has
252280304Sjkim  /// been loaded or parsed up to this point at which this function
253280304Sjkim  /// is called, so this is a good way to see what has been parsed
254280304Sjkim  /// in a module.
255280304Sjkim  ///
256280304Sjkim  /// @param[in] s
257280304Sjkim  ///     The stream to which to dump the object description.
258280304Sjkim  //------------------------------------------------------------------
259280304Sjkim  void Dump(Stream *s);
260280304Sjkim
261280304Sjkim  //------------------------------------------------------------------
262280304Sjkim  /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
263280304Sjkim  ///
264280304Sjkim  /// @see SymbolContextScope
265280304Sjkim  //------------------------------------------------------------------
26655714Skris  void DumpSymbolContext(Stream *s) override;
267280304Sjkim
268280304Sjkim  //------------------------------------------------------------------
269280304Sjkim  /// Find a symbol in the object file's symbol table.
270280304Sjkim  ///
271280304Sjkim  /// @param[in] name
272280304Sjkim  ///     The name of the symbol that we are looking for.
273280304Sjkim  ///
274280304Sjkim  /// @param[in] symbol_type
275280304Sjkim  ///     If set to eSymbolTypeAny, find a symbol of any type that
276280304Sjkim  ///     has a name that matches \a name. If set to any other valid
277280304Sjkim  ///     SymbolType enumeration value, then search only for
278280304Sjkim  ///     symbols that match \a symbol_type.
279280304Sjkim  ///
280280304Sjkim  /// @return
281280304Sjkim  ///     Returns a valid symbol pointer if a symbol was found,
28255714Skris  ///     nullptr otherwise.
283280304Sjkim  //------------------------------------------------------------------
284280304Sjkim  const Symbol *FindFirstSymbolWithNameAndType(
285280304Sjkim      const ConstString &name,
286280304Sjkim      lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
287280304Sjkim
288280304Sjkim  size_t FindSymbolsWithNameAndType(const ConstString &name,
289280304Sjkim                                    lldb::SymbolType symbol_type,
290280304Sjkim                                    SymbolContextList &sc_list);
29155714Skris
292280304Sjkim  size_t FindSymbolsMatchingRegExAndType(const RegularExpression &regex,
293280304Sjkim                                         lldb::SymbolType symbol_type,
294280304Sjkim                                         SymbolContextList &sc_list);
295280304Sjkim
296280304Sjkim  //------------------------------------------------------------------
297280304Sjkim  /// Find a function symbols in the object file's symbol table.
298280304Sjkim  ///
299280304Sjkim  /// @param[in] name
300280304Sjkim  ///     The name of the symbol that we are looking for.
301280304Sjkim  ///
302280304Sjkim  /// @param[in] name_type_mask
303280304Sjkim  ///     A mask that has one or more bitwise OR'ed values from the
30455714Skris  ///     lldb::FunctionNameType enumeration type that indicate what
305280304Sjkim  ///     kind of names we are looking for.
306280304Sjkim  ///
307280304Sjkim  /// @param[out] sc_list
308280304Sjkim  ///     A list to append any matching symbol contexts to.
309280304Sjkim  ///
310280304Sjkim  /// @return
311280304Sjkim  ///     The number of symbol contexts that were added to \a sc_list
312280304Sjkim  //------------------------------------------------------------------
313280304Sjkim  size_t FindFunctionSymbols(const ConstString &name, uint32_t name_type_mask,
314280304Sjkim                             SymbolContextList &sc_list);
315280304Sjkim
316280304Sjkim  //------------------------------------------------------------------
317280304Sjkim  /// Find compile units by partial or full path.
318280304Sjkim  ///
319280304Sjkim  /// Finds all compile units that match \a path in all of the modules
320280304Sjkim  /// and returns the results in \a sc_list.
321280304Sjkim  ///
322280304Sjkim  /// @param[in] path
323280304Sjkim  ///     The name of the function we are looking for.
324280304Sjkim  ///
325280304Sjkim  /// @param[in] append
326280304Sjkim  ///     If \b true, then append any compile units that were found
327280304Sjkim  ///     to \a sc_list. If \b false, then the \a sc_list is cleared
328280304Sjkim  ///     and the contents of \a sc_list are replaced.
329280304Sjkim  ///
330280304Sjkim  /// @param[out] sc_list
331280304Sjkim  ///     A symbol context list that gets filled in with all of the
33255714Skris  ///     matches.
333238405Sjkim  ///
334280304Sjkim  /// @return
335238405Sjkim  ///     The number of matches added to \a sc_list.
336238405Sjkim  //------------------------------------------------------------------
33755714Skris  size_t FindCompileUnits(const FileSpec &path, bool append,
338                          SymbolContextList &sc_list);
339
340  //------------------------------------------------------------------
341  /// Find functions by name.
342  ///
343  /// If the function is an inlined function, it will have a block,
344  /// representing the inlined function, and the function will be the
345  /// containing function.  If it is not inlined, then the block will
346  /// be NULL.
347  ///
348  /// @param[in] name
349  ///     The name of the compile unit we are looking for.
350  ///
351  /// @param[in] namespace_decl
352  ///     If valid, a namespace to search in.
353  ///
354  /// @param[in] name_type_mask
355  ///     A bit mask of bits that indicate what kind of names should
356  ///     be used when doing the lookup. Bits include fully qualified
357  ///     names, base names, C++ methods, or ObjC selectors.
358  ///     See FunctionNameType for more details.
359  ///
360  /// @param[in] append
361  ///     If \b true, any matches will be appended to \a sc_list, else
362  ///     matches replace the contents of \a sc_list.
363  ///
364  /// @param[out] sc_list
365  ///     A symbol context list that gets filled in with all of the
366  ///     matches.
367  ///
368  /// @return
369  ///     The number of matches added to \a sc_list.
370  //------------------------------------------------------------------
371  size_t FindFunctions(const ConstString &name,
372                       const CompilerDeclContext *parent_decl_ctx,
373                       uint32_t name_type_mask, bool symbols_ok,
374                       bool inlines_ok, bool append,
375                       SymbolContextList &sc_list);
376
377  //------------------------------------------------------------------
378  /// Find functions by name.
379  ///
380  /// If the function is an inlined function, it will have a block,
381  /// representing the inlined function, and the function will be the
382  /// containing function.  If it is not inlined, then the block will
383  /// be NULL.
384  ///
385  /// @param[in] regex
386  ///     A regular expression to use when matching the name.
387  ///
388  /// @param[in] append
389  ///     If \b true, any matches will be appended to \a sc_list, else
390  ///     matches replace the contents of \a sc_list.
391  ///
392  /// @param[out] sc_list
393  ///     A symbol context list that gets filled in with all of the
394  ///     matches.
395  ///
396  /// @return
397  ///     The number of matches added to \a sc_list.
398  //------------------------------------------------------------------
399  size_t FindFunctions(const RegularExpression &regex, bool symbols_ok,
400                       bool inlines_ok, bool append,
401                       SymbolContextList &sc_list);
402
403  //------------------------------------------------------------------
404  /// Find addresses by file/line
405  ///
406  /// @param[in] target_sp
407  ///     The target the addresses are desired for.
408  ///
409  /// @param[in] file
410  ///     Source file to locate.
411  ///
412  /// @param[in] line
413  ///     Source line to locate.
414  ///
415  /// @param[in] function
416  ///	    Optional filter function. Addresses within this function will be
417  ///     added to the 'local' list. All others will be added to the 'extern'
418  ///     list.
419  ///
420  /// @param[out] output_local
421  ///     All matching addresses within 'function'
422  ///
423  /// @param[out] output_extern
424  ///     All matching addresses not within 'function'
425  void FindAddressesForLine(const lldb::TargetSP target_sp,
426                            const FileSpec &file, uint32_t line,
427                            Function *function,
428                            std::vector<Address> &output_local,
429                            std::vector<Address> &output_extern);
430
431  //------------------------------------------------------------------
432  /// Find global and static variables by name.
433  ///
434  /// @param[in] name
435  ///     The name of the global or static variable we are looking
436  ///     for.
437  ///
438  /// @param[in] parent_decl_ctx
439  ///     If valid, a decl context that results must exist within
440  ///
441  /// @param[in] append
442  ///     If \b true, any matches will be appended to \a
443  ///     variable_list, else matches replace the contents of
444  ///     \a variable_list.
445  ///
446  /// @param[in] max_matches
447  ///     Allow the number of matches to be limited to \a
448  ///     max_matches. Specify UINT32_MAX to get all possible matches.
449  ///
450  /// @param[in] variable_list
451  ///     A list of variables that gets the matches appended to (if
452  ///     \a append it \b true), or replace (if \a append is \b false).
453  ///
454  /// @return
455  ///     The number of matches added to \a variable_list.
456  //------------------------------------------------------------------
457  size_t FindGlobalVariables(const ConstString &name,
458                             const CompilerDeclContext *parent_decl_ctx,
459                             bool append, size_t max_matches,
460                             VariableList &variable_list);
461
462  //------------------------------------------------------------------
463  /// Find global and static variables by regular expression.
464  ///
465  /// @param[in] regex
466  ///     A regular expression to use when matching the name.
467  ///
468  /// @param[in] append
469  ///     If \b true, any matches will be appended to \a
470  ///     variable_list, else matches replace the contents of
471  ///     \a variable_list.
472  ///
473  /// @param[in] max_matches
474  ///     Allow the number of matches to be limited to \a
475  ///     max_matches. Specify UINT32_MAX to get all possible matches.
476  ///
477  /// @param[in] variable_list
478  ///     A list of variables that gets the matches appended to (if
479  ///     \a append it \b true), or replace (if \a append is \b false).
480  ///
481  /// @return
482  ///     The number of matches added to \a variable_list.
483  //------------------------------------------------------------------
484  size_t FindGlobalVariables(const RegularExpression &regex, bool append,
485                             size_t max_matches, VariableList &variable_list);
486
487  //------------------------------------------------------------------
488  /// Find types by name.
489  ///
490  /// Type lookups in modules go through the SymbolVendor (which will
491  /// use one or more SymbolFile subclasses). The SymbolFile needs to
492  /// be able to lookup types by basename and not the fully qualified
493  /// typename. This allows the type accelerator tables to stay small,
494  /// even with heavily templatized C++. The type search will then
495  /// narrow down the search results. If "exact_match" is true, then
496  /// the type search will only match exact type name matches. If
497  /// "exact_match" is false, the type will match as long as the base
498  /// typename matches and as long as any immediate containing
499  /// namespaces/class scopes that are specified match. So to search
500  /// for a type "d" in "b::c", the name "b::c::d" can be specified
501  /// and it will match any class/namespace "b" which contains a
502  /// class/namespace "c" which contains type "d". We do this to
503  /// allow users to not always have to specify complete scoping on
504  /// all expressions, but it also allows for exact matching when
505  /// required.
506  ///
507  /// @param[in] sc
508  ///     A symbol context that scopes where to extract a type list
509  ///     from.
510  ///
511  /// @param[in] type_name
512  ///     The name of the type we are looking for that is a fully
513  ///     or partially qualified type name.
514  ///
515  /// @param[in] exact_match
516  ///     If \b true, \a type_name is fully qualified and must match
517  ///     exactly. If \b false, \a type_name is a partially qualified
518  ///     name where the leading namespaces or classes can be
519  ///     omitted to make finding types that a user may type
520  ///     easier.
521  ///
522  /// @param[out] type_list
523  ///     A type list gets populated with any matches.
524  ///
525  /// @return
526  ///     The number of matches added to \a type_list.
527  //------------------------------------------------------------------
528  size_t
529  FindTypes(const SymbolContext &sc, const ConstString &type_name,
530            bool exact_match, size_t max_matches,
531            llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
532            TypeList &types);
533
534  lldb::TypeSP FindFirstType(const SymbolContext &sc,
535                             const ConstString &type_name, bool exact_match);
536
537  //------------------------------------------------------------------
538  /// Find types by name that are in a namespace. This function is
539  /// used by the expression parser when searches need to happen in
540  /// an exact namespace scope.
541  ///
542  /// @param[in] sc
543  ///     A symbol context that scopes where to extract a type list
544  ///     from.
545  ///
546  /// @param[in] type_name
547  ///     The name of a type within a namespace that should not include
548  ///     any qualifying namespaces (just a type basename).
549  ///
550  /// @param[in] namespace_decl
551  ///     The namespace declaration that this type must exist in.
552  ///
553  /// @param[out] type_list
554  ///     A type list gets populated with any matches.
555  ///
556  /// @return
557  ///     The number of matches added to \a type_list.
558  //------------------------------------------------------------------
559  size_t FindTypesInNamespace(const SymbolContext &sc,
560                              const ConstString &type_name,
561                              const CompilerDeclContext *parent_decl_ctx,
562                              size_t max_matches, TypeList &type_list);
563
564  //------------------------------------------------------------------
565  /// Get const accessor for the module architecture.
566  ///
567  /// @return
568  ///     A const reference to the architecture object.
569  //------------------------------------------------------------------
570  const ArchSpec &GetArchitecture() const;
571
572  //------------------------------------------------------------------
573  /// Get const accessor for the module file specification.
574  ///
575  /// This function returns the file for the module on the host system
576  /// that is running LLDB. This can differ from the path on the
577  /// platform since we might be doing remote debugging.
578  ///
579  /// @return
580  ///     A const reference to the file specification object.
581  //------------------------------------------------------------------
582  const FileSpec &GetFileSpec() const { return m_file; }
583
584  //------------------------------------------------------------------
585  /// Get accessor for the module platform file specification.
586  ///
587  /// Platform file refers to the path of the module as it is known on
588  /// the remote system on which it is being debugged. For local
589  /// debugging this is always the same as Module::GetFileSpec(). But
590  /// remote debugging might mention a file "/usr/lib/liba.dylib"
591  /// which might be locally downloaded and cached. In this case the
592  /// platform file could be something like:
593  /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
594  /// The file could also be cached in a local developer kit directory.
595  ///
596  /// @return
597  ///     A const reference to the file specification object.
598  //------------------------------------------------------------------
599  const FileSpec &GetPlatformFileSpec() const {
600    if (m_platform_file)
601      return m_platform_file;
602    return m_file;
603  }
604
605  void SetPlatformFileSpec(const FileSpec &file) { m_platform_file = file; }
606
607  const FileSpec &GetRemoteInstallFileSpec() const {
608    return m_remote_install_file;
609  }
610
611  void SetRemoteInstallFileSpec(const FileSpec &file) {
612    m_remote_install_file = file;
613  }
614
615  const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; }
616
617  void PreloadSymbols();
618
619  void SetSymbolFileFileSpec(const FileSpec &file);
620
621  const llvm::sys::TimePoint<> &GetModificationTime() const {
622    return m_mod_time;
623  }
624
625  const llvm::sys::TimePoint<> &GetObjectModificationTime() const {
626    return m_object_mod_time;
627  }
628
629  void SetObjectModificationTime(const llvm::sys::TimePoint<> &mod_time) {
630    m_mod_time = mod_time;
631  }
632
633  //------------------------------------------------------------------
634  /// Tells whether this module is capable of being the main executable
635  /// for a process.
636  ///
637  /// @return
638  ///     \b true if it is, \b false otherwise.
639  //------------------------------------------------------------------
640  bool IsExecutable();
641
642  //------------------------------------------------------------------
643  /// Tells whether this module has been loaded in the target passed in.
644  /// This call doesn't distinguish between whether the module is loaded
645  /// by the dynamic loader, or by a "target module add" type call.
646  ///
647  /// @param[in] target
648  ///    The target to check whether this is loaded in.
649  ///
650  /// @return
651  ///     \b true if it is, \b false otherwise.
652  //------------------------------------------------------------------
653  bool IsLoadedInTarget(Target *target);
654
655  bool LoadScriptingResourceInTarget(Target *target, Status &error,
656                                     Stream *feedback_stream = nullptr);
657
658  //------------------------------------------------------------------
659  /// Get the number of compile units for this module.
660  ///
661  /// @return
662  ///     The number of compile units that the symbol vendor plug-in
663  ///     finds.
664  //------------------------------------------------------------------
665  size_t GetNumCompileUnits();
666
667  lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
668
669  const ConstString &GetObjectName() const;
670
671  uint64_t GetObjectOffset() const { return m_object_offset; }
672
673  //------------------------------------------------------------------
674  /// Get the object file representation for the current architecture.
675  ///
676  /// If the object file has not been located or parsed yet, this
677  /// function will find the best ObjectFile plug-in that can parse
678  /// Module::m_file.
679  ///
680  /// @return
681  ///     If Module::m_file does not exist, or no plug-in was found
682  ///     that can parse the file, or the object file doesn't contain
683  ///     the current architecture in Module::m_arch, nullptr will be
684  ///     returned, else a valid object file interface will be
685  ///     returned. The returned pointer is owned by this object and
686  ///     remains valid as long as the object is around.
687  //------------------------------------------------------------------
688  virtual ObjectFile *GetObjectFile();
689
690  //------------------------------------------------------------------
691  /// Get the unified section list for the module. This is the section
692  /// list created by the module's object file and any debug info and
693  /// symbol files created by the symbol vendor.
694  ///
695  /// If the symbol vendor has not been loaded yet, this function
696  /// will return the section list for the object file.
697  ///
698  /// @return
699  ///     Unified module section list.
700  //------------------------------------------------------------------
701  virtual SectionList *GetSectionList();
702
703  //------------------------------------------------------------------
704  /// Notify the module that the file addresses for the Sections have
705  /// been updated.
706  ///
707  /// If the Section file addresses for a module are updated, this
708  /// method should be called.  Any parts of the module, object file,
709  /// or symbol file that has cached those file addresses must invalidate
710  /// or update its cache.
711  //------------------------------------------------------------------
712  virtual void SectionFileAddressesChanged();
713
714  uint32_t GetVersion(uint32_t *versions, uint32_t num_versions);
715
716  //------------------------------------------------------------------
717  /// Load an object file from memory.
718  ///
719  /// If available, the size of the object file in memory may be
720  /// passed to avoid additional round trips to process memory.
721  /// If the size is not provided, a default value is used. This
722  /// value should be large enough to enable the ObjectFile plugins
723  /// to read the header of the object file without going back to the
724  /// process.
725  ///
726  /// @return
727  ///     The object file loaded from memory or nullptr, if the operation
728  ///     failed (see the `error` for more information in that case).
729  //------------------------------------------------------------------
730  ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
731                                  lldb::addr_t header_addr, Status &error,
732                                  size_t size_to_read = 512);
733  //------------------------------------------------------------------
734  /// Get the symbol vendor interface for the current architecture.
735  ///
736  /// If the symbol vendor file has not been located yet, this
737  /// function will find the best SymbolVendor plug-in that can
738  /// use the current object file.
739  ///
740  /// @return
741  ///     If this module does not have a valid object file, or no
742  ///     plug-in can be found that can use the object file, nullptr will
743  ///     be returned, else a valid symbol vendor plug-in interface
744  ///     will be returned. The returned pointer is owned by this
745  ///     object and remains valid as long as the object is around.
746  //------------------------------------------------------------------
747  virtual SymbolVendor *
748  GetSymbolVendor(bool can_create = true,
749                  lldb_private::Stream *feedback_strm = nullptr);
750
751  //------------------------------------------------------------------
752  /// Get accessor the type list for this module.
753  ///
754  /// @return
755  ///     A valid type list pointer, or nullptr if there is no valid
756  ///     symbol vendor for this module.
757  //------------------------------------------------------------------
758  TypeList *GetTypeList();
759
760  //------------------------------------------------------------------
761  /// Get a pointer to the UUID value contained in this object.
762  ///
763  /// If the executable image file doesn't not have a UUID value built
764  /// into the file format, an MD5 checksum of the entire file, or
765  /// slice of the file for the current architecture should be used.
766  ///
767  /// @return
768  ///     A const pointer to the internal copy of the UUID value in
769  ///     this module if this module has a valid UUID value, NULL
770  ///     otherwise.
771  //------------------------------------------------------------------
772  const lldb_private::UUID &GetUUID();
773
774  //------------------------------------------------------------------
775  /// A debugging function that will cause everything in a module to
776  /// be parsed.
777  ///
778  /// All compile units will be parsed, along with all globals and
779  /// static variables and all functions for those compile units.
780  /// All types, scopes, local variables, static variables, global
781  /// variables, and line tables will be parsed. This can be used
782  /// prior to dumping a module to see a complete list of the
783  /// resulting debug information that gets parsed, or as a debug
784  /// function to ensure that the module can consume all of the
785  /// debug data the symbol vendor provides.
786  //------------------------------------------------------------------
787  void ParseAllDebugSymbols();
788
789  bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr);
790
791  //------------------------------------------------------------------
792  /// Resolve the symbol context for the given address.
793  ///
794  /// Tries to resolve the matching symbol context based on a lookup
795  /// from the current symbol vendor.  If the lazy lookup fails,
796  /// an attempt is made to parse the eh_frame section to handle
797  /// stripped symbols.  If this fails, an attempt is made to resolve
798  /// the symbol to the previous address to handle the case of a
799  /// function with a tail call.
800  ///
801  /// Use properties of the modified SymbolContext to inspect any
802  /// resolved target, module, compilation unit, symbol, function,
803  /// function block or line entry.  Use the return value to determine
804  /// which of these properties have been modified.
805  ///
806  /// @param[in] so_addr
807  ///     A load address to resolve.
808  ///
809  /// @param[in] resolve_scope
810  ///     The scope that should be resolved (see SymbolContext::Scope).
811  ///     A combination of flags from the enumeration SymbolContextItem
812  ///     requesting a resolution depth.  Note that the flags that are
813  ///     actually resolved may be a superset of the requested flags.
814  ///     For instance, eSymbolContextSymbol requires resolution of
815  ///     eSymbolContextModule, and eSymbolContextFunction requires
816  ///     eSymbolContextSymbol.
817  ///
818  /// @param[out] sc
819  ///     The SymbolContext that is modified based on symbol resolution.
820  ///
821  /// @param[in] resolve_tail_call_address
822  ///     Determines if so_addr should resolve to a symbol in the case
823  ///     of a function whose last instruction is a call.  In this case,
824  ///     the PC can be one past the address range of the function.
825  ///
826  /// @return
827  ///     The scope that has been resolved (see SymbolContext::Scope).
828  ///
829  /// @see SymbolContext::Scope
830  //------------------------------------------------------------------
831  uint32_t
832  ResolveSymbolContextForAddress(const Address &so_addr, uint32_t resolve_scope,
833                                 SymbolContext &sc,
834                                 bool resolve_tail_call_address = false);
835
836  //------------------------------------------------------------------
837  /// Resolve items in the symbol context for a given file and line.
838  ///
839  /// Tries to resolve \a file_path and \a line to a list of matching
840  /// symbol contexts.
841  ///
842  /// The line table entries contains addresses that can be used to
843  /// further resolve the values in each match: the function, block,
844  /// symbol. Care should be taken to minimize the amount of
845  /// information that is requested to only what is needed --
846  /// typically the module, compile unit, line table and line table
847  /// entry are sufficient.
848  ///
849  /// @param[in] file_path
850  ///     A path to a source file to match. If \a file_path does not
851  ///     specify a directory, then this query will match all files
852  ///     whose base filename matches. If \a file_path does specify
853  ///     a directory, the fullpath to the file must match.
854  ///
855  /// @param[in] line
856  ///     The source line to match, or zero if just the compile unit
857  ///     should be resolved.
858  ///
859  /// @param[in] check_inlines
860  ///     Check for inline file and line number matches. This option
861  ///     should be used sparingly as it will cause all line tables
862  ///     for every compile unit to be parsed and searched for
863  ///     matching inline file entries.
864  ///
865  /// @param[in] resolve_scope
866  ///     The scope that should be resolved (see
867  ///     SymbolContext::Scope).
868  ///
869  /// @param[out] sc_list
870  ///     A symbol context list that gets matching symbols contexts
871  ///     appended to.
872  ///
873  /// @return
874  ///     The number of matches that were added to \a sc_list.
875  ///
876  /// @see SymbolContext::Scope
877  //------------------------------------------------------------------
878  uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line,
879                                           bool check_inlines,
880                                           uint32_t resolve_scope,
881                                           SymbolContextList &sc_list);
882
883  //------------------------------------------------------------------
884  /// Resolve items in the symbol context for a given file and line.
885  ///
886  /// Tries to resolve \a file_spec and \a line to a list of matching
887  /// symbol contexts.
888  ///
889  /// The line table entries contains addresses that can be used to
890  /// further resolve the values in each match: the function, block,
891  /// symbol. Care should be taken to minimize the amount of
892  /// information that is requested to only what is needed --
893  /// typically the module, compile unit, line table and line table
894  /// entry are sufficient.
895  ///
896  /// @param[in] file_spec
897  ///     A file spec to a source file to match. If \a file_path does
898  ///     not specify a directory, then this query will match all
899  ///     files whose base filename matches. If \a file_path does
900  ///     specify a directory, the fullpath to the file must match.
901  ///
902  /// @param[in] line
903  ///     The source line to match, or zero if just the compile unit
904  ///     should be resolved.
905  ///
906  /// @param[in] check_inlines
907  ///     Check for inline file and line number matches. This option
908  ///     should be used sparingly as it will cause all line tables
909  ///     for every compile unit to be parsed and searched for
910  ///     matching inline file entries.
911  ///
912  /// @param[in] resolve_scope
913  ///     The scope that should be resolved (see
914  ///     SymbolContext::Scope).
915  ///
916  /// @param[out] sc_list
917  ///     A symbol context list that gets filled in with all of the
918  ///     matches.
919  ///
920  /// @return
921  ///     A integer that contains SymbolContext::Scope bits set for
922  ///     each item that was successfully resolved.
923  ///
924  /// @see SymbolContext::Scope
925  //------------------------------------------------------------------
926  uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec,
927                                            uint32_t line, bool check_inlines,
928                                            uint32_t resolve_scope,
929                                            SymbolContextList &sc_list);
930
931  void SetFileSpecAndObjectName(const FileSpec &file,
932                                const ConstString &object_name);
933
934  bool GetIsDynamicLinkEditor();
935
936  TypeSystem *GetTypeSystemForLanguage(lldb::LanguageType language);
937
938  // Special error functions that can do printf style formatting that will
939  // prepend the message with
940  // something appropriate for this module (like the architecture, path and
941  // object name (if any)).
942  // This centralizes code so that everyone doesn't need to format their error
943  // and log messages on
944  // their own and keeps the output a bit more consistent.
945  void LogMessage(Log *log, const char *format, ...)
946      __attribute__((format(printf, 3, 4)));
947
948  void LogMessageVerboseBacktrace(Log *log, const char *format, ...)
949      __attribute__((format(printf, 3, 4)));
950
951  void ReportWarning(const char *format, ...)
952      __attribute__((format(printf, 2, 3)));
953
954  void ReportError(const char *format, ...)
955      __attribute__((format(printf, 2, 3)));
956
957  // Only report an error once when the module is first detected to be modified
958  // so we don't spam the console with many messages.
959  void ReportErrorIfModifyDetected(const char *format, ...)
960      __attribute__((format(printf, 2, 3)));
961
962  //------------------------------------------------------------------
963  // Return true if the file backing this module has changed since the
964  // module was originally created  since we saved the initial file
965  // modification time when the module first gets created.
966  //------------------------------------------------------------------
967  bool FileHasChanged() const;
968
969  //------------------------------------------------------------------
970  // SymbolVendor, SymbolFile and ObjectFile member objects should
971  // lock the module mutex to avoid deadlocks.
972  //------------------------------------------------------------------
973  std::recursive_mutex &GetMutex() const { return m_mutex; }
974
975  PathMappingList &GetSourceMappingList() { return m_source_mappings; }
976
977  const PathMappingList &GetSourceMappingList() const {
978    return m_source_mappings;
979  }
980
981  //------------------------------------------------------------------
982  /// Finds a source file given a file spec using the module source
983  /// path remappings (if any).
984  ///
985  /// Tries to resolve \a orig_spec by checking the module source path
986  /// remappings. It makes sure the file exists, so this call can be
987  /// expensive if the remappings are on a network file system, so
988  /// use this function sparingly (not in a tight debug info parsing
989  /// loop).
990  ///
991  /// @param[in] orig_spec
992  ///     The original source file path to try and remap.
993  ///
994  /// @param[out] new_spec
995  ///     The newly remapped filespec that is guaranteed to exist.
996  ///
997  /// @return
998  ///     /b true if \a orig_spec was successfully located and
999  ///     \a new_spec is filled in with an existing file spec,
1000  ///     \b false otherwise.
1001  //------------------------------------------------------------------
1002  bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
1003
1004  //------------------------------------------------------------------
1005  /// Remaps a source file given \a path into \a new_path.
1006  ///
1007  /// Remaps \a path if any source remappings match. This function
1008  /// does NOT stat the file system so it can be used in tight loops
1009  /// where debug info is being parsed.
1010  ///
1011  /// @param[in] path
1012  ///     The original source file path to try and remap.
1013  ///
1014  /// @param[out] new_path
1015  ///     The newly remapped filespec that is may or may not exist.
1016  ///
1017  /// @return
1018  ///     /b true if \a path was successfully located and \a new_path
1019  ///     is filled in with a new source path, \b false otherwise.
1020  //------------------------------------------------------------------
1021  bool RemapSourceFile(llvm::StringRef path, std::string &new_path) const;
1022  bool RemapSourceFile(const char *, std::string &) const = delete;
1023
1024  //------------------------------------------------------------------
1025  /// Loads this module to memory.
1026  ///
1027  /// Loads the bits needed to create an executable image to the memory.
1028  /// It is useful with bare-metal targets where target does not have the
1029  /// ability to start a process itself.
1030  ///
1031  /// @param[in] target
1032  ///     Target where to load the module.
1033  ///
1034  /// @return
1035  //------------------------------------------------------------------
1036  Status LoadInMemory(Target &target, bool set_pc);
1037
1038  //----------------------------------------------------------------------
1039  /// @class LookupInfo Module.h "lldb/Core/Module.h"
1040  /// @brief A class that encapsulates name lookup information.
1041  ///
1042  /// Users can type a wide variety of partial names when setting
1043  /// breakpoints by name or when looking for functions by name.
1044  /// SymbolVendor and SymbolFile objects are only required to implement
1045  /// name lookup for function basenames and for fully mangled names.
1046  /// This means if the user types in a partial name, we must reduce this
1047  /// to a name lookup that will work with all SymbolFile objects. So we
1048  /// might reduce a name lookup to look for a basename, and then prune
1049  /// out any results that don't match.
1050  ///
1051  /// The "m_name" member variable represents the name as it was typed
1052  /// by the user. "m_lookup_name" will be the name we actually search
1053  /// for through the symbol or objects files. Lanaguage is included in
1054  /// case we need to filter results by language at a later date. The
1055  /// "m_name_type_mask" member variable tells us what kinds of names we
1056  /// are looking for and can help us prune out unwanted results.
1057  ///
1058  /// Function lookups are done in Module.cpp, ModuleList.cpp and in
1059  /// BreakpointResolverName.cpp and they all now use this class to do
1060  /// lookups correctly.
1061  //----------------------------------------------------------------------
1062  class LookupInfo {
1063  public:
1064    LookupInfo()
1065        : m_name(), m_lookup_name(), m_language(lldb::eLanguageTypeUnknown),
1066          m_name_type_mask(0), m_match_name_after_lookup(false) {}
1067
1068    LookupInfo(const ConstString &name, uint32_t name_type_mask,
1069               lldb::LanguageType language);
1070
1071    const ConstString &GetName() const { return m_name; }
1072
1073    void SetName(const ConstString &name) { m_name = name; }
1074
1075    const ConstString &GetLookupName() const { return m_lookup_name; }
1076
1077    void SetLookupName(const ConstString &name) { m_lookup_name = name; }
1078
1079    uint32_t GetNameTypeMask() const { return m_name_type_mask; }
1080
1081    void SetNameTypeMask(uint32_t mask) { m_name_type_mask = mask; }
1082
1083    void Prune(SymbolContextList &sc_list, size_t start_idx) const;
1084
1085  protected:
1086    ConstString m_name;        ///< What the user originally typed
1087    ConstString m_lookup_name; ///< The actual name will lookup when calling in
1088                               ///the object or symbol file
1089    lldb::LanguageType
1090        m_language;            ///< Limit matches to only be for this language
1091    uint32_t m_name_type_mask; ///< One or more bits from lldb::FunctionNameType
1092                               ///that indicate what kind of names we are
1093                               ///looking for
1094    bool m_match_name_after_lookup; ///< If \b true, then demangled names that
1095                                    ///match will need to contain "m_name" in
1096                                    ///order to be considered a match
1097  };
1098
1099protected:
1100  //------------------------------------------------------------------
1101  // Member Variables
1102  //------------------------------------------------------------------
1103  mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
1104                                        ///in multi-threaded environments.
1105
1106  /// The modification time for this module when it was created.
1107  llvm::sys::TimePoint<> m_mod_time;
1108
1109  ArchSpec m_arch;      ///< The architecture for this module.
1110  UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
1111               ///match it up to debug symbols.
1112  FileSpec m_file; ///< The file representation on disk for this module (if
1113                   ///there is one).
1114  FileSpec m_platform_file; ///< The path to the module on the platform on which
1115                            ///it is being debugged
1116  FileSpec m_remote_install_file; ///< If set when debugging on remote
1117                                  ///platforms, this module will be installed at
1118                                  ///this location
1119  FileSpec m_symfile_spec;   ///< If this path is valid, then this is the file
1120                             ///that _will_ be used as the symbol file for this
1121                             ///module
1122  ConstString m_object_name; ///< The name an object within this module that is
1123                             ///selected, or empty of the module is represented
1124                             ///by \a m_file.
1125  uint64_t m_object_offset;
1126  llvm::sys::TimePoint<> m_object_mod_time;
1127  lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
1128                                   ///parser for this module as it may or may
1129                                   ///not be shared with the SymbolFile
1130  lldb::SymbolVendorUP
1131      m_symfile_ap; ///< A pointer to the symbol vendor for this module.
1132  std::vector<lldb::SymbolVendorUP>
1133      m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
1134                      ///changes the symbol file,
1135  ///< we need to keep all old symbol files around in case anyone has type
1136  ///references to them
1137  TypeSystemMap m_type_system_map;   ///< A map of any type systems associated
1138                                     ///with this module
1139  PathMappingList m_source_mappings; ///< Module specific source remappings for
1140                                     ///when you have debug info for a module
1141                                     ///that doesn't match where the sources
1142                                     ///currently are
1143  lldb::SectionListUP m_sections_ap; ///< Unified section list for module that
1144                                     ///is used by the ObjectFile and and
1145                                     ///ObjectFile instances for the debug info
1146
1147  std::atomic<bool> m_did_load_objfile{false};
1148  std::atomic<bool> m_did_load_symbol_vendor{false};
1149  std::atomic<bool> m_did_parse_uuid{false};
1150  mutable bool m_file_has_changed : 1,
1151      m_first_file_changed_log : 1; /// See if the module was modified after it
1152                                    /// was initially opened.
1153
1154  //------------------------------------------------------------------
1155  /// Resolve a file or load virtual address.
1156  ///
1157  /// Tries to resolve \a vm_addr as a file address (if \a
1158  /// vm_addr_is_file_addr is true) or as a load address if \a
1159  /// vm_addr_is_file_addr is false) in the symbol vendor.
1160  /// \a resolve_scope indicates what clients wish to resolve
1161  /// and can be used to limit the scope of what is parsed.
1162  ///
1163  /// @param[in] vm_addr
1164  ///     The load virtual address to resolve.
1165  ///
1166  /// @param[in] vm_addr_is_file_addr
1167  ///     If \b true, \a vm_addr is a file address, else \a vm_addr
1168  ///     if a load address.
1169  ///
1170  /// @param[in] resolve_scope
1171  ///     The scope that should be resolved (see
1172  ///     SymbolContext::Scope).
1173  ///
1174  /// @param[out] so_addr
1175  ///     The section offset based address that got resolved if
1176  ///     any bits are returned.
1177  ///
1178  /// @param[out] sc
1179  //      The symbol context that has objects filled in. Each bit
1180  ///     in the \a resolve_scope pertains to a member in the \a sc.
1181  ///
1182  /// @return
1183  ///     A integer that contains SymbolContext::Scope bits set for
1184  ///     each item that was successfully resolved.
1185  ///
1186  /// @see SymbolContext::Scope
1187  //------------------------------------------------------------------
1188  uint32_t ResolveSymbolContextForAddress(lldb::addr_t vm_addr,
1189                                          bool vm_addr_is_file_addr,
1190                                          uint32_t resolve_scope,
1191                                          Address &so_addr, SymbolContext &sc);
1192
1193  void SymbolIndicesToSymbolContextList(Symtab *symtab,
1194                                        std::vector<uint32_t> &symbol_indexes,
1195                                        SymbolContextList &sc_list);
1196
1197  bool SetArchitecture(const ArchSpec &new_arch);
1198
1199  SectionList *GetUnifiedSectionList();
1200
1201  friend class ModuleList;
1202  friend class ObjectFile;
1203  friend class SymbolFile;
1204
1205private:
1206  Module(); // Only used internally by CreateJITModule ()
1207
1208  size_t FindTypes_Impl(
1209      const SymbolContext &sc, const ConstString &name,
1210      const CompilerDeclContext *parent_decl_ctx, bool append,
1211      size_t max_matches,
1212      llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1213      TypeMap &types);
1214
1215  DISALLOW_COPY_AND_ASSIGN(Module);
1216};
1217
1218} // namespace lldb_private
1219
1220#endif // liblldb_Module_h_
1221