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