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 lookup info.
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 ///
307 /// \param[in] lookup_info
308 /// The lookup info of the function we are looking for.
309 ///
310 /// \param[out] sc_list
311 /// A symbol context list that gets filled in with all of the
312 /// matches.
313 void FindFunctions(const LookupInfo &lookup_info,
314 const CompilerDeclContext &parent_decl_ctx,
315 const ModuleFunctionSearchOptions &options,
316 SymbolContextList &sc_list);
317
318 /// Find functions by name.
319 ///
320 /// If the function is an inlined function, it will have a block,
321 /// representing the inlined function, and the function will be the
322 /// containing function. If it is not inlined, then the block will be NULL.
323 ///
324 /// \param[in] name
325 /// The name of the function we are looking for.
326 ///
327 /// \param[in] name_type_mask
328 /// A bit mask of bits that indicate what kind of names should
329 /// be used when doing the lookup. Bits include fully qualified
330 /// names, base names, C++ methods, or ObjC selectors.
331 /// See FunctionNameType for more details.
332 ///
333 /// \param[out] sc_list
334 /// A symbol context list that gets filled in with all of the
335 /// matches.
337 const CompilerDeclContext &parent_decl_ctx,
338 lldb::FunctionNameType name_type_mask,
339 const ModuleFunctionSearchOptions &options,
340 SymbolContextList &sc_list);
341
342 /// Find functions by compiler context.
343 void FindFunctions(llvm::ArrayRef<CompilerContext> compiler_ctx,
344 lldb::FunctionNameType name_type_mask,
345 const ModuleFunctionSearchOptions &options,
346 SymbolContextList &sc_list);
347
348 /// Find functions by name.
349 ///
350 /// If the function is an inlined function, it will have a block,
351 /// representing the inlined function, and the function will be the
352 /// containing function. If it is not inlined, then the block will be NULL.
353 ///
354 /// \param[in] regex
355 /// A regular expression to use when matching the name.
356 ///
357 /// \param[out] sc_list
358 /// A symbol context list that gets filled in with all of the
359 /// matches.
360 void FindFunctions(const RegularExpression &regex,
361 const ModuleFunctionSearchOptions &options,
362 SymbolContextList &sc_list);
363
364 /// Find addresses by file/line
365 ///
366 /// \param[in] target_sp
367 /// The target the addresses are desired for.
368 ///
369 /// \param[in] file
370 /// Source file to locate.
371 ///
372 /// \param[in] line
373 /// Source line to locate.
374 ///
375 /// \param[in] function
376 /// Optional filter function. Addresses within this function will be
377 /// added to the 'local' list. All others will be added to the 'extern'
378 /// list.
379 ///
380 /// \param[out] output_local
381 /// All matching addresses within 'function'
382 ///
383 /// \param[out] output_extern
384 /// All matching addresses not within 'function'
385 void FindAddressesForLine(const lldb::TargetSP target_sp,
386 const FileSpec &file, uint32_t line,
387 Function *function,
388 std::vector<Address> &output_local,
389 std::vector<Address> &output_extern);
390
391 /// Find global and static variables by name.
392 ///
393 /// \param[in] name
394 /// The name of the global or static variable we are looking
395 /// for.
396 ///
397 /// \param[in] parent_decl_ctx
398 /// If valid, a decl context that results must exist within
399 ///
400 /// \param[in] max_matches
401 /// Allow the number of matches to be limited to \a
402 /// max_matches. Specify UINT32_MAX to get all possible matches.
403 ///
404 /// \param[in] variable_list
405 /// A list of variables that gets the matches appended to.
406 ///
408 const CompilerDeclContext &parent_decl_ctx,
409 size_t max_matches, VariableList &variable_list);
410
411 /// Find global and static variables by regular expression.
412 ///
413 /// \param[in] regex
414 /// A regular expression to use when matching the name.
415 ///
416 /// \param[in] max_matches
417 /// Allow the number of matches to be limited to \a
418 /// max_matches. Specify UINT32_MAX to get all possible matches.
419 ///
420 /// \param[in] variable_list
421 /// A list of variables that gets the matches appended to.
422 ///
423 void FindGlobalVariables(const RegularExpression &regex, size_t max_matches,
424 VariableList &variable_list);
425
426 /// Find types using a type-matching object that contains all search
427 /// parameters.
428 ///
429 /// \see lldb_private::TypeQuery
430 ///
431 /// \param[in] query
432 /// A type matching object that contains all of the details of the type
433 /// search.
434 ///
435 /// \param[in] results
436 /// Any matching types will be populated into the \a results object using
437 /// TypeMap::InsertUnique(...).
438 void FindTypes(const TypeQuery &query, TypeResults &results);
439
440 /// Get const accessor for the module architecture.
441 ///
442 /// \return
443 /// A const reference to the architecture object.
444 const ArchSpec &GetArchitecture() const;
445
446 /// Get const accessor for the module file specification.
447 ///
448 /// This function returns the file for the module on the host system that is
449 /// running LLDB. This can differ from the path on the platform since we
450 /// might be doing remote debugging.
451 ///
452 /// \return
453 /// A const reference to the file specification object.
454 const FileSpec &GetFileSpec() const { return m_file; }
455
456 /// Get accessor for the module platform file specification.
457 ///
458 /// Platform file refers to the path of the module as it is known on the
459 /// remote system on which it is being debugged. For local debugging this is
460 /// always the same as Module::GetFileSpec(). But remote debugging might
461 /// mention a file "/usr/lib/liba.dylib" which might be locally downloaded
462 /// and cached. In this case the platform file could be something like:
463 /// "/tmp/lldb/platform-cache/remote.host.computer/usr/lib/liba.dylib" The
464 /// file could also be cached in a local developer kit directory.
465 ///
466 /// \return
467 /// A const reference to the file specification object.
469 if (m_platform_file)
470 return m_platform_file;
471 return m_file;
472 }
473
474 void SetPlatformFileSpec(const FileSpec &file) { m_platform_file = file; }
475
478 }
479
482 }
483
485
486 void PreloadSymbols();
487
488 void SetSymbolFileFileSpec(const FileSpec &file);
489
490 const llvm::sys::TimePoint<> &GetModificationTime() const {
491 return m_mod_time;
492 }
493
494 const llvm::sys::TimePoint<> &GetObjectModificationTime() const {
495 return m_object_mod_time;
496 }
497
498 /// This callback will be called by SymbolFile implementations when
499 /// parsing a compile unit that contains SDK information.
500 /// \param sysroot will be added to the path remapping dictionary.
501 void RegisterXcodeSDK(llvm::StringRef sdk, llvm::StringRef sysroot);
502
503 /// Tells whether this module is capable of being the main executable for a
504 /// process.
505 ///
506 /// \return
507 /// \b true if it is, \b false otherwise.
508 bool IsExecutable();
509
510 /// Tells whether this module has been loaded in the target passed in. This
511 /// call doesn't distinguish between whether the module is loaded by the
512 /// dynamic loader, or by a "target module add" type call.
513 ///
514 /// \param[in] target
515 /// The target to check whether this is loaded in.
516 ///
517 /// \return
518 /// \b true if it is, \b false otherwise.
519 bool IsLoadedInTarget(Target *target);
520
522 Stream &feedback_stream);
523
524 /// Get the number of compile units for this module.
525 ///
526 /// \return
527 /// The number of compile units that the symbol vendor plug-in
528 /// finds.
529 size_t GetNumCompileUnits();
530
532
534
535 uint64_t GetObjectOffset() const { return m_object_offset; }
536
537 /// Get the object file representation for the current architecture.
538 ///
539 /// If the object file has not been located or parsed yet, this function
540 /// will find the best ObjectFile plug-in that can parse Module::m_file.
541 ///
542 /// \return
543 /// If Module::m_file does not exist, or no plug-in was found
544 /// that can parse the file, or the object file doesn't contain
545 /// the current architecture in Module::m_arch, nullptr will be
546 /// returned, else a valid object file interface will be
547 /// returned. The returned pointer is owned by this object and
548 /// remains valid as long as the object is around.
549 virtual ObjectFile *GetObjectFile();
550
551 /// Get the unified section list for the module. This is the section list
552 /// created by the module's object file and any debug info and symbol files
553 /// created by the symbol vendor.
554 ///
555 /// If the symbol vendor has not been loaded yet, this function will return
556 /// the section list for the object file.
557 ///
558 /// \return
559 /// Unified module section list.
560 virtual SectionList *GetSectionList();
561
562 /// Notify the module that the file addresses for the Sections have been
563 /// updated.
564 ///
565 /// If the Section file addresses for a module are updated, this method
566 /// should be called. Any parts of the module, object file, or symbol file
567 /// that has cached those file addresses must invalidate or update its
568 /// cache.
569 virtual void SectionFileAddressesChanged();
570
571 /// Returns a reference to the UnwindTable for this Module
572 ///
573 /// The UnwindTable contains FuncUnwinders objects for any function in this
574 /// Module. If a FuncUnwinders object hasn't been created yet (i.e. the
575 /// function has yet to be unwound in a stack walk), it will be created when
576 /// requested. Specifically, we do not create FuncUnwinders objects for
577 /// functions until they are needed.
578 ///
579 /// \return
580 /// Returns the unwind table for this module. If this object has no
581 /// associated object file, an empty UnwindTable is returned.
583
584 llvm::VersionTuple GetVersion();
585
586 /// Load an object file from memory.
587 ///
588 /// If available, the size of the object file in memory may be passed to
589 /// avoid additional round trips to process memory. If the size is not
590 /// provided, a default value is used. This value should be large enough to
591 /// enable the ObjectFile plugins to read the header of the object file
592 /// without going back to the process.
593 ///
594 /// \return
595 /// The object file loaded from memory or nullptr, if the operation
596 /// failed (see the `error` for more information in that case).
598 lldb::addr_t header_addr, Status &error,
599 size_t size_to_read = 512);
600
601 /// Get the module's symbol file
602 ///
603 /// If the symbol file has already been loaded, this function returns it. All
604 /// arguments are ignored. If the symbol file has not been located yet, and
605 /// the can_create argument is false, the function returns nullptr. If
606 /// can_create is true, this function will find the best SymbolFile plug-in
607 /// that can use the current object file. feedback_strm, if not null, is used
608 /// to report the details of the search process.
609 virtual SymbolFile *GetSymbolFile(bool can_create = true,
610 Stream *feedback_strm = nullptr);
611
612 /// Get the module's symbol table
613 ///
614 /// If the symbol table has already been loaded, this function returns it.
615 /// Otherwise, it will only be loaded when can_create is true.
616 Symtab *GetSymtab(bool can_create = true);
617
618 /// Get a reference to the UUID value contained in this object.
619 ///
620 /// If the executable image file doesn't not have a UUID value built into
621 /// the file format, an MD5 checksum of the entire file, or slice of the
622 /// file for the current architecture should be used.
623 ///
624 /// \return
625 /// A const pointer to the internal copy of the UUID value in
626 /// this module if this module has a valid UUID value, NULL
627 /// otherwise.
629
630 /// A debugging function that will cause everything in a module to
631 /// be parsed.
632 ///
633 /// All compile units will be parsed, along with all globals and static
634 /// variables and all functions for those compile units. All types, scopes,
635 /// local variables, static variables, global variables, and line tables
636 /// will be parsed. This can be used prior to dumping a module to see a
637 /// complete list of the resulting debug information that gets parsed, or as
638 /// a debug function to ensure that the module can consume all of the debug
639 /// data the symbol vendor provides.
641
642 bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr);
643
644 /// Resolve the symbol context for the given address.
645 ///
646 /// Tries to resolve the matching symbol context based on a lookup from the
647 /// current symbol vendor. If the lazy lookup fails, an attempt is made to
648 /// parse the eh_frame section to handle stripped symbols. If this fails,
649 /// an attempt is made to resolve the symbol to the previous address to
650 /// handle the case of a function with a tail call.
651 ///
652 /// Use properties of the modified SymbolContext to inspect any resolved
653 /// target, module, compilation unit, symbol, function, function block or
654 /// line entry. Use the return value to determine which of these properties
655 /// have been modified.
656 ///
657 /// \param[in] so_addr
658 /// A load address to resolve.
659 ///
660 /// \param[in] resolve_scope
661 /// The scope that should be resolved (see SymbolContext::Scope).
662 /// A combination of flags from the enumeration SymbolContextItem
663 /// requesting a resolution depth. Note that the flags that are
664 /// actually resolved may be a superset of the requested flags.
665 /// For instance, eSymbolContextSymbol requires resolution of
666 /// eSymbolContextModule, and eSymbolContextFunction requires
667 /// eSymbolContextSymbol.
668 ///
669 /// \param[out] sc
670 /// The SymbolContext that is modified based on symbol resolution.
671 ///
672 /// \param[in] resolve_tail_call_address
673 /// Determines if so_addr should resolve to a symbol in the case
674 /// of a function whose last instruction is a call. In this case,
675 /// the PC can be one past the address range of the function.
676 ///
677 /// \return
678 /// The scope that has been resolved (see SymbolContext::Scope).
679 ///
680 /// \see SymbolContext::Scope
682 const Address &so_addr, lldb::SymbolContextItem resolve_scope,
683 SymbolContext &sc, bool resolve_tail_call_address = false);
684
685 /// Resolve items in the symbol context for a given file and line.
686 ///
687 /// Tries to resolve \a file_path and \a line to a list of matching symbol
688 /// contexts.
689 ///
690 /// The line table entries contains addresses that can be used to further
691 /// resolve the values in each match: the function, block, symbol. Care
692 /// should be taken to minimize the amount of information that is requested
693 /// to only what is needed -- typically the module, compile unit, line table
694 /// and line table entry are sufficient.
695 ///
696 /// \param[in] file_path
697 /// A path to a source file to match. If \a file_path does not
698 /// specify a directory, then this query will match all files
699 /// whose base filename matches. If \a file_path does specify
700 /// a directory, the fullpath to the file must match.
701 ///
702 /// \param[in] line
703 /// The source line to match, or zero if just the compile unit
704 /// should be resolved.
705 ///
706 /// \param[in] check_inlines
707 /// Check for inline file and line number matches. This option
708 /// should be used sparingly as it will cause all line tables
709 /// for every compile unit to be parsed and searched for
710 /// matching inline file entries.
711 ///
712 /// \param[in] resolve_scope
713 /// The scope that should be resolved (see
714 /// SymbolContext::Scope).
715 ///
716 /// \param[out] sc_list
717 /// A symbol context list that gets matching symbols contexts
718 /// appended to.
719 ///
720 /// \return
721 /// The number of matches that were added to \a sc_list.
722 ///
723 /// \see SymbolContext::Scope
725 const char *file_path, uint32_t line, bool check_inlines,
726 lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
727
728 /// Resolve items in the symbol context for a given file and line.
729 ///
730 /// Tries to resolve \a file_spec and \a line to a list of matching symbol
731 /// contexts.
732 ///
733 /// The line table entries contains addresses that can be used to further
734 /// resolve the values in each match: the function, block, symbol. Care
735 /// should be taken to minimize the amount of information that is requested
736 /// to only what is needed -- typically the module, compile unit, line table
737 /// and line table entry are sufficient.
738 ///
739 /// \param[in] file_spec
740 /// A file spec to a source file to match. If \a file_path does
741 /// not specify a directory, then this query will match all
742 /// files whose base filename matches. If \a file_path does
743 /// specify a directory, the fullpath to the file must match.
744 ///
745 /// \param[in] line
746 /// The source line to match, or zero if just the compile unit
747 /// should be resolved.
748 ///
749 /// \param[in] check_inlines
750 /// Check for inline file and line number matches. This option
751 /// should be used sparingly as it will cause all line tables
752 /// for every compile unit to be parsed and searched for
753 /// matching inline file entries.
754 ///
755 /// \param[in] resolve_scope
756 /// The scope that should be resolved (see
757 /// SymbolContext::Scope).
758 ///
759 /// \param[out] sc_list
760 /// A symbol context list that gets filled in with all of the
761 /// matches.
762 ///
763 /// \return
764 /// A integer that contains SymbolContext::Scope bits set for
765 /// each item that was successfully resolved.
766 ///
767 /// \see SymbolContext::Scope
769 const FileSpec &file_spec, uint32_t line, bool check_inlines,
770 lldb::SymbolContextItem resolve_scope, SymbolContextList &sc_list);
771
772 void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name);
773
775
776 llvm::Expected<lldb::TypeSystemSP>
778
779 /// Call \p callback for each \p TypeSystem in this \p Module.
780 /// Return true from callback to keep iterating, false to stop iterating.
781 void ForEachTypeSystem(llvm::function_ref<bool(lldb::TypeSystemSP)> callback);
782
783 // Special error functions that can do printf style formatting that will
784 // prepend the message with something appropriate for this module (like the
785 // architecture, path and object name (if any)). This centralizes code so
786 // that everyone doesn't need to format their error and log messages on their
787 // own and keeps the output a bit more consistent.
788 template <typename... Args>
789 void LogMessage(Log *log, const char *format, Args &&...args) {
790 LogMessage(log, llvm::formatv(format, std::forward<Args>(args)...));
791 }
792
793 template <typename... Args>
794 void LogMessageVerboseBacktrace(Log *log, const char *format,
795 Args &&...args) {
797 log, llvm::formatv(format, std::forward<Args>(args)...));
798 }
799
800 template <typename... Args>
801 void ReportWarning(const char *format, Args &&...args) {
802 ReportWarning(llvm::formatv(format, std::forward<Args>(args)...));
803 }
804
805 template <typename... Args>
806 void ReportError(const char *format, Args &&...args) {
807 ReportError(llvm::formatv(format, std::forward<Args>(args)...));
808 }
809
810 // Only report an error once when the module is first detected to be modified
811 // so we don't spam the console with many messages.
812 template <typename... Args>
813 void ReportErrorIfModifyDetected(const char *format, Args &&...args) {
815 llvm::formatv(format, std::forward<Args>(args)...));
816 }
817
818 void ReportWarningOptimization(std::optional<lldb::user_id_t> debugger_id);
819
820 void
822 std::optional<lldb::user_id_t> debugger_id);
823
824 // Return true if the file backing this module has changed since the module
825 // was originally created since we saved the initial file modification time
826 // when the module first gets created.
827 bool FileHasChanged() const;
828
829 // SymbolFile and ObjectFile member objects should lock the
830 // module mutex to avoid deadlocks.
831 std::recursive_mutex &GetMutex() const { return m_mutex; }
832
834
836 return m_source_mappings;
837 }
838
839 /// Finds a source file given a file spec using the module source path
840 /// remappings (if any).
841 ///
842 /// Tries to resolve \a orig_spec by checking the module source path
843 /// remappings. It makes sure the file exists, so this call can be expensive
844 /// if the remappings are on a network file system, so use this function
845 /// sparingly (not in a tight debug info parsing loop).
846 ///
847 /// \param[in] orig_spec
848 /// The original source file path to try and remap.
849 ///
850 /// \param[out] new_spec
851 /// The newly remapped filespec that is guaranteed to exist.
852 ///
853 /// \return
854 /// /b true if \a orig_spec was successfully located and
855 /// \a new_spec is filled in with an existing file spec,
856 /// \b false otherwise.
857 bool FindSourceFile(const FileSpec &orig_spec, FileSpec &new_spec) const;
858
859 /// Remaps a source file given \a path into \a new_path.
860 ///
861 /// Remaps \a path if any source remappings match. This function does NOT
862 /// stat the file system so it can be used in tight loops where debug info
863 /// is being parsed.
864 ///
865 /// \param[in] path
866 /// The original source file path to try and remap.
867 ///
868 /// \return
869 /// The newly remapped filespec that is may or may not exist if
870 /// \a path was successfully located.
871 std::optional<std::string> RemapSourceFile(llvm::StringRef path) const;
872 bool RemapSourceFile(const char *, std::string &) const = delete;
873
874 /// Update the ArchSpec to a more specific variant.
875 bool MergeArchitecture(const ArchSpec &arch_spec);
876
877 /// Accessor for the symbol table parse time metric.
878 ///
879 /// The value is returned as a reference to allow it to be updated by the
880 /// ElapsedTime RAII object.
882
883 /// Accessor for the symbol table index time metric.
884 ///
885 /// The value is returned as a reference to allow it to be updated by the
886 /// ElapsedTime RAII object.
888
892
893 void ResetStatistics();
894
895 /// \class LookupInfo Module.h "lldb/Core/Module.h"
896 /// A class that encapsulates name lookup information.
897 ///
898 /// Users can type a wide variety of partial names when setting breakpoints
899 /// by name or when looking for functions by name. The SymbolFile object is
900 /// only required to implement name lookup for function basenames and for
901 /// fully mangled names. This means if the user types in a partial name, we
902 /// must reduce this to a name lookup that will work with all SymbolFile
903 /// objects. So we might reduce a name lookup to look for a basename, and then
904 /// prune out any results that don't match.
905 ///
906 /// The "m_name" member variable represents the name as it was typed by the
907 /// user. "m_lookup_name" will be the name we actually search for through
908 /// the symbol or objects files. Lanaguage is included in case we need to
909 /// filter results by language at a later date. The "m_name_type_mask"
910 /// member variable tells us what kinds of names we are looking for and can
911 /// help us prune out unwanted results.
912 ///
913 /// Function lookups are done in Module.cpp, ModuleList.cpp and in
914 /// BreakpointResolverName.cpp and they all now use this class to do lookups
915 /// correctly.
917 public:
918 LookupInfo() = default;
919
920 LookupInfo(ConstString name, lldb::FunctionNameType name_type_mask,
921 lldb::LanguageType language);
922
923 ConstString GetName() const { return m_name; }
924
925 void SetName(ConstString name) { m_name = name; }
926
928
930
931 lldb::FunctionNameType GetNameTypeMask() const { return m_name_type_mask; }
932
933 void SetNameTypeMask(lldb::FunctionNameType mask) {
934 m_name_type_mask = mask;
935 }
936
938
940 ConstString function_name,
941 lldb::LanguageType language_type = lldb::eLanguageTypeUnknown) const;
942
943 void Prune(SymbolContextList &sc_list, size_t start_idx) const;
944
945 protected:
946 /// What the user originally typed
948
949 /// The actual name will lookup when calling in the object or symbol file
951
952 /// Limit matches to only be for this language
954
955 /// One or more bits from lldb::FunctionNameType that indicate what kind of
956 /// names we are looking for
957 lldb::FunctionNameType m_name_type_mask = lldb::eFunctionNameTypeNone;
958
959 /// If \b true, then demangled names that match will need to contain
960 /// "m_name" in order to be considered a match
962 };
963
964 /// Get a unique hash for this module.
965 ///
966 /// The hash should be enough to identify the file on disk and the
967 /// architecture of the file. If the module represents an object inside of a
968 /// file, then the hash should include the object name and object offset to
969 /// ensure a unique hash. Some examples:
970 /// - just a regular object file (mach-o, elf, coff, etc) should create a hash
971 /// - a universal mach-o file that contains to multiple architectures,
972 /// each architecture slice should have a unique hash even though they come
973 /// from the same file
974 /// - a .o file inside of a BSD archive. Each .o file will have an object name
975 /// and object offset that should produce a unique hash. The object offset
976 /// is needed as BSD archive files can contain multiple .o files that have
977 /// the same name.
978 uint32_t Hash();
979
980 /// Get a unique cache key for the current module.
981 ///
982 /// The cache key must be unique for a file on disk and not change if the file
983 /// is updated. This allows cache data to use this key as a prefix and as
984 /// files are modified in disk, we will overwrite the cache files. If one file
985 /// can contain multiple files, like a universal mach-o file or like a BSD
986 /// archive, the cache key must contain enough information to differentiate
987 /// these different files.
988 std::string GetCacheKey();
989
990 /// Get the global index file cache.
991 ///
992 /// LLDB can cache data for a module between runs. This cache directory can be
993 /// used to stored data that previously was manually created each time you debug.
994 /// Examples include debug information indexes, symbol tables, symbol table
995 /// indexes, and more.
996 ///
997 /// \returns
998 /// If caching is enabled in the lldb settings, return a pointer to the data
999 /// file cache. If caching is not enabled, return NULL.
1000 static DataFileCache *GetIndexCache();
1001protected:
1002 // Member Variables
1003 mutable std::recursive_mutex m_mutex; ///< A mutex to keep this object happy
1004 /// in multi-threaded environments.
1005
1006 /// The modification time for this module when it was created.
1007 llvm::sys::TimePoint<> m_mod_time;
1008
1009 ArchSpec m_arch; ///< The architecture for this module.
1010 UUID m_uuid; ///< Each module is assumed to have a unique identifier to help
1011 /// match it up to debug symbols.
1012 FileSpec m_file; ///< The file representation on disk for this module (if
1013 /// there is one).
1014 FileSpec m_platform_file; ///< The path to the module on the platform on which
1015 /// it is being debugged
1016 FileSpec m_remote_install_file; ///< If set when debugging on remote
1017 /// platforms, this module will be installed
1018 /// at this location
1019 FileSpec m_symfile_spec; ///< If this path is valid, then this is the file
1020 /// that _will_ be used as the symbol file for this
1021 /// module
1022 ConstString m_object_name; ///< The name an object within this module that is
1023 /// selected, or empty of the module is represented
1024 /// by \a m_file.
1025 uint64_t m_object_offset = 0;
1026 llvm::sys::TimePoint<> m_object_mod_time;
1027
1028 /// DataBuffer containing the module image, if it was provided at
1029 /// construction time. Otherwise the data will be retrieved by mapping
1030 /// one of the FileSpec members above.
1032
1033 lldb::ObjectFileSP m_objfile_sp; ///< A shared pointer to the object file
1034 /// parser for this module as it may or may
1035 /// not be shared with the SymbolFile
1036 UnwindTable m_unwind_table; ///< Table of FuncUnwinders
1037 /// objects created for this
1038 /// Module's functions
1040 m_symfile_up; ///< A pointer to the symbol vendor for this module.
1041 std::vector<lldb::SymbolVendorUP>
1042 m_old_symfiles; ///< If anyone calls Module::SetSymbolFileFileSpec() and
1043 /// changes the symbol file,
1044 ///< we need to keep all old symbol files around in case anyone has type
1045 /// references to them
1046 TypeSystemMap m_type_system_map; ///< A map of any type systems associated
1047 /// with this module
1048 /// Module specific source remappings for when you have debug info for a
1049 /// module that doesn't match where the sources currently are.
1052
1053 lldb::SectionListUP m_sections_up; ///< Unified section list for module that
1054 /// is used by the ObjectFile and
1055 /// ObjectFile instances for the debug info
1056
1057 std::atomic<bool> m_did_load_objfile{false};
1058 std::atomic<bool> m_did_load_symfile{false};
1059 std::atomic<bool> m_did_set_uuid{false};
1060 mutable bool m_file_has_changed : 1,
1061 m_first_file_changed_log : 1; /// See if the module was modified after it
1062 /// was initially opened.
1063 /// We store a symbol table parse time duration here because we might have
1064 /// an object file and a symbol file which both have symbol tables. The parse
1065 /// time for the symbol tables can be aggregated here.
1067 /// We store a symbol named index time duration here because we might have
1068 /// an object file and a symbol file which both have symbol tables. The parse
1069 /// time for the symbol tables can be aggregated here.
1071
1073
1074 /// A set of hashes of all warnings and errors, to avoid reporting them
1075 /// multiple times to the same Debugger.
1076 llvm::DenseMap<llvm::stable_hash, std::unique_ptr<std::once_flag>>
1078 std::recursive_mutex m_diagnostic_mutex;
1079
1081 std::vector<uint32_t> &symbol_indexes,
1082 SymbolContextList &sc_list);
1083
1084 bool SetArchitecture(const ArchSpec &new_arch);
1085
1086 void SetUUID(const lldb_private::UUID &uuid);
1087
1089
1090 friend class ModuleList;
1091 friend class ObjectFile;
1092 friend class SymbolFile;
1093
1094private:
1095 Module(); // Only used internally by CreateJITModule ()
1096
1097 Module(const Module &) = delete;
1098 const Module &operator=(const Module &) = delete;
1099
1100 void LogMessage(Log *log, const llvm::formatv_object_base &payload);
1102 const llvm::formatv_object_base &payload);
1103 void ReportWarning(const llvm::formatv_object_base &payload);
1104 void ReportError(const llvm::formatv_object_base &payload);
1105 void ReportErrorIfModifyDetected(const llvm::formatv_object_base &payload);
1106 std::once_flag *GetDiagnosticOnceFlag(llvm::StringRef msg);
1107};
1108
1109} // namespace lldb_private
1110
1111#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:916
void SetName(ConstString name)
Definition Module.h:925
void SetNameTypeMask(lldb::FunctionNameType mask)
Definition Module.h:933
lldb::FunctionNameType GetNameTypeMask() const
Definition Module.h:931
void SetLookupName(ConstString name)
Definition Module.h:929
lldb::LanguageType GetLanguageType() const
Definition Module.h:937
ConstString GetLookupName() const
Definition Module.h:927
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:950
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:957
bool NameMatchesLookupInfo(ConstString function_name, lldb::LanguageType language_type=lldb::eLanguageTypeUnknown) const
Definition Module.cpp:717
lldb::LanguageType m_language
Limit matches to only be for this language.
Definition Module.h:953
ConstString m_name
What the user originally typed.
Definition Module.h:947
ConstString GetName() const
Definition Module.h:923
void Prune(SymbolContextList &sc_list, size_t start_idx) const
Definition Module.cpp:750
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:961
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:350
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:589
std::atomic< bool > m_did_set_uuid
Definition Module.h:1059
void ReportWarningOptimization(std::optional< lldb::user_id_t > debugger_id)
Definition Module.cpp:1064
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:1050
llvm::sys::TimePoint m_object_mod_time
Definition Module.h:1026
virtual ObjectFile * GetObjectFile()
Get the object file representation for the current architecture.
Definition Module.cpp:1177
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:619
void ReportWarning(const char *format, Args &&...args)
Definition Module.h:801
FileSpec m_file
The file representation on disk for this module (if there is one).
Definition Module.h:1012
virtual SymbolFile * GetSymbolFile(bool can_create=true, Stream *feedback_strm=nullptr)
Get the module's symbol file.
Definition Module.cpp:977
static DataFileCache * GetIndexCache()
Get the global index file cache.
Definition Module.cpp:1639
std::vector< lldb::SymbolVendorUP > m_old_symfiles
If anyone calls Module::SetSymbolFileFileSpec() and changes the symbol file,.
Definition Module.h:1042
void ReportWarningUnsupportedLanguage(lldb::LanguageType language, std::optional< lldb::user_id_t > debugger_id)
Definition Module.cpp:1078
const llvm::sys::TimePoint & GetObjectModificationTime() const
Definition Module.h:494
std::once_flag * GetDiagnosticOnceFlag(llvm::StringRef msg)
Definition Module.cpp:1106
void FindCompileUnits(const FileSpec &path, SymbolContextList &sc_list)
Find compile units by partial or full path.
Definition Module.cpp:633
ConstString GetObjectName() const
Definition Module.cpp:1175
uint32_t Hash()
Get a unique hash for this module.
Definition Module.cpp:1615
lldb::ModuleSP CalculateSymbolContextModule() override
Definition Module.cpp:422
static Module * GetAllocatedModuleAtIndex(size_t idx)
Definition Module.cpp:124
std::recursive_mutex m_diagnostic_mutex
Definition Module.h:1078
UUID m_uuid
Each module is assumed to have a unique identifier to help match it up to debug symbols.
Definition Module.h:1010
std::optional< std::string > RemapSourceFile(llvm::StringRef path) const
Remaps a source file given path into new_path.
Definition Module.cpp:1544
const FileSpec & GetSymbolFileFileSpec() const
Definition Module.h:484
llvm::sys::TimePoint m_mod_time
The modification time for this module when it was created.
Definition Module.h:1007
lldb::CompUnitSP GetCompileUnitAtIndex(size_t idx)
Definition Module.cpp:435
FileSpec m_remote_install_file
If set when debugging on remote platforms, this module will be installed at this location.
Definition Module.h:1016
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:455
void SetFileSpecAndObjectName(const FileSpec &file, ConstString object_name)
Definition Module.cpp:1010
std::recursive_mutex m_mutex
A mutex to keep this object happy in multi-threaded environments.
Definition Module.h:1003
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:1031
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:1491
void SetSymbolFileFileSpec(const FileSpec &file)
Definition Module.cpp:1330
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:1551
void FindSymbolsWithNameAndType(ConstString name, lldb::SymbolType symbol_type, SymbolContextList &sc_list)
Definition Module.cpp:1285
void CalculateSymbolContext(SymbolContext *sc) override
Reconstruct the object's symbol context into sc.
Definition Module.cpp:418
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:1019
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:1070
bool ResolveFileAddress(lldb::addr_t vm_addr, Address &so_addr)
Definition Module.cpp:447
PathMappingList & GetSourceMappingList()
Definition Module.h:833
ArchSpec m_arch
The architecture for this module.
Definition Module.h:1009
void ReportError(const char *format, Args &&...args)
Definition Module.h:806
void SetPlatformFileSpec(const FileSpec &file)
Definition Module.h:474
const FileSpec & GetPlatformFileSpec() const
Get accessor for the module platform file specification.
Definition Module.h:468
lldb::SymbolVendorUP m_symfile_up
A pointer to the symbol vendor for this module.
Definition Module.h:1040
const Symbol * FindFirstSymbolWithNameAndType(ConstString name, lldb::SymbolType symbol_type=lldb::eSymbolTypeAny)
Find a symbol in the object file's symbol table.
Definition Module.cpp:1249
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:1077
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:238
std::recursive_mutex & GetMutex() const
Definition Module.h:831
llvm::VersionTuple GetVersion()
Definition Module.cpp:1600
void FindAddressesForLine(const lldb::TargetSP target_sp, const FileSpec &file, uint32_t line, Function *function, std::vector< Address > &output_local, std::vector< Address > &output_extern)
Find addresses by file/line.
Definition Module.cpp:931
StatisticsMap & GetSymbolLocatorStatistics()
Definition Module.h:889
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:811
void DumpSymbolContext(Stream *s) override
Dump the object's symbol context to the stream s.
Definition Module.cpp:424
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:1277
Symtab * GetSymtab(bool can_create=true)
Get the module's symbol table.
Definition Module.cpp:1004
size_t GetNumCompileUnits()
Get the number of compile units for this module.
Definition Module.cpp:428
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:1022
void LogMessage(Log *log, const char *format, Args &&...args)
Definition Module.h:789
bool MatchesModuleSpec(const ModuleSpec &module_ref)
Definition Module.cpp:1503
bool RemapSourceFile(const char *, std::string &) const =delete
~Module() override
Destructor.
Definition Module.cpp:270
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:300
bool LoadScriptingResourceInTarget(Target *target, Status &error, Stream &feedback_stream)
Definition Module.cpp:1415
TypeSystemMap m_type_system_map
A map of any type systems associated with this module.
Definition Module.h:1046
uint64_t m_object_offset
Definition Module.h:1025
const PathMappingList & GetSourceMappingList() const
Definition Module.h:835
void ForEachTypeSystem(llvm::function_ref< bool(lldb::TypeSystemSP)> callback)
Call callback for each TypeSystem in this Module.
Definition Module.cpp:380
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:1053
bool IsExecutable()
Tells whether this module is capable of being the main executable for a process.
Definition Module.cpp:1391
FileSpec m_platform_file
The path to the module on the platform on which it is being debugged.
Definition Module.h:1014
bool MergeArchitecture(const ArchSpec &arch_spec)
Update the ArchSpec to a more specific variant.
Definition Module.cpp:1572
bool FileHasChanged() const
Definition Module.cpp:1053
const ArchSpec & GetArchitecture() const
Get const accessor for the module architecture.
Definition Module.cpp:1019
friend class ObjectFile
Definition Module.h:1091
void LogMessageVerboseBacktrace(Log *log, const char *format, Args &&...args)
Definition Module.h:794
bool GetIsDynamicLinkEditor()
Definition Module.cpp:1606
std::string GetCacheKey()
Get a unique cache key for the current module.
Definition Module.cpp:1629
virtual SectionList * GetSectionList()
Get the unified section list for the module.
Definition Module.cpp:1219
uint64_t GetObjectOffset() const
Definition Module.h:535
llvm::Expected< lldb::TypeSystemSP > GetTypeSystemForLanguage(lldb::LanguageType language)
Definition Module.cpp:376
void Dump(Stream *s)
Dump a description of this object to a Stream.
Definition Module.cpp:1154
StatsDuration & GetSymtabIndexTime()
Accessor for the symbol table index time metric.
Definition Module.h:887
friend class ModuleList
Definition Module.h:1090
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:597
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:1033
void ReportErrorIfModifyDetected(const char *format, Args &&...args)
Definition Module.h:813
void FindSymbolsMatchingRegExAndType(const RegularExpression &regex, lldb::SymbolType symbol_type, SymbolContextList &sc_list, Mangled::NamePreference mangling_preference=Mangled::ePreferDemangled)
Definition Module.cpp:1297
std::atomic< bool > m_did_load_symfile
Definition Module.h:1058
UnwindTable & GetUnwindTable()
Returns a reference to the UnwindTable for this Module.
Definition Module.cpp:1237
void SetRemoteInstallFileSpec(const FileSpec &file)
Definition Module.h:480
std::string GetSpecificationDescription() const
Get the module path and object name.
Definition Module.cpp:1021
UnwindTable m_unwind_table
Table of FuncUnwinders objects created for this Module's functions.
Definition Module.h:1036
const FileSpec & GetFileSpec() const
Get const accessor for the module file specification.
Definition Module.h:454
bool IsLoadedInTarget(Target *target)
Tells whether this module has been loaded in the target passed in.
Definition Module.cpp:1398
void GetDescription(llvm::raw_ostream &s, lldb::DescriptionLevel level=lldb::eDescriptionLevelFull)
Definition Module.cpp:1031
void SetUUID(const lldb_private::UUID &uuid)
Definition Module.cpp:365
bool m_first_file_changed_log
Definition Module.h:1061
void SymbolIndicesToSymbolContextList(Symtab *symtab, std::vector< uint32_t > &symbol_indexes, SymbolContextList &sc_list)
Definition Module.cpp:1259
const llvm::sys::TimePoint & GetModificationTime() const
Definition Module.h:490
const FileSpec & GetRemoteInstallFileSpec() const
Definition Module.h:476
virtual void SectionFileAddressesChanged()
Notify the module that the file addresses for the Sections have been updated.
Definition Module.cpp:1229
std::atomic< bool > m_did_load_objfile
Definition Module.h:1057
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:1534
friend class SymbolFile
Definition Module.h:1092
const Module & operator=(const Module &)=delete
StatisticsMap m_symbol_locator_duration_map
Definition Module.h:1072
void FindTypes(const TypeQuery &query, TypeResults &results)
Find types using a type-matching object that contains all search parameters.
Definition Module.cpp:955
bool SetArchitecture(const ArchSpec &new_arch)
Definition Module.cpp:1483
SectionList * GetUnifiedSectionList()
Definition Module.cpp:1243
StatsDuration m_symtab_parse_time
See if the module was modified after it was initially opened.
Definition Module.h:1066
void ParseAllDebugSymbols()
A debugging function that will cause everything in a module to be parsed.
Definition Module.cpp:385
StatsDuration & GetSymtabParseTime()
Accessor for the symbol table parse time metric.
Definition Module.h:881
A plug-in interface definition class for object file parsers.
Definition ObjectFile.h:45
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