ClangExpressionDeclMap.h revision e562a073bba53fa46161feb51d1b1e36f9af9666
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 "lldb/Core/ClangForward.h" 23#include "lldb/Core/Value.h" 24#include "lldb/Symbol/TaggedASTType.h" 25 26namespace llvm { 27 class Type; 28 class Value; 29} 30 31namespace lldb_private { 32 33class ClangPersistentVariables; 34class Error; 35class Function; 36class NameSearchContext; 37class Variable; 38 39class ClangExpressionDeclMap 40{ 41public: 42 ClangExpressionDeclMap(ExecutionContext *exe_ctx, 43 ClangPersistentVariables &persistent_vars); 44 ~ClangExpressionDeclMap(); 45 46 // Interface for ClangStmtVisitor 47 bool GetIndexForDecl (uint32_t &index, 48 const clang::Decl *decl); 49 50 // Interface for IRForTarget 51 bool AddValueToStruct (llvm::Value *value, 52 const clang::NamedDecl *decl, 53 std::string &name, 54 void *type, 55 clang::ASTContext *ast_context, 56 size_t size, 57 off_t alignment); 58 bool DoStructLayout (); 59 bool GetStructInfo (uint32_t &num_elements, 60 size_t &size, 61 off_t &alignment); 62 bool GetStructElement (const clang::NamedDecl *&decl, 63 llvm::Value *&value, 64 off_t &offset, 65 uint32_t index); 66 67 bool GetFunctionInfo (const clang::NamedDecl *decl, 68 llvm::Value**& value, 69 uint64_t &ptr); 70 71 bool GetFunctionAddress (const char *name, 72 uint64_t &ptr); 73 74 // Interface for DwarfExpression 75 Value *GetValueForIndex (uint32_t index); 76 77 // Interface for CommandObjectExpression 78 bool Materialize(ExecutionContext *exe_ctx, 79 lldb::addr_t &struct_address, 80 Error &error); 81 82 bool DumpMaterializedStruct(ExecutionContext *exe_ctx, 83 Stream &s, 84 Error &error); 85 86 bool Dematerialize(ExecutionContext *exe_ctx, 87 lldb_private::Value &result_value, 88 Error &error); 89 90 // Interface for ClangASTSource 91 void GetDecls (NameSearchContext &context, 92 const char *name); 93 94 typedef TaggedASTType<0> TypeFromParser; 95 typedef TaggedASTType<1> TypeFromUser; 96private: 97 struct Tuple 98 { 99 const clang::NamedDecl *m_decl; 100 TypeFromParser m_parser_type; 101 TypeFromUser m_user_type; 102 lldb_private::Value *m_value; /* owned by ClangExpressionDeclMap */ 103 llvm::Value *m_llvm_value; 104 }; 105 106 struct StructMember 107 { 108 const clang::NamedDecl *m_decl; 109 llvm::Value *m_value; 110 std::string m_name; 111 TypeFromParser m_parser_type; 112 off_t m_offset; 113 size_t m_size; 114 off_t m_alignment; 115 }; 116 117 typedef std::vector<Tuple> TupleVector; 118 typedef TupleVector::iterator TupleIterator; 119 120 typedef std::vector<StructMember> StructMemberVector; 121 typedef StructMemberVector::iterator StructMemberIterator; 122 123 TupleVector m_tuples; 124 StructMemberVector m_members; 125 ExecutionContext *m_exe_ctx; 126 SymbolContext *m_sym_ctx; /* owned by ClangExpressionDeclMap */ 127 ClangPersistentVariables &m_persistent_vars; 128 off_t m_struct_alignment; 129 size_t m_struct_size; 130 bool m_struct_laid_out; 131 lldb::addr_t m_allocated_area; 132 lldb::addr_t m_materialized_location; 133 134 Variable *FindVariableInScope(const SymbolContext &sym_ctx, 135 const char *name, 136 TypeFromUser *type = NULL); 137 138 Value *GetVariableValue(ExecutionContext &exe_ctx, 139 Variable *var, 140 clang::ASTContext *parser_ast_context, 141 TypeFromUser *found_type = NULL, 142 TypeFromParser *parser_type = NULL); 143 144 void AddOneVariable(NameSearchContext &context, Variable *var); 145 void AddOneFunction(NameSearchContext &context, Function *fun, Symbol *sym); 146 void AddOneType(NameSearchContext &context, Type *type); 147 148 bool DoMaterialize (bool dematerialize, 149 ExecutionContext *exe_ctx, 150 lldb_private::Value *result_value, /* must be non-NULL if D is set */ 151 Error &err); 152 153 bool DoMaterializeOneVariable(bool dematerialize, 154 ExecutionContext &exe_ctx, 155 const SymbolContext &sym_ctx, 156 const char *name, 157 TypeFromUser type, 158 lldb::addr_t addr, 159 Error &err); 160}; 161 162class ClangPersistentVariables 163{ 164 165}; 166 167} // namespace lldb_private 168 169#endif // liblldb_ClangExpressionDeclMap_h_ 170