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