LLDB  mainline
ClangExpressionDeclMap.h
Go to the documentation of this file.
1 //===-- ClangExpressionDeclMap.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_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONDECLMAP_H
10 #define LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONDECLMAP_H
11 
12 #include <csignal>
13 #include <cstdint>
14 
15 #include <vector>
16 
17 #include "ClangASTSource.h"
19 
20 #include "lldb/Core/Value.h"
25 #include "lldb/lldb-public.h"
26 #include "clang/AST/Decl.h"
27 #include "llvm/ADT/DenseMap.h"
28 
29 namespace lldb_private {
30 
31 class ClangPersistentVariables;
32 
33 /// \class ClangExpressionDeclMap ClangExpressionDeclMap.h
34 /// "lldb/Expression/ClangExpressionDeclMap.h" Manages named entities that are
35 /// defined in LLDB's debug information.
36 ///
37 /// The Clang parser uses the ClangASTSource as an interface to request named
38 /// entities from outside an expression. The ClangASTSource reports back,
39 /// listing all possible objects corresponding to a particular name. But it
40 /// in turn relies on ClangExpressionDeclMap, which performs several important
41 /// functions.
42 ///
43 /// First, it records what variables and functions were looked up and what
44 /// Decls were returned for them.
45 ///
46 /// Second, it constructs a struct on behalf of IRForTarget, recording which
47 /// variables should be placed where and relaying this information back so
48 /// that IRForTarget can generate context-independent code.
49 ///
50 /// Third, it "materializes" this struct on behalf of the expression command,
51 /// finding the current values of each variable and placing them into the
52 /// struct so that it can be passed to the JITted version of the IR.
53 ///
54 /// Fourth and finally, it "dematerializes" the struct after the JITted code
55 /// has has executed, placing the new values back where it found the old ones.
57 public:
58  /// Constructor
59  ///
60  /// Initializes class variables.
61  ///
62  /// \param[in] keep_result_in_memory
63  /// If true, inhibits the normal deallocation of the memory for
64  /// the result persistent variable, and instead marks the variable
65  /// as persisting.
66  ///
67  /// \param[in] result_delegate
68  /// If non-NULL, use this delegate to report result values. This
69  /// allows the client ClangUserExpression to report a result.
70  ///
71  /// \param[in] target
72  /// The target to use when parsing.
73  ///
74  /// \param[in] importer
75  /// The ClangASTImporter to use when parsing.
76  ///
77  /// \param[in] ctx_obj
78  /// If not empty, then expression is evaluated in context of this object.
79  /// See the comment to `UserExpression::Evaluate` for details.
81  bool keep_result_in_memory,
83  const lldb::TargetSP &target,
84  const std::shared_ptr<ClangASTImporter> &importer, ValueObject *ctx_obj);
85 
86  /// Destructor
87  ~ClangExpressionDeclMap() override;
88 
89  /// Enable the state needed for parsing and IR transformation.
90  ///
91  /// \param[in] exe_ctx
92  /// The execution context to use when finding types for variables.
93  /// Also used to find a "scratch" AST context to store result types.
94  ///
95  /// \param[in] materializer
96  /// If non-NULL, the materializer to populate with information about
97  /// the variables to use
98  ///
99  /// \return
100  /// True if parsing is possible; false if it is unsafe to continue.
101  bool WillParse(ExecutionContext &exe_ctx, Materializer *materializer);
102 
103  void InstallCodeGenerator(clang::ASTConsumer *code_gen);
104 
105  void InstallDiagnosticManager(DiagnosticManager &diag_manager);
106 
107  /// Disable the state needed for parsing and IR transformation.
108  void DidParse();
109 
110  /// [Used by IRForTarget] Add a variable to the list of persistent
111  /// variables for the process.
112  ///
113  /// \param[in] decl
114  /// The Clang declaration for the persistent variable, used for
115  /// lookup during parsing.
116  ///
117  /// \param[in] name
118  /// The name of the persistent variable, usually $something.
119  ///
120  /// \param[in] type
121  /// The type of the variable, in the Clang parser's context.
122  ///
123  /// \return
124  /// True on success; false otherwise.
125  bool AddPersistentVariable(const clang::NamedDecl *decl,
126  ConstString name, TypeFromParser type,
127  bool is_result, bool is_lvalue);
128 
129  /// [Used by IRForTarget] Add a variable to the struct that needs to
130  /// be materialized each time the expression runs.
131  ///
132  /// \param[in] decl
133  /// The Clang declaration for the variable.
134  ///
135  /// \param[in] name
136  /// The name of the variable.
137  ///
138  /// \param[in] value
139  /// The LLVM IR value for this variable.
140  ///
141  /// \param[in] size
142  /// The size of the variable in bytes.
143  ///
144  /// \param[in] alignment
145  /// The required alignment of the variable in bytes.
146  ///
147  /// \return
148  /// True on success; false otherwise.
149  bool AddValueToStruct(const clang::NamedDecl *decl, ConstString name,
150  llvm::Value *value, size_t size,
151  lldb::offset_t alignment);
152 
153  /// [Used by IRForTarget] Finalize the struct, laying out the position of
154  /// each object in it.
155  ///
156  /// \return
157  /// True on success; false otherwise.
158  bool DoStructLayout();
159 
160  /// [Used by IRForTarget] Get general information about the laid-out struct
161  /// after DoStructLayout() has been called.
162  ///
163  /// \param[out] num_elements
164  /// The number of elements in the struct.
165  ///
166  /// \param[out] size
167  /// The size of the struct, in bytes.
168  ///
169  /// \param[out] alignment
170  /// The alignment of the struct, in bytes.
171  ///
172  /// \return
173  /// True if the information could be retrieved; false otherwise.
174  bool GetStructInfo(uint32_t &num_elements, size_t &size,
175  lldb::offset_t &alignment);
176 
177  /// [Used by IRForTarget] Get specific information about one field of the
178  /// laid-out struct after DoStructLayout() has been called.
179  ///
180  /// \param[out] decl
181  /// The parsed Decl for the field, as generated by ClangASTSource
182  /// on ClangExpressionDeclMap's behalf. In the case of the result
183  /// value, this will have the name $__lldb_result even if the
184  /// result value ends up having the name $1. This is an
185  /// implementation detail of IRForTarget.
186  ///
187  /// \param[out] value
188  /// The IR value for the field (usually a GlobalVariable). In
189  /// the case of the result value, this will have the correct
190  /// name ($1, for instance). This is an implementation detail
191  /// of IRForTarget.
192  ///
193  /// \param[out] offset
194  /// The offset of the field from the beginning of the struct.
195  /// As long as the struct is aligned according to its required
196  /// alignment, this offset will align the field correctly.
197  ///
198  /// \param[out] name
199  /// The name of the field as used in materialization.
200  ///
201  /// \param[in] index
202  /// The index of the field about which information is requested.
203  ///
204  /// \return
205  /// True if the information could be retrieved; false otherwise.
206  bool GetStructElement(const clang::NamedDecl *&decl, llvm::Value *&value,
207  lldb::offset_t &offset, ConstString &name,
208  uint32_t index);
209 
210  /// [Used by IRForTarget] Get information about a function given its Decl.
211  ///
212  /// \param[in] decl
213  /// The parsed Decl for the Function, as generated by ClangASTSource
214  /// on ClangExpressionDeclMap's behalf.
215  ///
216  /// \param[out] ptr
217  /// The absolute address of the function in the target.
218  ///
219  /// \return
220  /// True if the information could be retrieved; false otherwise.
221  bool GetFunctionInfo(const clang::NamedDecl *decl, uint64_t &ptr);
222 
223  /// [Used by IRForTarget] Get the address of a symbol given nothing but its
224  /// name.
225  ///
226  /// \param[in] target
227  /// The target to find the symbol in. If not provided,
228  /// then the current parsing context's Target.
229  ///
230  /// \param[in] process
231  /// The process to use. For Objective-C symbols, the process's
232  /// Objective-C language runtime may be queried if the process
233  /// is non-NULL.
234  ///
235  /// \param[in] name
236  /// The name of the symbol.
237  ///
238  /// \param[in] module
239  /// The module to limit the search to. This can be NULL
240  ///
241  /// \return
242  /// Valid load address for the symbol
243  lldb::addr_t GetSymbolAddress(Target &target, Process *process,
244  ConstString name, lldb::SymbolType symbol_type,
245  Module *module = nullptr);
246 
248  lldb::SymbolType symbol_type);
249 
250  struct TargetInfo {
252  size_t address_byte_size = 0;
253 
254  TargetInfo() = default;
255 
256  bool IsValid() {
258  }
259  };
260  TargetInfo GetTargetInfo();
261 
262  /// [Used by ClangASTSource] Find all entities matching a given name, using
263  /// a NameSearchContext to make Decls for them.
264  ///
265  /// \param[in] context
266  /// The NameSearchContext that can construct Decls for this name.
267  void FindExternalVisibleDecls(NameSearchContext &context) override;
268 
269  /// Find all entities matching a given name in a given module/namespace,
270  /// using a NameSearchContext to make Decls for them.
271  ///
272  /// \param[in] context
273  /// The NameSearchContext that can construct Decls for this name.
274  ///
275  /// \param[in] module
276  /// If non-NULL, the module to query.
277  ///
278  /// \param[in] namespace_decl
279  /// If valid and module is non-NULL, the parent namespace.
281  lldb::ModuleSP module,
282  const CompilerDeclContext &namespace_decl);
283 
284 protected:
285  /// Retrieves the declaration with the given name from the storage of
286  /// persistent declarations.
287  ///
288  /// \return
289  /// A persistent decl with the given name or a nullptr.
290  virtual clang::NamedDecl *GetPersistentDecl(ConstString name);
291 
292 private:
294  m_found_entities; ///< All entities that were looked up for the parser.
296  m_struct_members; ///< All entities that need to be placed in the struct.
297  bool m_keep_result_in_memory; ///< True if result persistent variables
298  ///generated by this expression should stay in
299  ///memory.
301  *m_result_delegate; ///< If non-NULL, used to report expression results to
302  ///ClangUserExpression.
303  ValueObject *m_ctx_obj; ///< If not empty, then expression is
304  ///evaluated in context of this object.
305  ///For details see the comment to
306  ///`UserExpression::Evaluate`.
307 
308  /// The following values should not live beyond parsing
309  class ParserVars {
310  public:
311  ParserVars() = default;
312 
314  if (m_exe_ctx.GetTargetPtr())
315  return m_exe_ctx.GetTargetPtr();
316  else if (m_sym_ctx.target_sp)
317  return m_sym_ctx.target_sp.get();
318  return nullptr;
319  }
320 
321  ExecutionContext m_exe_ctx; ///< The execution context to use when parsing.
322  SymbolContext m_sym_ctx; ///< The symbol context to use in finding variables
323  ///and types.
325  nullptr; ///< The persistent variables for the process.
326  bool m_enable_lookups = false; ///< Set to true during parsing if we have
327  ///found the first "$__lldb" name.
328  TargetInfo m_target_info; ///< Basic information about the target.
329  Materializer *m_materializer = nullptr; ///< If non-NULL, the materializer
330  ///to use when reporting used
331  ///variables.
332  clang::ASTConsumer *m_code_gen = nullptr; ///< If non-NULL, a code generator
333  ///that receives new top-level
334  ///functions.
336 
337  private:
338  ParserVars(const ParserVars &) = delete;
339  const ParserVars &operator=(const ParserVars &) = delete;
340  };
341 
342  std::unique_ptr<ParserVars> m_parser_vars;
343 
344  /// Activate parser-specific variables
346  if (!m_parser_vars.get())
347  m_parser_vars = std::make_unique<ParserVars>();
348  }
349 
350  /// Deallocate parser-specific variables
351  void DisableParserVars() { m_parser_vars.reset(); }
352 
353  /// The following values contain layout information for the materialized
354  /// struct, but are not specific to a single materialization
355  struct StructVars {
356  StructVars() : m_result_name(), m_object_pointer_type(nullptr, nullptr) {}
357 
359  0; ///< The alignment of the struct in bytes.
360  size_t m_struct_size = 0; ///< The size of the struct in bytes.
362  false; ///< True if the struct has been laid out and the
363  /// layout is valid (that is, no new fields have been
364  /// added since).
366  m_result_name; ///< The name of the result variable ($1, for example)
367  TypeFromUser m_object_pointer_type; ///< The type of the "this" variable, if
368  ///one exists
369  };
370 
371  std::unique_ptr<StructVars> m_struct_vars;
372 
373  /// Activate struct variables
375  if (!m_struct_vars.get())
376  m_struct_vars.reset(new struct StructVars);
377  }
378 
379  /// Deallocate struct variables
380  void DisableStructVars() { m_struct_vars.reset(); }
381 
384  m_ast_context->getLangOpts());
385  }
386 
387  /// Get this parser's ID for use in extracting parser- and JIT-specific data
388  /// from persistent variables.
389  uint64_t GetParserID() { return (uint64_t) this; }
390 
391  /// Should be called on all copied functions.
392  void MaybeRegisterFunctionBody(clang::FunctionDecl *copied_function_decl);
393 
394  /// Searches the persistent decls of the target for entities with the
395  /// given name.
396  ///
397  /// \param[in] context
398  /// The NameSearchContext that can construct Decls for this name.
399  ///
400  /// \param[in] name
401  /// The name of the entities that need to be found.
402  void SearchPersistenDecls(NameSearchContext &context, const ConstString name);
403 
404  /// Handles looking up $__lldb_class which requires special treatment.
405  ///
406  /// \param[in] context
407  /// The NameSearchContext that can construct Decls for this name.
408  void LookUpLldbClass(NameSearchContext &context);
409 
410  /// Handles looking up $__lldb_objc_class which requires special treatment.
411  ///
412  /// \param[in] context
413  /// The NameSearchContext that can construct Decls for this name.
414  void LookUpLldbObjCClass(NameSearchContext &context);
415 
416  /// Handles looking up the synthetic namespace that contains our local
417  /// variables for the current frame.
418  ///
419  /// \param[in] sym_ctx
420  /// The current SymbolContext of this frame.
421  ///
422  /// \param[in] name_context
423  /// The NameSearchContext that can construct Decls for this name.
425  NameSearchContext &name_context);
426 
427  /// Lookup entities in the ClangModulesDeclVendor.
428  /// \param[in] context
429  /// The NameSearchContext that can construct Decls for this name.
430  ///
431  /// \param[in] name
432  /// The name of the entities that need to be found.
434 
435  /// Looks up a local variable.
436  ///
437  /// \param[in] context
438  /// The NameSearchContext that can construct Decls for this name.
439  ///
440  /// \param[in] name
441  /// The name of the entities that need to be found.
442  ///
443  /// \param[in] sym_ctx
444  /// The current SymbolContext of this frame.
445  ///
446  /// \param[in] namespace_decl
447  /// The parent namespace if there is one.
448  ///
449  /// \return
450  /// True iff a local variable was found.
452  SymbolContext &sym_ctx,
453  const CompilerDeclContext &namespace_decl);
454 
455  /// Searches for functions in the given SymbolContextList.
456  ///
457  /// \param[in] sc_list
458  /// The SymbolContextList to search.
459  ///
460  /// \param[in] frame_decl_context
461  /// The current DeclContext of the current frame.
462  ///
463  /// \return
464  /// A SymbolContextList with any found functions in the front and
465  /// any unknown SymbolContexts which are not functions in the back.
466  /// The SymbolContexts for the functions are ordered by how close they are
467  /// to the DeclContext for the given frame DeclContext.
469  const SymbolContextList &sc_list,
470  const CompilerDeclContext &frame_decl_context);
471 
472  /// Looks up a function.
473  ///
474  /// \param[in] context
475  /// The NameSearchContext that can construct Decls for this name.
476  ///
477  /// \param[in] module_sp
478  /// If non-NULL, the module to query.
479  ///
480  /// \param[in] name
481  /// The name of the function that should be find.
482  ///
483  /// \param[in] namespace_decl
484  /// If valid and module is non-NULL, the parent namespace.
485  void LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp,
486  ConstString name,
487  const CompilerDeclContext &namespace_decl);
488 
489  /// Given a target, find a variable that matches the given name and type.
490  ///
491  /// \param[in] target
492  /// The target to use as a basis for finding the variable.
493  ///
494  /// \param[in] module
495  /// If non-NULL, the module to search.
496  ///
497  /// \param[in] name
498  /// The name as a plain C string.
499  ///
500  /// \param[in] namespace_decl
501  /// If non-NULL and module is non-NULL, the parent namespace.
502  ///
503  /// \return
504  /// The LLDB Variable found, or NULL if none was found.
505  lldb::VariableSP
506  FindGlobalVariable(Target &target, lldb::ModuleSP &module, ConstString name,
507  const CompilerDeclContext &namespace_decl);
508 
509  /// Get the value of a variable in a given execution context and return the
510  /// associated Types if needed.
511  ///
512  /// \param[in] var
513  /// The variable to evaluate.
514  ///
515  /// \param[out] var_location
516  /// The variable location value to fill in
517  ///
518  /// \param[out] found_type
519  /// The type of the found value, as it was found in the user process.
520  /// This is only useful when the variable is being inspected on behalf
521  /// of the parser, hence the default.
522  ///
523  /// \param[out] parser_type
524  /// The type of the found value, as it was copied into the parser's
525  /// AST context. This is only useful when the variable is being
526  /// inspected on behalf of the parser, hence the default.
527  ///
528  /// \return
529  /// Return true if the value was successfully filled in.
530  bool GetVariableValue(lldb::VariableSP &var,
531  lldb_private::Value &var_location,
532  TypeFromUser *found_type = nullptr,
533  TypeFromParser *parser_type = nullptr);
534 
535  /// Use the NameSearchContext to generate a Decl for the given LLDB
536  /// Variable, and put it in the Tuple list.
537  ///
538  /// \param[in] context
539  /// The NameSearchContext to use when constructing the Decl.
540  ///
541  /// \param[in] var
542  /// The LLDB Variable that needs a Decl.
543  ///
544  /// \param[in] valobj
545  /// The LLDB ValueObject for that variable.
546  void AddOneVariable(NameSearchContext &context, lldb::VariableSP var,
547  lldb::ValueObjectSP valobj);
548 
549  /// Use the NameSearchContext to generate a Decl for the given persistent
550  /// variable, and put it in the list of found entities.
551  ///
552  /// \param[in] context
553  /// The NameSearchContext to use when constructing the Decl.
554  ///
555  /// \param[in] pvar_sp
556  /// The persistent variable that needs a Decl.
557  void AddOneVariable(NameSearchContext &context,
558  lldb::ExpressionVariableSP &pvar_sp);
559 
560  /// Use the NameSearchContext to generate a Decl for the given LLDB symbol
561  /// (treated as a variable), and put it in the list of found entities.
562  void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol);
563 
564  /// Use the NameSearchContext to generate a Decl for the given function.
565  /// (Functions are not placed in the Tuple list.) Can handle both fully
566  /// typed functions and generic functions.
567  ///
568  /// \param[in] context
569  /// The NameSearchContext to use when constructing the Decl.
570  ///
571  /// \param[in] fun
572  /// The Function that needs to be created. If non-NULL, this is
573  /// a fully-typed function.
574  ///
575  /// \param[in] sym
576  /// The Symbol that corresponds to a function that needs to be
577  /// created with generic type (unitptr_t foo(...)).
578  void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym);
579 
580  /// Use the NameSearchContext to generate a Decl for the given register.
581  ///
582  /// \param[in] context
583  /// The NameSearchContext to use when constructing the Decl.
584  ///
585  /// \param[in] reg_info
586  /// The information corresponding to that register.
587  void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info);
588 
589  /// Use the NameSearchContext to generate a Decl for the given type. (Types
590  /// are not placed in the Tuple list.)
591  ///
592  /// \param[in] context
593  /// The NameSearchContext to use when constructing the Decl.
594  ///
595  /// \param[in] type
596  /// The type that needs to be created.
597  void AddOneType(NameSearchContext &context, const TypeFromUser &type);
598 
599  /// Adds the class in which the expression is evaluated to the lookup and
600  /// prepares the class to be used as a context for expression evaluation (for
601  /// example, it creates a fake member function that will contain the
602  /// expression LLDB is trying to evaluate).
603  ///
604  /// \param[in] context
605  /// The NameSearchContext to which the class should be added as a lookup
606  /// result.
607  ///
608  /// \param[in] type
609  /// The type of the class that serves as the evaluation context.
611  const TypeFromUser &type);
612 
613  /// Move a type out of the current ASTContext into another, but make sure to
614  /// export all components of the type also.
615  ///
616  /// \param[in] target
617  /// The TypeSystemClang to move to.
618  /// \param[in] source
619  /// The TypeSystemClang to move from. This is assumed to be going away.
620  /// \param[in] parser_type
621  /// The type as it appears in the source context.
622  ///
623  /// \return
624  /// Returns the moved type, or an empty type if there was a problem.
626  TypeFromParser parser_type);
627 
629 };
630 
631 } // namespace lldb_private
632 
633 #endif // LLDB_SOURCE_PLUGINS_EXPRESSIONPARSER_CLANG_CLANGEXPRESSIONDECLMAP_H
lldb_private::ClangExpressionDeclMap::ParserVars::m_materializer
Materializer * m_materializer
If non-NULL, the materializer to use when reporting used variables.
Definition: ClangExpressionDeclMap.h:329
lldb_private::ClangExpressionDeclMap::LookUpLldbClass
void LookUpLldbClass(NameSearchContext &context)
Handles looking up $__lldb_class which requires special treatment.
Definition: ClangExpressionDeclMap.cpp:758
lldb_private::ClangExpressionDeclMap::AddOneVariable
void AddOneVariable(NameSearchContext &context, lldb::VariableSP var, lldb::ValueObjectSP valobj)
Use the NameSearchContext to generate a Decl for the given LLDB Variable, and put it in the Tuple lis...
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb-public.h
lldb_private::ClangExpressionDeclMap::GetStructInfo
bool GetStructInfo(uint32_t &num_elements, size_t &size, lldb::offset_t &alignment)
[Used by IRForTarget] Get general information about the laid-out struct after DoStructLayout() has be...
Definition: ClangExpressionDeclMap.cpp:427
lldb_private::ClangExpressionDeclMap::ParserVars::ParserVars
ParserVars()=default
lldb_private::ClangASTSource::m_ast_context
clang::ASTContext * m_ast_context
The AST context requests are coming in for.
Definition: ClangASTSource.h:381
lldb_private::ClangPersistentVariables
Definition: ClangPersistentVariables.h:33
lldb_private::ClangExpressionDeclMap::GetScratchContext
TypeSystemClang * GetScratchContext(Target &target)
Definition: ClangExpressionDeclMap.h:382
lldb_private::ClangExpressionDeclMap::ParserVars::m_exe_ctx
ExecutionContext m_exe_ctx
The execution context to use when parsing.
Definition: ClangExpressionDeclMap.h:321
lldb_private::ClangExpressionDeclMap::DisableParserVars
void DisableParserVars()
Deallocate parser-specific variables.
Definition: ClangExpressionDeclMap.h:351
lldb_private::ClangExpressionDeclMap::InstallCodeGenerator
void InstallCodeGenerator(clang::ASTConsumer *code_gen)
Definition: ClangExpressionDeclMap.cpp:121
lldb_private::Value
Definition: Value.h:38
lldb_private::Symbol
Definition: Symbol.h:20
lldb_private::ClangExpressionDeclMap::GetVariableValue
bool GetVariableValue(lldb::VariableSP &var, lldb_private::Value &var_location, TypeFromUser *found_type=nullptr, TypeFromParser *parser_type=nullptr)
Get the value of a variable in a given execution context and return the associated Types if needed.
Definition: ClangExpressionDeclMap.cpp:1459
lldb_private::SymbolContext::target_sp
lldb::TargetSP target_sp
The Target for a given query.
Definition: SymbolContext.h:317
lldb_private::ClangExpressionDeclMap::m_result_delegate
Materializer::PersistentVariableDelegate * m_result_delegate
If non-NULL, used to report expression results to ClangUserExpression.
Definition: ClangExpressionDeclMap.h:301
lldb_private::ClangExpressionDeclMap::StructVars
The following values contain layout information for the materialized struct, but are not specific to ...
Definition: ClangExpressionDeclMap.h:355
lldb_private::NameSearchContext
Definition: NameSearchContext.h:26
lldb_private::Process
Definition: Process.h:341
lldb_private::ClangExpressionDeclMap::StructVars::m_struct_size
size_t m_struct_size
The size of the struct in bytes.
Definition: ClangExpressionDeclMap.h:360
lldb_private::ClangExpressionDeclMap::SearchPersistenDecls
void SearchPersistenDecls(NameSearchContext &context, const ConstString name)
Searches the persistent decls of the target for entities with the given name.
Definition: ClangExpressionDeclMap.cpp:729
lldb_private::ClangExpressionDeclMap::EnableStructVars
void EnableStructVars()
Activate struct variables.
Definition: ClangExpressionDeclMap.h:374
lldb_private::SymbolContextList
Definition: SymbolContext.h:379
lldb_private::ClangExpressionDeclMap::InstallDiagnosticManager
void InstallDiagnosticManager(DiagnosticManager &diag_manager)
Definition: ClangExpressionDeclMap.cpp:127
lldb_private::Module
Definition: Module.h:85
lldb_private::ClangExpressionDeclMap::LookUpLldbObjCClass
void LookUpLldbObjCClass(NameSearchContext &context)
Handles looking up $__lldb_objc_class which requires special treatment.
Definition: ClangExpressionDeclMap.cpp:859
lldb::offset_t
uint64_t offset_t
Definition: lldb-types.h:87
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb_private::ClangASTSource
Definition: ClangASTSource.h:33
lldb_private::ClangExpressionDeclMap::AddOneGenericVariable
void AddOneGenericVariable(NameSearchContext &context, const Symbol &symbol)
Use the NameSearchContext to generate a Decl for the given LLDB symbol (treated as a variable),...
Definition: ClangExpressionDeclMap.cpp:1632
lldb_private::ClangExpressionDeclMap::StructVars::m_struct_laid_out
bool m_struct_laid_out
True if the struct has been laid out and the layout is valid (that is, no new fields have been added ...
Definition: ClangExpressionDeclMap.h:361
lldb_private::ClangExpressionDeclMap::m_parser_vars
std::unique_ptr< ParserVars > m_parser_vars
Definition: ClangExpressionDeclMap.h:342
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:451
lldb_private::ClangExpressionDeclMap::ParserVars::m_persistent_vars
ClangPersistentVariables * m_persistent_vars
The persistent variables for the process.
Definition: ClangExpressionDeclMap.h:324
lldb_private::ClangExpressionDeclMap::EnableParserVars
void EnableParserVars()
Activate parser-specific variables.
Definition: ClangExpressionDeclMap.h:345
lldb_private::ClangExpressionDeclMap::ParserVars::GetTarget
Target * GetTarget()
Definition: ClangExpressionDeclMap.h:313
lldb_private::ClangExpressionDeclMap::StructVars::m_object_pointer_type
TypeFromUser m_object_pointer_type
The type of the "this" variable, if one exists.
Definition: ClangExpressionDeclMap.h:367
lldb_private::ClangExpressionDeclMap::AddContextClassType
void AddContextClassType(NameSearchContext &context, const TypeFromUser &type)
Adds the class in which the expression is evaluated to the lookup and prepares the class to be used a...
Definition: ClangExpressionDeclMap.cpp:1894
lldb_private::ClangExpressionDeclMap::DeportType
TypeFromUser DeportType(TypeSystemClang &target, TypeSystemClang &source, TypeFromParser parser_type)
Move a type out of the current ASTContext into another, but make sure to export all components of the...
Definition: ClangExpressionDeclMap.cpp:182
ClangASTSource.h
lldb_private::ClangExpressionDeclMap::ParserVars::m_target_info
TargetInfo m_target_info
Basic information about the target.
Definition: ClangExpressionDeclMap.h:328
lldb_private::Function
Definition: Function.h:413
lldb_private::ClangExpressionDeclMap::~ClangExpressionDeclMap
~ClangExpressionDeclMap() override
Destructor.
Definition: ClangExpressionDeclMap.cpp:76
lldb_private::ClangExpressionDeclMap::m_found_entities
ExpressionVariableList m_found_entities
All entities that were looked up for the parser.
Definition: ClangExpressionDeclMap.h:294
lldb_private::ClangExpressionDeclMap::LookupLocalVarNamespace
void LookupLocalVarNamespace(SymbolContext &sym_ctx, NameSearchContext &name_context)
Handles looking up the synthetic namespace that contains our local variables for the current frame.
Definition: ClangExpressionDeclMap.cpp:989
lldb_private::ClangExpressionDeclMap::AddPersistentVariable
bool AddPersistentVariable(const clang::NamedDecl *decl, ConstString name, TypeFromParser type, bool is_result, bool is_lvalue)
[Used by IRForTarget] Add a variable to the list of persistent variables for the process.
Definition: ClangExpressionDeclMap.cpp:192
lldb_private::ClangExpressionDeclMap::SearchFunctionsInSymbolContexts
SymbolContextList SearchFunctionsInSymbolContexts(const SymbolContextList &sc_list, const CompilerDeclContext &frame_decl_context)
Searches for functions in the given SymbolContextList.
Definition: ClangExpressionDeclMap.cpp:1117
lldb_private::ClangExpressionDeclMap::GetPersistentDecl
virtual clang::NamedDecl * GetPersistentDecl(ConstString name)
Retrieves the declaration with the given name from the storage of persistent declarations.
Definition: ClangExpressionDeclMap.cpp:715
lldb_private::ClangExpressionDeclMap::GetTargetInfo
TargetInfo GetTargetInfo()
Definition: ClangExpressionDeclMap.cpp:160
lldb_private::ClangExpressionDeclMap::TargetInfo
Definition: ClangExpressionDeclMap.h:250
lldb_private::ClangExpressionDeclMap::GetFunctionInfo
bool GetFunctionInfo(const clang::NamedDecl *decl, uint64_t &ptr)
[Used by IRForTarget] Get information about a function given its Decl.
Definition: ClangExpressionDeclMap.cpp:477
lldb_private::ClangExpressionDeclMap::StructVars::m_result_name
ConstString m_result_name
The name of the result variable ($1, for example)
Definition: ClangExpressionDeclMap.h:366
lldb_private::ClangExpressionDeclMap::StructVars::StructVars
StructVars()
Definition: ClangExpressionDeclMap.h:356
lldb_private::TaggedASTType< 1 >
lldb_private::ClangExpressionDeclMap::GetTypeSystemClang
TypeSystemClang * GetTypeSystemClang()
Definition: ClangExpressionDeclMap.cpp:623
lldb_private::ClangExpressionDeclMap::LookupLocalVariable
bool LookupLocalVariable(NameSearchContext &context, ConstString name, SymbolContext &sym_ctx, const CompilerDeclContext &namespace_decl)
Looks up a local variable.
Definition: ClangExpressionDeclMap.cpp:1062
lldb_private::ClangExpressionDeclMap::GetParserID
uint64_t GetParserID()
Get this parser's ID for use in extracting parser- and JIT-specific data from persistent variables.
Definition: ClangExpressionDeclMap.h:389
lldb_private::ClangExpressionDeclMap::TargetInfo::TargetInfo
TargetInfo()=default
lldb_private::TypeFromParser
TaggedASTType< 0 > TypeFromParser
Definition: TaggedASTType.h:39
lldb_private::ClangExpressionDeclMap::MaybeRegisterFunctionBody
void MaybeRegisterFunctionBody(clang::FunctionDecl *copied_function_decl)
Should be called on all copied functions.
Definition: ClangExpressionDeclMap.cpp:707
lldb_private::ConstString
Definition: ConstString.h:40
lldb_private::ClangExpressionDeclMap::LookupFunction
void LookupFunction(NameSearchContext &context, lldb::ModuleSP module_sp, ConstString name, const CompilerDeclContext &namespace_decl)
Looks up a function.
Definition: ClangExpressionDeclMap.cpp:1204
lldb_private::Materializer::PersistentVariableDelegate
Definition: Materializer.h:70
lldb_private::ExpressionVariableList
Definition: ExpressionVariable.h:120
lldb_private::ClangExpressionDeclMap::m_ctx_obj
ValueObject * m_ctx_obj
If not empty, then expression is evaluated in context of this object.
Definition: ClangExpressionDeclMap.h:303
lldb_private::ClangExpressionDeclMap::AddOneType
void AddOneType(NameSearchContext &context, const TypeFromUser &type)
Use the NameSearchContext to generate a Decl for the given type.
Definition: ClangExpressionDeclMap.cpp:1961
lldb_private::ClangExpressionDeclMap::DisableStructVars
void DisableStructVars()
Deallocate struct variables.
Definition: ClangExpressionDeclMap.h:380
lldb_private::ClangExpressionDeclMap::ParserVars::m_code_gen
clang::ASTConsumer * m_code_gen
If non-NULL, a code generator that receives new top-level functions.
Definition: ClangExpressionDeclMap.h:332
lldb_private::ClangExpressionDeclMap::TargetInfo::byte_order
lldb::ByteOrder byte_order
Definition: ClangExpressionDeclMap.h:251
lldb_private::Materializer
Definition: Materializer.h:23
lldb::SymbolType
SymbolType
Symbol types.
Definition: lldb-enumerations.h:612
lldb_private::CompilerDeclContext
Represents a generic declaration context in a program.
Definition: CompilerDeclContext.h:30
lldb_private::ClangExpressionDeclMap::ClangExpressionDeclMap
ClangExpressionDeclMap(bool keep_result_in_memory, Materializer::PersistentVariableDelegate *result_delegate, const lldb::TargetSP &target, const std::shared_ptr< ClangASTImporter > &importer, ValueObject *ctx_obj)
Constructor.
Definition: ClangExpressionDeclMap.cpp:64
lldb_private::ClangExpressionDeclMap::ParserVars::m_diagnostics
DiagnosticManager * m_diagnostics
Definition: ClangExpressionDeclMap.h:335
lldb_private::ClangExpressionDeclMap::ParserVars
The following values should not live beyond parsing.
Definition: ClangExpressionDeclMap.h:309
lldb_private::ClangExpressionDeclMap::DoStructLayout
bool DoStructLayout()
[Used by IRForTarget] Finalize the struct, laying out the position of each object in it.
Definition: ClangExpressionDeclMap.cpp:410
lldb_private::ClangExpressionDeclMap::TargetInfo::address_byte_size
size_t address_byte_size
Definition: ClangExpressionDeclMap.h:252
Materializer.h
lldb_private::ClangExpressionDeclMap::m_struct_members
ExpressionVariableList m_struct_members
All entities that need to be placed in the struct.
Definition: ClangExpressionDeclMap.h:296
lldb_private::ValueObject
ValueObject:
Definition: ValueObject.h:105
lldb_private::ClangExpressionDeclMap::TargetInfo::IsValid
bool IsValid()
Definition: ClangExpressionDeclMap.h:256
lldb_private::ClangExpressionDeclMap::StructVars::m_struct_alignment
lldb::offset_t m_struct_alignment
The alignment of the struct in bytes.
Definition: ClangExpressionDeclMap.h:358
lldb::eByteOrderInvalid
@ eByteOrderInvalid
Definition: lldb-enumerations.h:139
lldb_private::ClangExpressionDeclMap::FindGlobalVariable
lldb::VariableSP FindGlobalVariable(Target &target, lldb::ModuleSP &module, ConstString name, const CompilerDeclContext &namespace_decl)
Given a target, find a variable that matches the given name and type.
Definition: ClangExpressionDeclMap.cpp:608
uint32_t
lldb_private::ClangExpressionDeclMap::ParserVars::m_sym_ctx
SymbolContext m_sym_ctx
The symbol context to use in finding variables and types.
Definition: ClangExpressionDeclMap.h:322
lldb_private::ClangExpressionDeclMap::LookupInModulesDeclVendor
void LookupInModulesDeclVendor(NameSearchContext &context, ConstString name)
Lookup entities in the ClangModulesDeclVendor.
Definition: ClangExpressionDeclMap.cpp:1015
lldb_private::ClangExpressionDeclMap::AddValueToStruct
bool AddValueToStruct(const clang::NamedDecl *decl, ConstString name, llvm::Value *value, size_t size, lldb::offset_t alignment)
[Used by IRForTarget] Add a variable to the struct that needs to be materialized each time the expres...
Definition: ClangExpressionDeclMap.cpp:322
lldb_private::ClangExpressionDeclMap::GetStructElement
bool GetStructElement(const clang::NamedDecl *&decl, llvm::Value *&value, lldb::offset_t &offset, ConstString &name, uint32_t index)
[Used by IRForTarget] Get specific information about one field of the laid-out struct after DoStructL...
Definition: ClangExpressionDeclMap.cpp:441
lldb_private::DiagnosticManager
Definition: DiagnosticManager.h:93
TaggedASTType.h
lldb_private::ClangExpressionDeclMap::ParserVars::operator=
const ParserVars & operator=(const ParserVars &)=delete
lldb_private::ScratchTypeSystemClang::GetForTarget
static TypeSystemClang * GetForTarget(Target &target, llvm::Optional< IsolatedASTKind > ast_kind=DefaultAST, bool create_on_demand=true)
Returns the scratch TypeSystemClang for the given target.
Definition: TypeSystemClang.cpp:9728
lldb_private::ClangExpressionDeclMap::AddOneFunction
void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym)
Use the NameSearchContext to generate a Decl for the given function.
Definition: ClangExpressionDeclMap.cpp:1723
lldb_private::ClangExpressionDeclMap::GetSymbolAddress
lldb::addr_t GetSymbolAddress(Target &target, Process *process, ConstString name, lldb::SymbolType symbol_type, Module *module=nullptr)
[Used by IRForTarget] Get the address of a symbol given nothing but its name.
Definition: ClangExpressionDeclMap.cpp:496
SymbolContext.h
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TypeSystemClang
A TypeSystem implementation based on Clang.
Definition: TypeSystemClang.h:106
lldb_private::ClangExpressionDeclMap::m_struct_vars
std::unique_ptr< StructVars > m_struct_vars
Definition: ClangExpressionDeclMap.h:371
ClangExpressionVariable.h
lldb_private::ClangExpressionDeclMap::FindExternalVisibleDecls
void FindExternalVisibleDecls(NameSearchContext &context) override
[Used by ClangASTSource] Find all entities matching a given name, using a NameSearchContext to make D...
Definition: ClangExpressionDeclMap.cpp:643
lldb_private::ClangExpressionDeclMap::AddOneRegister
void AddOneRegister(NameSearchContext &context, const RegisterInfo *reg_info)
Use the NameSearchContext to generate a Decl for the given register.
Definition: ClangExpressionDeclMap.cpp:1684
Value.h
lldb_private::ClangExpressionDeclMap::WillParse
bool WillParse(ExecutionContext &exe_ctx, Materializer *materializer)
Enable the state needed for parsing and IR transformation.
Definition: ClangExpressionDeclMap.cpp:85
lldb_private::ClangExpressionDeclMap::DidParse
void DidParse()
Disable the state needed for parsing and IR transformation.
Definition: ClangExpressionDeclMap.cpp:133
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:200
ExecutionContext.h
lldb_private::ClangExpressionDeclMap::m_keep_result_in_memory
bool m_keep_result_in_memory
True if result persistent variables generated by this expression should stay in memory.
Definition: ClangExpressionDeclMap.h:297
lldb_private::ClangExpressionDeclMap
Definition: ClangExpressionDeclMap.h:56
lldb::ByteOrder
ByteOrder
Byte ordering definitions.
Definition: lldb-enumerations.h:138
lldb_private::ClangExpressionDeclMap::ParserVars::m_enable_lookups
bool m_enable_lookups
Set to true during parsing if we have found the first "$__lldb" name.
Definition: ClangExpressionDeclMap.h:326