LLDB  mainline
Module.h
Go to the documentation of this file.
1 //===-- Module.h ------------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #ifndef LLDB_CORE_MODULE_H
10 #define LLDB_CORE_MODULE_H
11 
12 #include "lldb/Core/Address.h"
13 #include "lldb/Core/ModuleList.h"
14 #include "lldb/Core/ModuleSpec.h"
15 #include "lldb/Symbol/ObjectFile.h"
17 #include "lldb/Symbol/TypeSystem.h"
19 #include "lldb/Target/Statistics.h"
20 #include "lldb/Utility/ArchSpec.h"
22 #include "lldb/Utility/FileSpec.h"
23 #include "lldb/Utility/Status.h"
24 #include "lldb/Utility/UUID.h"
25 #include "lldb/Utility/XcodeSDK.h"
26 #include "lldb/lldb-defines.h"
27 #include "lldb/lldb-enumerations.h"
28 #include "lldb/lldb-forward.h"
29 #include "lldb/lldb-types.h"
30 
31 #include "llvm/ADT/DenseSet.h"
32 #include "llvm/ADT/StringRef.h"
33 #include "llvm/Support/Chrono.h"
34 
35 #include <atomic>
36 #include <cstddef>
37 #include <cstdint>
38 #include <memory>
39 #include <mutex>
40 #include <string>
41 #include <vector>
42 
43 namespace lldb_private {
44 class CompilerDeclContext;
45 class Function;
46 class Log;
47 class ObjectFile;
48 class RegularExpression;
49 class SectionList;
50 class Stream;
51 class Symbol;
52 class SymbolContext;
53 class SymbolContextList;
54 class SymbolFile;
55 class Symtab;
56 class Target;
57 class TypeList;
58 class TypeMap;
59 class VariableList;
60 
61 /// Options used by Module::FindFunctions. This cannot be a nested class
62 /// because it must be forward-declared in ModuleList.h.
64  /// Include the symbol table.
65  bool include_symbols = false;
66  /// Include inlined functions.
67  bool include_inlines = false;
68 };
69 
70 /// \class Module Module.h "lldb/Core/Module.h"
71 /// A class that describes an executable image and its associated
72 /// object and symbol files.
73 ///
74 /// The module is designed to be able to select a single slice of an
75 /// executable image as it would appear on disk and during program execution.
76 ///
77 /// Modules control when and if information is parsed according to which
78 /// accessors are called. For example the object file (ObjectFile)
79 /// representation will only be parsed if the object file is requested using
80 /// the Module::GetObjectFile() is called. The debug symbols will only be
81 /// parsed if the symbol file (SymbolFile) is requested using the
82 /// Module::GetSymbolFile() method.
83 ///
84 /// The module will parse more detailed information as more queries are made.
85 class Module : public std::enable_shared_from_this<Module>,
86  public SymbolContextScope {
87 public:
88  class LookupInfo;
89  // Static functions that can track the lifetime of module objects. This is
90  // handy because we might have Module objects that are in shared pointers
91  // that aren't in the global module list (from ModuleList). If this is the
92  // case we need to know about it. The modules in the global list maintained
93  // by these functions can be viewed using the "target modules list" command
94  // using the "--global" (-g for short).
95  static size_t GetNumberAllocatedModules();
96 
97  static Module *GetAllocatedModuleAtIndex(size_t idx);
98 
99  static std::recursive_mutex &GetAllocationModuleCollectionMutex();
100 
101  /// Construct with file specification and architecture.
102  ///
103  /// Clients that wish to share modules with other targets should use
104  /// ModuleList::GetSharedModule().
105  ///
106  /// \param[in] file_spec
107  /// The file specification for the on disk representation of
108  /// this executable image.
109  ///
110  /// \param[in] arch
111  /// The architecture to set as the current architecture in
112  /// this module.
113  ///
114  /// \param[in] object_name
115  /// The name of an object in a module used to extract a module
116  /// within a module (.a files and modules that contain multiple
117  /// architectures).
118  ///
119  /// \param[in] object_offset
120  /// The offset within an existing module used to extract a
121  /// module within a module (.a files and modules that contain
122  /// multiple architectures).
123  Module(
124  const FileSpec &file_spec, const ArchSpec &arch,
125  const ConstString *object_name = nullptr,
126  lldb::offset_t object_offset = 0,
127  const llvm::sys::TimePoint<> &object_mod_time = llvm::sys::TimePoint<>());
128 
129  Module(const ModuleSpec &module_spec);
130 
131  template <typename ObjFilePlugin, typename... Args>
132  static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args) {
133  // Must create a module and place it into a shared pointer before we can
134  // create an object file since it has a std::weak_ptr back to the module,
135  // so we need to control the creation carefully in this static function
136  lldb::ModuleSP module_sp(new Module());
137  module_sp->m_objfile_sp =
138  std::make_shared<ObjFilePlugin>(module_sp, std::forward<Args>(args)...);
139  module_sp->m_did_load_objfile.store(true, std::memory_order_relaxed);
140 
141  // Once we get the object file, set module ArchSpec to the one we get from
142  // the object file. If the object file does not have an architecture, we
143  // consider the creation a failure.
144  ArchSpec arch = module_sp->m_objfile_sp->GetArchitecture();
145  if (!arch)
146  return nullptr;
147  module_sp->m_arch = arch;
148 
149  // Also copy the object file's FileSpec.
150  module_sp->m_file = module_sp->m_objfile_sp->GetFileSpec();
151  return module_sp;
152  }
153 
154  /// Destructor.
155  ~Module() override;
156 
157  bool MatchesModuleSpec(const ModuleSpec &module_ref);
158 
159  /// Set the load address for all sections in a module to be the file address
160  /// plus \a slide.
161  ///
162  /// Many times a module will be loaded in a target with a constant offset
163  /// applied to all top level sections. This function can set the load
164  /// address for all top level sections to be the section file address +
165  /// offset.
166  ///
167  /// \param[in] target
168  /// The target in which to apply the section load addresses.
169  ///
170  /// \param[in] value
171  /// if \a value_is_offset is true, then value is the offset to
172  /// apply to all file addresses for all top level sections in
173  /// the object file as each section load address is being set.
174  /// If \a value_is_offset is false, then "value" is the new
175  /// absolute base address for the image.
176  ///
177  /// \param[in] value_is_offset
178  /// If \b true, then \a value is an offset to apply to each
179  /// file address of each top level section.
180  /// If \b false, then \a value is the image base address that
181  /// will be used to rigidly slide all loadable sections.
182  ///
183  /// \param[out] changed
184  /// If any section load addresses were changed in \a target,
185  /// then \a changed will be set to \b true. Else \a changed
186  /// will be set to false. This allows this function to be
187  /// called multiple times on the same module for the same
188  /// target. If the module hasn't moved, then \a changed will
189  /// be false and no module updated notification will need to
190  /// be sent out.
191  ///
192  /// \return
193  /// /b True if any sections were successfully loaded in \a target,
194  /// /b false otherwise.
195  bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset,
196  bool &changed);
197 
198  /// \copydoc SymbolContextScope::CalculateSymbolContext(SymbolContext*)
199  ///
200  /// \see SymbolContextScope
201  void CalculateSymbolContext(SymbolContext *sc) override;
202 
203  lldb::ModuleSP CalculateSymbolContextModule() override;
204 
205  void
206  GetDescription(llvm::raw_ostream &s,
208 
209  /// Get the module path and object name.
210  ///
211  /// Modules can refer to object files. In this case the specification is
212  /// simple and would return the path to the file:
213  ///
214  /// "/usr/lib/foo.dylib"
215  ///
216  /// Modules can be .o files inside of a BSD archive (.a file). In this case,
217  /// the object specification will look like:
218  ///
219  /// "/usr/lib/foo.a(bar.o)"
220  ///
221  /// There are many places where logging wants to log this fully qualified
222  /// specification, so we centralize this functionality here.
223  ///
224  /// \return
225  /// The object path + object name if there is one.
227 
228  /// Dump a description of this object to a Stream.
229  ///
230  /// Dump a description of the contents of this object to the supplied stream
231  /// \a s. The dumped content will be only what has been loaded or parsed up
232  /// to this point at which this function is called, so this is a good way to
233  /// see what has been parsed in a module.
234  ///
235  /// \param[in] s
236  /// The stream to which to dump the object description.
237  void Dump(Stream *s);
238 
239  /// \copydoc SymbolContextScope::DumpSymbolContext(Stream*)
240  ///
241  /// \see SymbolContextScope
242  void DumpSymbolContext(Stream *s) override;
243 
244  /// Find a symbol in the object file's symbol table.
245  ///
246  /// \param[in] name
247  /// The name of the symbol that we are looking for.
248  ///
249  /// \param[in] symbol_type
250  /// If set to eSymbolTypeAny, find a symbol of any type that
251  /// has a name that matches \a name. If set to any other valid
252  /// SymbolType enumeration value, then search only for
253  /// symbols that match \a symbol_type.
254  ///
255  /// \return
256  /// Returns a valid symbol pointer if a symbol was found,
257  /// nullptr otherwise.
260 
262  lldb::SymbolType symbol_type,
263  SymbolContextList &sc_list);
264 
266  const RegularExpression &regex, lldb::SymbolType symbol_type,
267  SymbolContextList &sc_list,
268  Mangled::NamePreference mangling_preference = Mangled::ePreferDemangled);
269 
270  /// Find a function symbols in the object file's symbol table.
271  ///
272  /// \param[in] name
273  /// The name of the symbol that we are looking for.
274  ///
275  /// \param[in] name_type_mask
276  /// A mask that has one or more bitwise OR'ed values from the
277  /// lldb::FunctionNameType enumeration type that indicate what
278  /// kind of names we are looking for.
279  ///
280  /// \param[out] sc_list
281  /// A list to append any matching symbol contexts to.
282  void FindFunctionSymbols(ConstString name, uint32_t name_type_mask,
283  SymbolContextList &sc_list);
284 
285  /// Find compile units by partial or full path.
286  ///
287  /// Finds all compile units that match \a path in all of the modules and
288  /// returns the results in \a sc_list.
289  ///
290  /// \param[in] path
291  /// The name of the function we are looking for.
292  ///
293  /// \param[out] sc_list
294  /// A symbol context list that gets filled in with all of the
295  /// matches.
296  void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list);
297 
298  /// Find functions by lookup info.
299  ///
300  /// If the function is an inlined function, it will have a block,
301  /// representing the inlined function, and the function will be the
302  /// containing function. If it is not inlined, then the block will be NULL.
303  ///
304  /// \param[in] lookup_info
305  /// The lookup info of the function we are looking for.
306  ///
307  /// \param[out] sc_list
308  /// A symbol context list that gets filled in with all of the
309  /// matches.
310  void FindFunctions(const LookupInfo &lookup_info,
311  const CompilerDeclContext &parent_decl_ctx,
312  const ModuleFunctionSearchOptions &options,
313  SymbolContextList &sc_list);
314 
315  /// Find functions by name.
316  ///
317  /// If the function is an inlined function, it will have a block,
318  /// representing the inlined function, and the function will be the
319  /// containing function. If it is not inlined, then the block will be NULL.
320  ///
321  /// \param[in] name
322  /// The name of the function we are looking for.
323  ///
324  /// \param[in] name_type_mask
325  /// A bit mask of bits that indicate what kind of names should
326  /// be used when doing the lookup. Bits include fully qualified
327  /// names, base names, C++ methods, or ObjC selectors.
328  /// See FunctionNameType for more details.
329  ///
330  /// \param[out] sc_list
331  /// A symbol context list that gets filled in with all of the
332  /// matches.
333  void FindFunctions(ConstString name,
334  const CompilerDeclContext &parent_decl_ctx,
335  lldb::FunctionNameType name_type_mask,
336  const ModuleFunctionSearchOptions &options,
337  SymbolContextList &sc_list);
338 
339  /// Find functions by name.
340  ///
341  /// If the function is an inlined function, it will have a block,
342  /// representing the inlined function, and the function will be the
343  /// containing function. If it is not inlined, then the block will be NULL.
344  ///
345  /// \param[in] regex
346  /// A regular expression to use when matching the name.
347  ///
348  /// \param[out] sc_list
349  /// A symbol context list that gets filled in with all of the
350  /// matches.
351  void FindFunctions(const RegularExpression &regex,
352  const ModuleFunctionSearchOptions &options,
353  SymbolContextList &sc_list);
354 
355  /// Find addresses by file/line
356  ///
357  /// \param[in] target_sp
358  /// The target the addresses are desired for.
359  ///
360  /// \param[in] file
361  /// Source file to locate.
362  ///
363  /// \param[in] line
364  /// Source line to locate.
365  ///
366  /// \param[in] function
367  /// Optional filter function. Addresses within this function will be
368  /// added to the 'local' list. All others will be added to the 'extern'
369  /// list.
370  ///
371  /// \param[out] output_local
372  /// All matching addresses within 'function'
373  ///
374  /// \param[out] output_extern
375  /// All matching addresses not within 'function'
376  void FindAddressesForLine(const lldb::TargetSP target_sp,
377  const FileSpec &file, uint32_t line,
378  Function *function,
379  std::vector<Address> &output_local,
380  std::vector<Address> &output_extern);
381 
382  /// Find global and static variables by name.
383  ///
384  /// \param[in] name
385  /// The name of the global or static variable we are looking
386  /// for.
387  ///
388  /// \param[in] parent_decl_ctx
389  /// If valid, a decl context that results must exist within
390  ///
391  /// \param[in] max_matches
392  /// Allow the number of matches to be limited to \a
393  /// max_matches. Specify UINT32_MAX to get all possible matches.
394  ///
395  /// \param[in] variable_list
396  /// A list of variables that gets the matches appended to.
397  ///
399  const CompilerDeclContext &parent_decl_ctx,
400  size_t max_matches, VariableList &variable_list);
401 
402  /// Find global and static variables by regular expression.
403  ///
404  /// \param[in] regex
405  /// A regular expression to use when matching the name.
406  ///
407  /// \param[in] max_matches
408  /// Allow the number of matches to be limited to \a
409  /// max_matches. Specify UINT32_MAX to get all possible matches.
410  ///
411  /// \param[in] variable_list
412  /// A list of variables that gets the matches appended to.
413  ///
414  void FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
415  VariableList &variable_list);
416 
417  /// Find types by name.
418  ///
419  /// Type lookups in modules go through the SymbolFile. The SymbolFile needs to
420  /// be able to lookup types by basename and not the fully qualified typename.
421  /// This allows the type accelerator tables to stay small, even with heavily
422  /// templatized C++. The type search will then narrow down the search
423  /// results. If "exact_match" is true, then the type search will only match
424  /// exact type name matches. If "exact_match" is false, the type will match
425  /// as long as the base typename matches and as long as any immediate
426  /// containing namespaces/class scopes that are specified match. So to
427  /// search for a type "d" in "b::c", the name "b::c::d" can be specified and
428  /// it will match any class/namespace "b" which contains a class/namespace
429  /// "c" which contains type "d". We do this to allow users to not always
430  /// have to specify complete scoping on all expressions, but it also allows
431  /// for exact matching when required.
432  ///
433  /// \param[in] type_name
434  /// The name of the type we are looking for that is a fully
435  /// or partially qualified type name.
436  ///
437  /// \param[in] exact_match
438  /// If \b true, \a type_name is fully qualified and must match
439  /// exactly. If \b false, \a type_name is a partially qualified
440  /// name where the leading namespaces or classes can be
441  /// omitted to make finding types that a user may type
442  /// easier.
443  ///
444  /// \param[out] types
445  /// A type list gets populated with any matches.
446  ///
447  void
448  FindTypes(ConstString type_name, bool exact_match, size_t max_matches,
449  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
450  TypeList &types);
451 
452  /// Find types by name.
453  ///
454  /// This behaves like the other FindTypes method but allows to
455  /// specify a DeclContext and a language for the type being searched
456  /// for.
457  ///
458  /// \param searched_symbol_files
459  /// Prevents one file from being visited multiple times.
460  void
461  FindTypes(llvm::ArrayRef<CompilerContext> pattern, LanguageSet languages,
462  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
463  TypeMap &types);
464 
465  lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name,
466  bool exact_match);
467 
468  /// Find types by name that are in a namespace. This function is used by the
469  /// expression parser when searches need to happen in an exact namespace
470  /// scope.
471  ///
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).
475  ///
476  /// \param[out] type_list
477  /// A type list gets populated with any matches.
478  void FindTypesInNamespace(ConstString type_name,
479  const CompilerDeclContext &parent_decl_ctx,
480  size_t max_matches, TypeList &type_list);
481 
482  /// Get const accessor for the module architecture.
483  ///
484  /// \return
485  /// A const reference to the architecture object.
486  const ArchSpec &GetArchitecture() const;
487 
488  /// Get const accessor for the module file specification.
489  ///
490  /// This function returns the file for the module on the host system that is
491  /// running LLDB. This can differ from the path on the platform since we
492  /// might be doing remote debugging.
493  ///
494  /// \return
495  /// A const reference to the file specification object.
496  const FileSpec &GetFileSpec() const { return m_file; }
497 
498  /// Get accessor for the module platform file specification.
499  ///
500  /// Platform file refers to the path of the module as it is known on the
501  /// remote system on which it is being debugged. For local debugging this is
502  /// always the same as Module::GetFileSpec(). But remote debugging might
503  /// mention a file "/usr/lib/liba.dylib" which might be locally downloaded
504  /// and cached. In this case the platform file could be something like:
505  /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib" The
506  /// file could also be cached in a local developer kit directory.
507  ///
508  /// \return
509  /// A const reference to the file specification object.
510  const FileSpec &GetPlatformFileSpec() const {
511  if (m_platform_file)
512  return m_platform_file;
513  return m_file;
514  }
515 
516  void SetPlatformFileSpec(const FileSpec &file) { m_platform_file = file; }
517 
519  return m_remote_install_file;
520  }
521 
522  void SetRemoteInstallFileSpec(const FileSpec &file) {
523  m_remote_install_file = file;
524  }
525 
526  const FileSpec &GetSymbolFileFileSpec() const { return m_symfile_spec; }
527 
528  void PreloadSymbols();
529 
530  void SetSymbolFileFileSpec(const FileSpec &file);
531 
532  const llvm::sys::TimePoint<> &GetModificationTime() const {
533  return m_mod_time;
534  }
535 
536  const llvm::sys::TimePoint<> &GetObjectModificationTime() const {
537  return m_object_mod_time;
538  }
539 
540  /// This callback will be called by SymbolFile implementations when
541  /// parsing a compile unit that contains SDK information.
542  /// \param sysroot will be added to the path remapping dictionary.
543  void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot);
544 
545  /// Tells whether this module is capable of being the main executable for a
546  /// process.
547  ///
548  /// \return
549  /// \b true if it is, \b false otherwise.
550  bool IsExecutable();
551 
552  /// Tells whether this module has been loaded in the target passed in. This
553  /// call doesn't distinguish between whether the module is loaded by the
554  /// dynamic loader, or by a "target module add" type call.
555  ///
556  /// \param[in] target
557  /// The target to check whether this is loaded in.
558  ///
559  /// \return
560  /// \b true if it is, \b false otherwise.
561  bool IsLoadedInTarget(Target *target);
562 
564  Stream *feedback_stream = nullptr);
565 
566  /// Get the number of compile units for this module.
567  ///
568  /// \return
569  /// The number of compile units that the symbol vendor plug-in
570  /// finds.
571  size_t GetNumCompileUnits();
572 
573  lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx);
574 
575  ConstString GetObjectName() const;
576 
577  uint64_t GetObjectOffset() const { return m_object_offset; }
578 
579  /// Get the object file representation for the current architecture.
580  ///
581  /// If the object file has not been located or parsed yet, this function
582  /// will find the best ObjectFile plug-in that can parse Module::m_file.
583  ///
584  /// \return
585  /// If Module::m_file does not exist, or no plug-in was found
586  /// that can parse the file, or the object file doesn't contain
587  /// the current architecture in Module::m_arch, nullptr will be
588  /// returned, else a valid object file interface will be
589  /// returned. The returned pointer is owned by this object and
590  /// remains valid as long as the object is around.
591  virtual ObjectFile *GetObjectFile();
592 
593  /// Get the unified section list for the module. This is the section list
594  /// created by the module's object file and any debug info and symbol files
595  /// created by the symbol vendor.
596  ///
597  /// If the symbol vendor has not been loaded yet, this function will return
598  /// the section list for the object file.
599  ///
600  /// \return
601  /// Unified module section list.
602  virtual SectionList *GetSectionList();
603 
604  /// Notify the module that the file addresses for the Sections have been
605  /// updated.
606  ///
607  /// If the Section file addresses for a module are updated, this method
608  /// should be called. Any parts of the module, object file, or symbol file
609  /// that has cached those file addresses must invalidate or update its
610  /// cache.
611  virtual void SectionFileAddressesChanged();
612 
613  /// Returns a reference to the UnwindTable for this Module
614  ///
615  /// The UnwindTable contains FuncUnwinders objects for any function in this
616  /// Module. If a FuncUnwinders object hasn't been created yet (i.e. the
617  /// function has yet to be unwound in a stack walk), it will be created when
618  /// requested. Specifically, we do not create FuncUnwinders objects for
619  /// functions until they are needed.
620  ///
621  /// \return
622  /// Returns the unwind table for this module. If this object has no
623  /// associated object file, an empty UnwindTable is returned.
625 
626  llvm::VersionTuple GetVersion();
627 
628  /// Load an object file from memory.
629  ///
630  /// If available, the size of the object file in memory may be passed to
631  /// avoid additional round trips to process memory. If the size is not
632  /// provided, a default value is used. This value should be large enough to
633  /// enable the ObjectFile plugins to read the header of the object file
634  /// without going back to the process.
635  ///
636  /// \return
637  /// The object file loaded from memory or nullptr, if the operation
638  /// failed (see the `error` for more information in that case).
639  ObjectFile *GetMemoryObjectFile(const lldb::ProcessSP &process_sp,
640  lldb::addr_t header_addr, Status &error,
641  size_t size_to_read = 512);
642 
643  /// Get the module's symbol file
644  ///
645  /// If the symbol file has already been loaded, this function returns it. All
646  /// arguments are ignored. If the symbol file has not been located yet, and
647  /// the can_create argument is false, the function returns nullptr. If
648  /// can_create is true, this function will find the best SymbolFile plug-in
649  /// that can use the current object file. feedback_strm, if not null, is used
650  /// to report the details of the search process.
651  virtual SymbolFile *GetSymbolFile(bool can_create = true,
652  Stream *feedback_strm = nullptr);
653 
654  Symtab *GetSymtab();
655 
656  /// Get a reference to the UUID value contained in this object.
657  ///
658  /// If the executable image file doesn't not have a UUID value built into
659  /// the file format, an MD5 checksum of the entire file, or slice of the
660  /// file for the current architecture should be used.
661  ///
662  /// \return
663  /// A const pointer to the internal copy of the UUID value in
664  /// this module if this module has a valid UUID value, NULL
665  /// otherwise.
666  const lldb_private::UUID &GetUUID();
667 
668  /// A debugging function that will cause everything in a module to
669  /// be parsed.
670  ///
671  /// All compile units will be parsed, along with all globals and static
672  /// variables and all functions for those compile units. All types, scopes,
673  /// local variables, static variables, global variables, and line tables
674  /// will be parsed. This can be used prior to dumping a module to see a
675  /// complete list of the resulting debug information that gets parsed, or as
676  /// a debug function to ensure that the module can consume all of the debug
677  /// data the symbol vendor provides.
678  void ParseAllDebugSymbols();
679 
680  bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr);
681 
682  /// Resolve the symbol context for the given address.
683  ///
684  /// Tries to resolve the matching symbol context based on a lookup from the
685  /// current symbol vendor. If the lazy lookup fails, an attempt is made to
686  /// parse the eh_frame section to handle stripped symbols. If this fails,
687  /// an attempt is made to resolve the symbol to the previous address to
688  /// handle the case of a function with a tail call.
689  ///
690  /// Use properties of the modified SymbolContext to inspect any resolved
691  /// target, module, compilation unit, symbol, function, function block or
692  /// line entry. Use the return value to determine which of these properties
693  /// have been modified.
694  ///
695  /// \param[in] so_addr
696  /// A load address to resolve.
697  ///
698  /// \param[in] resolve_scope
699  /// The scope that should be resolved (see SymbolContext::Scope).
700  /// A combination of flags from the enumeration SymbolContextItem
701  /// requesting a resolution depth. Note that the flags that are
702  /// actually resolved may be a superset of the requested flags.
703  /// For instance, eSymbolContextSymbol requires resolution of
704  /// eSymbolContextModule, and eSymbolContextFunction requires
705  /// eSymbolContextSymbol.
706  ///
707  /// \param[out] sc
708  /// The SymbolContext that is modified based on symbol resolution.
709  ///
710  /// \param[in] resolve_tail_call_address
711  /// Determines if so_addr should resolve to a symbol in the case
712  /// of a function whose last instruction is a call. In this case,
713  /// the PC can be one past the address range of the function.
714  ///
715  /// \return
716  /// The scope that has been resolved (see SymbolContext::Scope).
717  ///
718  /// \see SymbolContext::Scope
720  const Address &so_addr, lldb::SymbolContextItem resolve_scope,
721  SymbolContext &sc, bool resolve_tail_call_address = false);
722 
723  /// Resolve items in the symbol context for a given file and line.
724  ///
725  /// Tries to resolve \a file_path and \a line to a list of matching symbol
726  /// contexts.
727  ///
728  /// The line table entries contains addresses that can be used to further
729  /// resolve the values in each match: the function, block, symbol. Care
730  /// should be taken to minimize the amount of information that is requested
731  /// to only what is needed -- typically the module, compile unit, line table
732  /// and line table entry are sufficient.
733  ///
734  /// \param[in] file_path
735  /// A path to a source file to match. If \a file_path does not
736  /// specify a directory, then this query will match all files
737  /// whose base filename matches. If \a file_path does specify
738  /// a directory, the fullpath to the file must match.
739  ///
740  /// \param[in] line
741  /// The source line to match, or zero if just the compile unit
742  /// should be resolved.
743  ///
744  /// \param[in] check_inlines
745  /// Check for inline file and line number matches. This option
746  /// should be used sparingly as it will cause all line tables
747  /// for every compile unit to be parsed and searched for
748  /// matching inline file entries.
749  ///
750  /// \param[in] resolve_scope
751  /// The scope that should be resolved (see
752  /// SymbolContext::Scope).
753  ///
754  /// \param[out] sc_list
755  /// A symbol context list that gets matching symbols contexts
756  /// appended to.
757  ///
758  /// \return
759  /// The number of matches that were added to \a sc_list.
760  ///
761  /// \see SymbolContext::Scope
763  const char *file_path, uint32_t line, bool check_inlines,
764  lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
765 
766  /// Resolve items in the symbol context for a given file and line.
767  ///
768  /// Tries to resolve \a file_spec and \a line to a list of matching symbol
769  /// contexts.
770  ///
771  /// The line table entries contains addresses that can be used to further
772  /// resolve the values in each match: the function, block, symbol. Care
773  /// should be taken to minimize the amount of information that is requested
774  /// to only what is needed -- typically the module, compile unit, line table
775  /// and line table entry are sufficient.
776  ///
777  /// \param[in] file_spec
778  /// A file spec to a source file to match. If \a file_path does
779  /// not specify a directory, then this query will match all
780  /// files whose base filename matches. If \a file_path does
781  /// specify a directory, the fullpath to the file must match.
782  ///
783  /// \param[in] line
784  /// The source line to match, or zero if just the compile unit
785  /// should be resolved.
786  ///
787  /// \param[in] check_inlines
788  /// Check for inline file and line number matches. This option
789  /// should be used sparingly as it will cause all line tables
790  /// for every compile unit to be parsed and searched for
791  /// matching inline file entries.
792  ///
793  /// \param[in] resolve_scope
794  /// The scope that should be resolved (see
795  /// SymbolContext::Scope).
796  ///
797  /// \param[out] sc_list
798  /// A symbol context list that gets filled in with all of the
799  /// matches.
800  ///
801  /// \return
802  /// A integer that contains SymbolContext::Scope bits set for
803  /// each item that was successfully resolved.
804  ///
805  /// \see SymbolContext::Scope
807  const FileSpec &file_spec, uint32_t line, bool check_inlines,
808  lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
809 
810  void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name);
811 
812  bool GetIsDynamicLinkEditor();
813 
814  llvm::Expected<TypeSystem &>
816 
817  // Special error functions that can do printf style formatting that will
818  // prepend the message with something appropriate for this module (like the
819  // architecture, path and object name (if any)). This centralizes code so
820  // that everyone doesn't need to format their error and log messages on their
821  // own and keeps the output a bit more consistent.
822  void LogMessage(Log *log, const char *format, ...)
823  __attribute__((format(printf, 3, 4)));
824 
825  void LogMessageVerboseBacktrace(Log *log, const char *format, ...)
826  __attribute__((format(printf, 3, 4)));
827 
828  void ReportWarning(const char *format, ...)
829  __attribute__((format(printf, 2, 3)));
830 
831  void ReportError(const char *format, ...)
832  __attribute__((format(printf, 2, 3)));
833 
834  // Only report an error once when the module is first detected to be modified
835  // so we don't spam the console with many messages.
836  void ReportErrorIfModifyDetected(const char *format, ...)
837  __attribute__((format(printf, 2, 3)));
838 
839  void ReportWarningOptimization(llvm::Optional<lldb::user_id_t> debugger_id);
840 
841  void
843  llvm::Optional<lldb::user_id_t> debugger_id);
844 
845  // Return true if the file backing this module has changed since the module
846  // was originally created since we saved the initial file modification time
847  // when the module first gets created.
848  bool FileHasChanged() const;
849 
850  // SymbolFile and ObjectFile member objects should lock the
851  // module mutex to avoid deadlocks.
852  std::recursive_mutex &GetMutex() const { return m_mutex; }
853 
855 
857  return m_source_mappings;
858  }
859 
860  /// Finds a source file given a file spec using the module source path
861  /// remappings (if any).
862  ///
863  /// Tries to resolve \a orig_spec by checking the module source path
864  /// remappings. It makes sure the file exists, so this call can be expensive
865  /// if the remappings are on a network file system, so use this function
866  /// sparingly (not in a tight debug info parsing loop).
867  ///
868  /// \param[in] orig_spec
869  /// The original source file path to try and remap.
870  ///
871  /// \param[out] new_spec
872  /// The newly remapped filespec that is guaranteed to exist.
873  ///
874  /// \return
875  /// /b true if \a orig_spec was successfully located and
876  /// \a new_spec is filled in with an existing file spec,
877  /// \b false otherwise.
878  bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
879 
880  /// Remaps a source file given \a path into \a new_path.
881  ///
882  /// Remaps \a path if any source remappings match. This function does NOT
883  /// stat the file system so it can be used in tight loops where debug info
884  /// is being parsed.
885  ///
886  /// \param[in] path
887  /// The original source file path to try and remap.
888  ///
889  /// \return
890  /// The newly remapped filespec that is may or may not exist if
891  /// \a path was successfully located.
892  llvm::Optional<std::string> RemapSourceFile(llvm::StringRef path) const;
893  bool RemapSourceFile(const char *, std::string &) const = delete;
894 
895  /// Update the ArchSpec to a more specific variant.
896  bool MergeArchitecture(const ArchSpec &arch_spec);
897 
898  /// Accessor for the symbol table parse time metric.
899  ///
900  /// The value is returned as a reference to allow it to be updated by the
901  /// ElapsedTime RAII object.
903 
904  /// Accessor for the symbol table index time metric.
905  ///
906  /// The value is returned as a reference to allow it to be updated by the
907  /// ElapsedTime RAII object.
909 
910  /// \class LookupInfo Module.h "lldb/Core/Module.h"
911  /// A class that encapsulates name lookup information.
912  ///
913  /// Users can type a wide variety of partial names when setting breakpoints
914  /// by name or when looking for functions by name. The SymbolFile object is
915  /// only required to implement name lookup for function basenames and for
916  /// fully mangled names. This means if the user types in a partial name, we
917  /// must reduce this to a name lookup that will work with all SymbolFile
918  /// objects. So we might reduce a name lookup to look for a basename, and then
919  /// prune out any results that don't match.
920  ///
921  /// The "m_name" member variable represents the name as it was typed by the
922  /// user. "m_lookup_name" will be the name we actually search for through
923  /// the symbol or objects files. Lanaguage is included in case we need to
924  /// filter results by language at a later date. The "m_name_type_mask"
925  /// member variable tells us what kinds of names we are looking for and can
926  /// help us prune out unwanted results.
927  ///
928  /// Function lookups are done in Module.cpp, ModuleList.cpp and in
929  /// BreakpointResolverName.cpp and they all now use this class to do lookups
930  /// correctly.
931  class LookupInfo {
932  public:
933  LookupInfo() = default;
934 
935  LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask,
936  lldb::LanguageType language);
937 
938  ConstString GetName() const { return m_name; }
939 
940  void SetName(ConstString name) { m_name = name; }
941 
943 
944  void SetLookupName(ConstString name) { m_lookup_name = name; }
945 
946  lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; }
947 
948  void SetNameTypeMask(lldb::FunctionNameType mask) {
949  m_name_type_mask = mask;
950  }
951 
953 
955  ConstString function_name,
956  lldb::LanguageType language_type = lldb::eLanguageTypeUnknown) const;
957 
958  void Prune(SymbolContextList &sc_list, size_t start_idx) const;
959 
960  protected:
961  /// What the user originally typed
963 
964  /// The actual name will lookup when calling in the object or symbol file
966 
967  /// Limit matches to only be for this language
969 
970  /// One or more bits from lldb::FunctionNameType that indicate what kind of
971  /// names we are looking for
972  lldb::FunctionNameType m_name_type_mask = lldb::eFunctionNameTypeNone;
973 
974  ///< If \b true, then demangled names that match will need to contain
975  ///< "m_name" in order to be considered a match
977  };
978 
979  /// Get a unique hash for this module.
980  ///
981  /// The hash should be enough to identify the file on disk and the
982  /// architecture of the file. If the module represents an object inside of a
983  /// file, then the hash should include the object name and object offset to
984  /// ensure a unique hash. Some examples:
985  /// - just a regular object file (mach-o, elf, coff, etc) should create a hash
986  /// - a universal mach-o file that contains to multiple architectures,
987  /// each architecture slice should have a unique hash even though they come
988  /// from the same file
989  /// - a .o file inside of a BSD archive. Each .o file will have an object name
990  /// and object offset that should produce a unique hash. The object offset
991  /// is needed as BSD archive files can contain multiple .o files that have
992  /// the same name.
993  uint32_t Hash();
994 
995  /// Get a unique cache key for the current module.
996  ///
997  /// The cache key must be unique for a file on disk and not change if the file
998  /// is updated. This allows cache data to use this key as a prefix and as
999  /// files are modified in disk, we will overwrite the cache files. If one file
1000  /// can contain multiple files, like a universal mach-o file or like a BSD
1001  /// archive, the cache key must contain enough information to differentiate
1002  /// these different files.
1004 
1005  /// Get the global index file cache.
1006  ///
1007  /// LLDB can cache data for a module between runs. This cache directory can be
1008  /// used to stored data that previously was manually created each time you debug.
1009  /// Examples include debug information indexes, symbol tables, symbol table
1010  /// indexes, and more.
1011  ///
1012  /// \returns
1013  /// If caching is enabled in the lldb settings, return a pointer to the data
1014  /// file cache. If caching is not enabled, return NULL.
1015  static DataFileCache *GetIndexCache();
1016 protected:
1017  // Member Variables
1018  mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
1019  /// in multi-threaded environments.
1020 
1021  /// The modification time for this module when it was created.
1022  llvm::sys::TimePoint<> m_mod_time;
1023 
1024  ArchSpec m_arch; ///< The architecture for this module.
1025  UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
1026  /// match it up to debug symbols.
1027  FileSpec m_file; ///< The file representation on disk for this module (if
1028  /// there is one).
1029  FileSpec m_platform_file; ///< The path to the module on the platform on which
1030  /// it is being debugged
1031  FileSpec m_remote_install_file; ///< If set when debugging on remote
1032  /// platforms, this module will be installed
1033  /// at this location
1034  FileSpec m_symfile_spec; ///< If this path is valid, then this is the file
1035  /// that _will_ be used as the symbol file for this
1036  /// module
1037  ConstString m_object_name; ///< The name an object within this module that is
1038  /// selected, or empty of the module is represented
1039  /// by \a m_file.
1040  uint64_t m_object_offset = 0;
1041  llvm::sys::TimePoint<> m_object_mod_time;
1042 
1043  /// DataBuffer containing the module image, if it was provided at
1044  /// construction time. Otherwise the data will be retrieved by mapping
1045  /// one of the FileSpec members above.
1046  lldb::DataBufferSP m_data_sp;
1047 
1048  lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
1049  /// parser for this module as it may or may
1050  /// not be shared with the SymbolFile
1051  llvm::Optional<UnwindTable> m_unwind_table; ///< Table of FuncUnwinders
1052  /// objects created for this
1053  /// Module's functions
1054  lldb::SymbolVendorUP
1055  m_symfile_up; ///< A pointer to the symbol vendor for this module.
1056  std::vector<lldb::SymbolVendorUP>
1057  m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
1058  /// changes the symbol file,
1059  ///< we need to keep all old symbol files around in case anyone has type
1060  /// references to them
1061  TypeSystemMap m_type_system_map; ///< A map of any type systems associated
1062  /// with this module
1063  /// Module specific source remappings for when you have debug info for a
1064  /// module that doesn't match where the sources currently are.
1067 
1068  lldb::SectionListUP m_sections_up; ///< Unified section list for module that
1069  /// is used by the ObjectFile and and
1070  /// ObjectFile instances for the debug info
1071 
1072  std::atomic<bool> m_did_load_objfile{false};
1073  std::atomic<bool> m_did_load_symfile{false};
1074  std::atomic<bool> m_did_set_uuid{false};
1075  mutable bool m_file_has_changed : 1,
1076  m_first_file_changed_log : 1; /// See if the module was modified after it
1077  /// was initially opened.
1078  /// We store a symbol table parse time duration here because we might have
1079  /// an object file and a symbol file which both have symbol tables. The parse
1080  /// time for the symbol tables can be aggregated here.
1082  /// We store a symbol named index time duration here because we might have
1083  /// an object file and a symbol file which both have symbol tables. The parse
1084  /// time for the symbol tables can be aggregated here.
1086 
1087  std::once_flag m_optimization_warning;
1088  std::once_flag m_language_warning;
1089 
1090  /// Resolve a file or load virtual address.
1091  ///
1092  /// Tries to resolve \a vm_addr as a file address (if \a
1093  /// vm_addr_is_file_addr is true) or as a load address if \a
1094  /// vm_addr_is_file_addr is false) in the symbol vendor. \a resolve_scope
1095  /// indicates what clients wish to resolve and can be used to limit the
1096  /// scope of what is parsed.
1097  ///
1098  /// \param[in] vm_addr
1099  /// The load virtual address to resolve.
1100  ///
1101  /// \param[in] vm_addr_is_file_addr
1102  /// If \b true, \a vm_addr is a file address, else \a vm_addr
1103  /// if a load address.
1104  ///
1105  /// \param[in] resolve_scope
1106  /// The scope that should be resolved (see
1107  /// SymbolContext::Scope).
1108  ///
1109  /// \param[out] so_addr
1110  /// The section offset based address that got resolved if
1111  /// any bits are returned.
1112  ///
1113  /// \param[out] sc
1114  // The symbol context that has objects filled in. Each bit
1115  /// in the \a resolve_scope pertains to a member in the \a sc.
1116  ///
1117  /// \return
1118  /// A integer that contains SymbolContext::Scope bits set for
1119  /// each item that was successfully resolved.
1120  ///
1121  /// \see SymbolContext::Scope
1123  bool vm_addr_is_file_addr,
1124  lldb::SymbolContextItem resolve_scope,
1125  Address &so_addr, SymbolContext &sc);
1126 
1128  std::vector<uint32_t> &symbol_indexes,
1129  SymbolContextList &sc_list);
1130 
1131  bool SetArchitecture(const ArchSpec &new_arch);
1132 
1133  void SetUUID(const lldb_private::UUID &uuid);
1134 
1136 
1137  friend class ModuleList;
1138  friend class ObjectFile;
1139  friend class SymbolFile;
1140 
1141 private:
1142  Module(); // Only used internally by CreateJITModule ()
1143 
1144  void FindTypes_Impl(
1145  ConstString name, const CompilerDeclContext &parent_decl_ctx,
1146  size_t max_matches,
1147  llvm::DenseSet<lldb_private::SymbolFile *> &searched_symbol_files,
1148  TypeMap &types);
1149 
1150  Module(const Module &) = delete;
1151  const Module &operator=(const Module &) = delete;
1152 };
1153 
1154 } // namespace lldb_private
1155 
1156 #endif // LLDB_CORE_MODULE_H
lldb_private::Module::SymbolIndicesToSymbolContextList
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
Definition: Module.cpp:1345
lldb_private::UUID
Definition: UUID.h:23
lldb_private::Module::GetObjectFile
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition: Module.cpp:1263
lldb_private::SymbolFile
Provides public interface for all SymbolFiles.
Definition: SymbolFile.h:46
lldb_private::ModuleList::GetGlobalModuleListProperties
static ModuleListProperties & GetGlobalModuleListProperties()
Definition: ModuleList.cpp:760
lldb_private::Module::GetSourceMappingList
PathMappingList & GetSourceMappingList()
Definition: Module.h:854
llvm
Definition: Debugger.h:50
lldb_private::ArchSpec
Definition: ArchSpec.h:32
lldb_private::Module::GetSymtabIndexTime
StatsDuration & GetSymtabIndexTime()
Accessor for the symbol table index time metric.
Definition: Module.h:908
lldb_private::RegularExpression
Definition: RegularExpression.h:18
lldb_private::Module::GetSymtabParseTime
StatsDuration & GetSymtabParseTime()
Accessor for the symbol table parse time metric.
Definition: Module.h:902
lldb_private::Module::CalculateSymbolContext
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition: Module.cpp:405
lldb_private::Module::m_file_has_changed
bool m_file_has_changed
Definition: Module.h:1075
lldb_private::Module::FileHasChanged
bool FileHasChanged() const
Definition: Module.cpp:1113
lldb_private::ModuleListProperties::GetSymlinkMappings
PathMappingList GetSymlinkMappings() const
Definition: ModuleList.cpp:184
lldb_private::Module::m_symfile_up
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
Definition: Module.h:1055
ModuleSpec.h
lldb_private::Module::GetIsDynamicLinkEditor
bool GetIsDynamicLinkEditor()
Definition: Module.cpp:1681
lldb_private::Symbol
Definition: Symbol.h:20
lldb_private::Module::m_unwind_table
llvm::Optional< UnwindTable > m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
Definition: Module.h:1051
UUID.h
lldb_private::Module::GetIndexCache
static DataFileCache * GetIndexCache()
Get the global index file cache.
Definition: Module.cpp:1714
lldb_private::Module::GetTypeSystemForLanguage
llvm::Expected< TypeSystem & > GetTypeSystemForLanguage(lldb::LanguageType language)
Definition: Module.cpp:368
lldb-defines.h
lldb_private::Module::GetSymtab
Symtab * GetSymtab()
Definition: Module.cpp:1064
lldb_private::Module::GetSymbolFileFileSpec
const FileSpec & GetSymbolFileFileSpec() const
Definition: Module.h:526
lldb_private::Module::ParseAllDebugSymbols
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
Definition: Module.cpp:372
lldb_private::Module::m_platform_file
FileSpec m_platform_file
The path to the module on the platform on which it is being debugged.
Definition: Module.h:1029
lldb_private::Module::m_objfile_sp
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 Sy...
Definition: Module.h:1048
__attribute__
__attribute__((always_inline)) int uuid_is_null(uuid_t uuid)
Definition: UuidCompatibility.h:18
lldb_private::Module::FindGlobalVariables
void FindGlobalVariables(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, VariableList &variable_list)
Find global and static variables by name.
Definition: Module.cpp:605
lldb_private::Module::LookupInfo::m_name
ConstString m_name
What the user originally typed.
Definition: Module.h:962
lldb_private::Module::LookupInfo::SetName
void SetName(ConstString name)
Definition: Module.h:940
lldb_private::Module::MergeArchitecture
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
Definition: Module.cpp:1655
lldb_private::Module::ReportWarningUnsupportedLanguage
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, llvm::Optional< lldb::user_id_t > debugger_id)
Definition: Module.cpp:1138
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::Module::GetSymbolFile
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition: Module.cpp:1048
lldb_private::Module
Definition: Module.h:85
lldb_private::UnwindTable
Definition: UnwindTable.h:23
lldb_private::Module::Hash
uint32_t Hash()
Get a unique hash for this module.
Definition: Module.cpp:1690
lldb_private::Module::FindTypes_Impl
void FindTypes_Impl(ConstString name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeMap &types)
Definition: Module.cpp:953
lldb_private::SectionList
Definition: Section.h:34
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb_private::Module::m_symtab_parse_time
StatsDuration m_symtab_parse_time
See if the module was modified after it was initially opened.
Definition: Module.h:1081
lldb_private::Stream
Definition: Stream.h:28
lldb_private::Args
Definition: Args.h:33
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ModuleFunctionSearchOptions::include_symbols
bool include_symbols
Include the symbol table.
Definition: Module.h:65
lldb_private::Module::m_optimization_warning
std::once_flag m_optimization_warning
Definition: Module.h:1087
lldb_private::Module::RegisterXcodeSDK
void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot)
This callback will be called by SymbolFile implementations when parsing a compile unit that contains ...
Definition: Module.cpp:1642
lldb_private::Module::SetPlatformFileSpec
void SetPlatformFileSpec(const FileSpec &file)
Definition: Module.h:516
lldb_private::StatsDuration
Definition: Statistics.h:27
lldb_private::Module::FindFirstType
lldb::TypeSP FindFirstType(const SymbolContext &sc, ConstString type_name, bool exact_match)
Definition: Module.cpp:977
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::Module::~Module
~Module() override
Destructor.
Definition: Module.cpp:265
lldb_private::Module::CalculateSymbolContextModule
lldb::ModuleSP CalculateSymbolContextModule() override
Definition: Module.cpp:409
lldb_private::Module::SetFileSpecAndObjectName
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
Definition: Module.cpp:1070
lldb_private::Module::ResolveSymbolContextForFilePath
uint32_t ResolveSymbolContextForFilePath(const char *file_path, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve items in the symbol context for a given file and line.
Definition: Module.cpp:575
lldb_private::Module::ReportError
void void void void ReportError(const char *format,...) __attribute__((format(printf
Definition: Module.cpp:1178
lldb_private::VariableList
Definition: VariableList.h:18
XcodeSDK.h
lldb_private::Module::ReportErrorIfModifyDetected
void void void void void ReportErrorIfModifyDetected(const char *format,...) __attribute__((format(printf
Definition: Module.cpp:1149
lldb_private::Module::LookupInfo::SetNameTypeMask
void SetNameTypeMask(lldb::FunctionNameType mask)
Definition: Module.h:948
lldb_private::Module::GetAllocatedModuleAtIndex
static Module * GetAllocatedModuleAtIndex(size_t idx)
Definition: Module.cpp:123
lldb_private::Module::LookupInfo::m_language
lldb::LanguageType m_language
Limit matches to only be for this language.
Definition: Module.h:968
lldb_private::ModuleFunctionSearchOptions::include_inlines
bool include_inlines
Include inlined functions.
Definition: Module.h:67
lldb_private::Module::ReportWarningOptimization
void void void void void void ReportWarningOptimization(llvm::Optional< lldb::user_id_t > debugger_id)
Definition: Module.cpp:1124
lldb_private::Module::FindTypesInNamespace
void FindTypesInNamespace(ConstString type_name, const CompilerDeclContext &parent_decl_ctx, size_t max_matches, TypeList &type_list)
Find types by name that are in a namespace.
Definition: Module.cpp:963
lldb_private::Module::SetRemoteInstallFileSpec
void SetRemoteInstallFileSpec(const FileSpec &file)
Definition: Module.h:522
lldb_private::Module::GetPlatformFileSpec
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition: Module.h:510
lldb_private::Module::m_did_load_symfile
std::atomic< bool > m_did_load_symfile
Definition: Module.h:1073
lldb_private::Module::SetSymbolFileFileSpec
void SetSymbolFileFileSpec(const FileSpec &file)
Definition: Module.cpp:1416
lldb_private::Module::GetFileSpec
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition: Module.h:496
lldb_private::Module::LookupInfo
Definition: Module.h:931
lldb_private::Module::m_sections_up
lldb::SectionListUP m_sections_up
Unified section list for module that is used by the ObjectFile and and ObjectFile instances for the d...
Definition: Module.h:1068
lldb_private::FileSpec
Definition: FileSpec.h:55
lldb_private::Module::LogMessageVerboseBacktrace
void void LogMessageVerboseBacktrace(Log *log, const char *format,...) __attribute__((format(printf
Definition: Module.cpp:1221
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb::eSymbolTypeAny
@ eSymbolTypeAny
Definition: lldb-enumerations.h:619
lldb_private::Module::LookupInfo::NameMatchesLookupInfo
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
Definition: Module.cpp:731
lldb_private::Function
Definition: Function.h:409
lldb_private::Module::LookupInfo::GetLanguageType
lldb::LanguageType GetLanguageType() const
Definition: Module.h:952
ModuleList.h
lldb_private::Module::GetDescription
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition: Module.cpp:1091
lldb_private::ModuleList
Definition: ModuleList.h:82
lldb_private::Module::m_uuid
UUID m_uuid
Each module is assumed to have a unique identifier to help match it up to debug symbols.
Definition: Module.h:1025
lldb_private::Module::m_object_name
ConstString m_object_name
The name an object within this module that is selected, or empty of the module is represented by m_fi...
Definition: Module.h:1037
lldb_private::Module::CreateModuleFromObjectFile
static lldb::ModuleSP CreateModuleFromObjectFile(Args &&...args)
Definition: Module.h:132
lldb_private::Module::m_object_mod_time
llvm::sys::TimePoint m_object_mod_time
Definition: Module.h:1041
lldb_private::Module::m_language_warning
std::once_flag m_language_warning
Definition: Module.h:1088
lldb_private::Module::LookupInfo::m_name_type_mask
lldb::FunctionNameType m_name_type_mask
One or more bits from lldb::FunctionNameType that indicate what kind of names we are looking for.
Definition: Module.h:972
lldb_private::Module::FindSymbolsMatchingRegExAndType
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list, Mangled::NamePreference mangling_preference=Mangled::ePreferDemangled)
Definition: Module.cpp:1383
lldb_private::Module::LookupInfo::GetName
ConstString GetName() const
Definition: Module.h:938
lldb_private::Module::GetObjectOffset
uint64_t GetObjectOffset() const
Definition: Module.h:577
lldb_private::Module::ResolveSymbolContextsForFileSpec
uint32_t ResolveSymbolContextsForFileSpec(const FileSpec &file_spec, uint32_t line, bool check_inlines, lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list)
Resolve items in the symbol context for a given file and line.
Definition: Module.cpp:583
lldb_private::TypeSystemMap
Definition: TypeSystem.h:514
lldb_private::NameMatch::RegularExpression
@ RegularExpression
lldb_private::Module::GetUnifiedSectionList
SectionList * GetUnifiedSectionList()
Definition: Module.cpp:1329
lldb_private::Module::ResolveFileAddress
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition: Module.cpp:436
SymbolContextScope.h
lldb_private::Module::GetVersion
llvm::VersionTuple GetVersion()
Definition: Module.cpp:1675
lldb_private::ConstString
Definition: ConstString.h:39
lldb_private::Module::SectionFileAddressesChanged
virtual void SectionFileAddressesChanged()
Notify the module that the file addresses for the Sections have been updated.
Definition: Module.cpp:1312
lldb_private::Module::LoadScriptingResourceInTarget
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream *feedback_stream=nullptr)
Definition: Module.cpp:1506
lldb_private::Module::LogMessage
void LogMessage(Log *log, const char *format,...) __attribute__((format(printf
Definition: Module.cpp:1208
lldb::eDescriptionLevelFull
@ eDescriptionLevelFull
Definition: lldb-enumerations.h:209
lldb-enumerations.h
lldb_private::Module::LookupInfo::SetLookupName
void SetLookupName(ConstString name)
Definition: Module.h:944
lldb_private::Module::GetMemoryObjectFile
ObjectFile * GetMemoryObjectFile(const lldb::ProcessSP &process_sp, lldb::addr_t header_addr, Status &error, size_t size_to_read=512)
Load an object file from memory.
Definition: Module.cpp:295
lldb_private::Module::GetObjectName
ConstString GetObjectName() const
Definition: Module.cpp:1261
lldb_private::Module::SetLoadAddress
bool SetLoadAddress(Target &target, lldb::addr_t value, bool value_is_offset, bool &changed)
Set the load address for all sections in a module to be the file address plus slide.
Definition: Module.cpp:1581
lldb_private::Module::m_remote_install_file
FileSpec m_remote_install_file
If set when debugging on remote platforms, this module will be installed at this location.
Definition: Module.h:1031
lldb_private::Module::FindFunctions
void FindFunctions(const LookupInfo &lookup_info, const CompilerDeclContext &parent_decl_ctx, const ModuleFunctionSearchOptions &options, SymbolContextList &sc_list)
Find functions by lookup info.
Definition: Module.cpp:825
lldb_private::Module::ReportWarning
void void void ReportWarning(const char *format,...) __attribute__((format(printf
Definition: Module.cpp:1193
string
string(SUBSTRING ${p} 10 -1 pStripped) if($
Definition: Plugins/CMakeLists.txt:40
lldb_private::Module::m_data_sp
lldb::DataBufferSP m_data_sp
DataBuffer containing the module image, if it was provided at construction time.
Definition: Module.h:1046
lldb_private::Module::m_first_file_changed_log
bool m_first_file_changed_log
Definition: Module.h:1076
lldb_private::Module::GetMutex
std::recursive_mutex & GetMutex() const
Definition: Module.h:852
TypeSystem.h
lldb_private::Module::GetUnwindTable
UnwindTable & GetUnwindTable()
Returns a reference to the UnwindTable for this Module.
Definition: Module.cpp:1320
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:618
lldb_private::Module::m_mod_time
llvm::sys::TimePoint m_mod_time
The modification time for this module when it was created.
Definition: Module.h:1022
Address.h
lldb_private::TypeMap
Definition: TypeMap.h:20
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
lldb_private::Module::FindCompileUnits
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list)
Find compile units by partial or full path.
Definition: Module.cpp:619
lldb_private::Module::GetNumCompileUnits
size_t GetNumCompileUnits()
Get the number of compile units for this module.
Definition: Module.cpp:415
lldb_private::SymbolContextScope
Definition: SymbolContextScope.h:64
ObjectFile.h
lldb_private::ModuleFunctionSearchOptions
Options used by Module::FindFunctions.
Definition: Module.h:63
lldb_private::Module::GetSourceMappingList
const PathMappingList & GetSourceMappingList() const
Definition: Module.h:856
lldb_private::Module::m_old_symfiles
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
Definition: Module.h:1057
lldb_private::Module::m_symfile_spec
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.
Definition: Module.h:1034
lldb_private::Module::GetRemoteInstallFileSpec
const FileSpec & GetRemoteInstallFileSpec() const
Definition: Module.h:518
lldb-types.h
lldb_private::Module::GetSectionList
virtual SectionList * GetSectionList()
Get the unified section list for the module.
Definition: Module.cpp:1302
lldb_private::Module::SetArchitecture
bool SetArchitecture(const ArchSpec &new_arch)
Definition: Module.cpp:1573
lldb_private::Module::operator=
const Module & operator=(const Module &)=delete
lldb_private::ModuleSpec
Definition: ModuleSpec.h:27
lldb_private::Status
Definition: Status.h:44
lldb_private::Module::LookupInfo::GetLookupName
ConstString GetLookupName() const
Definition: Module.h:942
lldb_private::Module::GetSpecificationDescription
std::string GetSpecificationDescription() const
Get the module path and object name.
Definition: Module.cpp:1081
lldb_private::Module::LookupInfo::m_lookup_name
ConstString m_lookup_name
The actual name will lookup when calling in the object or symbol file.
Definition: Module.h:965
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
lldb_private::Symtab
Definition: Symtab.h:22
uint32_t
lldb_private::PathMappingList
Definition: PathMappingList.h:20
lldb_private::Address
Definition: Address.h:59
lldb_private::Module::DumpSymbolContext
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition: Module.cpp:411
lldb_private::Module::LookupInfo::GetNameTypeMask
lldb::FunctionNameType GetNameTypeMask() const
Definition: Module.h:946
lldb_private::Module::PreloadSymbols
void PreloadSymbols()
Definition: Module.cpp:1400
lldb_private::Module::GetCacheKey
std::string GetCacheKey()
Get a unique cache key for the current module.
Definition: Module.cpp:1704
lldb_private::Module::ResolveSymbolContextForAddress
uint32_t ResolveSymbolContextForAddress(const Address &so_addr, lldb::SymbolContextItem resolve_scope, SymbolContext &sc, bool resolve_tail_call_address=false)
Resolve the symbol context for the given address.
Definition: Module.cpp:444
ArchSpec.h
lldb_private::Module::m_object_offset
uint64_t m_object_offset
Definition: Module.h:1040
lldb_private::Module::SetUUID
void SetUUID(const lldb_private::UUID &uuid)
Definition: Module.cpp:357
lldb_private::Module::FindSourceFile
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
Finds a source file given a file spec using the module source path remappings (if any).
Definition: Module.cpp:1624
lldb_private::Module::MatchesModuleSpec
bool MatchesModuleSpec(const ModuleSpec &module_ref)
Definition: Module.cpp:1593
lldb_private::Module::m_arch
ArchSpec m_arch
The architecture for this module.
Definition: Module.h:1024
lldb_private::Module::LookupInfo::m_match_name_after_lookup
bool m_match_name_after_lookup
Definition: Module.h:976
lldb_private::Module::FindAddressesForLine
void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, Function *function, std::vector< Address > &output_local, std::vector< Address > &output_extern)
Find addresses by file/line.
Definition: Module.cpp:929
lldb_private::Module::m_type_system_map
TypeSystemMap m_type_system_map
A map of any type systems associated with this module.
Definition: Module.h:1061
lldb_private::Module::IsLoadedInTarget
bool IsLoadedInTarget(Target *target)
Tells whether this module has been loaded in the target passed in.
Definition: Module.cpp:1489
lldb-forward.h
Statistics.h
lldb_private::DataFileCache
This class enables data to be cached into a directory using the llvm caching code.
Definition: DataFileCache.h:44
lldb_private::Module::FindTypes
void FindTypes(ConstString type_name, bool exact_match, size_t max_matches, llvm::DenseSet< lldb_private::SymbolFile * > &searched_symbol_files, TypeList &types)
Find types by name.
Definition: Module.cpp:987
Status.h
lldb::user_id_t
uint64_t user_id_t
Definition: lldb-types.h:84
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::Module::m_symtab_index_time
StatsDuration m_symtab_index_time
We store a symbol named index time duration here because we might have an object file and a symbol fi...
Definition: Module.h:1085
lldb_private::Module::GetNumberAllocatedModules
static size_t GetNumberAllocatedModules()
Definition: Module.cpp:117
lldb_private::Module::RemapSourceFile
llvm::Optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
Definition: Module.cpp:1635
lldb_private::TypeList
Definition: TypeList.h:20
lldb_private::LLDBLog::Target
@ Target
FileSpec.h
lldb_private::Module::GetObjectModificationTime
const llvm::sys::TimePoint & GetObjectModificationTime() const
Definition: Module.h:536
ConstString.h
lldb_private::Module::LookupInfo::LookupInfo
LookupInfo()=default
lldb_private::LanguageSet
A SmallBitVector that represents a set of source languages (lldb::LanguageType).
Definition: TypeSystem.h:43
lldb_private::Module::FindSymbolsWithNameAndType
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition: Module.cpp:1371
lldb_private::Module::LookupInfo::Prune
void Prune(SymbolContextList &sc_list, size_t start_idx) const
Definition: Module.cpp:766
lldb_private::Module::FindFirstSymbolWithNameAndType
const Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type=lldb::eSymbolTypeAny)
Find a symbol in the object file's symbol table.
Definition: Module.cpp:1335
lldb_private::Log
Definition: Log.h:115
lldb_private::Module::m_source_mappings
PathMappingList m_source_mappings
Module specific source remappings for when you have debug info for a module that doesn't match where ...
Definition: Module.h:1065
lldb_private::Module::GetArchitecture
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition: Module.cpp:1079
lldb_private::Module::GetUUID
const lldb_private::UUID & GetUUID()
Get a reference to the UUID value contained in this object.
Definition: Module.cpp:342
lldb_private::Module::Dump
void Dump(Stream *s)
Dump a description of this object to a Stream.
Definition: Module.cpp:1240
lldb_private::Module::FindFunctionSymbols
void FindFunctionSymbols(ConstString name, uint32_t name_type_mask, SymbolContextList &sc_list)
Find a function symbols in the object file's symbol table.
Definition: Module.cpp:1363
PathMappingList.h
lldb_private::Module::m_mutex
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
Definition: Module.h:1018
lldb
Definition: SBAddress.h:15
lldb_private::Module::GetAllocationModuleCollectionMutex
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
Definition: Module.cpp:105
lldb_private::Module::IsExecutable
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
Definition: Module.cpp:1482
lldb_private::Module::GetModificationTime
const llvm::sys::TimePoint & GetModificationTime() const
Definition: Module.h:532
lldb_private::ObjectFile
Definition: ObjectFile.h:60
lldb_private::CompilerContextKind::Function
@ Function
lldb::DescriptionLevel
DescriptionLevel
Description levels for "void GetDescription(Stream *, DescriptionLevel)" calls.
Definition: lldb-enumerations.h:207
lldb_private::Module::Module
Module()
Definition: Module.cpp:259
lldb_private::Module::GetCompileUnitAtIndex
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
Definition: Module.cpp:424
lldb_private::Module::m_file
FileSpec m_file
The file representation on disk for this module (if there is one).
Definition: Module.h:1027
lldb_private::Module::m_did_set_uuid
std::atomic< bool > m_did_set_uuid
Definition: Module.h:1074
lldb_private::Module::m_did_load_objfile
std::atomic< bool > m_did_load_objfile
Definition: Module.h:1072