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