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