ClangExpressionDeclMap.h revision 3aa7da5cb3327792415de44405e0896c6bdc305b
1//===-- ClangExpressionDeclMap.h --------------------------------*- C++ -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9
10#ifndef liblldb_ClangExpressionDeclMap_h_
11#define liblldb_ClangExpressionDeclMap_h_
12
13// C Includes
14#include <signal.h>
15#include <stdint.h>
16
17// C++ Includes
18#include <vector>
19
20// Other libraries and framework includes
21// Project includes
22#include "llvm/ADT/DenseMap.h"
23#include "lldb/Core/ClangForward.h"
24#include "lldb/Core/Value.h"
25#include "lldb/Expression/ClangExpressionVariable.h"
26#include "lldb/Symbol/TaggedASTType.h"
27#include "lldb/Symbol/SymbolContext.h"
28#include "lldb/Target/ExecutionContext.h"
29
30namespace llvm {
31    class Type;
32    class Value;
33}
34
35namespace lldb_private {
36
37class ClangExpressionVariables;
38class ClangPersistentVariables;
39class Error;
40class Function;
41class NameSearchContext;
42class Variable;
43
44//----------------------------------------------------------------------
45/// @class ClangExpressionDeclMap ClangExpressionDeclMap.h "lldb/Expression/ClangExpressionDeclMap.h"
46/// @brief Manages named entities that are defined in LLDB's debug information.
47///
48/// The Clang parser uses the ClangASTSource as an interface to request named
49/// entities from outside an expression.  The ClangASTSource reports back, listing
50/// all possible objects corresponding to a particular name.  But it in turn
51/// relies on ClangExpressionDeclMap, which performs several important functions.
52///
53/// First, it records what variables and functions were looked up and what Decls
54/// were returned for them.
55///
56/// Second, it constructs a struct on behalf of IRForTarget, recording which
57/// variables should be placed where and relaying this information back so that
58/// IRForTarget can generate context-independent code.
59///
60/// Third, it "materializes" this struct on behalf of the expression command,
61/// finding the current values of each variable and placing them into the
62/// struct so that it can be passed to the JITted version of the IR.
63///
64/// Fourth and finally, it "dematerializes" the struct after the JITted code has
65/// has executed, placing the new values back where it found the old ones.
66//----------------------------------------------------------------------
67class ClangExpressionDeclMap
68{
69public:
70    //------------------------------------------------------------------
71    /// Constructor
72    ///
73    /// Initializes class variabes.
74    //------------------------------------------------------------------
75    ClangExpressionDeclMap();
76
77    //------------------------------------------------------------------
78    /// Destructor
79    //------------------------------------------------------------------
80    ~ClangExpressionDeclMap();
81
82    //------------------------------------------------------------------
83    /// Enable the state needed for parsing and IR transformation.
84    ///
85    /// @param[in] exe_ctx
86    ///     The execution context to use when finding types for variables.
87    ///     Also used to find a "scratch" AST context to store result types.
88    //------------------------------------------------------------------
89    void WillParse(ExecutionContext &exe_ctx);
90
91    //------------------------------------------------------------------
92    /// Disable the state needed for parsing and IR transformation.
93    //------------------------------------------------------------------
94    void DidParse();
95
96    //------------------------------------------------------------------
97    /// [Used by IRForTarget] Get a new result variable name of the form
98    ///     $n, where n is a natural number starting with 0.
99    ///
100    /// @param[in] name
101    ///     The std::string to place the name into.
102    //------------------------------------------------------------------
103    const ConstString &
104    GetPersistentResultName ();
105
106    clang::NamespaceDecl *
107    AddNamespace (NameSearchContext &context,
108                  const ClangNamespaceDecl &namespace_decl);
109
110    //------------------------------------------------------------------
111    /// [Used by IRForTarget] Add a variable to the list of persistent
112    ///     variables for the process.
113    ///
114    /// @param[in] decl
115    ///     The Clang declaration for the persistent variable, used for
116    ///     lookup during parsing.
117    ///
118    /// @param[in] name
119    ///     The name of the persistent variable, usually $something.
120    ///
121    /// @param[in] type
122    ///     The type of the variable, in the Clang parser's context.
123    ///
124    /// @return
125    ///     True on success; false otherwise.
126    //------------------------------------------------------------------
127    bool AddPersistentVariable (const clang::NamedDecl *decl,
128                                const ConstString &name,
129                                TypeFromParser type);
130
131    //------------------------------------------------------------------
132    /// [Used by IRForTarget] Add a variable to the struct that needs to
133    ///     be materialized each time the expression runs.
134    ///
135    /// @param[in] decl
136    ///     The Clang declaration for the variable.
137    ///
138    /// @param[in] name
139    ///     The name of the variable.
140    ///
141    /// @param[in] value
142    ///     The LLVM IR value for this variable.
143    ///
144    /// @param[in] size
145    ///     The size of the variable in bytes.
146    ///
147    /// @param[in] alignment
148    ///     The required alignment of the variable in bytes.
149    ///
150    /// @return
151    ///     True on success; false otherwise.
152    //------------------------------------------------------------------
153    bool AddValueToStruct (const clang::NamedDecl *decl,
154                           const ConstString &name,
155                           llvm::Value *value,
156                           size_t size,
157                           off_t alignment);
158
159    //------------------------------------------------------------------
160    /// [Used by IRForTarget] Finalize the struct, laying out the position
161    /// of each object in it.
162    ///
163    /// @return
164    ///     True on success; false otherwise.
165    //------------------------------------------------------------------
166    bool DoStructLayout ();
167
168    //------------------------------------------------------------------
169    /// [Used by IRForTarget] Get general information about the laid-out
170    /// struct after DoStructLayout() has been called.
171    ///
172    /// @param[out] num_elements
173    ///     The number of elements in the struct.
174    ///
175    /// @param[out] size
176    ///     The size of the struct, in bytes.
177    ///
178    /// @param[out] alignment
179    ///     The alignment of the struct, in bytes.
180    ///
181    /// @return
182    ///     True if the information could be retrieved; false otherwise.
183    //------------------------------------------------------------------
184    bool GetStructInfo (uint32_t &num_elements,
185                        size_t &size,
186                        off_t &alignment);
187
188    //------------------------------------------------------------------
189    /// [Used by IRForTarget] Get specific information about one field
190    /// of the laid-out struct after DoStructLayout() has been called.
191    ///
192    /// @param[out] decl
193    ///     The parsed Decl for the field, as generated by ClangASTSource
194    ///     on ClangExpressionDeclMap's behalf.  In the case of the result
195    ///     value, this will have the name $__lldb_result even if the
196    ///     result value ends up having the name $1.  This is an
197    ///     implementation detail of IRForTarget.
198    ///
199    /// @param[out] value
200    ///     The IR value for the field (usually a GlobalVariable).  In
201    ///     the case of the result value, this will have the correct
202    ///     name ($1, for instance).  This is an implementation detail
203    ///     of IRForTarget.
204    ///
205    /// @param[out] offset
206    ///     The offset of the field from the beginning of the struct.
207    ///     As long as the struct is aligned according to its required
208    ///     alignment, this offset will align the field correctly.
209    ///
210    /// @param[out] name
211    ///     The name of the field as used in materialization.
212    ///
213    /// @param[in] index
214    ///     The index of the field about which information is requested.
215    ///
216    /// @return
217    ///     True if the information could be retrieved; false otherwise.
218    //------------------------------------------------------------------
219    bool GetStructElement (const clang::NamedDecl *&decl,
220                           llvm::Value *&value,
221                           off_t &offset,
222                           ConstString &name,
223                           uint32_t index);
224
225    //------------------------------------------------------------------
226    /// [Used by IRForTarget] Get information about a function given its
227    /// Decl.
228    ///
229    /// @param[in] decl
230    ///     The parsed Decl for the Function, as generated by ClangASTSource
231    ///     on ClangExpressionDeclMap's behalf.
232    ///
233    /// @param[out] value
234    ///     A pointer to the address where a Value for the function's address
235    ///     can be stored.  IRForTarget typically places a ConstantExpr here.
236    ///
237    /// @param[out] ptr
238    ///     The absolute address of the function in the target.
239    ///
240    /// @return
241    ///     True if the information could be retrieved; false otherwise.
242    //------------------------------------------------------------------
243    bool GetFunctionInfo (const clang::NamedDecl *decl,
244                          llvm::Value**& value,
245                          uint64_t &ptr);
246
247    //------------------------------------------------------------------
248    /// [Used by IRForTarget] Get the address of a function given nothing
249    /// but its name.  Some functions are needed but didn't get Decls made
250    /// during parsing -- specifically, sel_registerName is never called
251    /// in the generated IR but we need to call it nonetheless.
252    ///
253    /// @param[in] name
254    ///     The name of the function.
255    ///
256    /// @param[out] ptr
257    ///     The absolute address of the function in the target.
258    ///
259    /// @return
260    ///     True if the address could be retrieved; false otherwise.
261    //------------------------------------------------------------------
262    bool GetFunctionAddress (const ConstString &name,
263                             uint64_t &ptr);
264
265    //------------------------------------------------------------------
266    /// [Used by CommandObjectExpression] Materialize the entire struct
267    /// at a given address, which should be aligned as specified by
268    /// GetStructInfo().
269    ///
270    /// @param[in] exe_ctx
271    ///     The execution context at which to dump the struct.
272    ///
273    /// @param[in] struct_address
274    ///     The address at which the struct should be written.
275    ///
276    /// @param[in] error
277    ///     An Error to populate with any messages related to
278    ///     materializing the struct.
279    ///
280    /// @return
281    ///     True on success; false otherwise.
282    //------------------------------------------------------------------
283    bool Materialize(ExecutionContext &exe_ctx,
284                     lldb::addr_t &struct_address,
285                     Error &error);
286
287    //------------------------------------------------------------------
288    /// [Used by CommandObjectExpression] Get the "this" pointer
289    /// from a given execution context.
290    ///
291    /// @param[out] object_ptr
292    ///     The this pointer.
293    ///
294    /// @param[in] object_name
295    ///     The name of the object pointer -- "this," "self," or similar
296    ///     depending on language
297    ///
298    /// @param[in] exe_ctx
299    ///     The execution context at which to dump the struct.
300    ///
301    /// @param[in] error
302    ///     An Error to populate with any messages related to
303    ///     finding the "this" pointer.
304    ///
305    /// @return
306    ///     True on success; false otherwise.
307    //------------------------------------------------------------------
308    bool GetObjectPointer(lldb::addr_t &object_ptr,
309                          ConstString &object_name,
310                          ExecutionContext &exe_ctx,
311                          Error &error);
312
313    //------------------------------------------------------------------
314    /// [Used by CommandObjectExpression] Pretty-print a materialized
315    /// struct, which must have been materialized by Materialize(),
316    /// byte for byte on a given stream.
317    ///
318    /// @param[in] exe_ctx
319    ///     The execution context from which to read the struct.
320    ///
321    /// @param[in] s
322    ///     The stream on which to write the pretty-printed output.
323    ///
324    /// @param[in] error
325    ///     An Error to populate with any messages related to
326    ///     pretty-printing the struct.
327    ///
328    /// @return
329    ///     True on success; false otherwise.
330    //------------------------------------------------------------------
331    bool DumpMaterializedStruct(ExecutionContext &exe_ctx,
332                                Stream &s,
333                                Error &error);
334
335    //------------------------------------------------------------------
336    /// [Used by CommandObjectExpression] Deaterialize the entire struct.
337    ///
338    /// @param[in] exe_ctx
339    ///     The execution context from which to read the struct.
340    ///
341    /// @param[out] result
342    ///     A ClangExpressionVariable containing the result of the
343    ///     expression, for potential re-use.
344    ///
345    /// @param[in] error
346    ///     An Error to populate with any messages related to
347    ///     dematerializing the struct.
348    ///
349    /// @return
350    ///     True on success; false otherwise.
351    //------------------------------------------------------------------
352    bool Dematerialize(ExecutionContext &exe_ctx,
353                       ClangExpressionVariable *&result,
354                       Error &error);
355
356    //------------------------------------------------------------------
357    /// [Used by ClangASTSource] Find all entities matching a given name,
358    /// using a NameSearchContext to make Decls for them.
359    ///
360    /// @param[in] context
361    ///     The NameSearchContext that can construct Decls for this name.
362    ///
363    /// @param[in] name
364    ///     The name as a plain C string.  The NameSearchContext contains
365    ///     a DeclarationName for the name so at first the name may seem
366    ///     redundant, but ClangExpressionDeclMap operates in RTTI land so
367    ///     it can't access DeclarationName.
368    ///
369    /// @return
370    ///     True on success; false otherwise.
371    //------------------------------------------------------------------
372    void GetDecls (NameSearchContext &context,
373                   const ConstString &name);
374
375    //------------------------------------------------------------------
376    /// [Used by ClangASTSource] Report whether a $__lldb variable has
377    /// been searched for yet.  This is the trigger for beginning to
378    /// actually look for externally-defined names.  (Names that come
379    /// before this are typically the names of built-ins that don't need
380    /// to be looked up.)
381    ///
382    /// @return
383    ///     True if a $__lldb variable has been found.
384    //------------------------------------------------------------------
385    bool
386    GetLookupsEnabled ()
387    {
388        assert(m_parser_vars.get());
389        return m_parser_vars->m_enable_lookups;
390    }
391
392    //------------------------------------------------------------------
393    /// [Used by ClangASTSource] Indicate that a $__lldb variable has
394    /// been found.
395    //------------------------------------------------------------------
396    void
397    SetLookupsEnabled ()
398    {
399        assert(m_parser_vars.get());
400        m_parser_vars->m_enable_lookups = true;
401    }
402
403private:
404    ClangExpressionVariableStore    m_found_entities;           ///< All entities that were looked up for the parser.
405    ClangExpressionVariableList     m_struct_members;           ///< All entities that need to be placed in the struct.
406
407    //----------------------------------------------------------------------
408    /// The following values should not live beyond parsing
409    //----------------------------------------------------------------------
410    struct ParserVars {
411        ParserVars() :
412            m_exe_ctx(NULL),
413            m_sym_ctx(),
414            m_persistent_vars(NULL),
415            m_enable_lookups(false),
416            m_ignore_lookups(false)
417        {
418        }
419
420        ExecutionContext           *m_exe_ctx;          ///< The execution context to use when parsing.
421        SymbolContext               m_sym_ctx;          ///< The symbol context to use in finding variables and types.
422        ClangPersistentVariables   *m_persistent_vars;  ///< The persistent variables for the process.
423        bool                        m_enable_lookups;   ///< Set to true during parsing if we have found the first "$__lldb" name.
424        bool                        m_ignore_lookups;   ///< True during an import when we should be ignoring type lookups.
425    };
426
427    std::auto_ptr<ParserVars> m_parser_vars;
428
429    //----------------------------------------------------------------------
430    /// Activate parser-specific variables
431    //----------------------------------------------------------------------
432    void EnableParserVars()
433    {
434        if (!m_parser_vars.get())
435            m_parser_vars.reset(new struct ParserVars);
436    }
437
438    //----------------------------------------------------------------------
439    /// Deallocate parser-specific variables
440    //----------------------------------------------------------------------
441    void DisableParserVars()
442    {
443        m_parser_vars.reset();
444    }
445
446    //----------------------------------------------------------------------
447    /// The following values contain layout information for the materialized
448    /// struct, but are not specific to a single materialization
449    //----------------------------------------------------------------------
450    struct StructVars {
451        StructVars() :
452            m_struct_alignment(0),
453            m_struct_size(0),
454            m_struct_laid_out(false),
455            m_result_name(),
456            m_object_pointer_type(NULL, NULL)
457        {
458        }
459
460        off_t                       m_struct_alignment;         ///< The alignment of the struct in bytes.
461        size_t                      m_struct_size;              ///< The size of the struct in bytes.
462        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 since).
463        ConstString                 m_result_name;              ///< The name of the result variable ($1, for example)
464        TypeFromUser                m_object_pointer_type;      ///< The type of the "this" variable, if one exists
465    };
466
467    std::auto_ptr<StructVars> m_struct_vars;
468
469    //----------------------------------------------------------------------
470    /// Activate struct variables
471    //----------------------------------------------------------------------
472    void EnableStructVars()
473    {
474        if (!m_struct_vars.get())
475            m_struct_vars.reset(new struct StructVars);
476    }
477
478    //----------------------------------------------------------------------
479    /// Deallocate struct variables
480    //----------------------------------------------------------------------
481    void DisableStructVars()
482    {
483        m_struct_vars.reset();
484    }
485
486    //----------------------------------------------------------------------
487    /// The following values refer to a specific materialization of the
488    /// structure in a process
489    //----------------------------------------------------------------------
490    struct MaterialVars {
491        MaterialVars() :
492            m_allocated_area(NULL),
493            m_materialized_location(NULL)
494        {
495        }
496
497        Process                    *m_process;                  ///< The process that the struct is materialized into.
498        lldb::addr_t                m_allocated_area;           ///< The base of the memory allocated for the struct.  Starts on a potentially unaligned address and may therefore be larger than the struct.
499        lldb::addr_t                m_materialized_location;    ///< The address at which the struct is placed.  Falls inside the allocated area.
500    };
501
502    std::auto_ptr<MaterialVars> m_material_vars;
503
504    //----------------------------------------------------------------------
505    /// Activate materialization-specific variables
506    //----------------------------------------------------------------------
507    void EnableMaterialVars()
508    {
509        if (!m_material_vars.get())
510            m_material_vars.reset(new struct MaterialVars);
511    }
512
513    //----------------------------------------------------------------------
514    /// Deallocate materialization-specific variables
515    //----------------------------------------------------------------------
516    void DisableMaterialVars()
517    {
518        m_material_vars.reset();
519    }
520
521    //------------------------------------------------------------------
522    /// Given a stack frame, find a variable that matches the given name and
523    /// type.  We need this for expression re-use; we may not always get the
524    /// same lldb::Variable back, and we want the expression to work wherever
525    /// it can.  Returns the variable defined in the tightest scope.
526    ///
527    /// @param[in] frame
528    ///     The stack frame to use as a basis for finding the variable.
529    ///
530    /// @param[in] name
531    ///     The name as a plain C string.
532    ///
533    /// @param[in] type
534    ///     The required type for the variable.  This function may be called
535    ///     during parsing, in which case we don't know its type; hence the
536    ///     default.
537    ///
538    /// @return
539    ///     The LLDB Variable found, or NULL if none was found.
540    //------------------------------------------------------------------
541    Variable *FindVariableInScope(StackFrame &frame,
542                                  const ConstString &name,
543                                  TypeFromUser *type = NULL);
544
545    //------------------------------------------------------------------
546    /// Get the value of a variable in a given execution context and return
547    /// the associated Types if needed.
548    ///
549    /// @param[in] exe_ctx
550    ///     The execution context to look for the variable in.
551    ///
552    /// @param[in] var
553    ///     The variable to evaluate.
554    ///
555    /// @param[in] parser_ast_context
556    ///     The AST context of the parser, to store the found type in.
557    ///
558    /// @param[out] found_type
559    ///     The type of the found value, as it was found in the user process.
560    ///     This is only useful when the variable is being inspected on behalf
561    ///     of the parser, hence the default.
562    ///
563    /// @param[out] parser_type
564    ///     The type of the found value, as it was copied into the parser's
565    ///     AST context.  This is only useful when the variable is being
566    ///     inspected on behalf of the parser, hence the default.
567    ///
568    /// @param[in] decl
569    ///     The Decl to be looked up.
570    ///
571    /// @return
572    ///     The LLDB Value for the variable.
573    //------------------------------------------------------------------
574    Value *GetVariableValue(ExecutionContext &exe_ctx,
575                            Variable *var,
576                            clang::ASTContext *parser_ast_context,
577                            TypeFromUser *found_type = NULL,
578                            TypeFromParser *parser_type = NULL);
579
580    //------------------------------------------------------------------
581    /// Use the NameSearchContext to generate a Decl for the given LLDB
582    /// Variable, and put it in the Tuple list.
583    ///
584    /// @param[in] context
585    ///     The NameSearchContext to use when constructing the Decl.
586    ///
587    /// @param[in] var
588    ///     The LLDB Variable that needs a Decl.
589    //------------------------------------------------------------------
590    void AddOneVariable(NameSearchContext &context,
591                        Variable *var);
592
593    //------------------------------------------------------------------
594    /// Use the NameSearchContext to generate a Decl for the given
595    /// persistent variable, and put it in the Tuple list.
596    ///
597    /// @param[in] context
598    ///     The NameSearchContext to use when constructing the Decl.
599    ///
600    /// @param[in] pvar
601    ///     The persistent variable that needs a Decl.
602    //------------------------------------------------------------------
603    void AddOneVariable(NameSearchContext &context, ClangExpressionVariable *pvar);
604
605    //------------------------------------------------------------------
606    /// Use the NameSearchContext to generate a Decl for the given
607    /// function.  (Functions are not placed in the Tuple list.)  Can
608    /// handle both fully typed functions and generic functions.
609    ///
610    /// @param[in] context
611    ///     The NameSearchContext to use when constructing the Decl.
612    ///
613    /// @param[in] fun
614    ///     The Function that needs to be created.  If non-NULL, this is
615    ///     a fully-typed function.
616    ///
617    /// @param[in] sym
618    ///     The Symbol that corresponds to a function that needs to be
619    ///     created with generic type (unitptr_t foo(...)).
620    //------------------------------------------------------------------
621    void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym);
622
623    //------------------------------------------------------------------
624    /// Use the NameSearchContext to generate a Decl for the given
625    /// register.
626    ///
627    /// @param[in] context
628    ///     The NameSearchContext to use when constructing the Decl.
629    ///
630    /// @param[in] reg_info
631    ///     The information corresponding to that register.
632    //------------------------------------------------------------------
633    void AddOneRegister(NameSearchContext &context, const lldb::RegisterInfo *reg_info);
634
635    //------------------------------------------------------------------
636    /// Use the NameSearchContext to generate a Decl for the given
637    /// type.  (Types are not placed in the Tuple list.)
638    ///
639    /// @param[in] context
640    ///     The NameSearchContext to use when constructing the Decl.
641    ///
642    /// @param[in] type
643    ///     The type that needs to be created.
644    ///
645    /// @param[in] add_method
646    ///     True if a method with signature void $__lldb_expr(void*)
647    ///     should be added to the C++ class type passed in
648    //------------------------------------------------------------------
649    void AddOneType(NameSearchContext &context,
650                    TypeFromUser &type,
651                    bool add_method = false);
652
653    //------------------------------------------------------------------
654    /// Actually do the task of materializing or dematerializing the struct.
655    /// Since both tasks are very similar, although ClangExpressionDeclMap
656    /// exposes two functions to the outside, both call DoMaterialize.
657    ///
658    /// @param[in] dematerialize
659    ///     True if the struct is to be dematerialized; false if it is to
660    ///     be materialized.
661    ///
662    /// @param[in] exe_ctx
663    ///     The execution context to use.
664    ///
665    /// @param[out] result
666    ///     If the struct is being dematerialized, a pointer into which the
667    ///     location of the result persistent variable is placed.  If not,
668    ///     NULL.
669    ///
670    /// @param[in] err
671    ///     An Error to populate with any messages related to
672    ///     (de)materializing the struct.
673    ///
674    /// @return
675    ///     True on success; false otherwise.
676    //------------------------------------------------------------------
677    bool DoMaterialize (bool dematerialize,
678                        ExecutionContext &exe_ctx,
679                        ClangExpressionVariable **result,
680                        Error &err);
681
682    //------------------------------------------------------------------
683    /// Clean up the state required to dematerialize the variable.
684    //------------------------------------------------------------------
685    void DidDematerialize ();
686
687    //------------------------------------------------------------------
688    /// Actually do the task of materializing or dematerializing a persistent
689    /// variable.
690    ///
691    /// @param[in] dematerialize
692    ///     True if the variable is to be dematerialized; false if it is to
693    ///     be materialized.
694    ///
695    /// @param[in] exe_ctx
696    ///     The execution context to use.
697    ///
698    /// @param[in] name
699    ///     The name of the persistent variable.
700    ///
701    /// @param[in] addr
702    ///     The address at which to materialize the variable.
703    ///
704    /// @param[in] err
705    ///     An Error to populate with any messages related to
706    ///     (de)materializing the persistent variable.
707    ///
708    /// @return
709    ///     True on success; false otherwise.
710    //------------------------------------------------------------------
711    bool DoMaterializeOnePersistentVariable(bool dematerialize,
712                                            ExecutionContext &exe_ctx,
713                                            const ConstString &name,
714                                            lldb::addr_t addr,
715                                            Error &err);
716
717    //------------------------------------------------------------------
718    /// Actually do the task of materializing or dematerializing a
719    /// variable.
720    ///
721    /// @param[in] dematerialize
722    ///     True if the variable is to be dematerialized; false if it is to
723    ///     be materialized.
724    ///
725    /// @param[in] exe_ctx
726    ///     The execution context to use.
727    ///
728    /// @param[in] sym_ctx
729    ///     The symbol context to use (for looking the variable up).
730    ///
731    /// @param[in] name
732    ///     The name of the variable (for looking the variable up).
733    ///
734    /// @param[in] type
735    ///     The required type of the variable (for looking the variable up).
736    ///
737    /// @param[in] addr
738    ///     The address at which to materialize the variable.
739    ///
740    /// @param[in] err
741    ///     An Error to populate with any messages related to
742    ///     (de)materializing the persistent variable.
743    ///
744    /// @return
745    ///     True on success; false otherwise.
746    //------------------------------------------------------------------
747    bool DoMaterializeOneVariable(bool dematerialize,
748                                  ExecutionContext &exe_ctx,
749                                  const SymbolContext &sym_ctx,
750                                  const ConstString &name,
751                                  TypeFromUser type,
752                                  lldb::addr_t addr,
753                                  Error &err);
754
755    //------------------------------------------------------------------
756    /// Actually do the task of materializing or dematerializing a
757    /// register variable.
758    ///
759    /// @param[in] dematerialize
760    ///     True if the variable is to be dematerialized; false if it is to
761    ///     be materialized.
762    ///
763    /// @param[in] exe_ctx
764    ///     The execution context to use.
765    ///
766    /// @param[in] reg_ctx
767    ///     The register context to use.
768    ///
769    /// @param[in] reg_info
770    ///     The information for the register to read/write.
771    ///
772    /// @param[in] addr
773    ///     The address at which to materialize the variable.
774    ///
775    /// @param[in] err
776    ///     An Error to populate with any messages related to
777    ///     (de)materializing the persistent variable.
778    ///
779    /// @return
780    ///     True on success; false otherwise.
781    //------------------------------------------------------------------
782    bool DoMaterializeOneRegister(bool dematerialize,
783                                  ExecutionContext &exe_ctx,
784                                  RegisterContext &reg_ctx,
785                                  const lldb::RegisterInfo &reg_info,
786                                  lldb::addr_t addr,
787                                  Error &err);
788
789    //------------------------------------------------------------------
790    /// A wrapper for ClangASTContext::CopyType that sets a flag that
791    /// indicates that we should not respond to queries during import.
792    ///
793    /// @param[in] dest_context
794    ///     The target AST context, typically the parser's AST context.
795    ///
796    /// @param[in] source_context
797    ///     The source AST context, typically the AST context of whatever
798    ///     symbol file the type was found in.
799    ///
800    /// @param[in] clang_type
801    ///     The source type.
802    ///
803    /// @return
804    ///     The imported type.
805    //------------------------------------------------------------------
806    void *GuardedCopyType (clang::ASTContext *dest_context,
807                           clang::ASTContext *source_context,
808                           void *clang_type);
809};
810
811} // namespace lldb_private
812
813#endif  // liblldb_ClangExpressionDeclMap_h_
814