Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- ClangExpressionDeclMap.cpp -----------------------------*- 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 | #include "lldb/Expression/ClangExpressionDeclMap.h" |
| 11 | |
| 12 | // C Includes |
| 13 | // C++ Includes |
| 14 | // Other libraries and framework includes |
| 15 | // Project includes |
Sean Callanan | 47a5c4c | 2010-09-23 03:01:22 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclarationName.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 17 | #include "lldb/lldb-private.h" |
| 18 | #include "lldb/Core/Address.h" |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Error.h" |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #include "lldb/Core/Module.h" |
| 22 | #include "lldb/Expression/ClangASTSource.h" |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 23 | #include "lldb/Expression/ClangPersistentVariables.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 24 | #include "lldb/Symbol/ClangASTContext.h" |
| 25 | #include "lldb/Symbol/CompileUnit.h" |
| 26 | #include "lldb/Symbol/Function.h" |
| 27 | #include "lldb/Symbol/ObjectFile.h" |
| 28 | #include "lldb/Symbol/SymbolContext.h" |
| 29 | #include "lldb/Symbol/Type.h" |
| 30 | #include "lldb/Symbol/TypeList.h" |
| 31 | #include "lldb/Symbol/Variable.h" |
| 32 | #include "lldb/Symbol/VariableList.h" |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 33 | #include "lldb/Target/ExecutionContext.h" |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 34 | #include "lldb/Target/Process.h" |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 35 | #include "lldb/Target/RegisterContext.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | #include "lldb/Target/StackFrame.h" |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 37 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 39 | using namespace lldb_private; |
| 40 | using namespace clang; |
| 41 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 42 | ClangExpressionDeclMap::ClangExpressionDeclMap (ExecutionContext *exe_ctx) : |
| 43 | m_found_entities (), |
| 44 | m_struct_members (), |
| 45 | m_exe_ctx (), |
| 46 | m_sym_ctx (), |
| 47 | m_persistent_vars (NULL), |
| 48 | m_struct_alignment (0), |
| 49 | m_struct_size (0), |
| 50 | m_struct_laid_out (false), |
| 51 | m_enable_lookups (false), |
| 52 | m_allocated_area (0), |
| 53 | m_materialized_location (0), |
| 54 | m_result_name (), |
| 55 | m_object_pointer_type (), |
| 56 | m_lookedup_types () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 57 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 58 | if (exe_ctx) |
| 59 | { |
| 60 | m_exe_ctx = *exe_ctx; |
| 61 | if (exe_ctx->frame) |
| 62 | m_sym_ctx = exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything); |
| 63 | if (exe_ctx->process) |
| 64 | m_persistent_vars = &exe_ctx->process->GetPersistentVariables(); |
| 65 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | ClangExpressionDeclMap::~ClangExpressionDeclMap() |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 69 | { |
| 70 | for (uint64_t entity_index = 0, num_entities = m_found_entities.Size(); |
| 71 | entity_index < num_entities; |
| 72 | ++entity_index) |
| 73 | { |
| 74 | ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(entity_index)); |
| 75 | if (entity.m_parser_vars.get() && |
| 76 | entity.m_parser_vars->m_lldb_value) |
| 77 | delete entity.m_parser_vars->m_lldb_value; |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 78 | |
| 79 | entity.DisableParserVars(); |
| 80 | } |
| 81 | |
| 82 | for (uint64_t pvar_index = 0, num_pvars = m_persistent_vars->Size(); |
| 83 | pvar_index < num_pvars; |
| 84 | ++pvar_index) |
| 85 | { |
| 86 | ClangExpressionVariable &pvar(m_persistent_vars->VariableAtIndex(pvar_index)); |
| 87 | pvar.DisableParserVars(); |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 88 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 89 | |
Sean Callanan | 7a60b94 | 2010-10-08 01:58:41 +0000 | [diff] [blame] | 90 | if (m_materialized_location) |
Sean Callanan | c2c6f77 | 2010-10-26 00:31:56 +0000 | [diff] [blame^] | 91 | { |
| 92 | //#define SINGLE_STEP_EXPRESSIONS |
| 93 | |
| 94 | #ifndef SINGLE_STEP_EXPRESSIONS |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 95 | m_exe_ctx.process->DeallocateMemory(m_materialized_location); |
Sean Callanan | c2c6f77 | 2010-10-26 00:31:56 +0000 | [diff] [blame^] | 96 | #endif |
Sean Callanan | 7a60b94 | 2010-10-08 01:58:41 +0000 | [diff] [blame] | 97 | m_materialized_location = 0; |
| 98 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 99 | } |
| 100 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 101 | // Interface for IRForTarget |
| 102 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 103 | const ConstString & |
| 104 | ClangExpressionDeclMap::GetPersistentResultName () |
Sean Callanan | 82b74c8 | 2010-08-12 01:56:52 +0000 | [diff] [blame] | 105 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 106 | if (!m_result_name) |
| 107 | m_persistent_vars->GetNextResultName(m_result_name); |
| 108 | return m_result_name; |
Sean Callanan | 82b74c8 | 2010-08-12 01:56:52 +0000 | [diff] [blame] | 109 | } |
| 110 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 111 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 112 | ClangExpressionDeclMap::AddPersistentVariable |
| 113 | ( |
| 114 | const clang::NamedDecl *decl, |
| 115 | const ConstString &name, |
| 116 | TypeFromParser parser_type |
| 117 | ) |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 118 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 119 | clang::ASTContext *context(m_exe_ctx.target->GetScratchClangASTContext()->getASTContext()); |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 120 | |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 121 | TypeFromUser user_type(ClangASTContext::CopyType(context, |
Sean Callanan | 82b74c8 | 2010-08-12 01:56:52 +0000 | [diff] [blame] | 122 | parser_type.GetASTContext(), |
| 123 | parser_type.GetOpaqueQualType()), |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 124 | context); |
| 125 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 126 | if (!m_persistent_vars->CreatePersistentVariable (name, user_type)) |
| 127 | return false; |
| 128 | |
| 129 | ClangExpressionVariable *var = m_persistent_vars->GetVariable(name); |
| 130 | |
| 131 | if (!var) |
| 132 | return false; |
| 133 | |
| 134 | var->EnableParserVars(); |
| 135 | |
| 136 | var->m_parser_vars->m_named_decl = decl; |
| 137 | var->m_parser_vars->m_parser_type = parser_type; |
| 138 | |
| 139 | return true; |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 143 | ClangExpressionDeclMap::AddValueToStruct |
| 144 | ( |
| 145 | const clang::NamedDecl *decl, |
| 146 | const ConstString &name, |
| 147 | llvm::Value *value, |
| 148 | size_t size, |
| 149 | off_t alignment |
| 150 | ) |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 151 | { |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 152 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 153 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 154 | m_struct_laid_out = false; |
| 155 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 156 | if (m_struct_members.GetVariable(decl)) |
| 157 | return true; |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 158 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 159 | ClangExpressionVariable *var = m_found_entities.GetVariable(decl); |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 160 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 161 | if (!var) |
| 162 | var = m_persistent_vars->GetVariable(decl); |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 163 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 164 | if (!var) |
| 165 | return false; |
| 166 | |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 167 | if (log) |
| 168 | log->Printf("Adding value for decl %p [%s - %s] to the structure", |
| 169 | decl, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 170 | name.GetCString(), |
| 171 | var->m_name.GetCString()); |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 172 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 173 | // We know entity->m_parser_vars is valid because we used a parser variable |
| 174 | // to find it |
| 175 | var->m_parser_vars->m_llvm_value = value; |
| 176 | |
| 177 | var->EnableJITVars(); |
| 178 | var->m_jit_vars->m_alignment = alignment; |
| 179 | var->m_jit_vars->m_size = size; |
| 180 | |
| 181 | m_struct_members.AddVariable(*var); |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 182 | |
| 183 | return true; |
| 184 | } |
| 185 | |
| 186 | bool |
| 187 | ClangExpressionDeclMap::DoStructLayout () |
| 188 | { |
| 189 | if (m_struct_laid_out) |
| 190 | return true; |
| 191 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 192 | off_t cursor = 0; |
| 193 | |
| 194 | m_struct_alignment = 0; |
| 195 | m_struct_size = 0; |
| 196 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 197 | for (uint64_t member_index = 0, num_members = m_struct_members.Size(); |
| 198 | member_index < num_members; |
| 199 | ++member_index) |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 200 | { |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 201 | ClangExpressionVariable &member(m_struct_members.VariableAtIndex(member_index)); |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 202 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 203 | if (!member.m_jit_vars.get()) |
| 204 | return false; |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 205 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 206 | if (member_index == 0) |
| 207 | m_struct_alignment = member.m_jit_vars->m_alignment; |
| 208 | |
| 209 | if (cursor % member.m_jit_vars->m_alignment) |
| 210 | cursor += (member.m_jit_vars->m_alignment - (cursor % member.m_jit_vars->m_alignment)); |
| 211 | |
| 212 | member.m_jit_vars->m_offset = cursor; |
| 213 | cursor += member.m_jit_vars->m_size; |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | m_struct_size = cursor; |
| 217 | |
| 218 | m_struct_laid_out = true; |
| 219 | return true; |
| 220 | } |
| 221 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 222 | bool ClangExpressionDeclMap::GetStructInfo |
| 223 | ( |
| 224 | uint32_t &num_elements, |
| 225 | size_t &size, |
| 226 | off_t &alignment |
| 227 | ) |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 228 | { |
| 229 | if (!m_struct_laid_out) |
| 230 | return false; |
| 231 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 232 | num_elements = m_struct_members.Size(); |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 233 | size = m_struct_size; |
| 234 | alignment = m_struct_alignment; |
| 235 | |
| 236 | return true; |
| 237 | } |
| 238 | |
| 239 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 240 | ClangExpressionDeclMap::GetStructElement |
| 241 | ( |
| 242 | const clang::NamedDecl *&decl, |
| 243 | llvm::Value *&value, |
| 244 | off_t &offset, |
| 245 | ConstString &name, |
| 246 | uint32_t index |
| 247 | ) |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 248 | { |
| 249 | if (!m_struct_laid_out) |
| 250 | return false; |
| 251 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 252 | if (index >= m_struct_members.Size()) |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 253 | return false; |
| 254 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 255 | ClangExpressionVariable &member(m_struct_members.VariableAtIndex(index)); |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 256 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 257 | if (!member.m_parser_vars.get() || |
| 258 | !member.m_jit_vars.get()) |
| 259 | return false; |
| 260 | |
| 261 | decl = member.m_parser_vars->m_named_decl; |
| 262 | value = member.m_parser_vars->m_llvm_value; |
| 263 | offset = member.m_jit_vars->m_offset; |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 264 | name = member.m_name; |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 265 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 266 | return true; |
| 267 | } |
| 268 | |
Sean Callanan | 02fbafa | 2010-07-27 21:39:39 +0000 | [diff] [blame] | 269 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 270 | ClangExpressionDeclMap::GetFunctionInfo |
| 271 | ( |
| 272 | const clang::NamedDecl *decl, |
| 273 | llvm::Value**& value, |
| 274 | uint64_t &ptr |
| 275 | ) |
Sean Callanan | ba992c5 | 2010-07-27 02:07:53 +0000 | [diff] [blame] | 276 | { |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 277 | ClangExpressionVariable *entity = m_found_entities.GetVariable(decl); |
| 278 | |
| 279 | if (!entity) |
| 280 | return false; |
Sean Callanan | ba992c5 | 2010-07-27 02:07:53 +0000 | [diff] [blame] | 281 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 282 | // We know m_parser_vars is valid since we searched for the variable by |
| 283 | // its NamedDecl |
Sean Callanan | ba992c5 | 2010-07-27 02:07:53 +0000 | [diff] [blame] | 284 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 285 | value = &entity->m_parser_vars->m_llvm_value; |
| 286 | ptr = entity->m_parser_vars->m_lldb_value->GetScalar().ULongLong(); |
| 287 | |
| 288 | return true; |
Sean Callanan | ba992c5 | 2010-07-27 02:07:53 +0000 | [diff] [blame] | 289 | } |
| 290 | |
Sean Callanan | f5857a0 | 2010-07-31 01:32:05 +0000 | [diff] [blame] | 291 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 292 | ClangExpressionDeclMap::GetFunctionAddress |
| 293 | ( |
| 294 | const ConstString &name, |
| 295 | uint64_t &ptr |
| 296 | ) |
Sean Callanan | f5857a0 | 2010-07-31 01:32:05 +0000 | [diff] [blame] | 297 | { |
| 298 | // Back out in all cases where we're not fully initialized |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 299 | if (m_exe_ctx.frame == NULL) |
Sean Callanan | f5857a0 | 2010-07-31 01:32:05 +0000 | [diff] [blame] | 300 | return false; |
| 301 | |
Sean Callanan | f5857a0 | 2010-07-31 01:32:05 +0000 | [diff] [blame] | 302 | SymbolContextList sym_ctxs; |
| 303 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 304 | m_sym_ctx.FindFunctionsByName(name, false, sym_ctxs); |
Sean Callanan | f5857a0 | 2010-07-31 01:32:05 +0000 | [diff] [blame] | 305 | |
| 306 | if (!sym_ctxs.GetSize()) |
| 307 | return false; |
| 308 | |
| 309 | SymbolContext sym_ctx; |
| 310 | sym_ctxs.GetContextAtIndex(0, sym_ctx); |
| 311 | |
| 312 | const Address *fun_address; |
| 313 | |
| 314 | if (sym_ctx.function) |
| 315 | fun_address = &sym_ctx.function->GetAddressRange().GetBaseAddress(); |
| 316 | else if (sym_ctx.symbol) |
| 317 | fun_address = &sym_ctx.symbol->GetAddressRangeRef().GetBaseAddress(); |
| 318 | else |
| 319 | return false; |
| 320 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 321 | ptr = fun_address->GetLoadAddress (m_exe_ctx.target); |
Sean Callanan | f5857a0 | 2010-07-31 01:32:05 +0000 | [diff] [blame] | 322 | |
| 323 | return true; |
| 324 | } |
| 325 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 326 | // Interface for CommandObjectExpression |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 327 | |
| 328 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 329 | ClangExpressionDeclMap::Materialize |
| 330 | ( |
| 331 | ExecutionContext *exe_ctx, |
| 332 | lldb::addr_t &struct_address, |
| 333 | Error &err |
| 334 | ) |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 335 | { |
| 336 | bool result = DoMaterialize(false, exe_ctx, NULL, err); |
| 337 | |
| 338 | if (result) |
| 339 | struct_address = m_materialized_location; |
| 340 | |
| 341 | return result; |
| 342 | } |
| 343 | |
| 344 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 345 | ClangExpressionDeclMap::GetObjectPointer |
| 346 | ( |
| 347 | lldb::addr_t &object_ptr, |
| 348 | ExecutionContext *exe_ctx, |
| 349 | Error &err |
| 350 | ) |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 351 | { |
| 352 | if (!exe_ctx || !exe_ctx->frame || !exe_ctx->target || !exe_ctx->process) |
| 353 | { |
| 354 | err.SetErrorString("Couldn't load 'this' because the context is incomplete"); |
| 355 | return false; |
| 356 | } |
| 357 | |
| 358 | if (!m_object_pointer_type.GetOpaqueQualType()) |
| 359 | { |
| 360 | err.SetErrorString("Couldn't load 'this' because its type is unknown"); |
| 361 | return false; |
| 362 | } |
| 363 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 364 | static ConstString g_this_cs ("this"); |
| 365 | Variable *object_ptr_var = FindVariableInScope(*exe_ctx->frame, g_this_cs, &m_object_pointer_type); |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 366 | |
| 367 | if (!object_ptr_var) |
| 368 | { |
| 369 | err.SetErrorString("Couldn't find 'this' with appropriate type in scope"); |
| 370 | return false; |
| 371 | } |
| 372 | |
| 373 | std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(*exe_ctx, |
| 374 | object_ptr_var, |
| 375 | m_object_pointer_type.GetASTContext())); |
| 376 | |
| 377 | if (!location_value.get()) |
| 378 | { |
| 379 | err.SetErrorString("Couldn't get the location for 'this'"); |
| 380 | return false; |
| 381 | } |
| 382 | |
| 383 | if (location_value->GetValueType() == Value::eValueTypeLoadAddress) |
| 384 | { |
| 385 | lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); |
| 386 | uint32_t address_byte_size = exe_ctx->target->GetArchitecture().GetAddressByteSize(); |
| 387 | lldb::ByteOrder address_byte_order = exe_ctx->process->GetByteOrder(); |
| 388 | |
| 389 | if (ClangASTType::GetClangTypeBitWidth(m_object_pointer_type.GetASTContext(), m_object_pointer_type.GetOpaqueQualType()) != address_byte_size * 8) |
| 390 | { |
| 391 | err.SetErrorStringWithFormat("'this' is not of an expected pointer size"); |
| 392 | return false; |
| 393 | } |
| 394 | |
| 395 | DataBufferHeap data; |
| 396 | data.SetByteSize(address_byte_size); |
| 397 | Error read_error; |
| 398 | |
| 399 | if (exe_ctx->process->ReadMemory (value_addr, data.GetBytes(), address_byte_size, read_error) != address_byte_size) |
| 400 | { |
| 401 | err.SetErrorStringWithFormat("Coldn't read 'this' from the target: %s", read_error.AsCString()); |
| 402 | return false; |
| 403 | } |
| 404 | |
| 405 | DataExtractor extractor(data.GetBytes(), data.GetByteSize(), address_byte_order, address_byte_size); |
| 406 | |
| 407 | uint32_t offset = 0; |
| 408 | |
| 409 | object_ptr = extractor.GetPointer(&offset); |
| 410 | |
| 411 | return true; |
| 412 | } |
| 413 | else |
| 414 | { |
| 415 | err.SetErrorString("'this' is not in memory; LLDB must be extended to handle registers"); |
| 416 | return false; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 421 | ClangExpressionDeclMap::Dematerialize |
| 422 | ( |
| 423 | ExecutionContext *exe_ctx, |
| 424 | ClangExpressionVariable *&result, |
| 425 | Error &err |
| 426 | ) |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 427 | { |
Sean Callanan | 82b74c8 | 2010-08-12 01:56:52 +0000 | [diff] [blame] | 428 | return DoMaterialize(true, exe_ctx, &result, err); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 429 | } |
| 430 | |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 431 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 432 | ClangExpressionDeclMap::DumpMaterializedStruct |
| 433 | ( |
| 434 | ExecutionContext *exe_ctx, |
| 435 | Stream &s, |
| 436 | Error &err |
| 437 | ) |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 438 | { |
| 439 | if (!m_struct_laid_out) |
| 440 | { |
| 441 | err.SetErrorString("Structure hasn't been laid out yet"); |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | if (!exe_ctx) |
| 446 | { |
| 447 | err.SetErrorString("Received null execution context"); |
| 448 | return false; |
| 449 | } |
| 450 | |
| 451 | |
| 452 | if (!exe_ctx->process) |
| 453 | { |
| 454 | err.SetErrorString("Couldn't find the process"); |
| 455 | return false; |
| 456 | } |
| 457 | |
| 458 | if (!exe_ctx->target) |
| 459 | { |
| 460 | err.SetErrorString("Couldn't find the target"); |
| 461 | return false; |
| 462 | } |
| 463 | |
| 464 | lldb::DataBufferSP data(new DataBufferHeap(m_struct_size, 0)); |
| 465 | |
| 466 | Error error; |
| 467 | if (exe_ctx->process->ReadMemory (m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) |
| 468 | { |
| 469 | err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString()); |
| 470 | return false; |
| 471 | } |
| 472 | |
| 473 | DataExtractor extractor(data, exe_ctx->process->GetByteOrder(), exe_ctx->target->GetArchitecture().GetAddressByteSize()); |
| 474 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 475 | for (uint64_t member_index = 0, num_members = m_struct_members.Size(); |
| 476 | member_index < num_members; |
| 477 | ++member_index) |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 478 | { |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 479 | ClangExpressionVariable &member (m_struct_members.VariableAtIndex(member_index)); |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 480 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 481 | s.Printf("[%s]\n", member.m_name.GetCString()); |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 482 | |
| 483 | if (!member.m_jit_vars.get()) |
| 484 | return false; |
| 485 | |
| 486 | extractor.Dump(&s, // stream |
| 487 | member.m_jit_vars->m_offset, // offset |
| 488 | lldb::eFormatBytesWithASCII, // format |
| 489 | 1, // byte size of individual entries |
| 490 | member.m_jit_vars->m_size, // number of entries |
| 491 | 16, // entries per line |
| 492 | m_materialized_location + member.m_jit_vars->m_offset, // address to print |
| 493 | 0, // bit size (bitfields only; 0 means ignore) |
| 494 | 0); // bit alignment (bitfields only; 0 means ignore) |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 495 | |
| 496 | s.PutChar('\n'); |
| 497 | } |
| 498 | |
| 499 | return true; |
| 500 | } |
| 501 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 502 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 503 | ClangExpressionDeclMap::DoMaterialize |
| 504 | ( |
| 505 | bool dematerialize, |
| 506 | ExecutionContext *exe_ctx, |
| 507 | ClangExpressionVariable **result, |
| 508 | Error &err |
| 509 | ) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 510 | { |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 511 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
Sean Callanan | 82b74c8 | 2010-08-12 01:56:52 +0000 | [diff] [blame] | 512 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 513 | if (!m_struct_laid_out) |
| 514 | { |
| 515 | err.SetErrorString("Structure hasn't been laid out yet"); |
| 516 | return LLDB_INVALID_ADDRESS; |
| 517 | } |
| 518 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 519 | if (!exe_ctx) |
| 520 | { |
| 521 | err.SetErrorString("Received null execution context"); |
| 522 | return LLDB_INVALID_ADDRESS; |
| 523 | } |
| 524 | |
Sean Callanan | 4583927 | 2010-07-24 01:37:44 +0000 | [diff] [blame] | 525 | if (!exe_ctx->frame) |
| 526 | { |
| 527 | err.SetErrorString("Received null execution frame"); |
| 528 | return LLDB_INVALID_ADDRESS; |
| 529 | } |
| 530 | |
Sean Callanan | e8a59a8 | 2010-09-13 21:34:21 +0000 | [diff] [blame] | 531 | if (!m_struct_size) |
| 532 | { |
| 533 | if (log) |
| 534 | log->PutCString("Not bothering to allocate a struct because no arguments are needed"); |
| 535 | |
| 536 | m_allocated_area = NULL; |
| 537 | |
| 538 | return true; |
| 539 | } |
| 540 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 541 | const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); |
| 542 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 543 | if (!dematerialize) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 544 | { |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 545 | if (m_materialized_location) |
| 546 | { |
| 547 | exe_ctx->process->DeallocateMemory(m_materialized_location); |
| 548 | m_materialized_location = 0; |
| 549 | } |
| 550 | |
Sean Callanan | 7a60b94 | 2010-10-08 01:58:41 +0000 | [diff] [blame] | 551 | if (log) |
| 552 | log->PutCString("Allocating memory for materialized argument struct"); |
| 553 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 554 | lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, |
| 555 | lldb::ePermissionsReadable | lldb::ePermissionsWritable, |
| 556 | err); |
| 557 | |
| 558 | if (mem == LLDB_INVALID_ADDRESS) |
| 559 | return false; |
| 560 | |
| 561 | m_allocated_area = mem; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 564 | m_materialized_location = m_allocated_area; |
| 565 | |
| 566 | if (m_materialized_location % m_struct_alignment) |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 567 | m_materialized_location += (m_struct_alignment - (m_materialized_location % m_struct_alignment)); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 568 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 569 | for (uint64_t member_index = 0, num_members = m_struct_members.Size(); |
| 570 | member_index < num_members; |
| 571 | ++member_index) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 572 | { |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 573 | ClangExpressionVariable &member (m_struct_members.VariableAtIndex(member_index)); |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 574 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 575 | if (!member.m_parser_vars.get()) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 576 | return false; |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 577 | |
| 578 | ClangExpressionVariable *entity = m_found_entities.GetVariable(member.m_parser_vars->m_named_decl); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 579 | ClangExpressionVariable *persistent_variable = m_persistent_vars->GetVariable(member.m_name); |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 580 | |
| 581 | if (entity) |
| 582 | { |
| 583 | if (!member.m_jit_vars.get()) |
| 584 | return false; |
| 585 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 586 | if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, member.m_name, member.m_user_type, m_materialized_location + member.m_jit_vars->m_offset, err)) |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 587 | return false; |
| 588 | } |
| 589 | else if (persistent_variable) |
| 590 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 591 | if (member.m_name == m_result_name) |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 592 | { |
| 593 | if (!dematerialize) |
| 594 | continue; |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 595 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 596 | if (log) |
| 597 | log->PutCString("Found result member in the struct"); |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 598 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 599 | *result = &member; |
| 600 | } |
| 601 | |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 602 | if (log) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 603 | log->Printf("Searched for persistent variable %s and found %s", member.m_name.GetCString(), persistent_variable->m_name.GetCString()); |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 604 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 605 | if (!DoMaterializeOnePersistentVariable(dematerialize, *exe_ctx, persistent_variable->m_name, m_materialized_location + member.m_jit_vars->m_offset, err)) |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 606 | return false; |
| 607 | } |
| 608 | else |
| 609 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 610 | err.SetErrorStringWithFormat("Unexpected variable %s", member.m_name.GetCString()); |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 611 | return false; |
| 612 | } |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 613 | } |
| 614 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 615 | return true; |
| 616 | } |
| 617 | |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 618 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 619 | ClangExpressionDeclMap::DoMaterializeOnePersistentVariable |
| 620 | ( |
| 621 | bool dematerialize, |
| 622 | ExecutionContext &exe_ctx, |
| 623 | const ConstString &name, |
| 624 | lldb::addr_t addr, |
| 625 | Error &err |
| 626 | ) |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 627 | { |
Sean Callanan | a622343 | 2010-08-20 01:02:30 +0000 | [diff] [blame] | 628 | ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 629 | |
| 630 | if (!pvar) |
| 631 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 632 | err.SetErrorStringWithFormat("Undefined persistent variable %s", name.GetCString()); |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 633 | return LLDB_INVALID_ADDRESS; |
| 634 | } |
| 635 | |
| 636 | size_t pvar_size = pvar->Size(); |
Sean Callanan | a622343 | 2010-08-20 01:02:30 +0000 | [diff] [blame] | 637 | |
Greg Clayton | 66ed2fb | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 638 | if (!pvar->m_data_sp.get()) |
Sean Callanan | a622343 | 2010-08-20 01:02:30 +0000 | [diff] [blame] | 639 | return false; |
| 640 | |
Greg Clayton | 66ed2fb | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 641 | uint8_t *pvar_data = pvar->m_data_sp->GetBytes(); |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 642 | Error error; |
| 643 | |
| 644 | if (dematerialize) |
| 645 | { |
| 646 | if (exe_ctx.process->ReadMemory (addr, pvar_data, pvar_size, error) != pvar_size) |
| 647 | { |
| 648 | err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); |
| 649 | return false; |
| 650 | } |
| 651 | } |
| 652 | else |
| 653 | { |
| 654 | if (exe_ctx.process->WriteMemory (addr, pvar_data, pvar_size, error) != pvar_size) |
| 655 | { |
| 656 | err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); |
| 657 | return false; |
| 658 | } |
| 659 | } |
| 660 | |
| 661 | return true; |
| 662 | } |
| 663 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 664 | bool |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 665 | ClangExpressionDeclMap::DoMaterializeOneVariable |
| 666 | ( |
| 667 | bool dematerialize, |
| 668 | ExecutionContext &exe_ctx, |
| 669 | const SymbolContext &sym_ctx, |
| 670 | const ConstString &name, |
| 671 | TypeFromUser type, |
| 672 | lldb::addr_t addr, |
| 673 | Error &err |
| 674 | ) |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 675 | { |
| 676 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 677 | |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 678 | if (!exe_ctx.frame || !exe_ctx.process) |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 679 | return false; |
| 680 | |
| 681 | Variable *var = FindVariableInScope(*exe_ctx.frame, name, &type); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 682 | |
| 683 | if (!var) |
| 684 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 685 | err.SetErrorStringWithFormat("Couldn't find %s with appropriate type", name.GetCString()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 686 | return false; |
| 687 | } |
| 688 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 689 | if (log) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 690 | log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name.GetCString(), type.GetOpaqueQualType()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 691 | |
| 692 | std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(exe_ctx, |
| 693 | var, |
| 694 | type.GetASTContext())); |
| 695 | |
| 696 | if (!location_value.get()) |
| 697 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 698 | err.SetErrorStringWithFormat("Couldn't get value for %s", name.GetCString()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 699 | return false; |
| 700 | } |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 701 | |
| 702 | // The size of the type contained in addr |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 703 | |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 704 | size_t addr_bit_size = ClangASTType::GetClangTypeBitWidth(type.GetASTContext(), type.GetOpaqueQualType()); |
| 705 | size_t addr_byte_size = addr_bit_size % 8 ? ((addr_bit_size + 8) / 8) : (addr_bit_size / 8); |
| 706 | |
| 707 | Value::ValueType value_type = location_value->GetValueType(); |
| 708 | |
| 709 | switch (value_type) |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 710 | { |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 711 | default: |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 712 | { |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 713 | StreamString ss; |
| 714 | |
| 715 | location_value->Dump(&ss); |
| 716 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 717 | err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name.GetCString(), ss.GetString().c_str()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 718 | return false; |
| 719 | } |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 720 | break; |
| 721 | case Value::eValueTypeLoadAddress: |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 722 | { |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 723 | lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); |
| 724 | |
| 725 | DataBufferHeap data; |
| 726 | data.SetByteSize(addr_byte_size); |
| 727 | |
| 728 | lldb::addr_t src_addr; |
| 729 | lldb::addr_t dest_addr; |
| 730 | |
| 731 | if (dematerialize) |
| 732 | { |
| 733 | src_addr = addr; |
| 734 | dest_addr = value_addr; |
| 735 | } |
| 736 | else |
| 737 | { |
| 738 | src_addr = value_addr; |
| 739 | dest_addr = addr; |
| 740 | } |
| 741 | |
| 742 | Error error; |
| 743 | if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), addr_byte_size, error) != addr_byte_size) |
| 744 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 745 | err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", name.GetCString(), error.AsCString()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 746 | return false; |
| 747 | } |
| 748 | |
| 749 | if (exe_ctx.process->WriteMemory (dest_addr, data.GetBytes(), addr_byte_size, error) != addr_byte_size) |
| 750 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 751 | err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", name.GetCString(), error.AsCString()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 752 | return false; |
| 753 | } |
| 754 | |
| 755 | if (log) |
| 756 | log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 757 | } |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 758 | break; |
| 759 | case Value::eValueTypeScalar: |
| 760 | { |
| 761 | if (location_value->GetContextType() != Value::eContextTypeDCRegisterInfo) |
| 762 | { |
| 763 | StreamString ss; |
| 764 | |
| 765 | location_value->Dump(&ss); |
| 766 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 767 | err.SetErrorStringWithFormat("%s is a scalar of unhandled type: %s", name.GetCString(), ss.GetString().c_str()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 768 | return false; |
| 769 | } |
| 770 | |
| 771 | lldb::RegisterInfo *register_info = location_value->GetRegisterInfo(); |
| 772 | |
| 773 | if (!register_info) |
| 774 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 775 | err.SetErrorStringWithFormat("Couldn't get the register information for %s", name.GetCString()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 776 | return false; |
| 777 | } |
| 778 | |
| 779 | RegisterContext *register_context = exe_ctx.GetRegisterContext(); |
| 780 | |
| 781 | if (!register_context) |
| 782 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 783 | err.SetErrorStringWithFormat("Couldn't read register context to read %s from %s", name.GetCString(), register_info->name); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 784 | return false; |
| 785 | } |
| 786 | |
| 787 | uint32_t register_number = register_info->kinds[lldb::eRegisterKindLLDB]; |
| 788 | uint32_t register_byte_size = register_info->byte_size; |
| 789 | |
| 790 | if (dematerialize) |
| 791 | { |
| 792 | // Moving from addr into a register |
| 793 | // |
| 794 | // Case 1: addr_byte_size and register_byte_size are the same |
| 795 | // |
| 796 | // |AABBCCDD| Address contents |
| 797 | // |AABBCCDD| Register contents |
| 798 | // |
| 799 | // Case 2: addr_byte_size is bigger than register_byte_size |
| 800 | // |
| 801 | // Error! (The register should always be big enough to hold the data) |
| 802 | // |
| 803 | // Case 3: register_byte_size is bigger than addr_byte_size |
| 804 | // |
| 805 | // |AABB| Address contents |
| 806 | // |AABB0000| Register contents [on little-endian hardware] |
| 807 | // |0000AABB| Register contents [on big-endian hardware] |
| 808 | |
| 809 | if (addr_byte_size > register_byte_size) |
| 810 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 811 | err.SetErrorStringWithFormat("%s is too big to store in %s", name.GetCString(), register_info->name); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 812 | return false; |
| 813 | } |
| 814 | |
| 815 | uint32_t register_offset; |
| 816 | |
| 817 | switch (exe_ctx.process->GetByteOrder()) |
| 818 | { |
| 819 | default: |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 820 | err.SetErrorStringWithFormat("%s is stored with an unhandled byte order", name.GetCString()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 821 | return false; |
| 822 | case lldb::eByteOrderLittle: |
| 823 | register_offset = 0; |
| 824 | break; |
| 825 | case lldb::eByteOrderBig: |
| 826 | register_offset = register_byte_size - addr_byte_size; |
| 827 | break; |
| 828 | } |
| 829 | |
| 830 | DataBufferHeap register_data (register_byte_size, 0); |
| 831 | |
| 832 | Error error; |
| 833 | if (exe_ctx.process->ReadMemory (addr, register_data.GetBytes() + register_offset, addr_byte_size, error) != addr_byte_size) |
| 834 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 835 | err.SetErrorStringWithFormat ("Couldn't read %s from the target: %s", name.GetCString(), error.AsCString()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 836 | return false; |
| 837 | } |
| 838 | |
| 839 | DataExtractor register_extractor (register_data.GetBytes(), register_byte_size, exe_ctx.process->GetByteOrder(), exe_ctx.process->GetAddressByteSize()); |
| 840 | |
| 841 | if (!register_context->WriteRegisterBytes(register_number, register_extractor, 0)) |
| 842 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 843 | err.SetErrorStringWithFormat("Couldn't read %s from %s", name.GetCString(), register_info->name); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 844 | return false; |
| 845 | } |
| 846 | } |
| 847 | else |
| 848 | { |
| 849 | // Moving from a register into addr |
| 850 | // |
| 851 | // Case 1: addr_byte_size and register_byte_size are the same |
| 852 | // |
| 853 | // |AABBCCDD| Register contents |
| 854 | // |AABBCCDD| Address contents |
| 855 | // |
| 856 | // Case 2: addr_byte_size is bigger than register_byte_size |
| 857 | // |
| 858 | // Error! (The register should always be big enough to hold the data) |
| 859 | // |
| 860 | // Case 3: register_byte_size is bigger than addr_byte_size |
| 861 | // |
| 862 | // |AABBCCDD| Register contents |
| 863 | // |AABB| Address contents on little-endian hardware |
| 864 | // |CCDD| Address contents on big-endian hardware |
| 865 | |
| 866 | if (addr_byte_size > register_byte_size) |
| 867 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 868 | err.SetErrorStringWithFormat("%s is too big to store in %s", name.GetCString(), register_info->name); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 869 | return false; |
| 870 | } |
| 871 | |
| 872 | uint32_t register_offset; |
| 873 | |
| 874 | switch (exe_ctx.process->GetByteOrder()) |
| 875 | { |
| 876 | default: |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 877 | err.SetErrorStringWithFormat("%s is stored with an unhandled byte order", name.GetCString()); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 878 | return false; |
| 879 | case lldb::eByteOrderLittle: |
| 880 | register_offset = 0; |
| 881 | break; |
| 882 | case lldb::eByteOrderBig: |
| 883 | register_offset = register_byte_size - addr_byte_size; |
| 884 | break; |
| 885 | } |
| 886 | |
| 887 | DataExtractor register_extractor; |
| 888 | |
| 889 | if (!register_context->ReadRegisterBytes(register_number, register_extractor)) |
| 890 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 891 | err.SetErrorStringWithFormat("Couldn't read %s from %s", name.GetCString(), register_info->name); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 892 | return false; |
| 893 | } |
| 894 | |
| 895 | const void *register_data = register_extractor.GetData(®ister_offset, addr_byte_size); |
| 896 | |
| 897 | if (!register_data) |
| 898 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 899 | err.SetErrorStringWithFormat("Read but couldn't extract data for %s from %s", name.GetCString(), register_info->name); |
Sean Callanan | 17c6a05 | 2010-10-05 20:18:48 +0000 | [diff] [blame] | 900 | return false; |
| 901 | } |
| 902 | |
| 903 | Error error; |
| 904 | if (exe_ctx.process->WriteMemory (addr, register_data, addr_byte_size, error) != addr_byte_size) |
| 905 | { |
| 906 | err.SetErrorStringWithFormat ("Couldn't write %s to the target: %s", error.AsCString()); |
| 907 | return false; |
| 908 | } |
| 909 | } |
| 910 | } |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 911 | } |
| 912 | |
| 913 | return true; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 914 | } |
| 915 | |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 916 | Variable * |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 917 | ClangExpressionDeclMap::FindVariableInScope |
| 918 | ( |
| 919 | StackFrame &frame, |
| 920 | const ConstString &name, |
| 921 | TypeFromUser *type |
| 922 | ) |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 923 | { |
| 924 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 925 | |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 926 | VariableList *var_list = frame.GetVariableList(true); |
| 927 | |
Greg Clayton | bf8e42b | 2010-10-14 22:52:14 +0000 | [diff] [blame] | 928 | if (!var_list) |
| 929 | return NULL; |
| 930 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 931 | lldb::VariableSP var = var_list->FindVariable(name); |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 932 | |
| 933 | if (!var) |
| 934 | return NULL; |
| 935 | |
| 936 | if (!type) |
| 937 | return var.get(); |
| 938 | |
| 939 | if (type->GetASTContext() == var->GetType()->GetClangAST()) |
| 940 | { |
Greg Clayton | 462d414 | 2010-09-29 01:12:09 +0000 | [diff] [blame] | 941 | if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetClangType())) |
Sean Callanan | cc07462 | 2010-09-14 21:59:34 +0000 | [diff] [blame] | 942 | return NULL; |
| 943 | } |
| 944 | else |
| 945 | { |
| 946 | if (log) |
| 947 | log->PutCString("Skipping a candidate variable because of different AST contexts"); |
| 948 | return NULL; |
| 949 | } |
| 950 | |
| 951 | return var.get(); |
| 952 | |
| 953 | return NULL; |
| 954 | } |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 955 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 956 | // Interface for ClangASTSource |
| 957 | void |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 958 | ClangExpressionDeclMap::GetDecls |
| 959 | ( |
| 960 | NameSearchContext &context, |
| 961 | const ConstString &name |
| 962 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 963 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 964 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 965 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 966 | if (log) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 967 | log->Printf("Hunting for a definition for '%s'", name.GetCString()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 968 | |
| 969 | // Back out in all cases where we're not fully initialized |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 970 | if (m_exe_ctx.frame == NULL) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 971 | return; |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 972 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 973 | static ConstString g_lldb_class_name ("$__lldb_class"); |
| 974 | if (name == g_lldb_class_name) |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 975 | { |
| 976 | // Clang is looking for the type of "this" |
| 977 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 978 | VariableList *vars = m_exe_ctx.frame->GetVariableList(false); |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 979 | |
| 980 | if (!vars) |
| 981 | return; |
| 982 | |
| 983 | lldb::VariableSP this_var = vars->FindVariable(ConstString("this")); |
| 984 | |
| 985 | if (!this_var) |
| 986 | return; |
| 987 | |
| 988 | Type *this_type = this_var->GetType(); |
| 989 | |
| 990 | if (!this_type) |
| 991 | return; |
| 992 | |
Greg Clayton | 462d414 | 2010-09-29 01:12:09 +0000 | [diff] [blame] | 993 | TypeFromUser this_user_type(this_type->GetClangType(), |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 994 | this_type->GetClangAST()); |
| 995 | |
| 996 | m_object_pointer_type = this_user_type; |
| 997 | |
| 998 | void *pointer_target_type; |
| 999 | |
| 1000 | if (!ClangASTContext::IsPointerType(this_user_type.GetOpaqueQualType(), |
| 1001 | &pointer_target_type)) |
| 1002 | return; |
| 1003 | |
| 1004 | TypeFromUser class_user_type(pointer_target_type, |
| 1005 | this_type->GetClangAST()); |
| 1006 | |
| 1007 | AddOneType(context, class_user_type, true); |
| 1008 | |
| 1009 | return; |
| 1010 | } |
| 1011 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1012 | SymbolContextList sym_ctxs; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1013 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1014 | // Only look for functions by name out in our symbols if the function |
| 1015 | // doesn't start with our phony prefix of '$' |
| 1016 | if (name.GetCString()[0] != '$') |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1017 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1018 | |
| 1019 | Variable *var = FindVariableInScope(*m_exe_ctx.frame, name); |
| 1020 | |
| 1021 | // If we found a variable in scope, no need to pull up function names |
| 1022 | if (var != NULL) |
| 1023 | { |
| 1024 | AddOneVariable(context, var); |
| 1025 | } |
| 1026 | else |
| 1027 | { |
| 1028 | m_sym_ctx.FindFunctionsByName (name, false, sym_ctxs); |
| 1029 | |
| 1030 | bool found_specific = false; |
| 1031 | Symbol *generic_symbol = NULL; |
| 1032 | Symbol *non_extern_symbol = NULL; |
| 1033 | |
| 1034 | for (uint32_t index = 0, num_indices = sym_ctxs.GetSize(); |
| 1035 | index < num_indices; |
| 1036 | ++index) |
| 1037 | { |
| 1038 | SymbolContext sym_ctx; |
| 1039 | sym_ctxs.GetContextAtIndex(index, sym_ctx); |
Sean Callanan | 3cfbd33 | 2010-10-06 00:10:07 +0000 | [diff] [blame] | 1040 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1041 | if (sym_ctx.function) |
| 1042 | { |
| 1043 | // TODO only do this if it's a C function; C++ functions may be |
| 1044 | // overloaded |
| 1045 | if (!found_specific) |
| 1046 | AddOneFunction(context, sym_ctx.function, NULL); |
| 1047 | found_specific = true; |
| 1048 | } |
| 1049 | else if (sym_ctx.symbol) |
| 1050 | { |
| 1051 | if (sym_ctx.symbol->IsExternal()) |
| 1052 | generic_symbol = sym_ctx.symbol; |
| 1053 | else |
| 1054 | non_extern_symbol = sym_ctx.symbol; |
| 1055 | } |
| 1056 | } |
| 1057 | |
Sean Callanan | 92aa666 | 2010-09-07 21:49:41 +0000 | [diff] [blame] | 1058 | if (!found_specific) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1059 | { |
| 1060 | if (generic_symbol) |
| 1061 | AddOneFunction(context, NULL, generic_symbol); |
| 1062 | else if (non_extern_symbol) |
| 1063 | AddOneFunction(context, NULL, non_extern_symbol); |
| 1064 | } |
Sean Callanan | 92aa666 | 2010-09-07 21:49:41 +0000 | [diff] [blame] | 1065 | } |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1066 | } |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1067 | else |
Sean Callanan | 3cfbd33 | 2010-10-06 00:10:07 +0000 | [diff] [blame] | 1068 | { |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1069 | ClangExpressionVariable *pvar(m_persistent_vars->GetVariable(name)); |
| 1070 | |
| 1071 | if (pvar) |
| 1072 | AddOneVariable(context, pvar); |
Sean Callanan | 3cfbd33 | 2010-10-06 00:10:07 +0000 | [diff] [blame] | 1073 | } |
| 1074 | |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1075 | |
Sean Callanan | 6df0840 | 2010-09-27 23:54:58 +0000 | [diff] [blame] | 1076 | // See information on gating of this operation next to the definition for |
| 1077 | // m_lookedup_types. |
| 1078 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1079 | const char *name_uniq = name.GetCString(); |
Sean Callanan | 6df0840 | 2010-09-27 23:54:58 +0000 | [diff] [blame] | 1080 | |
| 1081 | if (m_lookedup_types.find(name_uniq) == m_lookedup_types.end()) |
| 1082 | { |
| 1083 | // 1 The name is added to m_lookedup_types. |
| 1084 | m_lookedup_types.insert(std::pair<const char*, bool>(name_uniq, true)); |
| 1085 | |
| 1086 | // 2 The type is looked up and added, potentially causing more type loookups. |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1087 | lldb::TypeSP type = m_sym_ctx.FindTypeByName (name); |
Sean Callanan | 6df0840 | 2010-09-27 23:54:58 +0000 | [diff] [blame] | 1088 | |
| 1089 | if (type.get()) |
| 1090 | { |
Greg Clayton | 462d414 | 2010-09-29 01:12:09 +0000 | [diff] [blame] | 1091 | TypeFromUser user_type(type->GetClangType(), |
Sean Callanan | 6df0840 | 2010-09-27 23:54:58 +0000 | [diff] [blame] | 1092 | type->GetClangAST()); |
| 1093 | |
| 1094 | AddOneType(context, user_type, false); |
| 1095 | } |
| 1096 | |
| 1097 | // 3 The name is removed from m_lookedup_types. |
| 1098 | m_lookedup_types.erase(name_uniq); |
| 1099 | } |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1100 | } |
| 1101 | |
| 1102 | Value * |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1103 | ClangExpressionDeclMap::GetVariableValue |
| 1104 | ( |
| 1105 | ExecutionContext &exe_ctx, |
| 1106 | Variable *var, |
| 1107 | clang::ASTContext *parser_ast_context, |
| 1108 | TypeFromUser *user_type, |
| 1109 | TypeFromParser *parser_type |
| 1110 | ) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1111 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 1112 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 1113 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1114 | Type *var_type = var->GetType(); |
| 1115 | |
| 1116 | if (!var_type) |
| 1117 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1118 | if (log) |
| 1119 | log->PutCString("Skipped a definition because it has no type"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1120 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1121 | } |
| 1122 | |
Greg Clayton | 462d414 | 2010-09-29 01:12:09 +0000 | [diff] [blame] | 1123 | void *var_opaque_type = var_type->GetClangType(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1124 | |
| 1125 | if (!var_opaque_type) |
| 1126 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1127 | if (log) |
| 1128 | log->PutCString("Skipped a definition because it has no Clang type"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1129 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1130 | } |
| 1131 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1132 | TypeList *type_list = var_type->GetTypeList(); |
| 1133 | |
| 1134 | if (!type_list) |
| 1135 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1136 | if (log) |
| 1137 | log->PutCString("Skipped a definition because the type has no associated type list"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1138 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1139 | } |
| 1140 | |
| 1141 | clang::ASTContext *exe_ast_ctx = type_list->GetClangASTContext().getASTContext(); |
| 1142 | |
| 1143 | if (!exe_ast_ctx) |
| 1144 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1145 | if (log) |
| 1146 | log->PutCString("There is no AST context for the current execution context"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1147 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1150 | DWARFExpression &var_location_expr = var->LocationExpression(); |
| 1151 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1152 | std::auto_ptr<Value> var_location(new Value); |
| 1153 | |
Greg Clayton | 178710c | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1154 | lldb::addr_t loclist_base_load_addr = LLDB_INVALID_ADDRESS; |
| 1155 | |
| 1156 | if (var_location_expr.IsLocationList()) |
| 1157 | { |
| 1158 | SymbolContext var_sc; |
| 1159 | var->CalculateSymbolContext (&var_sc); |
Greg Clayton | eea2640 | 2010-09-14 23:36:40 +0000 | [diff] [blame] | 1160 | loclist_base_load_addr = var_sc.function->GetAddressRange().GetBaseAddress().GetLoadAddress (exe_ctx.target); |
Greg Clayton | 178710c | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1161 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1162 | Error err; |
| 1163 | |
Greg Clayton | 178710c | 2010-09-14 02:20:48 +0000 | [diff] [blame] | 1164 | if (!var_location_expr.Evaluate(&exe_ctx, exe_ast_ctx, loclist_base_load_addr, NULL, *var_location.get(), &err)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1165 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1166 | if (log) |
| 1167 | log->Printf("Error evaluating location: %s", err.AsCString()); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1168 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1169 | } |
| 1170 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1171 | clang::ASTContext *var_ast_context = type_list->GetClangASTContext().getASTContext(); |
| 1172 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1173 | void *type_to_use; |
| 1174 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 1175 | if (parser_ast_context) |
| 1176 | { |
| 1177 | type_to_use = ClangASTContext::CopyType(parser_ast_context, var_ast_context, var_opaque_type); |
| 1178 | |
| 1179 | if (parser_type) |
| 1180 | *parser_type = TypeFromParser(type_to_use, parser_ast_context); |
| 1181 | } |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1182 | else |
| 1183 | type_to_use = var_opaque_type; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1184 | |
| 1185 | if (var_location.get()->GetContextType() == Value::eContextTypeInvalid) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1186 | var_location.get()->SetContext(Value::eContextTypeOpaqueClangQualType, type_to_use); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1187 | |
| 1188 | if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress) |
| 1189 | { |
| 1190 | SymbolContext var_sc; |
| 1191 | var->CalculateSymbolContext(&var_sc); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1192 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1193 | if (!var_sc.module_sp) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1194 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1195 | |
| 1196 | ObjectFile *object_file = var_sc.module_sp->GetObjectFile(); |
| 1197 | |
| 1198 | if (!object_file) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1199 | return NULL; |
| 1200 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1201 | Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList()); |
| 1202 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1203 | lldb::addr_t load_addr = so_addr.GetLoadAddress(m_exe_ctx.target); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1204 | |
| 1205 | var_location->GetScalar() = load_addr; |
| 1206 | var_location->SetValueType(Value::eValueTypeLoadAddress); |
| 1207 | } |
| 1208 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 1209 | if (user_type) |
| 1210 | *user_type = TypeFromUser(var_opaque_type, var_ast_context); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1211 | |
| 1212 | return var_location.release(); |
| 1213 | } |
| 1214 | |
| 1215 | void |
| 1216 | ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 1217 | Variable* var) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1218 | { |
| 1219 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 1220 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 1221 | TypeFromUser ut; |
| 1222 | TypeFromParser pt; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1223 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1224 | Value *var_location = GetVariableValue (m_exe_ctx, |
| 1225 | var, |
| 1226 | context.GetASTContext(), |
| 1227 | &ut, |
| 1228 | &pt); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 1229 | |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 1230 | NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1231 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 1232 | ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1233 | std::string decl_name(context.m_decl_name.getAsString()); |
| 1234 | entity.m_name.SetCString (decl_name.c_str()); |
| 1235 | entity.m_user_type = ut; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1236 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 1237 | entity.EnableParserVars(); |
| 1238 | entity.m_parser_vars->m_parser_type = pt; |
| 1239 | entity.m_parser_vars->m_named_decl = var_decl; |
| 1240 | entity.m_parser_vars->m_llvm_value = NULL; |
| 1241 | entity.m_parser_vars->m_lldb_value = var_location; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1242 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1243 | if (log) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1244 | { |
| 1245 | log->Printf("Found variable %s, returned (NamedDecl)%p", decl_name.c_str(), var_decl); |
| 1246 | } |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1247 | } |
| 1248 | |
| 1249 | void |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 1250 | ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, |
Sean Callanan | a622343 | 2010-08-20 01:02:30 +0000 | [diff] [blame] | 1251 | ClangExpressionVariable *pvar) |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 1252 | { |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 1253 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 1254 | |
Sean Callanan | a622343 | 2010-08-20 01:02:30 +0000 | [diff] [blame] | 1255 | TypeFromUser user_type = pvar->m_user_type; |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 1256 | |
| 1257 | TypeFromParser parser_type(ClangASTContext::CopyType(context.GetASTContext(), |
| 1258 | user_type.GetASTContext(), |
| 1259 | user_type.GetOpaqueQualType()), |
| 1260 | context.GetASTContext()); |
| 1261 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 1262 | NamedDecl *var_decl = context.AddVarDecl(parser_type.GetOpaqueQualType()); |
| 1263 | |
| 1264 | pvar->EnableParserVars(); |
| 1265 | pvar->m_parser_vars->m_parser_type = parser_type; |
| 1266 | pvar->m_parser_vars->m_named_decl = var_decl; |
| 1267 | pvar->m_parser_vars->m_llvm_value = NULL; |
| 1268 | pvar->m_parser_vars->m_lldb_value = NULL; |
Sean Callanan | 45690fe | 2010-08-30 22:17:16 +0000 | [diff] [blame] | 1269 | |
| 1270 | if (log) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1271 | log->Printf("Added pvar %s, returned (NamedDecl)%p", pvar->m_name.GetCString(), var_decl); |
Sean Callanan | a48fe16 | 2010-08-11 03:57:18 +0000 | [diff] [blame] | 1272 | } |
| 1273 | |
| 1274 | void |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1275 | ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1276 | Function* fun, |
| 1277 | Symbol* symbol) |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1278 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 1279 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1280 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1281 | NamedDecl *fun_decl; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1282 | std::auto_ptr<Value> fun_location(new Value); |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1283 | const Address *fun_address; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1284 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1285 | // only valid for Functions, not for Symbols |
| 1286 | void *fun_opaque_type = NULL; |
| 1287 | clang::ASTContext *fun_ast_context = NULL; |
| 1288 | |
| 1289 | if (fun) |
| 1290 | { |
Sean Callanan | 55261a1 | 2010-09-08 22:38:54 +0000 | [diff] [blame] | 1291 | #define BROKEN_OVERLOADING |
| 1292 | // Awaiting a fix on the Clang side |
| 1293 | #ifndef BROKEN_OVERLOADING |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1294 | Type *fun_type = fun->GetType(); |
| 1295 | |
| 1296 | if (!fun_type) |
| 1297 | { |
| 1298 | if (log) |
| 1299 | log->PutCString("Skipped a function because it has no type"); |
| 1300 | return; |
| 1301 | } |
| 1302 | |
Greg Clayton | 462d414 | 2010-09-29 01:12:09 +0000 | [diff] [blame] | 1303 | fun_opaque_type = fun_type->GetClangType(); |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1304 | |
| 1305 | if (!fun_opaque_type) |
| 1306 | { |
| 1307 | if (log) |
| 1308 | log->PutCString("Skipped a function because it has no Clang type"); |
| 1309 | return; |
| 1310 | } |
| 1311 | |
| 1312 | fun_address = &fun->GetAddressRange().GetBaseAddress(); |
| 1313 | |
| 1314 | TypeList *type_list = fun_type->GetTypeList(); |
| 1315 | fun_ast_context = type_list->GetClangASTContext().getASTContext(); |
| 1316 | void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type); |
| 1317 | |
| 1318 | fun_decl = context.AddFunDecl(copied_type); |
Sean Callanan | 55261a1 | 2010-09-08 22:38:54 +0000 | [diff] [blame] | 1319 | #else |
| 1320 | fun_address = &fun->GetAddressRange().GetBaseAddress(); |
| 1321 | |
| 1322 | fun_decl = context.AddGenericFunDecl(); |
| 1323 | #endif |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 1324 | } |
| 1325 | else if (symbol) |
| 1326 | { |
| 1327 | fun_address = &symbol->GetAddressRangeRef().GetBaseAddress(); |
| 1328 | |
| 1329 | fun_decl = context.AddGenericFunDecl(); |
| 1330 | } |
| 1331 | else |
| 1332 | { |
| 1333 | if (log) |
| 1334 | log->PutCString("AddOneFunction called with no function and no symbol"); |
| 1335 | return; |
| 1336 | } |
| 1337 | |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1338 | lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx.target); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1339 | fun_location->SetValueType(Value::eValueTypeLoadAddress); |
| 1340 | fun_location->GetScalar() = load_addr; |
| 1341 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 1342 | ClangExpressionVariable &entity(m_found_entities.VariableAtIndex(m_found_entities.CreateVariable())); |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1343 | std::string decl_name(context.m_decl_name.getAsString()); |
| 1344 | entity.m_name.SetCString(decl_name.c_str()); |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 1345 | entity.m_user_type = TypeFromUser(fun_opaque_type, fun_ast_context);; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 1346 | |
Sean Callanan | 8c12720 | 2010-08-23 23:09:38 +0000 | [diff] [blame] | 1347 | entity.EnableParserVars(); |
| 1348 | entity.m_parser_vars->m_named_decl = fun_decl; |
| 1349 | entity.m_parser_vars->m_llvm_value = NULL; |
| 1350 | entity.m_parser_vars->m_lldb_value = fun_location.release(); |
| 1351 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 1352 | if (log) |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1353 | { |
| 1354 | log->Printf("Found %s function %s, returned (NamedDecl)%p", (fun ? "specific" : "generic"), decl_name.c_str(), fun_decl); |
| 1355 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1356 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1357 | |
| 1358 | void |
| 1359 | ClangExpressionDeclMap::AddOneType(NameSearchContext &context, |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 1360 | TypeFromUser &ut, |
| 1361 | bool add_method) |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1362 | { |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 1363 | clang::ASTContext *parser_ast_context = context.GetASTContext(); |
| 1364 | clang::ASTContext *user_ast_context = ut.GetASTContext(); |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1365 | |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 1366 | void *copied_type = ClangASTContext::CopyType(parser_ast_context, user_ast_context, ut.GetOpaqueQualType()); |
| 1367 | |
| 1368 | TypeFromParser parser_type(copied_type, parser_ast_context); |
| 1369 | |
| 1370 | if (add_method && ClangASTContext::IsAggregateType(copied_type)) |
| 1371 | { |
| 1372 | void *args[1]; |
| 1373 | |
| 1374 | args[0] = ClangASTContext::GetVoidPtrType(parser_ast_context, false); |
| 1375 | |
| 1376 | void *method_type = ClangASTContext::CreateFunctionType (parser_ast_context, |
| 1377 | ClangASTContext::GetBuiltInType_void(parser_ast_context), |
| 1378 | args, |
| 1379 | 1, |
| 1380 | false, |
| 1381 | ClangASTContext::GetTypeQualifiers(copied_type)); |
Greg Clayton | 30449d5 | 2010-10-01 02:31:07 +0000 | [diff] [blame] | 1382 | |
Greg Clayton | 1d8173f | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1383 | const bool is_virtual = false; |
| 1384 | const bool is_static = false; |
| 1385 | const bool is_inline = false; |
Greg Clayton | 30449d5 | 2010-10-01 02:31:07 +0000 | [diff] [blame] | 1386 | const bool is_explicit = false; |
| 1387 | |
Greg Clayton | 1d8173f | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1388 | ClangASTContext::AddMethodToCXXRecordType (parser_ast_context, |
| 1389 | copied_type, |
Greg Clayton | 8de27c7 | 2010-10-15 22:48:33 +0000 | [diff] [blame] | 1390 | "$__lldb_expr", |
Greg Clayton | 1d8173f | 2010-09-24 05:15:53 +0000 | [diff] [blame] | 1391 | method_type, |
| 1392 | lldb::eAccessPublic, |
| 1393 | is_virtual, |
| 1394 | is_static, |
Greg Clayton | 30449d5 | 2010-10-01 02:31:07 +0000 | [diff] [blame] | 1395 | is_inline, |
| 1396 | is_explicit); |
Sean Callanan | 3c9c5eb | 2010-09-21 00:44:12 +0000 | [diff] [blame] | 1397 | } |
Sean Callanan | 93a4b1a | 2010-08-04 01:02:13 +0000 | [diff] [blame] | 1398 | |
| 1399 | context.AddTypeDecl(copied_type); |
| 1400 | } |