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