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 Stream &feedback_stream);
515
516 /// Get the number of compile units for this module.
517 ///
518 /// \return
519 /// The number of compile units that the symbol vendor plug-in
520 /// finds.
521 size_t GetNumCompileUnits();
522
524
526
527 uint64_t GetObjectOffset() const { return m_object_offset; }
528
529 /// Get the object file representation for the current architecture.
530 ///
531 /// If the object file has not been located or parsed yet, this function
532 /// will find the best ObjectFile plug-in that can parse Module::m_file.
533 ///
534 /// \return
535 /// If Module::m_file does not exist, or no plug-in was found
536 /// that can parse the file, or the object file doesn't contain
537 /// the current architecture in Module::m_arch, nullptr will be
538 /// returned, else a valid object file interface will be
539 /// returned. The returned pointer is owned by this object and
540 /// remains valid as long as the object is around.
541 virtual ObjectFile *GetObjectFile();
542
543 /// Get the unified section list for the module. This is the section list
544 /// created by the module's object file and any debug info and symbol files
545 /// created by the symbol vendor.
546 ///
547 /// If the symbol vendor has not been loaded yet, this function will return
548 /// the section list for the object file.
549 ///
550 /// \return
551 /// Unified module section list.
552 virtual SectionList *GetSectionList();
553
554 /// Notify the module that the file addresses for the Sections have been
555 /// updated.
556 ///
557 /// If the Section file addresses for a module are updated, this method
558 /// should be called. Any parts of the module, object file, or symbol file
559 /// that has cached those file addresses must invalidate or update its
560 /// cache.
561 virtual void SectionFileAddressesChanged();
562
563 /// Returns a reference to the UnwindTable for this Module
564 ///
565 /// The UnwindTable contains FuncUnwinders objects for any function in this
566 /// Module. If a FuncUnwinders object hasn't been created yet (i.e. the
567 /// function has yet to be unwound in a stack walk), it will be created when
568 /// requested. Specifically, we do not create FuncUnwinders objects for
569 /// functions until they are needed.
570 ///
571 /// \return
572 /// Returns the unwind table for this module. If this object has no
573 /// associated object file, an empty UnwindTable is returned.
575
576 llvm::VersionTuple GetVersion();
577
578 /// Load an object file from memory.
579 ///
580 /// If available, the size of the object file in memory may be passed to
581 /// avoid additional round trips to process memory. If the size is not
582 /// provided, a default value is used. This value should be large enough to
583 /// enable the ObjectFile plugins to read the header of the object file
584 /// without going back to the process.
585 ///
586 /// \return
587 /// The object file loaded from memory or nullptr, if the operation
588 /// failed (see the `error` for more information in that case).
590 lldb::addr_t header_addr, Status &error,
591 size_t size_to_read = 512);
592
593 /// Get the module's symbol file
594 ///
595 /// If the symbol file has already been loaded, this function returns it. All
596 /// arguments are ignored. If the symbol file has not been located yet, and
597 /// the can_create argument is false, the function returns nullptr. If
598 /// can_create is true, this function will find the best SymbolFile plug-in
599 /// that can use the current object file. feedback_strm, if not null, is used
600 /// to report the details of the search process.
601 virtual SymbolFile *GetSymbolFile(bool can_create = true,
602 Stream *feedback_strm = nullptr);
603
604 /// Get the module's symbol table
605 ///
606 /// If the symbol table has already been loaded, this function returns it.
607 /// Otherwise, it will only be loaded when can_create is true.
608 Symtab *GetSymtab(bool can_create = true);
609
610 /// Get a reference to the UUID value contained in this object.
611 ///
612 /// If the executable image file doesn't not have a UUID value built into
613 /// the file format, an MD5 checksum of the entire file, or slice of the
614 /// file for the current architecture should be used.
615 ///
616 /// \return
617 /// A const pointer to the internal copy of the UUID value in
618 /// this module if this module has a valid UUID value, NULL
619 /// otherwise.
621
622 /// A debugging function that will cause everything in a module to
623 /// be parsed.
624 ///
625 /// All compile units will be parsed, along with all globals and static
626 /// variables and all functions for those compile units. All types, scopes,
627 /// local variables, static variables, global variables, and line tables
628 /// will be parsed. This can be used prior to dumping a module to see a
629 /// complete list of the resulting debug information that gets parsed, or as
630 /// a debug function to ensure that the module can consume all of the debug
631 /// data the symbol vendor provides.
633
634 bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr);
635
636 /// Resolve the symbol context for the given address.
637 ///
638 /// Tries to resolve the matching symbol context based on a lookup from the
639 /// current symbol vendor. If the lazy lookup fails, an attempt is made to
640 /// parse the eh_frame section to handle stripped symbols. If this fails,
641 /// an attempt is made to resolve the symbol to the previous address to
642 /// handle the case of a function with a tail call.
643 ///
644 /// Use properties of the modified SymbolContext to inspect any resolved
645 /// target, module, compilation unit, symbol, function, function block or
646 /// line entry. Use the return value to determine which of these properties
647 /// have been modified.
648 ///
649 /// \param[in] so_addr
650 /// A load address to resolve.
651 ///
652 /// \param[in] resolve_scope
653 /// The scope that should be resolved (see SymbolContext::Scope).
654 /// A combination of flags from the enumeration SymbolContextItem
655 /// requesting a resolution depth. Note that the flags that are
656 /// actually resolved may be a superset of the requested flags.
657 /// For instance, eSymbolContextSymbol requires resolution of
658 /// eSymbolContextModule, and eSymbolContextFunction requires
659 /// eSymbolContextSymbol.
660 ///
661 /// \param[out] sc
662 /// The SymbolContext that is modified based on symbol resolution.
663 ///
664 /// \param[in] resolve_tail_call_address
665 /// Determines if so_addr should resolve to a symbol in the case
666 /// of a function whose last instruction is a call. In this case,
667 /// the PC can be one past the address range of the function.
668 ///
669 /// \return
670 /// The scope that has been resolved (see SymbolContext::Scope).
671 ///
672 /// \see SymbolContext::Scope
674 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
675 SymbolContext &sc, bool resolve_tail_call_address = false);
676
677 /// Resolve items in the symbol context for a given file and line.
678 ///
679 /// Tries to resolve \a file_path and \a line to a list of matching symbol
680 /// contexts.
681 ///
682 /// The line table entries contains addresses that can be used to further
683 /// resolve the values in each match: the function, block, symbol. Care
684 /// should be taken to minimize the amount of information that is requested
685 /// to only what is needed -- typically the module, compile unit, line table
686 /// and line table entry are sufficient.
687 ///
688 /// \param[in] file_path
689 /// A path to a source file to match. If \a file_path does not
690 /// specify a directory, then this query will match all files
691 /// whose base filename matches. If \a file_path does specify
692 /// a directory, the fullpath to the file must match.
693 ///
694 /// \param[in] line
695 /// The source line to match, or zero if just the compile unit
696 /// should be resolved.
697 ///
698 /// \param[in] check_inlines
699 /// Check for inline file and line number matches. This option
700 /// should be used sparingly as it will cause all line tables
701 /// for every compile unit to be parsed and searched for
702 /// matching inline file entries.
703 ///
704 /// \param[in] resolve_scope
705 /// The scope that should be resolved (see
706 /// SymbolContext::Scope).
707 ///
708 /// \param[out] sc_list
709 /// A symbol context list that gets matching symbols contexts
710 /// appended to.
711 ///
712 /// \return
713 /// The number of matches that were added to \a sc_list.
714 ///
715 /// \see SymbolContext::Scope
717 const char *file_path, uint32_t line, bool check_inlines,
718 lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
719
720 /// Resolve items in the symbol context for a given file and line.
721 ///
722 /// Tries to resolve \a file_spec and \a line to a list of matching symbol
723 /// contexts.
724 ///
725 /// The line table entries contains addresses that can be used to further
726 /// resolve the values in each match: the function, block, symbol. Care
727 /// should be taken to minimize the amount of information that is requested
728 /// to only what is needed -- typically the module, compile unit, line table
729 /// and line table entry are sufficient.
730 ///
731 /// \param[in] file_spec
732 /// A file spec to a source file to match. If \a file_path does
733 /// not specify a directory, then this query will match all
734 /// files whose base filename matches. If \a file_path does
735 /// specify a directory, the fullpath to the file must match.
736 ///
737 /// \param[in] line
738 /// The source line to match, or zero if just the compile unit
739 /// should be resolved.
740 ///
741 /// \param[in] check_inlines
742 /// Check for inline file and line number matches. This option
743 /// should be used sparingly as it will cause all line tables
744 /// for every compile unit to be parsed and searched for
745 /// matching inline file entries.
746 ///
747 /// \param[in] resolve_scope
748 /// The scope that should be resolved (see
749 /// SymbolContext::Scope).
750 ///
751 /// \param[out] sc_list
752 /// A symbol context list that gets filled in with all of the
753 /// matches.
754 ///
755 /// \return
756 /// A integer that contains SymbolContext::Scope bits set for
757 /// each item that was successfully resolved.
758 ///
759 /// \see SymbolContext::Scope
761 const FileSpec &file_spec, uint32_t line, bool check_inlines,
762 lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
763
764 void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name);
765
767
768 llvm::Expected<lldb::TypeSystemSP>
770
771 /// Call \p callback for each \p TypeSystem in this \p Module.
772 /// Return true from callback to keep iterating, false to stop iterating.
773 void ForEachTypeSystem(llvm::function_ref<bool(lldb::TypeSystemSP)> callback);
774
775 // Special error functions that can do printf style formatting that will
776 // prepend the message with something appropriate for this module (like the
777 // architecture, path and object name (if any)). This centralizes code so
778 // that everyone doesn't need to format their error and log messages on their
779 // own and keeps the output a bit more consistent.
780 template <typename... Args>
781 void LogMessage(Log *log, const char *format, Args &&...args) {
782 LogMessage(log, llvm::formatv(format, std::forward<Args>(args)...));
783 }
784
785 template <typename... Args>
786 void LogMessageVerboseBacktrace(Log *log, const char *format,
787 Args &&...args) {
789 log, llvm::formatv(format, std::forward<Args>(args)...));
790 }
791
792 template <typename... Args>
793 void ReportWarning(const char *format, Args &&...args) {
794 ReportWarning(llvm::formatv(format, std::forward<Args>(args)...));
795 }
796
797 template <typename... Args>
798 void ReportError(const char *format, Args &&...args) {
799 ReportError(llvm::formatv(format, std::forward<Args>(args)...));
800 }
801
802 // Only report an error once when the module is first detected to be modified
803 // so we don't spam the console with many messages.
804 template <typename... Args>
805 void ReportErrorIfModifyDetected(const char *format, Args &&...args) {
807 llvm::formatv(format, std::forward<Args>(args)...));
808 }
809
810 void ReportWarningOptimization(std::optional<lldb::user_id_t> debugger_id);
811
812 void
814 std::optional<lldb::user_id_t> debugger_id);
815
816 // Return true if the file backing this module has changed since the module
817 // was originally created since we saved the initial file modification time
818 // when the module first gets created.
819 bool FileHasChanged() const;
820
821 // SymbolFile and ObjectFile member objects should lock the
822 // module mutex to avoid deadlocks.
823 std::recursive_mutex &GetMutex() const { return m_mutex; }
824
826
828 return m_source_mappings;
829 }
830
831 /// Finds a source file given a file spec using the module source path
832 /// remappings (if any).
833 ///
834 /// Tries to resolve \a orig_spec by checking the module source path
835 /// remappings. It makes sure the file exists, so this call can be expensive
836 /// if the remappings are on a network file system, so use this function
837 /// sparingly (not in a tight debug info parsing loop).
838 ///
839 /// \param[in] orig_spec
840 /// The original source file path to try and remap.
841 ///
842 /// \param[out] new_spec
843 /// The newly remapped filespec that is guaranteed to exist.
844 ///
845 /// \return
846 /// /b true if \a orig_spec was successfully located and
847 /// \a new_spec is filled in with an existing file spec,
848 /// \b false otherwise.
849 bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
850
851 /// Remaps a source file given \a path into \a new_path.
852 ///
853 /// Remaps \a path if any source remappings match. This function does NOT
854 /// stat the file system so it can be used in tight loops where debug info
855 /// is being parsed.
856 ///
857 /// \param[in] path
858 /// The original source file path to try and remap.
859 ///
860 /// \return
861 /// The newly remapped filespec that is may or may not exist if
862 /// \a path was successfully located.
863 std::optional<std::string> RemapSourceFile(llvm::StringRef path) const;
864 bool RemapSourceFile(const char *, std::string &) const = delete;
865
866 /// Update the ArchSpec to a more specific variant.
867 bool MergeArchitecture(const ArchSpec &arch_spec);
868
869 /// Accessor for the symbol table parse time metric.
870 ///
871 /// The value is returned as a reference to allow it to be updated by the
872 /// ElapsedTime RAII object.
874
875 /// Accessor for the symbol table index time metric.
876 ///
877 /// The value is returned as a reference to allow it to be updated by the
878 /// ElapsedTime RAII object.
880
884
885 void ResetStatistics();
886
887 /// \class LookupInfo Module.h "lldb/Core/Module.h"
888 /// A class that encapsulates name lookup information.
889 ///
890 /// Users can type a wide variety of partial names when setting breakpoints
891 /// by name or when looking for functions by name. The SymbolFile object is
892 /// only required to implement name lookup for function basenames and for
893 /// fully mangled names. This means if the user types in a partial name, we
894 /// must reduce this to a name lookup that will work with all SymbolFile
895 /// objects. So we might reduce a name lookup to look for a basename, and then
896 /// prune out any results that don't match.
897 ///
898 /// The "m_name" member variable represents the name as it was typed by the
899 /// user. "m_lookup_name" will be the name we actually search for through
900 /// the symbol or objects files. Lanaguage is included in case we need to
901 /// filter results by language at a later date. The "m_name_type_mask"
902 /// member variable tells us what kinds of names we are looking for and can
903 /// help us prune out unwanted results.
904 ///
905 /// Function lookups are done in Module.cpp, ModuleList.cpp and in
906 /// BreakpointResolverName.cpp and they all now use this class to do lookups
907 /// correctly.
909 public:
910 LookupInfo() = default;
911
912 /// Creates a vector of lookup infos for function name resolution.
913 ///
914 /// \param[in] name
915 /// The function name to search for. This can be a simple name like
916 /// "foo" or a qualified name like "Class::method".
917 ///
918 /// \param[in] name_type_mask
919 /// A bitmask specifying what types of names to search for
920 /// (e.g., eFunctionNameTypeFull, eFunctionNameTypeBase,
921 /// eFunctionNameTypeMethod, eFunctionNameTypeAuto). Multiple types
922 /// can be combined with bitwise OR.
923 ///
924 /// \param[in] lang_type
925 /// The language to create lookups for. If eLanguageTypeUnknown is
926 /// passed, creates one LookupInfo for each language plugin currently
927 /// available in LLDB. If a specific language is provided, creates only
928 // a single LookupInfo for that language.
929 ///
930 /// \return
931 /// A vector of LookupInfo objects, one per relevant language.
932 static std::vector<LookupInfo>
933 MakeLookupInfos(ConstString name, lldb::FunctionNameType name_type_mask,
934 lldb::LanguageType lang_type);
935
936 ConstString GetName() const { return m_name; }
937
938 void SetName(ConstString name) { m_name = name; }
939
941
943
944 lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; }
945
946 void SetNameTypeMask(lldb::FunctionNameType mask) {
947 m_name_type_mask = mask;
948 }
949
951
953 ConstString function_name,
954 lldb::LanguageType language_type = lldb::eLanguageTypeUnknown) const;
955
956 void Prune(SymbolContextList &sc_list, size_t start_idx) const;
957
958 protected:
959 /// What the user originally typed
961
962 /// The actual name will lookup when calling in the object or symbol file
964
965 /// Limit matches to only be for this language
967
968 /// One or more bits from lldb::FunctionNameType that indicate what kind of
969 /// names we are looking for
970 lldb::FunctionNameType m_name_type_mask = lldb::eFunctionNameTypeNone;
971
972 /// If \b true, then demangled names that match will need to contain
973 /// "m_name" in order to be considered a match
975
976 private:
977 LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask,
978 lldb::LanguageType lang_type);
979 };
980
981 /// Get a unique hash for this module.
982 ///
983 /// The hash should be enough to identify the file on disk and the
984 /// architecture of the file. If the module represents an object inside of a
985 /// file, then the hash should include the object name and object offset to
986 /// ensure a unique hash. Some examples:
987 /// - just a regular object file (mach-o, elf, coff, etc) should create a hash
988 /// - a universal mach-o file that contains to multiple architectures,
989 /// each architecture slice should have a unique hash even though they come
990 /// from the same file
991 /// - a .o file inside of a BSD archive. Each .o file will have an object name
992 /// and object offset that should produce a unique hash. The object offset
993 /// is needed as BSD archive files can contain multiple .o files that have
994 /// the same name.
995 uint32_t Hash();
996
997 /// Get a unique cache key for the current module.
998 ///
999 /// The cache key must be unique for a file on disk and not change if the file
1000 /// is updated. This allows cache data to use this key as a prefix and as
1001 /// files are modified in disk, we will overwrite the cache files. If one file
1002 /// can contain multiple files, like a universal mach-o file or like a BSD
1003 /// archive, the cache key must contain enough information to differentiate
1004 /// these different files.
1005 std::string GetCacheKey();
1006
1007 /// Get the global index file cache.
1008 ///
1009 /// LLDB can cache data for a module between runs. This cache directory can be
1010 /// used to stored data that previously was manually created each time you debug.
1011 /// Examples include debug information indexes, symbol tables, symbol table
1012 /// indexes, and more.
1013 ///
1014 /// \returns
1015 /// If caching is enabled in the lldb settings, return a pointer to the data
1016 /// file cache. If caching is not enabled, return NULL.
1017 static DataFileCache *GetIndexCache();
1018protected:
1019 // Member Variables
1020 mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
1021 /// in multi-threaded environments.
1022
1023 /// The modification time for this module when it was created.
1024 llvm::sys::TimePoint<> m_mod_time;
1025
1026 ArchSpec m_arch; ///< The architecture for this module.
1027 UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
1028 /// match it up to debug symbols.
1029 FileSpec m_file; ///< The file representation on disk for this module (if
1030 /// there is one).
1031 FileSpec m_platform_file; ///< The path to the module on the platform on which
1032 /// it is being debugged
1033 FileSpec m_remote_install_file; ///< If set when debugging on remote
1034 /// platforms, this module will be installed
1035 /// at this location
1036 FileSpec m_symfile_spec; ///< If this path is valid, then this is the file
1037 /// that _will_ be used as the symbol file for this
1038 /// module
1039 ConstString m_object_name; ///< The name an object within this module that is
1040 /// selected, or empty of the module is represented
1041 /// by \a m_file.
1042 uint64_t m_object_offset = 0;
1043 llvm::sys::TimePoint<> m_object_mod_time;
1044
1045 /// DataBuffer containing the module image, if it was provided at
1046 /// construction time. Otherwise the data will be retrieved by mapping
1047 /// one of the FileSpec members above.
1049
1050 lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
1051 /// parser for this module as it may or may
1052 /// not be shared with the SymbolFile
1053 UnwindTable m_unwind_table; ///< Table of FuncUnwinders
1054 /// objects created for this
1055 /// Module's functions
1057 m_symfile_up; ///< A pointer to the symbol vendor for this module.
1058 std::vector<lldb::SymbolVendorUP>
1059 m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
1060 /// changes the symbol file,
1061 ///< we need to keep all old symbol files around in case anyone has type
1062 /// references to them
1063 TypeSystemMap m_type_system_map; ///< A map of any type systems associated
1064 /// with this module
1065 /// Module specific source remappings for when you have debug info for a
1066 /// module that doesn't match where the sources currently are.
1069
1070 lldb::SectionListUP m_sections_up; ///< Unified section list for module that
1071 /// is used by the ObjectFile and
1072 /// ObjectFile instances for the debug info
1073
1074 std::atomic<bool> m_did_load_objfile{false};
1075 std::atomic<bool> m_did_load_symfile{false};
1076 std::atomic<bool> m_did_set_uuid{false};
1077 mutable bool m_file_has_changed : 1,
1078 m_first_file_changed_log : 1; /// See if the module was modified after it
1079 /// was initially opened.
1080 /// We store a symbol table parse time duration here because we might have
1081 /// an object file and a symbol file which both have symbol tables. The parse
1082 /// time for the symbol tables can be aggregated here.
1084 /// We store a symbol named index time duration here because we might have
1085 /// an object file and a symbol file which both have symbol tables. The parse
1086 /// time for the symbol tables can be aggregated here.
1088
1090
1091 /// A set of hashes of all warnings and errors, to avoid reporting them
1092 /// multiple times to the same Debugger.
1093 llvm::DenseMap<llvm::stable_hash, std::unique_ptr<std::once_flag>>
1095 std::recursive_mutex m_diagnostic_mutex;
1096
1098 std::vector<uint32_t> &symbol_indexes,
1099 SymbolContextList &sc_list);
1100
1101 bool SetArchitecture(const ArchSpec &new_arch);
1102
1103 void SetUUID(const lldb_private::UUID &uuid);
1104
1106
1107 friend class ModuleList;
1108 friend class ObjectFile;
1109 friend class SymbolFile;
1110
1111private:
1112 Module(); // Only used internally by CreateJITModule ()
1113
1114 Module(const Module &) = delete;
1115 const Module &operator=(const Module &) = delete;
1116
1117 void LogMessage(Log *log, const llvm::formatv_object_base &payload);
1119 const llvm::formatv_object_base &payload);
1120 void ReportWarning(const llvm::formatv_object_base &payload);
1121 void ReportError(const llvm::formatv_object_base &payload);
1122 void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
1123 std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
1124};
1125
1126} // namespace lldb_private
1127
1128#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:31
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:908
void SetName(ConstString name)
Definition Module.h:938
static std::vector< LookupInfo > MakeLookupInfos(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType lang_type)
Creates a vector of lookup infos for function name resolution.
Definition Module.cpp:700
LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask, lldb::LanguageType lang_type)
void SetNameTypeMask(lldb::FunctionNameType mask)
Definition Module.h:946
lldb::FunctionNameType GetNameTypeMask() const
Definition Module.h:944
void SetLookupName(ConstString name)
Definition Module.h:942
lldb::LanguageType GetLanguageType() const
Definition Module.h:950
ConstString GetLookupName() const
Definition Module.h:940
ConstString m_lookup_name
The actual name will lookup when calling in the object or symbol file.
Definition Module.h:963
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:970
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
Definition Module.cpp:729
lldb::LanguageType m_language
Limit matches to only be for this language.
Definition Module.h:966
ConstString m_name
What the user originally typed.
Definition Module.h:960
ConstString GetName() const
Definition Module.h:936
void Prune(SymbolContextList &sc_list, size_t start_idx) const
Definition Module.cpp:762
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:974
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:347
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:586
std::atomic< bool > m_did_set_uuid
Definition Module.h:1076
void ReportWarningOptimization(std::optional< lldb::user_id_t > debugger_id)
Definition Module.cpp:1078
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:1067
llvm::sys::TimePoint m_object_mod_time
Definition Module.h:1043
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition Module.cpp:1191
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:616
void ReportWarning(const char *format, Args &&...args)
Definition Module.h:793
FileSpec m_file
The file representation on disk for this module (if there is one).
Definition Module.h:1029
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition Module.cpp:991
static DataFileCache * GetIndexCache()
Get the global index file cache.
Definition Module.cpp:1653
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
Definition Module.h:1059
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, std::optional< lldb::user_id_t > debugger_id)
Definition Module.cpp:1092
const llvm::sys::TimePoint & GetObjectModificationTime() const
Definition Module.h:486
std::once_flag * GetDiagnosticOnceFlag(llvm::StringRef msg)
Definition Module.cpp:1120
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list)
Find compile units by partial or full path.
Definition Module.cpp:630
ConstString GetObjectName() const
Definition Module.cpp:1189
uint32_t Hash()
Get a unique hash for this module.
Definition Module.cpp:1629
lldb::ModuleSP CalculateSymbolContextModule() override
Definition Module.cpp:419
static Module * GetAllocatedModuleAtIndex(size_t idx)
Definition Module.cpp:121
std::recursive_mutex m_diagnostic_mutex
Definition Module.h:1095
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:1027
std::optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
Definition Module.cpp:1558
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:1024
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
Definition Module.cpp:432
FileSpec m_remote_install_file
If set when debugging on remote platforms, this module will be installed at this location.
Definition Module.h:1033
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:452
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
Definition Module.cpp:1024
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
Definition Module.h:1020
static std::recursive_mutex & GetAllocationModuleCollectionMutex()
Definition Module.cpp:103
lldb::DataBufferSP m_data_sp
DataBuffer containing the module image, if it was provided at construction time.
Definition Module.h:1048
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:1505
void SetSymbolFileFileSpec(const FileSpec &file)
Definition Module.cpp:1344
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:1565
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition Module.cpp:1299
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition Module.cpp:415
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:1036
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:1087
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition Module.cpp:444
PathMappingList & GetSourceMappingList()
Definition Module.h:825
ArchSpec m_arch
The architecture for this module.
Definition Module.h:1026
void ReportError(const char *format, Args &&...args)
Definition Module.h:798
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:1057
const Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type=lldb::eSymbolTypeAny)
Find a symbol in the object file's symbol table.
Definition Module.cpp:1263
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:1094
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:823
llvm::VersionTuple GetVersion()
Definition Module.cpp:1614
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:945
StatisticsMap & GetSymbolLocatorStatistics()
Definition Module.h:881
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition Module.cpp:421
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:1291
Symtab * GetSymtab(bool can_create=true)
Get the module's symbol table.
Definition Module.cpp:1018
size_t GetNumCompileUnits()
Get the number of compile units for this module.
Definition Module.cpp:425
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:1039
void LogMessage(Log *log, const char *format, Args &&...args)
Definition Module.h:781
bool MatchesModuleSpec(const ModuleSpec &module_ref)
Definition Module.cpp:1517
bool RemapSourceFile(const char *, std::string &) const =delete
~Module() override
Destructor.
Definition Module.cpp:267
static size_t GetNumberAllocatedModules()
Definition Module.cpp:115
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:297
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream &feedback_stream)
Definition Module.cpp:1429
TypeSystemMap m_type_system_map
A map of any type systems associated with this module.
Definition Module.h:1063
uint64_t m_object_offset
Definition Module.h:1042
const PathMappingList & GetSourceMappingList() const
Definition Module.h:827
void ForEachTypeSystem(llvm::function_ref< bool(lldb::TypeSystemSP)> callback)
Call callback for each TypeSystem in this Module.
Definition Module.cpp:377
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:1070
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
Definition Module.cpp:1405
FileSpec m_platform_file
The path to the module on the platform on which it is being debugged.
Definition Module.h:1031
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
Definition Module.cpp:1586
bool FileHasChanged() const
Definition Module.cpp:1067
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition Module.cpp:1033
friend class ObjectFile
Definition Module.h:1108
void LogMessageVerboseBacktrace(Log *log, const char *format, Args &&...args)
Definition Module.h:786
bool GetIsDynamicLinkEditor()
Definition Module.cpp:1620
std::string GetCacheKey()
Get a unique cache key for the current module.
Definition Module.cpp:1643
virtual SectionList * GetSectionList()
Get the unified section list for the module.
Definition Module.cpp:1233
uint64_t GetObjectOffset() const
Definition Module.h:527
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)
Definition Module.cpp:373
void Dump(Stream *s)
Dump a description of this object to a Stream.
Definition Module.cpp:1168
StatsDuration & GetSymtabIndexTime()
Accessor for the symbol table index time metric.
Definition Module.h:879
friend class ModuleList
Definition Module.h:1107
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:594
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:1050
void ReportErrorIfModifyDetected(const char *format, Args &&...args)
Definition Module.h:805
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list, Mangled::NamePreference mangling_preference=Mangled::ePreferDemangled)
Definition Module.cpp:1311
std::atomic< bool > m_did_load_symfile
Definition Module.h:1075
UnwindTable & GetUnwindTable()
Returns a reference to the UnwindTable for this Module.
Definition Module.cpp:1251
void SetRemoteInstallFileSpec(const FileSpec &file)
Definition Module.h:472
std::string GetSpecificationDescription() const
Get the module path and object name.
Definition Module.cpp:1035
UnwindTable m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
Definition Module.h:1053
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:1412
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition Module.cpp:1045
void SetUUID(const lldb_private::UUID &uuid)
Definition Module.cpp:362
bool m_first_file_changed_log
Definition Module.h:1078
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
Definition Module.cpp:1273
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:1243
std::atomic< bool > m_did_load_objfile
Definition Module.h:1074
bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const
Finds a source file given a file spec using the module source path remappings (if any).
Definition Module.cpp:1548
friend class SymbolFile
Definition Module.h:1109
const Module & operator=(const Module &)=delete
StatisticsMap m_symbol_locator_duration_map
Definition Module.h:1089
void FindTypes(const TypeQuery &query, TypeResults &results)
Find types using a type-matching object that contains all search parameters.
Definition Module.cpp:969
bool SetArchitecture(const ArchSpec &new_arch)
Definition Module.cpp:1497
SectionList * GetUnifiedSectionList()
Definition Module.cpp:1257
StatsDuration m_symtab_parse_time
See if the module was modified after it was initially opened.
Definition Module.h:1083
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
Definition Module.cpp:382
StatsDuration & GetSymtabParseTime()
Accessor for the symbol table parse time metric.
Definition Module.h:873
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::shared_ptr< lldb_private::DataBuffer > DataBufferSP
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::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