Module.h revision 302d78c71902398ce1f422bd09216dd53a6abb88
1//===-- Module.h ------------------------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_Module_h_
11#define liblldb_Module_h_
12
13#include "lldb/Core/ArchSpec.h"
14#include "lldb/Core/Section.h"
15#include "lldb/Core/UUID.h"
16#include "lldb/Symbol/ObjectFile.h"
17#include "lldb/Host/Mutex.h"
18#include "lldb/Host/TimeValue.h"
19#include "lldb/Symbol/ClangASTContext.h"
20#include "lldb/Symbol/CompileUnit.h"
21#include "lldb/Symbol/SymbolContext.h"
22#include "lldb/Symbol/Symtab.h"
23#include "lldb/Symbol/TypeList.h"
24
25//----------------------------------------------------------------------
26/// @class Module Module.h "lldb/Core/Module.h"
27/// @brief A class that describes an executable image and its associated
28///        object and symbol files.
29///
30/// The module is designed to be able to select a single slice of an
31/// executable image as it would appear on disk and during program
32/// execution.
33///
34/// Modules control when and if information is parsed according to which
35/// accessors are called. For example the object file (ObjectFile)
36/// representation will only be parsed if the object file is requested
37/// using the Module::GetObjectFile() is called. The debug symbols
38/// will only be parsed if the symbol vendor (SymbolVendor) is
39/// requested using the Module::GetSymbolVendor() is called.
40///
41/// The module will parse more detailed information as more queries are
42/// made.
43//----------------------------------------------------------------------
44namespace lldb_private {
45
46class Module :
47    public std::tr1::enable_shared_from_this<Module>,
48    public SymbolContextScope
49{
50public:
51    friend class ModuleList;
52    friend bool ObjectFile::SetModulesArchitecture (const ArchSpec &new_arch);
53
54	// Static functions that can track the lifetime of moodule objects.
55	// This is handy because we might have Module objects that are in
56	// shared pointers that aren't in the global module list (from
57	// ModuleList). If this is the case we need to know about it.
58    // The modules in the global list maintained by these functions
59    // can be viewed using the "target modules list" command using the
60    // "--global" (-g for short).
61    static size_t
62    GetNumberAllocatedModules ();
63
64    static Module *
65    GetAllocatedModuleAtIndex (size_t idx);
66
67    static Mutex *
68    GetAllocationModuleCollectionMutex();
69
70    //------------------------------------------------------------------
71    /// Construct with file specification and architecture.
72    ///
73    /// Clients that wish to share modules with other targets should
74    /// use ModuleList::GetSharedModule().
75    ///
76    /// @param[in] file_spec
77    ///     The file specification for the on disk repesentation of
78    ///     this executable image.
79    ///
80    /// @param[in] arch
81    ///     The architecture to set as the current architecture in
82    ///     this module.
83    ///
84    /// @param[in] object_name
85    ///     The name of an object in a module used to extract a module
86    ///     within a module (.a files and modules that contain multiple
87    ///     architectures).
88    ///
89    /// @param[in] object_offset
90    ///     The offset within an existing module used to extract a
91    ///     module within a module (.a files and modules that contain
92    ///     multiple architectures).
93    //------------------------------------------------------------------
94    Module (const FileSpec& file_spec,
95            const ArchSpec& arch,
96            const ConstString *object_name = NULL,
97            off_t object_offset = 0);
98
99    Module (const FileSpec& file_spec,
100            const lldb::ProcessSP &processSP,
101            lldb::addr_t header_addr);
102    //------------------------------------------------------------------
103    /// Destructor.
104    //------------------------------------------------------------------
105    virtual
106    ~Module ();
107
108
109    //------------------------------------------------------------------
110    /// Set the load address for all sections in a module to be the
111    /// file address plus \a slide.
112    ///
113    /// Many times a module will be loaded in a target with a constant
114    /// offset applied to all top level sections. This function can
115    /// set the load address for all top level sections to be the
116    /// section file address + offset.
117    ///
118    /// @param[in] target
119    ///     The target in which to apply the section load addresses.
120    ///
121    /// @param[in] offset
122    ///     The offset to apply to all file addresses for all top
123    ///     level sections in the object file as each section load
124    ///     address is being set.
125    ///
126    /// @param[out] changed
127    ///     If any section load addresses were changed in \a target,
128    ///     then \a changed will be set to \b true. Else \a changed
129    ///     will be set to false. This allows this function to be
130    ///     called multiple times on the same module for the same
131    ///     target. If the module hasn't moved, then \a changed will
132    ///     be false and no module updated notification will need to
133    ///     be sent out.
134    ///
135    /// @return
136    ///     /b True if any sections were successfully loaded in \a target,
137    ///     /b false otherwise.
138    //------------------------------------------------------------------
139    bool
140    SetLoadAddress (Target &target,
141                    lldb::addr_t offset,
142                    bool &changed);
143
144    //------------------------------------------------------------------
145    /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
146    ///
147    /// @see SymbolContextScope
148    //------------------------------------------------------------------
149    virtual void
150    CalculateSymbolContext (SymbolContext* sc);
151
152    virtual Module *
153    CalculateSymbolContextModule ();
154
155    void
156    GetDescription (Stream *s,
157                    lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
158
159    //------------------------------------------------------------------
160    /// Dump a description of this object to a Stream.
161    ///
162    /// Dump a description of the contents of this object to the
163    /// supplied stream \a s. The dumped content will be only what has
164    /// been loaded or parsed up to this point at which this function
165    /// is called, so this is a good way to see what has been parsed
166    /// in a module.
167    ///
168    /// @param[in] s
169    ///     The stream to which to dump the object descripton.
170    //------------------------------------------------------------------
171    void
172    Dump (Stream *s);
173
174    //------------------------------------------------------------------
175    /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
176    ///
177    /// @see SymbolContextScope
178    //------------------------------------------------------------------
179    virtual void
180    DumpSymbolContext (Stream *s);
181
182    //------------------------------------------------------------------
183    /// Find a symbol in the object files symbol table.
184    ///
185    /// @param[in] name
186    ///     The name of the symbol that we are looking for.
187    ///
188    /// @param[in] symbol_type
189    ///     If set to eSymbolTypeAny, find a symbol of any type that
190    ///     has a name that matches \a name. If set to any other valid
191    ///     SymbolType enumeration value, then search only for
192    ///     symbols that match \a symbol_type.
193    ///
194    /// @return
195    ///     Returns a valid symbol pointer if a symbol was found,
196    ///     NULL otherwise.
197    //------------------------------------------------------------------
198    const Symbol *
199    FindFirstSymbolWithNameAndType (const ConstString &name,
200                                    lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
201
202    size_t
203    FindSymbolsWithNameAndType (const ConstString &name,
204                                lldb::SymbolType symbol_type,
205                                SymbolContextList &sc_list);
206
207    size_t
208    FindSymbolsMatchingRegExAndType (const RegularExpression &regex,
209                                     lldb::SymbolType symbol_type,
210                                     SymbolContextList &sc_list);
211
212    //------------------------------------------------------------------
213    /// Find compile units by partial or full path.
214    ///
215    /// Finds all compile units that match \a path in all of the modules
216    /// and returns the results in \a sc_list.
217    ///
218    /// @param[in] path
219    ///     The name of the function we are looking for.
220    ///
221    /// @param[in] append
222    ///     If \b true, then append any compile units that were found
223    ///     to \a sc_list. If \b false, then the \a sc_list is cleared
224    ///     and the contents of \a sc_list are replaced.
225    ///
226    /// @param[out] sc_list
227    ///     A symbol context list that gets filled in with all of the
228    ///     matches.
229    ///
230    /// @return
231    ///     The number of matches added to \a sc_list.
232    //------------------------------------------------------------------
233    uint32_t
234    FindCompileUnits (const FileSpec &path,
235                      bool append,
236                      SymbolContextList &sc_list);
237
238
239    //------------------------------------------------------------------
240    /// Find functions by name.
241    ///
242    /// If the function is an inlined function, it will have a block,
243    /// representing the inlined function, and the function will be the
244    /// containing function.  If it is not inlined, then the block will
245    /// be NULL.
246    ///
247    /// @param[in] name
248    ///     The name of the compile unit we are looking for.
249    ///
250    /// @param[in] namespace_decl
251    ///     If valid, a namespace to search in.
252    ///
253    /// @param[in] name_type_mask
254    ///     A bit mask of bits that indicate what kind of names should
255    ///     be used when doing the lookup. Bits include fully qualified
256    ///     names, base names, C++ methods, or ObjC selectors.
257    ///     See FunctionNameType for more details.
258    ///
259    /// @param[in] append
260    ///     If \b true, any matches will be appended to \a sc_list, else
261    ///     matches replace the contents of \a sc_list.
262    ///
263    /// @param[out] sc_list
264    ///     A symbol context list that gets filled in with all of the
265    ///     matches.
266    ///
267    /// @return
268    ///     The number of matches added to \a sc_list.
269    //------------------------------------------------------------------
270    uint32_t
271    FindFunctions (const ConstString &name,
272                   const ClangNamespaceDecl *namespace_decl,
273                   uint32_t name_type_mask,
274                   bool symbols_ok,
275                   bool inlines_ok,
276                   bool append,
277                   SymbolContextList& sc_list);
278
279    //------------------------------------------------------------------
280    /// Find functions by name.
281    ///
282    /// If the function is an inlined function, it will have a block,
283    /// representing the inlined function, and the function will be the
284    /// containing function.  If it is not inlined, then the block will
285    /// be NULL.
286    ///
287    /// @param[in] regex
288    ///     A regular expression to use when matching the name.
289    ///
290    /// @param[in] append
291    ///     If \b true, any matches will be appended to \a sc_list, else
292    ///     matches replace the contents of \a sc_list.
293    ///
294    /// @param[out] sc_list
295    ///     A symbol context list that gets filled in with all of the
296    ///     matches.
297    ///
298    /// @return
299    ///     The number of matches added to \a sc_list.
300    //------------------------------------------------------------------
301    uint32_t
302    FindFunctions (const RegularExpression& regex,
303                   bool symbols_ok,
304                   bool inlines_ok,
305                   bool append,
306                   SymbolContextList& sc_list);
307
308    //------------------------------------------------------------------
309    /// Find global and static variables by name.
310    ///
311    /// @param[in] name
312    ///     The name of the global or static variable we are looking
313    ///     for.
314    ///
315    /// @param[in] namespace_decl
316    ///     If valid, a namespace to search in.
317    ///
318    /// @param[in] append
319    ///     If \b true, any matches will be appended to \a
320    ///     variable_list, else matches replace the contents of
321    ///     \a variable_list.
322    ///
323    /// @param[in] max_matches
324    ///     Allow the number of matches to be limited to \a
325    ///     max_matches. Specify UINT32_MAX to get all possible matches.
326    ///
327    /// @param[in] variable_list
328    ///     A list of variables that gets the matches appended to (if
329    ///     \a append it \b true), or replace (if \a append is \b false).
330    ///
331    /// @return
332    ///     The number of matches added to \a variable_list.
333    //------------------------------------------------------------------
334    uint32_t
335    FindGlobalVariables (const ConstString &name,
336                         const ClangNamespaceDecl *namespace_decl,
337                         bool append,
338                         uint32_t max_matches,
339                         VariableList& variable_list);
340
341    //------------------------------------------------------------------
342    /// Find global and static variables by regular exression.
343    ///
344    /// @param[in] regex
345    ///     A regular expression to use when matching the name.
346    ///
347    /// @param[in] append
348    ///     If \b true, any matches will be appended to \a
349    ///     variable_list, else matches replace the contents of
350    ///     \a variable_list.
351    ///
352    /// @param[in] max_matches
353    ///     Allow the number of matches to be limited to \a
354    ///     max_matches. Specify UINT32_MAX to get all possible matches.
355    ///
356    /// @param[in] variable_list
357    ///     A list of variables that gets the matches appended to (if
358    ///     \a append it \b true), or replace (if \a append is \b false).
359    ///
360    /// @return
361    ///     The number of matches added to \a variable_list.
362    //------------------------------------------------------------------
363    uint32_t
364    FindGlobalVariables (const RegularExpression& regex,
365                         bool append,
366                         uint32_t max_matches,
367                         VariableList& variable_list);
368
369    //------------------------------------------------------------------
370    /// Find types by name.
371    ///
372    /// @param[in] sc
373    ///     A symbol context that scopes where to extract a type list
374    ///     from.
375    ///
376    /// @param[in] name
377    ///     The name of the type we are looking for.
378    ///
379    /// @param[in] namespace_decl
380    ///     If valid, a namespace to search in.
381    ///
382    /// @param[in] append
383    ///     If \b true, any matches will be appended to \a
384    ///     variable_list, else matches replace the contents of
385    ///     \a variable_list.
386    ///
387    /// @param[in] max_matches
388    ///     Allow the number of matches to be limited to \a
389    ///     max_matches. Specify UINT32_MAX to get all possible matches.
390    ///
391    /// @param[in] encoding
392    ///     Limit the search to specific types, or get all types if
393    ///     set to Type::invalid.
394    ///
395    /// @param[in] udt_name
396    ///     If the encoding is a user defined type, specify the name
397    ///     of the user defined type ("struct", "union", "class", etc).
398    ///
399    /// @param[out] type_list
400    ///     A type list gets populated with any matches.
401    ///
402    /// @return
403    ///     The number of matches added to \a type_list.
404    //------------------------------------------------------------------
405    uint32_t
406    FindTypes (const SymbolContext& sc,
407               const ConstString &name,
408               const ClangNamespaceDecl *namespace_decl,
409               bool append,
410               uint32_t max_matches,
411               TypeList& types);
412
413    //------------------------------------------------------------------
414    /// Get const accessor for the module architecture.
415    ///
416    /// @return
417    ///     A const reference to the architecture object.
418    //------------------------------------------------------------------
419    const ArchSpec&
420    GetArchitecture () const;
421
422    //------------------------------------------------------------------
423    /// Get const accessor for the module file specification.
424    ///
425    /// This function returns the file for the module on the host system
426    /// that is running LLDB. This can differ from the path on the
427    /// platform since we might be doing remote debugging.
428    ///
429    /// @return
430    ///     A const reference to the file specification object.
431    //------------------------------------------------------------------
432    const FileSpec &
433    GetFileSpec () const
434    {
435        return m_file;
436    }
437
438    //------------------------------------------------------------------
439    /// Get accessor for the module platform file specification.
440    ///
441    /// Platform file refers to the path of the module as it is known on
442    /// the remote system on which it is being debugged. For local
443    /// debugging this is always the same as Module::GetFileSpec(). But
444    /// remote debugging might mention a file "/usr/lib/liba.dylib"
445    /// which might be locally downloaded and cached. In this case the
446    /// platform file could be something like:
447    /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
448    /// The file could also be cached in a local developer kit directory.
449    ///
450    /// @return
451    ///     A const reference to the file specification object.
452    //------------------------------------------------------------------
453    const FileSpec &
454    GetPlatformFileSpec () const
455    {
456        if (m_platform_file)
457            return m_platform_file;
458        return m_file;
459    }
460
461    void
462    SetPlatformFileSpec (const FileSpec &file)
463    {
464        m_platform_file = file;
465    }
466
467    const TimeValue &
468    GetModificationTime () const;
469
470    //------------------------------------------------------------------
471    /// Tells whether this module is capable of being the main executable
472    /// for a process.
473    ///
474    /// @return
475    ///     \b true if it is, \b false otherwise.
476    //------------------------------------------------------------------
477    bool
478    IsExecutable ();
479
480    //------------------------------------------------------------------
481    /// Tells whether this module has been loaded in the target passed in.
482    /// This call doesn't distinguish between whether the module is loaded
483    /// by the dynamic loader, or by a "target module add" type call.
484    ///
485    /// @param[in] target
486    ///    The target to check whether this is loaded in.
487    ///
488    /// @return
489    ///     \b true if it is, \b false otherwise.
490    //------------------------------------------------------------------
491    bool
492    IsLoadedInTarget (Target *target);
493
494    //------------------------------------------------------------------
495    /// Get the number of compile units for this module.
496    ///
497    /// @return
498    ///     The number of compile units that the symbol vendor plug-in
499    ///     finds.
500    //------------------------------------------------------------------
501    uint32_t
502    GetNumCompileUnits();
503
504    lldb::CompUnitSP
505    GetCompileUnitAtIndex (uint32_t);
506
507    const ConstString &
508    GetObjectName() const;
509
510    uint64_t
511    GetObjectOffset() const
512    {
513        return m_object_offset;
514    }
515
516    //------------------------------------------------------------------
517    /// Get the object file representation for the current architecture.
518    ///
519    /// If the object file has not been located or parsed yet, this
520    /// function will find the best ObjectFile plug-in that can parse
521    /// Module::m_file.
522    ///
523    /// @return
524    ///     If Module::m_file does not exist, or no plug-in was found
525    ///     that can parse the file, or the object file doesn't contain
526    ///     the current architecture in Module::m_arch, NULL will be
527    ///     returned, else a valid object file interface will be
528    ///     returned. The returned pointer is owned by this object and
529    ///     remains valid as long as the object is around.
530    //------------------------------------------------------------------
531    ObjectFile *
532    GetObjectFile ();
533
534    //------------------------------------------------------------------
535    /// Get the symbol vendor interface for the current architecture.
536    ///
537    /// If the symbol vendor file has not been located yet, this
538    /// function will find the best SymbolVendor plug-in that can
539    /// use the current object file.
540    ///
541    /// @return
542    ///     If this module does not have a valid object file, or no
543    ///     plug-in can be found that can use the object file, NULL will
544    ///     be returned, else a valid symbol vendor plug-in interface
545    ///     will be returned. The returned pointer is owned by this
546    ///     object and remains valid as long as the object is around.
547    //------------------------------------------------------------------
548    SymbolVendor*
549    GetSymbolVendor(bool can_create = true);
550
551    //------------------------------------------------------------------
552    /// Get accessor the type list for this module.
553    ///
554    /// @return
555    ///     A valid type list pointer, or NULL if there is no valid
556    ///     symbol vendor for this module.
557    //------------------------------------------------------------------
558    TypeList*
559    GetTypeList ();
560
561    //------------------------------------------------------------------
562    /// Get a pointer to the UUID value contained in this object.
563    ///
564    /// If the executable image file doesn't not have a UUID value built
565    /// into the file format, an MD5 checksum of the entire file, or
566    /// slice of the file for the current architecture should be used.
567    ///
568    /// @return
569    ///     A const pointer to the internal copy of the UUID value in
570    ///     this module if this module has a valid UUID value, NULL
571    ///     otherwise.
572    //------------------------------------------------------------------
573    const lldb_private::UUID &
574    GetUUID ();
575
576    //------------------------------------------------------------------
577    /// A debugging function that will cause everything in a module to
578    /// be parsed.
579    ///
580    /// All compile units will be pasred, along with all globals and
581    /// static variables and all functions for those compile units.
582    /// All types, scopes, local variables, static variables, global
583    /// variables, and line tables will be parsed. This can be used
584    /// prior to dumping a module to see a complete list of the
585    /// resuling debug information that gets parsed, or as a debug
586    /// function to ensure that the module can consume all of the
587    /// debug data the symbol vendor provides.
588    //------------------------------------------------------------------
589    void
590    ParseAllDebugSymbols();
591
592    bool
593    ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr);
594
595    uint32_t
596    ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc);
597
598    //------------------------------------------------------------------
599    /// Resolve items in the symbol context for a given file and line.
600    ///
601    /// Tries to resolve \a file_path and \a line to a list of matching
602    /// symbol contexts.
603    ///
604    /// The line table entries contains addresses that can be used to
605    /// further resolve the values in each match: the function, block,
606    /// symbol. Care should be taken to minimize the amount of
607    /// information that is requested to only what is needed --
608    /// typically the module, compile unit, line table and line table
609    /// entry are sufficient.
610    ///
611    /// @param[in] file_path
612    ///     A path to a source file to match. If \a file_path does not
613    ///     specify a directory, then this query will match all files
614    ///     whose base filename matches. If \a file_path does specify
615    ///     a directory, the fullpath to the file must match.
616    ///
617    /// @param[in] line
618    ///     The source line to match, or zero if just the compile unit
619    ///     should be resolved.
620    ///
621    /// @param[in] check_inlines
622    ///     Check for inline file and line number matches. This option
623    ///     should be used sparingly as it will cause all line tables
624    ///     for every compile unit to be parsed and searched for
625    ///     matching inline file entries.
626    ///
627    /// @param[in] resolve_scope
628    ///     The scope that should be resolved (see
629    ///     SymbolContext::Scope).
630    ///
631    /// @param[out] sc_list
632    ///     A symbol context list that gets matching symbols contexts
633    ///     appended to.
634    ///
635    /// @return
636    ///     The number of matches that were added to \a sc_list.
637    ///
638    /// @see SymbolContext::Scope
639    //------------------------------------------------------------------
640    uint32_t
641    ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
642
643    //------------------------------------------------------------------
644    /// Resolve items in the symbol context for a given file and line.
645    ///
646    /// Tries to resolve \a file_spec and \a line to a list of matching
647    /// symbol contexts.
648    ///
649    /// The line table entries contains addresses that can be used to
650    /// further resolve the values in each match: the function, block,
651    /// symbol. Care should be taken to minimize the amount of
652    /// information that is requested to only what is needed --
653    /// typically the module, compile unit, line table and line table
654    /// entry are sufficient.
655    ///
656    /// @param[in] file_spec
657    ///     A file spec to a source file to match. If \a file_path does
658    ///     not specify a directory, then this query will match all
659    ///     files whose base filename matches. If \a file_path does
660    ///     specify a directory, the fullpath to the file must match.
661    ///
662    /// @param[in] line
663    ///     The source line to match, or zero if just the compile unit
664    ///     should be resolved.
665    ///
666    /// @param[in] check_inlines
667    ///     Check for inline file and line number matches. This option
668    ///     should be used sparingly as it will cause all line tables
669    ///     for every compile unit to be parsed and searched for
670    ///     matching inline file entries.
671    ///
672    /// @param[in] resolve_scope
673    ///     The scope that should be resolved (see
674    ///     SymbolContext::Scope).
675    ///
676    /// @param[out] sc_list
677    ///     A symbol context list that gets filled in with all of the
678    ///     matches.
679    ///
680    /// @return
681    ///     A integer that contains SymbolContext::Scope bits set for
682    ///     each item that was successfully resolved.
683    ///
684    /// @see SymbolContext::Scope
685    //------------------------------------------------------------------
686    uint32_t
687    ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
688
689
690    void
691    SetFileSpecAndObjectName (const FileSpec &file,
692                              const ConstString &object_name);
693
694    bool
695    GetIsDynamicLinkEditor () const
696    {
697        return m_is_dynamic_loader_module;
698    }
699
700    void
701    SetIsDynamicLinkEditor (bool b)
702    {
703        m_is_dynamic_loader_module = b;
704    }
705
706    ClangASTContext &
707    GetClangASTContext ();
708
709    // Special error functions that can do printf style formatting that will prepend the message with
710    // something appropriate for this module (like the architecture, path and object name (if any)).
711    // This centralizes code so that everyone doesn't need to format their error and log messages on
712    // their own and keeps the output a bit more consistent.
713    void
714    LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
715
716    void
717    ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
718
719    void
720    ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
721
722    // Only report an error once when the module is first detected to be modified
723    // so we don't spam the console with many messages.
724    void
725    ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
726
727    bool
728    GetModified (bool use_cached_only);
729
730    bool
731    SetModified (bool b);
732
733protected:
734    //------------------------------------------------------------------
735    // Member Variables
736    //------------------------------------------------------------------
737    mutable Mutex               m_mutex;        ///< A mutex to keep this object happy in multi-threaded environments.
738    TimeValue                   m_mod_time;     ///< The modification time for this module when it was created.
739    ArchSpec                    m_arch;         ///< The architecture for this module.
740    lldb_private::UUID          m_uuid;         ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
741    FileSpec                    m_file;         ///< The file representation on disk for this module (if there is one).
742    FileSpec                    m_platform_file;///< The path to the module on the platform on which it is being debugged
743    ConstString                 m_object_name;  ///< The name an object within this module that is selected, or empty of the module is represented by \a m_file.
744    uint64_t                    m_object_offset;
745    lldb::ObjectFileSP          m_objfile_sp;   ///< A shared pointer to the object file parser for this module as it may or may not be shared with the SymbolFile
746    std::auto_ptr<SymbolVendor> m_symfile_ap;   ///< A pointer to the symbol vendor for this module.
747    ClangASTContext             m_ast;          ///< The AST context for this module.
748    bool                        m_did_load_objfile:1,
749                                m_did_load_symbol_vendor:1,
750                                m_did_parse_uuid:1,
751                                m_did_init_ast:1,
752                                m_is_dynamic_loader_module:1,
753                                m_was_modified:1;   /// See if the module was modified after it was initially opened.
754
755    //------------------------------------------------------------------
756    /// Resolve a file or load virtual address.
757    ///
758    /// Tries to resolve \a vm_addr as a file address (if \a
759    /// vm_addr_is_file_addr is true) or as a load address if \a
760    /// vm_addr_is_file_addr is false) in the symbol vendor.
761    /// \a resolve_scope indicates what clients wish to resolve
762    /// and can be used to limit the scope of what is parsed.
763    ///
764    /// @param[in] vm_addr
765    ///     The load virtual address to resolve.
766    ///
767    /// @param[in] vm_addr_is_file_addr
768    ///     If \b true, \a vm_addr is a file address, else \a vm_addr
769    ///     if a load address.
770    ///
771    /// @param[in] resolve_scope
772    ///     The scope that should be resolved (see
773    ///     SymbolContext::Scope).
774    ///
775    /// @param[out] so_addr
776    ///     The section offset based address that got resolved if
777    ///     any bits are returned.
778    ///
779    /// @param[out] sc
780    //      The symbol context that has objects filled in. Each bit
781    ///     in the \a resolve_scope pertains to a member in the \a sc.
782    ///
783    /// @return
784    ///     A integer that contains SymbolContext::Scope bits set for
785    ///     each item that was successfully resolved.
786    ///
787    /// @see SymbolContext::Scope
788    //------------------------------------------------------------------
789    uint32_t
790    ResolveSymbolContextForAddress (lldb::addr_t vm_addr,
791                                    bool vm_addr_is_file_addr,
792                                    uint32_t resolve_scope,
793                                    Address& so_addr,
794                                    SymbolContext& sc);
795
796    void
797    SymbolIndicesToSymbolContextList (Symtab *symtab,
798                                      std::vector<uint32_t> &symbol_indexes,
799                                      SymbolContextList &sc_list);
800
801    bool
802    SetArchitecture (const ArchSpec &new_arch);
803
804private:
805
806    uint32_t
807    FindTypes_Impl (const SymbolContext& sc,
808                    const ConstString &name,
809                    const ClangNamespaceDecl *namespace_decl,
810                    bool append,
811                    uint32_t max_matches,
812                    TypeList& types);
813
814
815    DISALLOW_COPY_AND_ASSIGN (Module);
816};
817
818} // namespace lldb_private
819
820#endif  // liblldb_Module_h_
821