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 representation 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 lldb::offset_t object_offset = 0,
92 const TimeValue *object_mod_time_ptr = NULL);
94 Module (const ModuleSpec &module_spec);
97 CreateJITModule (const lldb::ObjectFileJITDelegateSP &delegate_sp);
99 //------------------------------------------------------------------
101 //------------------------------------------------------------------
106 MatchesModuleSpec (const ModuleSpec &module_ref);
108 //------------------------------------------------------------------
109 /// Set the load address for all sections in a module to be the
110 /// file address plus \a slide.
112 /// Many times a module will be loaded in a target with a constant
113 /// offset applied to all top level sections. This function can
114 /// set the load address for all top level sections to be the
115 /// section file address + offset.
117 /// @param[in] target
118 /// The target in which to apply the section load addresses.
121 /// if \a value_is_offset is true, then value is the offset to
122 /// apply to all file addresses for all top level sections in
123 /// the object file as each section load address is being set.
124 /// If \a value_is_offset is false, then "value" is the new
125 /// absolute base address for the image.
127 /// @param[in] value_is_offset
128 /// If \b true, then \a value is an offset to apply to each
129 /// file address of each top level section.
130 /// If \b false, then \a value is the image base address that
131 /// will be used to rigidly slide all loadable sections.
133 /// @param[out] changed
134 /// If any section load addresses were changed in \a target,
135 /// then \a changed will be set to \b true. Else \a changed
136 /// will be set to false. This allows this function to be
137 /// called multiple times on the same module for the same
138 /// target. If the module hasn't moved, then \a changed will
139 /// be false and no module updated notification will need to
143 /// /b True if any sections were successfully loaded in \a target,
144 /// /b false otherwise.
145 //------------------------------------------------------------------
147 SetLoadAddress (Target &target,
149 bool value_is_offset,
152 //------------------------------------------------------------------
153 /// @copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
155 /// @see SymbolContextScope
156 //------------------------------------------------------------------
158 CalculateSymbolContext (SymbolContext* sc);
160 virtual lldb::ModuleSP
161 CalculateSymbolContextModule ();
164 GetDescription (Stream *s,
165 lldb::DescriptionLevel level = lldb::eDescriptionLevelFull);
167 //------------------------------------------------------------------
168 /// Get the module path and object name.
170 /// Modules can refer to object files. In this case the specification
171 /// is simple and would return the path to the file:
173 /// "/usr/lib/foo.dylib"
175 /// Modules can be .o files inside of a BSD archive (.a file). In
176 /// this case, the object specification will look like:
178 /// "/usr/lib/foo.a(bar.o)"
180 /// There are many places where logging wants to log this fully
181 /// qualified specification, so we centralize this functionality
185 /// The object path + object name if there is one.
186 //------------------------------------------------------------------
188 GetSpecificationDescription () const;
190 //------------------------------------------------------------------
191 /// Dump a description of this object to a Stream.
193 /// Dump a description of the contents of this object to the
194 /// supplied stream \a s. The dumped content will be only what has
195 /// been loaded or parsed up to this point at which this function
196 /// is called, so this is a good way to see what has been parsed
200 /// The stream to which to dump the object description.
201 //------------------------------------------------------------------
205 //------------------------------------------------------------------
206 /// @copydoc SymbolContextScope::DumpSymbolContext(Stream*)
208 /// @see SymbolContextScope
209 //------------------------------------------------------------------
211 DumpSymbolContext (Stream *s);
214 //------------------------------------------------------------------
215 /// Find a symbol in the object file's symbol table.
218 /// The name of the symbol that we are looking for.
220 /// @param[in] symbol_type
221 /// If set to eSymbolTypeAny, find a symbol of any type that
222 /// has a name that matches \a name. If set to any other valid
223 /// SymbolType enumeration value, then search only for
224 /// symbols that match \a symbol_type.
227 /// Returns a valid symbol pointer if a symbol was found,
229 //------------------------------------------------------------------
231 FindFirstSymbolWithNameAndType (const ConstString &name,
232 lldb::SymbolType symbol_type = lldb::eSymbolTypeAny);
235 FindSymbolsWithNameAndType (const ConstString &name,
236 lldb::SymbolType symbol_type,
237 SymbolContextList &sc_list);
240 FindSymbolsMatchingRegExAndType (const RegularExpression ®ex,
241 lldb::SymbolType symbol_type,
242 SymbolContextList &sc_list);
244 //------------------------------------------------------------------
245 /// Find a funciton symbols in the object file's symbol table.
248 /// The name of the symbol that we are looking for.
250 /// @param[in] name_type_mask
251 /// A mask that has one or more bitwise OR'ed values from the
252 /// lldb::FunctionNameType enumeration type that indicate what
253 /// kind of names we are looking for.
255 /// @param[out] sc_list
256 /// A list to append any matching symbol contexts to.
259 /// The number of symbol contexts that were added to \a sc_list
260 //------------------------------------------------------------------
262 FindFunctionSymbols (const ConstString &name,
263 uint32_t name_type_mask,
264 SymbolContextList& sc_list);
266 //------------------------------------------------------------------
267 /// Find compile units by partial or full path.
269 /// Finds all compile units that match \a path in all of the modules
270 /// and returns the results in \a sc_list.
273 /// The name of the function we are looking for.
275 /// @param[in] append
276 /// If \b true, then append any compile units that were found
277 /// to \a sc_list. If \b false, then the \a sc_list is cleared
278 /// and the contents of \a sc_list are replaced.
280 /// @param[out] sc_list
281 /// A symbol context list that gets filled in with all of the
285 /// The number of matches added to \a sc_list.
286 //------------------------------------------------------------------
288 FindCompileUnits (const FileSpec &path,
290 SymbolContextList &sc_list);
293 //------------------------------------------------------------------
294 /// Find functions by name.
296 /// If the function is an inlined function, it will have a block,
297 /// representing the inlined function, and the function will be the
298 /// containing function. If it is not inlined, then the block will
302 /// The name of the compile unit we are looking for.
304 /// @param[in] namespace_decl
305 /// If valid, a namespace to search in.
307 /// @param[in] name_type_mask
308 /// A bit mask of bits that indicate what kind of names should
309 /// be used when doing the lookup. Bits include fully qualified
310 /// names, base names, C++ methods, or ObjC selectors.
311 /// See FunctionNameType for more details.
313 /// @param[in] append
314 /// If \b true, any matches will be appended to \a sc_list, else
315 /// matches replace the contents of \a sc_list.
317 /// @param[out] sc_list
318 /// A symbol context list that gets filled in with all of the
322 /// The number of matches added to \a sc_list.
323 //------------------------------------------------------------------
325 FindFunctions (const ConstString &name,
326 const ClangNamespaceDecl *namespace_decl,
327 uint32_t name_type_mask,
331 SymbolContextList& sc_list);
333 //------------------------------------------------------------------
334 /// Find functions by name.
336 /// If the function is an inlined function, it will have a block,
337 /// representing the inlined function, and the function will be the
338 /// containing function. If it is not inlined, then the block will
342 /// A regular expression to use when matching the name.
344 /// @param[in] append
345 /// If \b true, any matches will be appended to \a sc_list, else
346 /// matches replace the contents of \a sc_list.
348 /// @param[out] sc_list
349 /// A symbol context list that gets filled in with all of the
353 /// The number of matches added to \a sc_list.
354 //------------------------------------------------------------------
356 FindFunctions (const RegularExpression& regex,
360 SymbolContextList& sc_list);
362 //------------------------------------------------------------------
363 /// Find addresses by file/line
365 /// @param[in] target_sp
366 /// The target the addresses are desired for.
369 /// Source file to locate.
372 /// Source line to locate.
374 /// @param[in] function
375 /// Optional filter function. Addresses within this function will be
376 /// added to the 'local' list. All others will be added to the 'extern' list.
378 /// @param[out] output_local
379 /// All matching addresses within 'function'
381 /// @param[out] output_extern
382 /// All matching addresses not within 'function'
383 void FindAddressesForLine (const lldb::TargetSP target_sp,
384 const FileSpec &file, uint32_t line,
386 std::vector<Address> &output_local, std::vector<Address> &output_extern);
388 //------------------------------------------------------------------
389 /// Find global and static variables by name.
392 /// The name of the global or static variable we are looking
395 /// @param[in] namespace_decl
396 /// If valid, a namespace to search in.
398 /// @param[in] append
399 /// If \b true, any matches will be appended to \a
400 /// variable_list, else matches replace the contents of
401 /// \a variable_list.
403 /// @param[in] max_matches
404 /// Allow the number of matches to be limited to \a
405 /// max_matches. Specify UINT32_MAX to get all possible matches.
407 /// @param[in] variable_list
408 /// A list of variables that gets the matches appended to (if
409 /// \a append it \b true), or replace (if \a append is \b false).
412 /// The number of matches added to \a variable_list.
413 //------------------------------------------------------------------
415 FindGlobalVariables (const ConstString &name,
416 const ClangNamespaceDecl *namespace_decl,
419 VariableList& variable_list);
421 //------------------------------------------------------------------
422 /// Find global and static variables by regular expression.
425 /// A regular expression to use when matching the name.
427 /// @param[in] append
428 /// If \b true, any matches will be appended to \a
429 /// variable_list, else matches replace the contents of
430 /// \a variable_list.
432 /// @param[in] max_matches
433 /// Allow the number of matches to be limited to \a
434 /// max_matches. Specify UINT32_MAX to get all possible matches.
436 /// @param[in] variable_list
437 /// A list of variables that gets the matches appended to (if
438 /// \a append it \b true), or replace (if \a append is \b false).
441 /// The number of matches added to \a variable_list.
442 //------------------------------------------------------------------
444 FindGlobalVariables (const RegularExpression& regex,
447 VariableList& variable_list);
449 //------------------------------------------------------------------
450 /// Find types by name.
452 /// Type lookups in modules go through the SymbolVendor (which will
453 /// use one or more SymbolFile subclasses). The SymbolFile needs to
454 /// be able to lookup types by basename and not the fully qualified
455 /// typename. This allows the type accelerator tables to stay small,
456 /// even with heavily templatized C++. The type search will then
457 /// narrow down the search results. If "exact_match" is true, then
458 /// the type search will only match exact type name matches. If
459 /// "exact_match" is false, the type will match as long as the base
460 /// typename matches and as long as any immediate containing
461 /// namespaces/class scopes that are specified match. So to search
462 /// for a type "d" in "b::c", the name "b::c::d" can be specified
463 /// and it will match any class/namespace "b" which contains a
464 /// class/namespace "c" which contains type "d". We do this to
465 /// allow users to not always have to specify complete scoping on
466 /// all expressions, but it also allows for exact matching when
470 /// A symbol context that scopes where to extract a type list
473 /// @param[in] type_name
474 /// The name of the type we are looking for that is a fully
475 /// or partially qualified type name.
477 /// @param[in] exact_match
478 /// If \b true, \a type_name is fully qualified and must match
479 /// exactly. If \b false, \a type_name is a partially qualified
480 /// name where the leading namespaces or classes can be
481 /// omitted to make finding types that a user may type
484 /// @param[out] type_list
485 /// A type list gets populated with any matches.
488 /// The number of matches added to \a type_list.
489 //------------------------------------------------------------------
491 FindTypes (const SymbolContext& sc,
492 const ConstString &type_name,
498 FindFirstType (const SymbolContext& sc,
499 const ConstString &type_name,
502 //------------------------------------------------------------------
503 /// Find types by name that are in a namespace. This function is
504 /// used by the expression parser when searches need to happen in
505 /// an exact namespace scope.
508 /// A symbol context that scopes where to extract a type list
511 /// @param[in] type_name
512 /// The name of a type within a namespace that should not include
513 /// any qualifying namespaces (just a type basename).
515 /// @param[in] namespace_decl
516 /// The namespace declaration that this type must exist in.
518 /// @param[out] type_list
519 /// A type list gets populated with any matches.
522 /// The number of matches added to \a type_list.
523 //------------------------------------------------------------------
525 FindTypesInNamespace (const SymbolContext& sc,
526 const ConstString &type_name,
527 const ClangNamespaceDecl *namespace_decl,
529 TypeList& type_list);
531 //------------------------------------------------------------------
532 /// Get const accessor for the module architecture.
535 /// A const reference to the architecture object.
536 //------------------------------------------------------------------
538 GetArchitecture () const;
540 //------------------------------------------------------------------
541 /// Get const accessor for the module file specification.
543 /// This function returns the file for the module on the host system
544 /// that is running LLDB. This can differ from the path on the
545 /// platform since we might be doing remote debugging.
548 /// A const reference to the file specification object.
549 //------------------------------------------------------------------
556 //------------------------------------------------------------------
557 /// Get accessor for the module platform file specification.
559 /// Platform file refers to the path of the module as it is known on
560 /// the remote system on which it is being debugged. For local
561 /// debugging this is always the same as Module::GetFileSpec(). But
562 /// remote debugging might mention a file "/usr/lib/liba.dylib"
563 /// which might be locally downloaded and cached. In this case the
564 /// platform file could be something like:
565 /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib"
566 /// The file could also be cached in a local developer kit directory.
569 /// A const reference to the file specification object.
570 //------------------------------------------------------------------
572 GetPlatformFileSpec () const
575 return m_platform_file;
580 SetPlatformFileSpec (const FileSpec &file)
582 m_platform_file = file;
586 GetRemoteInstallFileSpec () const
588 return m_remote_install_file;
592 SetRemoteInstallFileSpec (const FileSpec &file)
594 m_remote_install_file = file;
598 GetSymbolFileFileSpec () const
600 return m_symfile_spec;
604 SetSymbolFileFileSpec (const FileSpec &file);
607 GetModificationTime () const
613 GetObjectModificationTime () const
615 return m_object_mod_time;
619 SetObjectModificationTime (const TimeValue &mod_time)
621 m_mod_time = mod_time;
624 //------------------------------------------------------------------
625 /// Tells whether this module is capable of being the main executable
629 /// \b true if it is, \b false otherwise.
630 //------------------------------------------------------------------
634 //------------------------------------------------------------------
635 /// Tells whether this module has been loaded in the target passed in.
636 /// This call doesn't distinguish between whether the module is loaded
637 /// by the dynamic loader, or by a "target module add" type call.
639 /// @param[in] target
640 /// The target to check whether this is loaded in.
643 /// \b true if it is, \b false otherwise.
644 //------------------------------------------------------------------
646 IsLoadedInTarget (Target *target);
649 LoadScriptingResourceInTarget (Target *target,
651 Stream* feedback_stream = NULL);
653 //------------------------------------------------------------------
654 /// Get the number of compile units for this module.
657 /// The number of compile units that the symbol vendor plug-in
659 //------------------------------------------------------------------
661 GetNumCompileUnits();
664 GetCompileUnitAtIndex (size_t idx);
667 GetObjectName() const;
670 GetObjectOffset() const
672 return m_object_offset;
675 //------------------------------------------------------------------
676 /// Get the object file representation for the current architecture.
678 /// If the object file has not been located or parsed yet, this
679 /// function will find the best ObjectFile plug-in that can parse
683 /// If Module::m_file does not exist, or no plug-in was found
684 /// that can parse the file, or the object file doesn't contain
685 /// the current architecture in Module::m_arch, NULL will be
686 /// returned, else a valid object file interface will be
687 /// returned. The returned pointer is owned by this object and
688 /// remains valid as long as the object is around.
689 //------------------------------------------------------------------
693 //------------------------------------------------------------------
694 /// Get the unified section list for the module. This is the section
695 /// list created by the module's object file and any debug info and
696 /// symbol files created by the symbol vendor.
698 /// If the symbol vendor has not been loaded yet, this function
699 /// will return the section list for the object file.
702 /// Unified module section list.
703 //------------------------------------------------------------------
704 virtual SectionList *
707 //------------------------------------------------------------------
708 /// Notify the module that the file addresses for the Sections have
711 /// If the Section file addresses for a module are updated, this
712 /// method should be called. Any parts of the module, object file,
713 /// or symbol file that has cached those file addresses must invalidate
714 /// or update its cache.
715 //------------------------------------------------------------------
717 SectionFileAddressesChanged ();
720 GetVersion (uint32_t *versions, uint32_t num_versions);
722 //------------------------------------------------------------------
723 /// Load an object file from memory.
725 /// If available, the size of the object file in memory may be
726 /// passed to avoid additional round trips to process memory.
727 /// If the size is not provided, a default value is used. This
728 /// value should be large enough to enable the ObjectFile plugins
729 /// to read the header of the object file without going back to the
733 /// The object file loaded from memory or NULL, if the operation
734 /// failed (see the `error` for more information in that case).
735 //------------------------------------------------------------------
737 GetMemoryObjectFile (const lldb::ProcessSP &process_sp,
738 lldb::addr_t header_addr,
740 size_t size_to_read = 512);
741 //------------------------------------------------------------------
742 /// Get the symbol vendor interface for the current architecture.
744 /// If the symbol vendor file has not been located yet, this
745 /// function will find the best SymbolVendor plug-in that can
746 /// use the current object file.
749 /// If this module does not have a valid object file, or no
750 /// plug-in can be found that can use the object file, NULL will
751 /// be returned, else a valid symbol vendor plug-in interface
752 /// will be returned. The returned pointer is owned by this
753 /// object and remains valid as long as the object is around.
754 //------------------------------------------------------------------
755 virtual SymbolVendor*
756 GetSymbolVendor(bool can_create = true,
757 lldb_private::Stream *feedback_strm = NULL);
759 //------------------------------------------------------------------
760 /// Get accessor the type list for this module.
763 /// A valid type list pointer, or NULL if there is no valid
764 /// symbol vendor for this module.
765 //------------------------------------------------------------------
769 //------------------------------------------------------------------
770 /// Get a pointer to the UUID value contained in this object.
772 /// If the executable image file doesn't not have a UUID value built
773 /// into the file format, an MD5 checksum of the entire file, or
774 /// slice of the file for the current architecture should be used.
777 /// A const pointer to the internal copy of the UUID value in
778 /// this module if this module has a valid UUID value, NULL
780 //------------------------------------------------------------------
781 const lldb_private::UUID &
784 //------------------------------------------------------------------
785 /// A debugging function that will cause everything in a module to
788 /// All compile units will be parsed, along with all globals and
789 /// static variables and all functions for those compile units.
790 /// All types, scopes, local variables, static variables, global
791 /// variables, and line tables will be parsed. This can be used
792 /// prior to dumping a module to see a complete list of the
793 /// resulting debug information that gets parsed, or as a debug
794 /// function to ensure that the module can consume all of the
795 /// debug data the symbol vendor provides.
796 //------------------------------------------------------------------
798 ParseAllDebugSymbols();
801 ResolveFileAddress (lldb::addr_t vm_addr, Address& so_addr);
803 //------------------------------------------------------------------
804 /// Resolve the symbol context for the given address.
806 /// Tries to resolve the matching symbol context based on a lookup
807 /// from the current symbol vendor. If the lazy lookup fails,
808 /// an attempt is made to parse the eh_frame section to handle
809 /// stripped symbols. If this fails, an attempt is made to resolve
810 /// the symbol to the previous address to handle the case of a
811 /// function with a tail call.
813 /// Use properties of the modified SymbolContext to inspect any
814 /// resolved target, module, compilation unit, symbol, function,
815 /// function block or line entry. Use the return value to determine
816 /// which of these properties have been modified.
818 /// @param[in] so_addr
819 /// A load address to resolve.
821 /// @param[in] resolve_scope
822 /// The scope that should be resolved (see SymbolContext::Scope).
823 /// A combination of flags from the enumeration SymbolContextItem
824 /// requesting a resolution depth. Note that the flags that are
825 /// actually resolved may be a superset of the requested flags.
826 /// For instance, eSymbolContextSymbol requires resolution of
827 /// eSymbolContextModule, and eSymbolContextFunction requires
828 /// eSymbolContextSymbol.
831 /// The SymbolContext that is modified based on symbol resolution.
833 /// @param[in] resolve_tail_call_address
834 /// Determines if so_addr should resolve to a symbol in the case
835 /// of a function whose last instruction is a call. In this case,
836 /// the PC can be one past the address range of the function.
839 /// The scope that has been resolved (see SymbolContext::Scope).
841 /// @see SymbolContext::Scope
842 //------------------------------------------------------------------
844 ResolveSymbolContextForAddress (const Address& so_addr, uint32_t resolve_scope,
845 SymbolContext& sc, bool resolve_tail_call_address = false);
847 //------------------------------------------------------------------
848 /// Resolve items in the symbol context for a given file and line.
850 /// Tries to resolve \a file_path and \a line to a list of matching
853 /// The line table entries contains addresses that can be used to
854 /// further resolve the values in each match: the function, block,
855 /// symbol. Care should be taken to minimize the amount of
856 /// information that is requested to only what is needed --
857 /// typically the module, compile unit, line table and line table
858 /// entry are sufficient.
860 /// @param[in] file_path
861 /// A path to a source file to match. If \a file_path does not
862 /// specify a directory, then this query will match all files
863 /// whose base filename matches. If \a file_path does specify
864 /// a directory, the fullpath to the file must match.
867 /// The source line to match, or zero if just the compile unit
868 /// should be resolved.
870 /// @param[in] check_inlines
871 /// Check for inline file and line number matches. This option
872 /// should be used sparingly as it will cause all line tables
873 /// for every compile unit to be parsed and searched for
874 /// matching inline file entries.
876 /// @param[in] resolve_scope
877 /// The scope that should be resolved (see
878 /// SymbolContext::Scope).
880 /// @param[out] sc_list
881 /// A symbol context list that gets matching symbols contexts
885 /// The number of matches that were added to \a sc_list.
887 /// @see SymbolContext::Scope
888 //------------------------------------------------------------------
890 ResolveSymbolContextForFilePath (const char *file_path, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
892 //------------------------------------------------------------------
893 /// Resolve items in the symbol context for a given file and line.
895 /// Tries to resolve \a file_spec and \a line to a list of matching
898 /// The line table entries contains addresses that can be used to
899 /// further resolve the values in each match: the function, block,
900 /// symbol. Care should be taken to minimize the amount of
901 /// information that is requested to only what is needed --
902 /// typically the module, compile unit, line table and line table
903 /// entry are sufficient.
905 /// @param[in] file_spec
906 /// A file spec to a source file to match. If \a file_path does
907 /// not specify a directory, then this query will match all
908 /// files whose base filename matches. If \a file_path does
909 /// specify a directory, the fullpath to the file must match.
912 /// The source line to match, or zero if just the compile unit
913 /// should be resolved.
915 /// @param[in] check_inlines
916 /// Check for inline file and line number matches. This option
917 /// should be used sparingly as it will cause all line tables
918 /// for every compile unit to be parsed and searched for
919 /// matching inline file entries.
921 /// @param[in] resolve_scope
922 /// The scope that should be resolved (see
923 /// SymbolContext::Scope).
925 /// @param[out] sc_list
926 /// A symbol context list that gets filled in with all of the
930 /// A integer that contains SymbolContext::Scope bits set for
931 /// each item that was successfully resolved.
933 /// @see SymbolContext::Scope
934 //------------------------------------------------------------------
936 ResolveSymbolContextsForFileSpec (const FileSpec &file_spec, uint32_t line, bool check_inlines, uint32_t resolve_scope, SymbolContextList& sc_list);
940 SetFileSpecAndObjectName (const FileSpec &file,
941 const ConstString &object_name);
944 GetIsDynamicLinkEditor () const
946 return m_is_dynamic_loader_module;
950 SetIsDynamicLinkEditor (bool b)
952 m_is_dynamic_loader_module = b;
956 GetClangASTContext ();
958 // Special error functions that can do printf style formatting that will prepend the message with
959 // something appropriate for this module (like the architecture, path and object name (if any)).
960 // This centralizes code so that everyone doesn't need to format their error and log messages on
961 // their own and keeps the output a bit more consistent.
963 LogMessage (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
966 LogMessageVerboseBacktrace (Log *log, const char *format, ...) __attribute__ ((format (printf, 3, 4)));
969 ReportWarning (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
972 ReportError (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
974 // Only report an error once when the module is first detected to be modified
975 // so we don't spam the console with many messages.
977 ReportErrorIfModifyDetected (const char *format, ...) __attribute__ ((format (printf, 2, 3)));
979 //------------------------------------------------------------------
980 // Return true if the file backing this module has changed since the
981 // module was originally created since we saved the initial file
982 // modification time when the module first gets created.
983 //------------------------------------------------------------------
985 FileHasChanged () const;
987 //------------------------------------------------------------------
988 // SymbolVendor, SymbolFile and ObjectFile member objects should
989 // lock the module mutex to avoid deadlocks.
990 //------------------------------------------------------------------
998 GetSourceMappingList ()
1000 return m_source_mappings;
1003 const PathMappingList &
1004 GetSourceMappingList () const
1006 return m_source_mappings;
1009 //------------------------------------------------------------------
1010 /// Finds a source file given a file spec using the module source
1011 /// path remappings (if any).
1013 /// Tries to resolve \a orig_spec by checking the module source path
1014 /// remappings. It makes sure the file exists, so this call can be
1015 /// expensive if the remappings are on a network file system, so
1016 /// use this function sparingly (not in a tight debug info parsing
1019 /// @param[in] orig_spec
1020 /// The original source file path to try and remap.
1022 /// @param[out] new_spec
1023 /// The newly remapped filespec that is guaranteed to exist.
1026 /// /b true if \a orig_spec was successfully located and
1027 /// \a new_spec is filled in with an existing file spec,
1028 /// \b false otherwise.
1029 //------------------------------------------------------------------
1031 FindSourceFile (const FileSpec &orig_spec, FileSpec &new_spec) const;
1033 //------------------------------------------------------------------
1034 /// Remaps a source file given \a path into \a new_path.
1036 /// Remaps \a path if any source remappings match. This function
1037 /// does NOT stat the file system so it can be used in tight loops
1038 /// where debug info is being parsed.
1041 /// The original source file path to try and remap.
1043 /// @param[out] new_path
1044 /// The newly remapped filespec that is may or may not exist.
1047 /// /b true if \a path was successfully located and \a new_path
1048 /// is filled in with a new source path, \b false otherwise.
1049 //------------------------------------------------------------------
1051 RemapSourceFile (const char *path, std::string &new_path) const;
1054 //------------------------------------------------------------------
1055 /// Prepare to do a function name lookup.
1057 /// Looking up functions by name can be a tricky thing. LLDB requires
1058 /// that accelerator tables contain full names for functions as well
1059 /// as function basenames which include functions, class methods and
1060 /// class functions. When the user requests that an action use a
1061 /// function by name, we are sometimes asked to automatically figure
1062 /// out what a name could possibly map to. A user might request a
1063 /// breakpoint be set on "count". If no options are supplied to limit
1064 /// the scope of where to search for count, we will by default match
1065 /// any function names named "count", all class and instance methods
1066 /// named "count" (no matter what the namespace or contained context)
1067 /// and any selectors named "count". If a user specifies "a::b" we
1068 /// will search for the basename "b", and then prune the results that
1069 /// don't match "a::b" (note that "c::a::b" and "d::e::a::b" will
1070 /// match a query of "a::b".
1073 /// The user supplied name to use in the lookup
1075 /// @param[in] name_type_mask
1076 /// The mask of bits from lldb::FunctionNameType enumerations
1077 /// that tell us what kind of name we are looking for.
1079 /// @param[out] lookup_name
1080 /// The actual name that will be used when calling
1081 /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols()
1083 /// @param[out] lookup_name_type_mask
1084 /// The actual name mask that should be used in the calls to
1085 /// SymbolVendor::FindFunctions() or Symtab::FindFunctionSymbols()
1087 /// @param[out] match_name_after_lookup
1088 /// A boolean that indicates if we need to iterate through any
1089 /// match results obtained from SymbolVendor::FindFunctions() or
1090 /// Symtab::FindFunctionSymbols() to see if the name contains
1091 /// \a name. For example if \a name is "a::b", this function will
1092 /// return a \a lookup_name of "b", with \a match_name_after_lookup
1093 /// set to true to indicate any matches will need to be checked
1094 /// to make sure they contain \a name.
1095 //------------------------------------------------------------------
1097 PrepareForFunctionNameLookup (const ConstString &name,
1098 uint32_t name_type_mask,
1099 ConstString &lookup_name,
1100 uint32_t &lookup_name_type_mask,
1101 bool &match_name_after_lookup);
1104 //------------------------------------------------------------------
1106 //------------------------------------------------------------------
1107 mutable Mutex m_mutex; ///< A mutex to keep this object happy in multi-threaded environments.
1108 TimeValue m_mod_time; ///< The modification time for this module when it was created.
1109 ArchSpec m_arch; ///< The architecture for this module.
1110 lldb_private::UUID m_uuid; ///< Each module is assumed to have a unique identifier to help match it up to debug symbols.
1111 FileSpec m_file; ///< The file representation on disk for this module (if there is one).
1112 FileSpec m_platform_file;///< The path to the module on the platform on which it is being debugged
1113 FileSpec m_remote_install_file; ///< If set when debugging on remote platforms, this module will be installed at this location
1114 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
1115 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.
1116 uint64_t m_object_offset;
1117 TimeValue m_object_mod_time;
1118 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
1119 std::unique_ptr<SymbolVendor> m_symfile_ap; ///< A pointer to the symbol vendor for this module.
1120 ClangASTContext m_ast; ///< The AST context for this module.
1121 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
1122 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
1124 bool m_did_load_objfile:1,
1125 m_did_load_symbol_vendor:1,
1128 m_is_dynamic_loader_module:1;
1129 mutable bool m_file_has_changed:1,
1130 m_first_file_changed_log:1; /// See if the module was modified after it was initially opened.
1132 //------------------------------------------------------------------
1133 /// Resolve a file or load virtual address.
1135 /// Tries to resolve \a vm_addr as a file address (if \a
1136 /// vm_addr_is_file_addr is true) or as a load address if \a
1137 /// vm_addr_is_file_addr is false) in the symbol vendor.
1138 /// \a resolve_scope indicates what clients wish to resolve
1139 /// and can be used to limit the scope of what is parsed.
1141 /// @param[in] vm_addr
1142 /// The load virtual address to resolve.
1144 /// @param[in] vm_addr_is_file_addr
1145 /// If \b true, \a vm_addr is a file address, else \a vm_addr
1146 /// if a load address.
1148 /// @param[in] resolve_scope
1149 /// The scope that should be resolved (see
1150 /// SymbolContext::Scope).
1152 /// @param[out] so_addr
1153 /// The section offset based address that got resolved if
1154 /// any bits are returned.
1157 // The symbol context that has objects filled in. Each bit
1158 /// in the \a resolve_scope pertains to a member in the \a sc.
1161 /// A integer that contains SymbolContext::Scope bits set for
1162 /// each item that was successfully resolved.
1164 /// @see SymbolContext::Scope
1165 //------------------------------------------------------------------
1167 ResolveSymbolContextForAddress (lldb::addr_t vm_addr,
1168 bool vm_addr_is_file_addr,
1169 uint32_t resolve_scope,
1174 SymbolIndicesToSymbolContextList (Symtab *symtab,
1175 std::vector<uint32_t> &symbol_indexes,
1176 SymbolContextList &sc_list);
1179 SetArchitecture (const ArchSpec &new_arch);
1182 GetUnifiedSectionList();
1184 friend class ModuleList;
1185 friend class ObjectFile;
1186 friend class SymbolFile;
1190 Module (); // Only used internally by CreateJITModule ()
1193 FindTypes_Impl (const SymbolContext& sc,
1194 const ConstString &name,
1195 const ClangNamespaceDecl *namespace_decl,
1201 DISALLOW_COPY_AND_ASSIGN (Module);
1204 } // namespace lldb_private
1206 #endif // liblldb_Module_h_