1 //===-- Module.h ------------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef liblldb_Module_h_
11 #define liblldb_Module_h_
13 #include "lldb/Core/ArchSpec.h"
14 #include "lldb/Core/UUID.h"
15 #include "lldb/Host/FileSpec.h"
16 #include "lldb/Host/Mutex.h"
17 #include "lldb/Host/TimeValue.h"
18 #include "lldb/Symbol/ClangASTContext.h"
19 #include "lldb/Symbol/SymbolContextScope.h"
20 #include "lldb/Target/PathMappingList.h"
22 namespace lldb_private {
24 //----------------------------------------------------------------------
25 /// @class Module Module.h "lldb/Core/Module.h"
26 /// @brief A class that describes an executable image and its associated
27 /// object and symbol files.
29 /// The module is designed to be able to select a single slice of an
30 /// executable image as it would appear on disk and during program
33 /// Modules control when and if information is parsed according to which
34 /// accessors are called. For example the object file (ObjectFile)
35 /// representation will only be parsed if the object file is requested
36 /// using the Module::GetObjectFile() is called. The debug symbols
37 /// will only be parsed if the symbol vendor (SymbolVendor) is
38 /// requested using the Module::GetSymbolVendor() is called.
40 /// The module will parse more detailed information as more queries are
42 //----------------------------------------------------------------------
44 public std::enable_shared_from_this<Module>,
45 public SymbolContextScope
48 // Static functions that can track the lifetime of module objects.
49 // This is handy because we might have Module objects that are in
50 // shared pointers that aren't in the global module list (from
51 // ModuleList). If this is the case we need to know about it.
52 // The modules in the global list maintained by these functions
53 // can be viewed using the "target modules list" command using the
54 // "--global" (-g for short).
56 GetNumberAllocatedModules ();
59 GetAllocatedModuleAtIndex (size_t idx);
62 GetAllocationModuleCollectionMutex();
64 //------------------------------------------------------------------
65 /// Construct with file specification and architecture.
67 /// Clients that wish to share modules with other targets should
68 /// use ModuleList::GetSharedModule().
70 /// @param[in] file_spec
71 /// The file specification for the on disk repesentation of
72 /// this executable image.
75 /// The architecture to set as the current architecture in
78 /// @param[in] object_name
79 /// The name of an object in a module used to extract a module
80 /// within a module (.a files and modules that contain multiple
83 /// @param[in] object_offset
84 /// The offset within an existing module used to extract a
85 /// module within a module (.a files and modules that contain
86 /// multiple architectures).
87 //------------------------------------------------------------------
88 Module (const FileSpec& file_spec,
90 const ConstString *object_name = NULL,
91 off_t object_offset = 0,
92 const TimeValue *object_mod_time_ptr = NULL);
94 Module (const ModuleSpec &module_spec);
95 //------------------------------------------------------------------
97 //------------------------------------------------------------------
102 MatchesModuleSpec (const ModuleSpec &module_ref);
104 //------------------------------------------------------------------
105 /// Set the load address for all sections in a module to be the
106 /// file address plus \a slide.
108 /// Many times a module will be loaded in a target with a constant
109 /// offset applied to all top level sections. This function can
110 /// set the load address for all top level sections to be the
111 /// section file address + offset.
113 /// @param[in] target
114 /// The target in which to apply the section load addresses.
116 /// @param[in] offset
117 /// The offset to apply to all file addresses for all top
118 /// level sections in the object file as each section load
119 /// address is being set.
121 /// @param[out] changed
122 /// If any section load addresses were changed in \a target,
123 /// then \a changed will be set to \b true. Else \a changed
124 /// will be set to false. This allows this function to be
125 /// called multiple times on the same module for the same
126 /// target. If the module hasn't moved, then \a changed will
127 /// be false and no module updated notification will need to
131 /// /b True if any sections were successfully loaded in \a target,
132 /// /b false otherwise.
133 //------------------------------------------------------------------
135 SetLoadAddress (Target &target,
139 //------------------------------------------------------------------
140 /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
142 /// @see SymbolContextScope
143 //------------------------------------------------------------------
145 CalculateSymbolContext (SymbolContext* sc);
147 virtual lldb::ModuleSP
148 CalculateSymbolContextModule ();
151 GetDescription (Stream *s,
152 lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
154 //------------------------------------------------------------------
155 /// Get the module path and object name.
157 /// Modules can refer to object files. In this case the specification
158 /// is simple and would return the path to the file:
160 /// "/usr/lib/foo.dylib"
162 /// Modules can be .o files inside of a BSD archive (.a file). In
163 /// this case, the object specification will look like:
165 /// "/usr/lib/foo.a(bar.o)"
167 /// There are many places where logging wants to log this fully
168 /// qualified specification, so we centralize this functionality
172 /// The object path + object name if there is one.
173 //------------------------------------------------------------------
175 GetSpecificationDescription () const;
177 //------------------------------------------------------------------
178 /// Dump a description of this object to a Stream.
180 /// Dump a description of the contents of this object to the
181 /// supplied stream \a s. The dumped content will be only what has
182 /// been loaded or parsed up to this point at which this function
183 /// is called, so this is a good way to see what has been parsed
187 /// The stream to which to dump the object descripton.
188 //------------------------------------------------------------------
192 //------------------------------------------------------------------
193 /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
195 /// @see SymbolContextScope
196 //------------------------------------------------------------------
198 DumpSymbolContext (Stream *s);
201 //------------------------------------------------------------------
202 /// Find a symbol in the object file's symbol table.
205 /// The name of the symbol that we are looking for.
207 /// @param[in] symbol_type
208 /// If set to eSymbolTypeAny, find a symbol of any type that
209 /// has a name that matches \a name. If set to any other valid
210 /// SymbolType enumeration value, then search only for
211 /// symbols that match \a symbol_type.
214 /// Returns a valid symbol pointer if a symbol was found,
216 //------------------------------------------------------------------
218 FindFirstSymbolWithNameAndType (const ConstString &name,
219 lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
222 FindSymbolsWithNameAndType (const ConstString &name,
223 lldb::SymbolType symbol_type,
224 SymbolContextList &sc_list);
227 FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
228 lldb::SymbolType symbol_type,
229 SymbolContextList &sc_list);
231 //------------------------------------------------------------------
232 /// Find a funciton symbols in the object file's symbol table.
235 /// The name of the symbol that we are looking for.
237 /// @param[in] name_type_mask
238 /// A mask that has one or more bitwise OR'ed values from the
239 /// lldb::FunctionNameType enumeration type that indicate what
240 /// kind of names we are looking for.
242 /// @param[out] sc_list
243 /// A list to append any matching symbol contexts to.
246 /// The number of symbol contexts that were added to \a sc_list
247 //------------------------------------------------------------------
249 FindFunctionSymbols (const ConstString &name,
250 uint32_t name_type_mask,
251 SymbolContextList& sc_list);
253 //------------------------------------------------------------------
254 /// Find compile units by partial or full path.
256 /// Finds all compile units that match \a path in all of the modules
257 /// and returns the results in \a sc_list.
260 /// The name of the function we are looking for.
262 /// @param[in] append
263 /// If \b true, then append any compile units that were found
264 /// to \a sc_list. If \b false, then the \a sc_list is cleared
265 /// and the contents of \a sc_list are replaced.
267 /// @param[out] sc_list
268 /// A symbol context list that gets filled in with all of the
272 /// The number of matches added to \a sc_list.
273 //------------------------------------------------------------------
275 FindCompileUnits (const FileSpec &path,
277 SymbolContextList &sc_list);
280 //------------------------------------------------------------------
281 /// Find functions by name.
283 /// If the function is an inlined function, it will have a block,
284 /// representing the inlined function, and the function will be the
285 /// containing function. If it is not inlined, then the block will
289 /// The name of the compile unit we are looking for.
291 /// @param[in] namespace_decl
292 /// If valid, a namespace to search in.
294 /// @param[in] name_type_mask
295 /// A bit mask of bits that indicate what kind of names should
296 /// be used when doing the lookup. Bits include fully qualified
297 /// names, base names, C++ methods, or ObjC selectors.
298 /// See FunctionNameType for more details.
300 /// @param[in] append
301 /// If \b true, any matches will be appended to \a sc_list, else
302 /// matches replace the contents of \a sc_list.
304 /// @param[out] sc_list
305 /// A symbol context list that gets filled in with all of the
309 /// The number of matches added to \a sc_list.
310 //------------------------------------------------------------------
312 FindFunctions (const ConstString &name,
313 const ClangNamespaceDecl *namespace_decl,
314 uint32_t name_type_mask,
318 SymbolContextList& sc_list);
320 //------------------------------------------------------------------
321 /// Find functions by name.
323 /// If the function is an inlined function, it will have a block,
324 /// representing the inlined function, and the function will be the
325 /// containing function. If it is not inlined, then the block will
329 /// A regular expression to use when matching the name.
331 /// @param[in] append
332 /// If \b true, any matches will be appended to \a sc_list, else
333 /// matches replace the contents of \a sc_list.
335 /// @param[out] sc_list
336 /// A symbol context list that gets filled in with all of the
340 /// The number of matches added to \a sc_list.
341 //------------------------------------------------------------------
343 FindFunctions (const RegularExpression& regex,
347 SymbolContextList& sc_list);
349 //------------------------------------------------------------------
350 /// Find global and static variables by name.
353 /// The name of the global or static variable we are looking
356 /// @param[in] namespace_decl
357 /// If valid, a namespace to search in.
359 /// @param[in] append
360 /// If \b true, any matches will be appended to \a
361 /// variable_list, else matches replace the contents of
362 /// \a variable_list.
364 /// @param[in] max_matches
365 /// Allow the number of matches to be limited to \a
366 /// max_matches. Specify UINT32_MAX to get all possible matches.
368 /// @param[in] variable_list
369 /// A list of variables that gets the matches appended to (if
370 /// \a append it \b true), or replace (if \a append is \b false).
373 /// The number of matches added to \a variable_list.
374 //------------------------------------------------------------------
376 FindGlobalVariables (const ConstString &name,
377 const ClangNamespaceDecl *namespace_decl,
380 VariableList& variable_list);
382 //------------------------------------------------------------------
383 /// Find global and static variables by regular exression.
386 /// A regular expression to use when matching the name.
388 /// @param[in] append
389 /// If \b true, any matches will be appended to \a
390 /// variable_list, else matches replace the contents of
391 /// \a variable_list.
393 /// @param[in] max_matches
394 /// Allow the number of matches to be limited to \a
395 /// max_matches. Specify UINT32_MAX to get all possible matches.
397 /// @param[in] variable_list
398 /// A list of variables that gets the matches appended to (if
399 /// \a append it \b true), or replace (if \a append is \b false).
402 /// The number of matches added to \a variable_list.
403 //------------------------------------------------------------------
405 FindGlobalVariables (const RegularExpression& regex,
408 VariableList& variable_list);
410 //------------------------------------------------------------------
411 /// Find types by name.
413 /// Type lookups in modules go through the SymbolVendor (which will
414 /// use one or more SymbolFile subclasses). The SymbolFile needs to
415 /// be able to lookup types by basename and not the fully qualified
416 /// typename. This allows the type accelerator tables to stay small,
417 /// even with heavily templatized C++. The type search will then
418 /// narrow down the search results. If "exact_match" is true, then
419 /// the type search will only match exact type name matches. If
420 /// "exact_match" is false, the type will match as long as the base
421 /// typename matches and as long as any immediate containing
422 /// namespaces/class scopes that are specified match. So to search
423 /// for a type "d" in "b::c", the name "b::c::d" can be specified
424 /// and it will match any class/namespace "b" which contains a
425 /// class/namespace "c" which contains type "d". We do this to
426 /// allow users to not always have to specify complete scoping on
427 /// all expressions, but it also allows for exact matching when
431 /// A symbol context that scopes where to extract a type list
434 /// @param[in] type_name
435 /// The name of the type we are looking for that is a fully
436 /// or partially qualfieid type name.
438 /// @param[in] exact_match
439 /// If \b true, \a type_name is fully qualifed and must match
440 /// exactly. If \b false, \a type_name is a partially qualfied
441 /// name where the leading namespaces or classes can be
442 /// omitted to make finding types that a user may type
445 /// @param[out] type_list
446 /// A type list gets populated with any matches.
449 /// The number of matches added to \a type_list.
450 //------------------------------------------------------------------
452 FindTypes (const SymbolContext& sc,
453 const ConstString &type_name,
459 FindFirstType (const SymbolContext& sc,
460 const ConstString &type_name,
463 //------------------------------------------------------------------
464 /// Find types by name that are in a namespace. This function is
465 /// used by the expression parser when searches need to happen in
466 /// an exact namespace scope.
469 /// A symbol context that scopes where to extract a type list
472 /// @param[in] type_name
473 /// The name of a type within a namespace that should not include
474 /// any qualifying namespaces (just a type basename).
476 /// @param[in] namespace_decl
477 /// The namespace declaration that this type must exist in.
479 /// @param[out] type_list
480 /// A type list gets populated with any matches.
483 /// The number of matches added to \a type_list.
484 //------------------------------------------------------------------
486 FindTypesInNamespace (const SymbolContext& sc,
487 const ConstString &type_name,
488 const ClangNamespaceDecl *namespace_decl,
490 TypeList& type_list);
492 //------------------------------------------------------------------
493 /// Get const accessor for the module architecture.
496 /// A const reference to the architecture object.
497 //------------------------------------------------------------------
499 GetArchitecture () const;
501 //------------------------------------------------------------------
502 /// Get const accessor for the module file specification.
504 /// This function returns the file for the module on the host system
505 /// that is running LLDB. This can differ from the path on the
506 /// platform since we might be doing remote debugging.
509 /// A const reference to the file specification object.
510 //------------------------------------------------------------------
517 //------------------------------------------------------------------
518 /// Get accessor for the module platform file specification.
520 /// Platform file refers to the path of the module as it is known on
521 /// the remote system on which it is being debugged. For local
522 /// debugging this is always the same as Module::GetFileSpec(). But
523 /// remote debugging might mention a file "/usr/lib/liba.dylib"
524 /// which might be locally downloaded and cached. In this case the
525 /// platform file could be something like:
526 /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
527 /// The file could also be cached in a local developer kit directory.
530 /// A const reference to the file specification object.
531 //------------------------------------------------------------------
533 GetPlatformFileSpec () const
536 return m_platform_file;
541 SetPlatformFileSpec (const FileSpec &file)
543 m_platform_file = file;
547 GetSymbolFileFileSpec () const
549 return m_symfile_spec;
553 SetSymbolFileFileSpec (const FileSpec &file);
556 GetModificationTime () const
562 GetObjectModificationTime () const
564 return m_object_mod_time;
568 SetObjectModificationTime (const TimeValue &mod_time)
570 m_mod_time = mod_time;
573 //------------------------------------------------------------------
574 /// Tells whether this module is capable of being the main executable
578 /// \b true if it is, \b false otherwise.
579 //------------------------------------------------------------------
583 //------------------------------------------------------------------
584 /// Tells whether this module has been loaded in the target passed in.
585 /// This call doesn't distinguish between whether the module is loaded
586 /// by the dynamic loader, or by a "target module add" type call.
588 /// @param[in] target
589 /// The target to check whether this is loaded in.
592 /// \b true if it is, \b false otherwise.
593 //------------------------------------------------------------------
595 IsLoadedInTarget (Target *target);
598 LoadScriptingResourceInTarget (Target *target,
600 Stream* feedback_stream = NULL);
602 //------------------------------------------------------------------
603 /// Get the number of compile units for this module.
606 /// The number of compile units that the symbol vendor plug-in
608 //------------------------------------------------------------------
610 GetNumCompileUnits();
613 GetCompileUnitAtIndex (size_t idx);
616 GetObjectName() const;
619 GetObjectOffset() const
621 return m_object_offset;
624 //------------------------------------------------------------------
625 /// Get the object file representation for the current architecture.
627 /// If the object file has not been located or parsed yet, this
628 /// function will find the best ObjectFile plug-in that can parse
632 /// If Module::m_file does not exist, or no plug-in was found
633 /// that can parse the file, or the object file doesn't contain
634 /// the current architecture in Module::m_arch, NULL will be
635 /// returned, else a valid object file interface will be
636 /// returned. The returned pointer is owned by this object and
637 /// remains valid as long as the object is around.
638 //------------------------------------------------------------------
642 //------------------------------------------------------------------
643 /// Get the unified section list for the module. This is the section
644 /// list created by the module's object file and any debug info and
645 /// symbol files created by the symbol vendor.
647 /// If the symbol vendor has not been loaded yet, this function
648 /// will return the section list for the object file.
651 /// Unified module section list.
652 //------------------------------------------------------------------
653 virtual SectionList *
657 GetVersion (uint32_t *versions, uint32_t num_versions);
659 // Load an object file from memory.
661 GetMemoryObjectFile (const lldb::ProcessSP &process_sp,
662 lldb::addr_t header_addr,
664 //------------------------------------------------------------------
665 /// Get the symbol vendor interface for the current architecture.
667 /// If the symbol vendor file has not been located yet, this
668 /// function will find the best SymbolVendor plug-in that can
669 /// use the current object file.
672 /// If this module does not have a valid object file, or no
673 /// plug-in can be found that can use the object file, NULL will
674 /// be returned, else a valid symbol vendor plug-in interface
675 /// will be returned. The returned pointer is owned by this
676 /// object and remains valid as long as the object is around.
677 //------------------------------------------------------------------
678 virtual SymbolVendor*
679 GetSymbolVendor(bool can_create = true,
680 lldb_private::Stream *feedback_strm = NULL);
682 //------------------------------------------------------------------
683 /// Get accessor the type list for this module.
686 /// A valid type list pointer, or NULL if there is no valid
687 /// symbol vendor for this module.
688 //------------------------------------------------------------------
692 //------------------------------------------------------------------
693 /// Get a pointer to the UUID value contained in this object.
695 /// If the executable image file doesn't not have a UUID value built
696 /// into the file format, an MD5 checksum of the entire file, or
697 /// slice of the file for the current architecture should be used.
700 /// A const pointer to the internal copy of the UUID value in
701 /// this module if this module has a valid UUID value, NULL
703 //------------------------------------------------------------------
704 const lldb_private::UUID &
707 //------------------------------------------------------------------
708 /// A debugging function that will cause everything in a module to
711 /// All compile units will be pasred, along with all globals and
712 /// static variables and all functions for those compile units.
713 /// All types, scopes, local variables, static variables, global
714 /// variables, and line tables will be parsed. This can be used
715 /// prior to dumping a module to see a complete list of the
716 /// resuling debug information that gets parsed, or as a debug
717 /// function to ensure that the module can consume all of the
718 /// debug data the symbol vendor provides.
719 //------------------------------------------------------------------
721 ParseAllDebugSymbols();
724 ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr);
727 ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope, SymbolContext& sc);
729 //------------------------------------------------------------------
730 /// Resolve items in the symbol context for a given file and line.
732 /// Tries to resolve \a file_path and \a line to a list of matching
735 /// The line table entries contains addresses that can be used to
736 /// further resolve the values in each match: the function, block,
737 /// symbol. Care should be taken to minimize the amount of
738 /// information that is requested to only what is needed --
739 /// typically the module, compile unit, line table and line table
740 /// entry are sufficient.
742 /// @param[in] file_path
743 /// A path to a source file to match. If \a file_path does not
744 /// specify a directory, then this query will match all files
745 /// whose base filename matches. If \a file_path does specify
746 /// a directory, the fullpath to the file must match.
749 /// The source line to match, or zero if just the compile unit
750 /// should be resolved.
752 /// @param[in] check_inlines
753 /// Check for inline file and line number matches. This option
754 /// should be used sparingly as it will cause all line tables
755 /// for every compile unit to be parsed and searched for
756 /// matching inline file entries.
758 /// @param[in] resolve_scope
759 /// The scope that should be resolved (see
760 /// SymbolContext::Scope).
762 /// @param[out] sc_list
763 /// A symbol context list that gets matching symbols contexts
767 /// The number of matches that were added to \a sc_list.
769 /// @see SymbolContext::Scope
770 //------------------------------------------------------------------
772 ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
774 //------------------------------------------------------------------
775 /// Resolve items in the symbol context for a given file and line.
777 /// Tries to resolve \a file_spec and \a line to a list of matching
780 /// The line table entries contains addresses that can be used to
781 /// further resolve the values in each match: the function, block,
782 /// symbol. Care should be taken to minimize the amount of
783 /// information that is requested to only what is needed --
784 /// typically the module, compile unit, line table and line table
785 /// entry are sufficient.
787 /// @param[in] file_spec
788 /// A file spec to a source file to match. If \a file_path does
789 /// not specify a directory, then this query will match all
790 /// files whose base filename matches. If \a file_path does
791 /// specify a directory, the fullpath to the file must match.
794 /// The source line to match, or zero if just the compile unit
795 /// should be resolved.
797 /// @param[in] check_inlines
798 /// Check for inline file and line number matches. This option
799 /// should be used sparingly as it will cause all line tables
800 /// for every compile unit to be parsed and searched for
801 /// matching inline file entries.
803 /// @param[in] resolve_scope
804 /// The scope that should be resolved (see
805 /// SymbolContext::Scope).
807 /// @param[out] sc_list
808 /// A symbol context list that gets filled in with all of the
812 /// A integer that contains SymbolContext::Scope bits set for
813 /// each item that was successfully resolved.
815 /// @see SymbolContext::Scope
816 //------------------------------------------------------------------
818 ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
822 SetFileSpecAndObjectName (const FileSpec &file,
823 const ConstString &object_name);
826 GetIsDynamicLinkEditor () const
828 return m_is_dynamic_loader_module;
832 SetIsDynamicLinkEditor (bool b)
834 m_is_dynamic_loader_module = b;
838 GetClangASTContext ();
840 // Special error functions that can do printf style formatting that will prepend the message with
841 // something appropriate for this module (like the architecture, path and object name (if any)).
842 // This centralizes code so that everyone doesn't need to format their error and log messages on
843 // their own and keeps the output a bit more consistent.
845 LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
848 LogMessageVerboseBacktrace (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
851 ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
854 ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
856 // Only report an error once when the module is first detected to be modified
857 // so we don't spam the console with many messages.
859 ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
861 //------------------------------------------------------------------
862 // Return true if the file backing this module has changed since the
863 // module was originally created since we saved the intial file
864 // modification time when the module first gets created.
865 //------------------------------------------------------------------
867 FileHasChanged () const;
869 //------------------------------------------------------------------
870 // SymbolVendor, SymbolFile and ObjectFile member objects should
871 // lock the module mutex to avoid deadlocks.
872 //------------------------------------------------------------------
880 GetSourceMappingList ()
882 return m_source_mappings;
885 const PathMappingList &
886 GetSourceMappingList () const
888 return m_source_mappings;
891 //------------------------------------------------------------------
892 /// Finds a source file given a file spec using the module source
893 /// path remappings (if any).
895 /// Tries to resolve \a orig_spec by checking the module source path
896 /// remappings. It makes sure the file exists, so this call can be
897 /// expensive if the remappings are on a network file system, so
898 /// use this function sparingly (not in a tight debug info parsing
901 /// @param[in] orig_spec
902 /// The original source file path to try and remap.
904 /// @param[out] new_spec
905 /// The newly remapped filespec that is guaranteed to exist.
908 /// /b true if \a orig_spec was successfully located and
909 /// \a new_spec is filled in with an existing file spec,
910 /// \b false otherwise.
911 //------------------------------------------------------------------
913 FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
915 //------------------------------------------------------------------
916 /// Remaps a source file given \a path into \a new_path.
918 /// Remaps \a path if any source remappings match. This function
919 /// does NOT stat the file system so it can be used in tight loops
920 /// where debug info is being parsed.
923 /// The original source file path to try and remap.
925 /// @param[out] new_path
926 /// The newly remapped filespec that is may or may not exist.
929 /// /b true if \a path was successfully located and \a new_path
930 /// is filled in with a new source path, \b false otherwise.
931 //------------------------------------------------------------------
933 RemapSourceFile (const char *path, std::string &new_path) const;
936 //------------------------------------------------------------------
937 /// Prepare to do a function name lookup.
939 /// Looking up functions by name can be a tricky thing. LLDB requires
940 /// that accelerator tables contain full names for functions as well
941 /// as function basenames which include functions, class methods and
942 /// class functions. When the user requests that an action use a
943 /// function by name, we are sometimes asked to automatically figure
944 /// out what a name could possibly map to. A user might request a
945 /// breakpoint be set on "count". If no options are supplied to limit
946 /// the scope of where to search for count, we will by default match
947 /// any function names named "count", all class and instance methods
948 /// named "count" (no matter what the namespace or contained context)
949 /// and any selectors named "count". If a user specifies "a::b" we
950 /// will search for the basename "b", and then prune the results that
951 /// don't match "a::b" (note that "c::a::b" and "d::e::a::b" will
952 /// match a query of "a::b".
955 /// The user supplied name to use in the lookup
957 /// @param[in] name_type_mask
958 /// The mask of bits from lldb::FunctionNameType enumerations
959 /// that tell us what kind of name we are looking for.
961 /// @param[out] lookup_name
962 /// The actual name that will be used when calling
963 /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols()
965 /// @param[out] lookup_name_type_mask
966 /// The actual name mask that should be used in the calls to
967 /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols()
969 /// @param[out] match_name_after_lookup
970 /// A boolean that indicates if we need to iterate through any
971 /// match results obtained from SymbolVendor::FindFunctions() or
972 /// Symtab::FindFunctionSymbols() to see if the name contains
973 /// \a name. For example if \a name is "a::b", this function will
974 /// return a \a lookup_name of "b", with \a match_name_after_lookup
975 /// set to true to indicate any matches will need to be checked
976 /// to make sure they contain \a name.
977 //------------------------------------------------------------------
979 PrepareForFunctionNameLookup (const ConstString &name,
980 uint32_t name_type_mask,
981 ConstString &lookup_name,
982 uint32_t &lookup_name_type_mask,
983 bool &match_name_after_lookup);
986 //------------------------------------------------------------------
988 //------------------------------------------------------------------
989 mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
990 TimeValue m_mod_time; ///< The modification time for this module when it was created.
991 ArchSpec m_arch; ///< The architecture for this module.
992 lldb_private::UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
993 FileSpec m_file; ///< The file representation on disk for this module (if there is one).
994 FileSpec m_platform_file;///< The path to the module on the platform on which it is being debugged
995 FileSpec m_symfile_spec; ///< If this path is valid, then this is the file that _will_ be used as the symbol file for this module
996 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.
997 uint64_t m_object_offset;
998 TimeValue m_object_mod_time;
999 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
1000 std::unique_ptr<SymbolVendor> m_symfile_ap; ///< A pointer to the symbol vendor for this module.
1001 ClangASTContext m_ast; ///< The AST context for this module.
1002 PathMappingList m_source_mappings; ///< Module specific source remappings for when you have debug info for a module that doesn't match where the sources currently are
1003 std::unique_ptr<lldb_private::SectionList> m_sections_ap; ///< Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the debug info
1005 bool m_did_load_objfile:1,
1006 m_did_load_symbol_vendor:1,
1009 m_is_dynamic_loader_module:1;
1010 mutable bool m_file_has_changed:1,
1011 m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.
1013 //------------------------------------------------------------------
1014 /// Resolve a file or load virtual address.
1016 /// Tries to resolve \a vm_addr as a file address (if \a
1017 /// vm_addr_is_file_addr is true) or as a load address if \a
1018 /// vm_addr_is_file_addr is false) in the symbol vendor.
1019 /// \a resolve_scope indicates what clients wish to resolve
1020 /// and can be used to limit the scope of what is parsed.
1022 /// @param[in] vm_addr
1023 /// The load virtual address to resolve.
1025 /// @param[in] vm_addr_is_file_addr
1026 /// If \b true, \a vm_addr is a file address, else \a vm_addr
1027 /// if a load address.
1029 /// @param[in] resolve_scope
1030 /// The scope that should be resolved (see
1031 /// SymbolContext::Scope).
1033 /// @param[out] so_addr
1034 /// The section offset based address that got resolved if
1035 /// any bits are returned.
1038 // The symbol context that has objects filled in. Each bit
1039 /// in the \a resolve_scope pertains to a member in the \a sc.
1042 /// A integer that contains SymbolContext::Scope bits set for
1043 /// each item that was successfully resolved.
1045 /// @see SymbolContext::Scope
1046 //------------------------------------------------------------------
1048 ResolveSymbolContextForAddress (lldb::addr_t vm_addr,
1049 bool vm_addr_is_file_addr,
1050 uint32_t resolve_scope,
1055 SymbolIndicesToSymbolContextList (Symtab *symtab,
1056 std::vector<uint32_t> &symbol_indexes,
1057 SymbolContextList &sc_list);
1060 SetArchitecture (const ArchSpec &new_arch);
1063 GetUnifiedSectionList();
1065 friend class ModuleList;
1066 friend class ObjectFile;
1067 friend class SymbolFile;
1072 FindTypes_Impl (const SymbolContext& sc,
1073 const ConstString &name,
1074 const ClangNamespaceDecl *namespace_decl,
1080 DISALLOW_COPY_AND_ASSIGN (Module);
1083 } // namespace lldb_private
1085 #endif // liblldb_Module_h_