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 |
| 16 | #include "lldb/lldb-private.h" |
| 17 | #include "lldb/Core/Address.h" |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Error.h" |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Module.h" |
| 21 | #include "lldb/Expression/ClangASTSource.h" |
| 22 | #include "lldb/Symbol/ClangASTContext.h" |
| 23 | #include "lldb/Symbol/CompileUnit.h" |
| 24 | #include "lldb/Symbol/Function.h" |
| 25 | #include "lldb/Symbol/ObjectFile.h" |
| 26 | #include "lldb/Symbol/SymbolContext.h" |
| 27 | #include "lldb/Symbol/Type.h" |
| 28 | #include "lldb/Symbol/TypeList.h" |
| 29 | #include "lldb/Symbol/Variable.h" |
| 30 | #include "lldb/Symbol/VariableList.h" |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 31 | #include "lldb/Target/ExecutionContext.h" |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 32 | #include "lldb/Target/Process.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 33 | #include "lldb/Target/StackFrame.h" |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 34 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 36 | using namespace lldb_private; |
| 37 | using namespace clang; |
| 38 | |
| 39 | ClangExpressionDeclMap::ClangExpressionDeclMap(ExecutionContext *exe_ctx) : |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 40 | m_exe_ctx(exe_ctx), |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 41 | m_struct_laid_out(false), |
| 42 | m_materialized_location(0) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 43 | { |
| 44 | if (exe_ctx && exe_ctx->frame) |
| 45 | m_sym_ctx = new SymbolContext(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); |
| 46 | else |
| 47 | m_sym_ctx = NULL; |
| 48 | } |
| 49 | |
| 50 | ClangExpressionDeclMap::~ClangExpressionDeclMap() |
| 51 | { |
| 52 | uint32_t num_tuples = m_tuples.size (); |
| 53 | uint32_t tuple_index; |
| 54 | |
| 55 | for (tuple_index = 0; tuple_index < num_tuples; ++tuple_index) |
| 56 | delete m_tuples[tuple_index].m_value; |
| 57 | |
| 58 | if (m_sym_ctx) |
| 59 | delete m_sym_ctx; |
| 60 | } |
| 61 | |
| 62 | bool |
| 63 | ClangExpressionDeclMap::GetIndexForDecl (uint32_t &index, |
| 64 | const clang::Decl *decl) |
| 65 | { |
| 66 | uint32_t num_tuples = m_tuples.size (); |
| 67 | uint32_t tuple_index; |
| 68 | |
| 69 | for (tuple_index = 0; tuple_index < num_tuples; ++tuple_index) |
| 70 | { |
| 71 | if (m_tuples[tuple_index].m_decl == decl) |
| 72 | { |
| 73 | index = tuple_index; |
| 74 | return true; |
| 75 | } |
| 76 | } |
| 77 | |
| 78 | return false; |
| 79 | } |
| 80 | |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 81 | // Interface for IRForTarget |
| 82 | |
| 83 | bool |
| 84 | ClangExpressionDeclMap::AddValueToStruct (llvm::Value *value, |
| 85 | const clang::NamedDecl *decl, |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 86 | std::string &name, |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 87 | void *parser_type, |
| 88 | clang::ASTContext *parser_ast_context, |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 89 | size_t size, |
| 90 | off_t alignment) |
| 91 | { |
| 92 | m_struct_laid_out = false; |
| 93 | |
| 94 | StructMemberIterator iter; |
| 95 | |
| 96 | for (iter = m_members.begin(); |
| 97 | iter != m_members.end(); |
| 98 | ++iter) |
| 99 | { |
| 100 | if (iter->m_decl == decl) |
| 101 | return true; |
| 102 | } |
| 103 | |
| 104 | StructMember member; |
| 105 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 106 | member.m_value = value; |
| 107 | member.m_decl = decl; |
| 108 | member.m_name = name; |
| 109 | member.m_parser_type = TypeFromParser(parser_type, parser_ast_context); |
| 110 | member.m_offset = 0; |
| 111 | member.m_size = size; |
| 112 | member.m_alignment = alignment; |
Sean Callanan | 8bce665 | 2010-07-13 21:41:46 +0000 | [diff] [blame] | 113 | |
| 114 | m_members.push_back(member); |
| 115 | |
| 116 | return true; |
| 117 | } |
| 118 | |
| 119 | bool |
| 120 | ClangExpressionDeclMap::DoStructLayout () |
| 121 | { |
| 122 | if (m_struct_laid_out) |
| 123 | return true; |
| 124 | |
| 125 | StructMemberIterator iter; |
| 126 | |
| 127 | off_t cursor = 0; |
| 128 | |
| 129 | m_struct_alignment = 0; |
| 130 | m_struct_size = 0; |
| 131 | |
| 132 | for (iter = m_members.begin(); |
| 133 | iter != m_members.end(); |
| 134 | ++iter) |
| 135 | { |
| 136 | if (iter == m_members.begin()) |
| 137 | m_struct_alignment = iter->m_alignment; |
| 138 | |
| 139 | if (cursor % iter->m_alignment) |
| 140 | cursor += (iter->m_alignment - (cursor % iter->m_alignment)); |
| 141 | |
| 142 | iter->m_offset = cursor; |
| 143 | cursor += iter->m_size; |
| 144 | } |
| 145 | |
| 146 | m_struct_size = cursor; |
| 147 | |
| 148 | m_struct_laid_out = true; |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | bool ClangExpressionDeclMap::GetStructInfo (uint32_t &num_elements, |
| 153 | size_t &size, |
| 154 | off_t &alignment) |
| 155 | { |
| 156 | if (!m_struct_laid_out) |
| 157 | return false; |
| 158 | |
| 159 | num_elements = m_members.size(); |
| 160 | size = m_struct_size; |
| 161 | alignment = m_struct_alignment; |
| 162 | |
| 163 | return true; |
| 164 | } |
| 165 | |
| 166 | bool |
| 167 | ClangExpressionDeclMap::GetStructElement (const clang::NamedDecl *&decl, |
| 168 | llvm::Value *&value, |
| 169 | off_t &offset, |
| 170 | uint32_t index) |
| 171 | { |
| 172 | if (!m_struct_laid_out) |
| 173 | return false; |
| 174 | |
| 175 | if (index >= m_members.size()) |
| 176 | return false; |
| 177 | |
| 178 | decl = m_members[index].m_decl; |
| 179 | value = m_members[index].m_value; |
| 180 | offset = m_members[index].m_offset; |
| 181 | |
| 182 | return true; |
| 183 | } |
| 184 | |
Sean Callanan | ba992c5 | 2010-07-27 02:07:53 +0000 | [diff] [blame^] | 185 | uint64_t |
| 186 | ClangExpressionDeclMap::GetFunctionAddress (const clang::NamedDecl *decl) |
| 187 | { |
| 188 | TupleIterator iter; |
| 189 | |
| 190 | for (iter = m_tuples.begin(); |
| 191 | iter != m_tuples.end(); |
| 192 | ++iter) |
| 193 | { |
| 194 | if (decl == iter->m_decl) |
| 195 | { |
| 196 | return iter->m_value->GetScalar().ULongLong(); |
| 197 | } |
| 198 | } |
| 199 | |
| 200 | return 0; |
| 201 | } |
| 202 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 203 | // Interface for DwarfExpression |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 204 | lldb_private::Value |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 205 | *ClangExpressionDeclMap::GetValueForIndex (uint32_t index) |
| 206 | { |
| 207 | if (index >= m_tuples.size ()) |
| 208 | return NULL; |
| 209 | |
| 210 | return m_tuples[index].m_value; |
| 211 | } |
| 212 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 213 | // Interface for CommandObjectExpression |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 214 | |
| 215 | bool |
| 216 | ClangExpressionDeclMap::Materialize (ExecutionContext *exe_ctx, |
| 217 | lldb::addr_t &struct_address, |
| 218 | Error &err) |
| 219 | { |
| 220 | bool result = DoMaterialize(false, exe_ctx, NULL, err); |
| 221 | |
| 222 | if (result) |
| 223 | struct_address = m_materialized_location; |
| 224 | |
| 225 | return result; |
| 226 | } |
| 227 | |
| 228 | bool |
| 229 | ClangExpressionDeclMap::Dematerialize (ExecutionContext *exe_ctx, |
| 230 | lldb_private::Value &result_value, |
| 231 | Error &err) |
| 232 | { |
| 233 | return DoMaterialize(true, exe_ctx, &result_value, err); |
| 234 | } |
| 235 | |
Sean Callanan | 32824aa | 2010-07-23 22:19:18 +0000 | [diff] [blame] | 236 | bool |
| 237 | ClangExpressionDeclMap::DumpMaterializedStruct(ExecutionContext *exe_ctx, |
| 238 | Stream &s, |
| 239 | Error &err) |
| 240 | { |
| 241 | if (!m_struct_laid_out) |
| 242 | { |
| 243 | err.SetErrorString("Structure hasn't been laid out yet"); |
| 244 | return false; |
| 245 | } |
| 246 | |
| 247 | if (!exe_ctx) |
| 248 | { |
| 249 | err.SetErrorString("Received null execution context"); |
| 250 | return false; |
| 251 | } |
| 252 | |
| 253 | |
| 254 | if (!exe_ctx->process) |
| 255 | { |
| 256 | err.SetErrorString("Couldn't find the process"); |
| 257 | return false; |
| 258 | } |
| 259 | |
| 260 | if (!exe_ctx->target) |
| 261 | { |
| 262 | err.SetErrorString("Couldn't find the target"); |
| 263 | return false; |
| 264 | } |
| 265 | |
| 266 | lldb::DataBufferSP data(new DataBufferHeap(m_struct_size, 0)); |
| 267 | |
| 268 | Error error; |
| 269 | if (exe_ctx->process->ReadMemory (m_materialized_location, data->GetBytes(), data->GetByteSize(), error) != data->GetByteSize()) |
| 270 | { |
| 271 | err.SetErrorStringWithFormat ("Couldn't read struct from the target: %s", error.AsCString()); |
| 272 | return false; |
| 273 | } |
| 274 | |
| 275 | DataExtractor extractor(data, exe_ctx->process->GetByteOrder(), exe_ctx->target->GetArchitecture().GetAddressByteSize()); |
| 276 | |
| 277 | StructMemberIterator iter; |
| 278 | |
| 279 | for (iter = m_members.begin(); |
| 280 | iter != m_members.end(); |
| 281 | ++iter) |
| 282 | { |
| 283 | s.Printf("[%s]\n", iter->m_name.c_str()); |
| 284 | |
| 285 | extractor.Dump(&s, // stream |
| 286 | iter->m_offset, // offset |
| 287 | lldb::eFormatBytesWithASCII, // format |
| 288 | 1, // byte size of individual entries |
| 289 | iter->m_size, // number of entries |
| 290 | 16, // entries per line |
| 291 | m_materialized_location + iter->m_offset, // address to print |
| 292 | 0, // bit size (bitfields only; 0 means ignore) |
| 293 | 0); // bit alignment (bitfields only; 0 means ignore) |
| 294 | |
| 295 | s.PutChar('\n'); |
| 296 | } |
| 297 | |
| 298 | return true; |
| 299 | } |
| 300 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 301 | bool |
| 302 | ClangExpressionDeclMap::DoMaterialize (bool dematerialize, |
| 303 | ExecutionContext *exe_ctx, |
| 304 | lldb_private::Value *result_value, |
| 305 | Error &err) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 306 | { |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 307 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 308 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 309 | if (!m_struct_laid_out) |
| 310 | { |
| 311 | err.SetErrorString("Structure hasn't been laid out yet"); |
| 312 | return LLDB_INVALID_ADDRESS; |
| 313 | } |
| 314 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 315 | if (!exe_ctx) |
| 316 | { |
| 317 | err.SetErrorString("Received null execution context"); |
| 318 | return LLDB_INVALID_ADDRESS; |
| 319 | } |
| 320 | |
Sean Callanan | 4583927 | 2010-07-24 01:37:44 +0000 | [diff] [blame] | 321 | if (!exe_ctx->frame) |
| 322 | { |
| 323 | err.SetErrorString("Received null execution frame"); |
| 324 | return LLDB_INVALID_ADDRESS; |
| 325 | } |
| 326 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 327 | const SymbolContext &sym_ctx(exe_ctx->frame->GetSymbolContext(lldb::eSymbolContextEverything)); |
| 328 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 329 | if (!dematerialize) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 330 | { |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 331 | if (m_materialized_location) |
| 332 | { |
| 333 | exe_ctx->process->DeallocateMemory(m_materialized_location); |
| 334 | m_materialized_location = 0; |
| 335 | } |
| 336 | |
| 337 | lldb::addr_t mem = exe_ctx->process->AllocateMemory(m_struct_alignment + m_struct_size, |
| 338 | lldb::ePermissionsReadable | lldb::ePermissionsWritable, |
| 339 | err); |
| 340 | |
| 341 | if (mem == LLDB_INVALID_ADDRESS) |
| 342 | return false; |
| 343 | |
| 344 | m_allocated_area = mem; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 345 | } |
| 346 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 347 | m_materialized_location = m_allocated_area; |
| 348 | |
| 349 | if (m_materialized_location % m_struct_alignment) |
| 350 | { |
| 351 | m_materialized_location += (m_struct_alignment - (m_materialized_location % m_struct_alignment)); |
| 352 | } |
| 353 | |
| 354 | StructMemberIterator iter; |
| 355 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 356 | for (iter = m_members.begin(); |
| 357 | iter != m_members.end(); |
| 358 | ++iter) |
| 359 | { |
| 360 | uint32_t tuple_index; |
| 361 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 362 | if (!GetIndexForDecl(tuple_index, iter->m_decl)) |
| 363 | { |
| 364 | if (iter->m_name.find("___clang_expr_result") == std::string::npos) |
| 365 | { |
| 366 | err.SetErrorStringWithFormat("Unexpected variable %s", iter->m_name.c_str()); |
| 367 | return false; |
| 368 | } |
| 369 | |
| 370 | if (log) |
| 371 | log->Printf("Found special result variable %s", iter->m_name.c_str()); |
| 372 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 373 | if (dematerialize) |
| 374 | { |
| 375 | clang::ASTContext *context(exe_ctx->target->GetScratchClangASTContext()->getASTContext()); |
| 376 | |
| 377 | if (!context) |
| 378 | { |
| 379 | err.SetErrorString("Couldn't find a scratch AST context to put the result type into"); |
| 380 | } |
| 381 | |
| 382 | TypeFromUser copied_type(ClangASTContext::CopyType(context, |
| 383 | iter->m_parser_type.GetASTContext(), |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 384 | iter->m_parser_type.GetOpaqueQualType()), |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 385 | context); |
| 386 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 387 | result_value->SetContext(Value::eContextTypeOpaqueClangQualType, copied_type.GetOpaqueQualType()); |
| 388 | |
| 389 | result_value->SetValueType(Value::eValueTypeLoadAddress); |
| 390 | result_value->GetScalar() = (uintptr_t)m_materialized_location + iter->m_offset; |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 391 | } |
| 392 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 393 | continue; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 394 | } |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 395 | |
| 396 | Tuple &tuple(m_tuples[tuple_index]); |
| 397 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 398 | if (!DoMaterializeOneVariable(dematerialize, *exe_ctx, sym_ctx, iter->m_name.c_str(), tuple.m_user_type, m_materialized_location + iter->m_offset, err)) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 399 | return false; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 400 | } |
| 401 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 402 | return true; |
| 403 | } |
| 404 | |
| 405 | bool |
| 406 | ClangExpressionDeclMap::DoMaterializeOneVariable(bool dematerialize, |
| 407 | ExecutionContext &exe_ctx, |
| 408 | const SymbolContext &sym_ctx, |
| 409 | const char *name, |
| 410 | TypeFromUser type, |
| 411 | lldb::addr_t addr, |
| 412 | Error &err) |
| 413 | { |
| 414 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 415 | |
| 416 | Variable *var = FindVariableInScope(sym_ctx, name, &type); |
| 417 | |
| 418 | if (!var) |
| 419 | { |
| 420 | err.SetErrorStringWithFormat("Couldn't find %s with appropriate type", name); |
| 421 | return false; |
| 422 | } |
| 423 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 424 | if (log) |
| 425 | log->Printf("%s %s with type %p", (dematerialize ? "Dematerializing" : "Materializing"), name, type.GetOpaqueQualType()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 426 | |
| 427 | std::auto_ptr<lldb_private::Value> location_value(GetVariableValue(exe_ctx, |
| 428 | var, |
| 429 | type.GetASTContext())); |
| 430 | |
| 431 | if (!location_value.get()) |
| 432 | { |
| 433 | err.SetErrorStringWithFormat("Couldn't get value for %s", name); |
| 434 | return false; |
| 435 | } |
| 436 | |
| 437 | if (location_value->GetValueType() == Value::eValueTypeLoadAddress) |
| 438 | { |
| 439 | lldb::addr_t value_addr = location_value->GetScalar().ULongLong(); |
| 440 | |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 441 | size_t bit_size = ClangASTContext::GetTypeBitSize(type.GetASTContext(), type.GetOpaqueQualType()); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 442 | size_t byte_size = bit_size % 8 ? ((bit_size + 8) / 8) : (bit_size / 8); |
| 443 | |
| 444 | DataBufferHeap data; |
| 445 | data.SetByteSize(byte_size); |
| 446 | |
| 447 | lldb::addr_t src_addr; |
| 448 | lldb::addr_t dest_addr; |
| 449 | |
| 450 | if (dematerialize) |
| 451 | { |
| 452 | src_addr = addr; |
| 453 | dest_addr = value_addr; |
| 454 | } |
| 455 | else |
| 456 | { |
| 457 | src_addr = value_addr; |
| 458 | dest_addr = addr; |
| 459 | } |
| 460 | |
| 461 | Error error; |
| 462 | if (exe_ctx.process->ReadMemory (src_addr, data.GetBytes(), byte_size, error) != byte_size) |
| 463 | { |
| 464 | err.SetErrorStringWithFormat ("Couldn't read a composite type from the target: %s", error.AsCString()); |
| 465 | return false; |
| 466 | } |
| 467 | |
| 468 | if (exe_ctx.process->WriteMemory (dest_addr, data.GetBytes(), byte_size, error) != byte_size) |
| 469 | { |
| 470 | err.SetErrorStringWithFormat ("Couldn't write a composite type to the target: %s", error.AsCString()); |
| 471 | return false; |
| 472 | } |
| 473 | |
| 474 | if (log) |
| 475 | log->Printf("Copied from 0x%llx to 0x%llx", (uint64_t)src_addr, (uint64_t)addr); |
| 476 | } |
| 477 | else |
| 478 | { |
| 479 | StreamString ss; |
| 480 | |
| 481 | location_value->Dump(&ss); |
| 482 | |
| 483 | err.SetErrorStringWithFormat("%s has a value of unhandled type: %s", name, ss.GetString().c_str()); |
| 484 | } |
| 485 | |
| 486 | return true; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 487 | } |
| 488 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 489 | Variable* |
| 490 | ClangExpressionDeclMap::FindVariableInScope(const SymbolContext &sym_ctx, |
| 491 | const char *name, |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 492 | TypeFromUser *type) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 493 | { |
| 494 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 495 | |
| 496 | Function *function(m_sym_ctx->function); |
| 497 | Block *block(m_sym_ctx->block); |
| 498 | |
| 499 | if (!function || !block) |
| 500 | { |
| 501 | if (log) |
| 502 | log->Printf("function = %p, block = %p", function, block); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 503 | return NULL; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | BlockList& blocks(function->GetBlocks(true)); |
| 507 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 508 | ConstString name_cs(name); |
| 509 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 510 | lldb::user_id_t current_block_id; |
| 511 | |
| 512 | for (current_block_id = block->GetID(); |
| 513 | current_block_id != Block::InvalidID; |
| 514 | current_block_id = blocks.GetParent(current_block_id)) |
| 515 | { |
| 516 | Block *current_block(blocks.GetBlockByID(current_block_id)); |
| 517 | |
| 518 | lldb::VariableListSP var_list = current_block->GetVariableList(false, true); |
| 519 | |
| 520 | if (!var_list) |
| 521 | continue; |
| 522 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 523 | lldb::VariableSP var = var_list->FindVariable(name_cs); |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 524 | |
| 525 | if (!var) |
| 526 | continue; |
| 527 | |
| 528 | // var->GetType()->GetClangAST() is the program's AST context and holds |
| 529 | // var->GetType()->GetOpaqueClangQualType(). |
| 530 | |
| 531 | // type is m_type for one of the struct members, which was added by |
| 532 | // AddValueToStruct. That type was extracted from the AST context of |
| 533 | // the compiler in IRForTarget. The original for the type was copied |
| 534 | // out of the program's AST context by AddOneVariable. |
| 535 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 536 | // So that we can compare these two without having to copy back |
| 537 | // something we already had in the original AST context, we maintain |
| 538 | // m_orig_type and m_ast_context (which are passed into |
| 539 | // MaterializeOneVariable by Materialize) for each variable. |
| 540 | |
| 541 | if (!type) |
| 542 | return var.get(); |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 543 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 544 | if (type->GetASTContext() == var->GetType()->GetClangAST()) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 545 | { |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 546 | if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type, var->GetType()->GetOpaqueClangQualType())) |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 547 | continue; |
| 548 | } |
| 549 | else |
| 550 | { |
| 551 | if (log) |
| 552 | log->PutCString("Skipping a candidate variable because of different AST contexts"); |
| 553 | continue; |
| 554 | } |
| 555 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 556 | return var.get(); |
| 557 | } |
| 558 | |
| 559 | { |
| 560 | CompileUnit *compile_unit = m_sym_ctx->comp_unit; |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 561 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 562 | if (!compile_unit) |
| 563 | { |
| 564 | if (log) |
| 565 | log->Printf("compile_unit = %p", compile_unit); |
| 566 | return NULL; |
| 567 | } |
| 568 | |
| 569 | lldb::VariableListSP var_list = compile_unit->GetVariableList(true); |
| 570 | |
| 571 | if (!var_list) |
| 572 | return NULL; |
| 573 | |
| 574 | lldb::VariableSP var = var_list->FindVariable(name_cs); |
| 575 | |
| 576 | if (!var) |
| 577 | return NULL; |
| 578 | |
| 579 | if (!type) |
| 580 | return var.get(); |
| 581 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 582 | if (type->GetASTContext() == var->GetType()->GetClangAST()) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 583 | { |
Sean Callanan | 841026f | 2010-07-23 00:16:21 +0000 | [diff] [blame] | 584 | if (!ClangASTContext::AreTypesSame(type->GetASTContext(), type->GetOpaqueQualType(), var->GetType()->GetOpaqueClangQualType())) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 585 | return NULL; |
| 586 | } |
| 587 | else |
| 588 | { |
| 589 | if (log) |
| 590 | log->PutCString("Skipping a candidate variable because of different AST contexts"); |
| 591 | return NULL; |
| 592 | } |
| 593 | |
| 594 | return var.get(); |
| 595 | } |
| 596 | |
| 597 | return NULL; |
| 598 | } |
| 599 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 600 | // Interface for ClangASTSource |
| 601 | void |
| 602 | ClangExpressionDeclMap::GetDecls(NameSearchContext &context, |
| 603 | const char *name) |
| 604 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 605 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 606 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 607 | if (log) |
| 608 | log->Printf("Hunting for a definition for %s", name); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 609 | |
| 610 | // Back out in all cases where we're not fully initialized |
| 611 | if (!m_exe_ctx || !m_exe_ctx->frame || !m_sym_ctx) |
| 612 | return; |
| 613 | |
| 614 | Function *function = m_sym_ctx->function; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 615 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 616 | if (!function) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 617 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 618 | if (log) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 619 | log->Printf("Can't evaluate an expression when not in a function"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 620 | return; |
| 621 | } |
| 622 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 623 | ConstString name_cs(name); |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 624 | SymbolContextList sym_ctxs; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 625 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 626 | m_sym_ctx->FindFunctionsByName(name_cs, false, sym_ctxs); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 627 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 628 | for (uint32_t index = 0, num_indices = sym_ctxs.GetSize(); |
| 629 | index < num_indices; |
| 630 | ++index) |
| 631 | { |
| 632 | SymbolContext sym_ctx; |
| 633 | sym_ctxs.GetContextAtIndex(index, sym_ctx); |
| 634 | |
| 635 | if (sym_ctx.function) |
| 636 | AddOneFunction(context, sym_ctx.function, NULL); |
| 637 | else if(sym_ctx.symbol) |
| 638 | AddOneFunction(context, NULL, sym_ctx.symbol); |
| 639 | } |
| 640 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 641 | Variable *var = FindVariableInScope(*m_sym_ctx, name); |
| 642 | |
| 643 | if (var) |
| 644 | AddOneVariable(context, var); |
| 645 | } |
| 646 | |
| 647 | Value * |
| 648 | ClangExpressionDeclMap::GetVariableValue(ExecutionContext &exe_ctx, |
| 649 | Variable *var, |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 650 | clang::ASTContext *parser_ast_context, |
| 651 | TypeFromUser *user_type, |
| 652 | TypeFromParser *parser_type) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 653 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 654 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 655 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 656 | Type *var_type = var->GetType(); |
| 657 | |
| 658 | if (!var_type) |
| 659 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 660 | if (log) |
| 661 | log->PutCString("Skipped a definition because it has no type"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 662 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 663 | } |
| 664 | |
| 665 | void *var_opaque_type = var_type->GetOpaqueClangQualType(); |
| 666 | |
| 667 | if (!var_opaque_type) |
| 668 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 669 | if (log) |
| 670 | log->PutCString("Skipped a definition because it has no Clang type"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 671 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 672 | } |
| 673 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 674 | TypeList *type_list = var_type->GetTypeList(); |
| 675 | |
| 676 | if (!type_list) |
| 677 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 678 | if (log) |
| 679 | 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] | 680 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 681 | } |
| 682 | |
| 683 | clang::ASTContext *exe_ast_ctx = type_list->GetClangASTContext().getASTContext(); |
| 684 | |
| 685 | if (!exe_ast_ctx) |
| 686 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 687 | if (log) |
| 688 | log->PutCString("There is no AST context for the current execution context"); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 689 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 690 | } |
| 691 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 692 | DWARFExpression &var_location_expr = var->LocationExpression(); |
| 693 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 694 | std::auto_ptr<Value> var_location(new Value); |
| 695 | |
| 696 | Error err; |
| 697 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 698 | if (!var_location_expr.Evaluate(&exe_ctx, exe_ast_ctx, NULL, *var_location.get(), &err)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 699 | { |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 700 | if (log) |
| 701 | log->Printf("Error evaluating location: %s", err.AsCString()); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 702 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 703 | } |
| 704 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 705 | clang::ASTContext *var_ast_context = type_list->GetClangASTContext().getASTContext(); |
| 706 | |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 707 | void *type_to_use; |
| 708 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 709 | if (parser_ast_context) |
| 710 | { |
| 711 | type_to_use = ClangASTContext::CopyType(parser_ast_context, var_ast_context, var_opaque_type); |
| 712 | |
| 713 | if (parser_type) |
| 714 | *parser_type = TypeFromParser(type_to_use, parser_ast_context); |
| 715 | } |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 716 | else |
| 717 | type_to_use = var_opaque_type; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 718 | |
| 719 | if (var_location.get()->GetContextType() == Value::eContextTypeInvalid) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 720 | var_location.get()->SetContext(Value::eContextTypeOpaqueClangQualType, type_to_use); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 721 | |
| 722 | if (var_location.get()->GetValueType() == Value::eValueTypeFileAddress) |
| 723 | { |
| 724 | SymbolContext var_sc; |
| 725 | var->CalculateSymbolContext(&var_sc); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 726 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 727 | if (!var_sc.module_sp) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 728 | return NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 729 | |
| 730 | ObjectFile *object_file = var_sc.module_sp->GetObjectFile(); |
| 731 | |
| 732 | if (!object_file) |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 733 | return NULL; |
| 734 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 735 | Address so_addr(var_location->GetScalar().ULongLong(), object_file->GetSectionList()); |
| 736 | |
| 737 | lldb::addr_t load_addr = so_addr.GetLoadAddress(m_exe_ctx->process); |
| 738 | |
| 739 | var_location->GetScalar() = load_addr; |
| 740 | var_location->SetValueType(Value::eValueTypeLoadAddress); |
| 741 | } |
| 742 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 743 | if (user_type) |
| 744 | *user_type = TypeFromUser(var_opaque_type, var_ast_context); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 745 | |
| 746 | return var_location.release(); |
| 747 | } |
| 748 | |
| 749 | void |
| 750 | ClangExpressionDeclMap::AddOneVariable(NameSearchContext &context, |
| 751 | Variable* var) |
| 752 | { |
| 753 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
| 754 | |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 755 | TypeFromUser ut; |
| 756 | TypeFromParser pt; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 757 | |
| 758 | Value *var_location = GetVariableValue(*m_exe_ctx, |
| 759 | var, |
| 760 | context.GetASTContext(), |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 761 | &ut, |
| 762 | &pt); |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 763 | |
Greg Clayton | 1674b12 | 2010-07-21 22:12:05 +0000 | [diff] [blame] | 764 | NamedDecl *var_decl = context.AddVarDecl(pt.GetOpaqueQualType()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 765 | |
| 766 | Tuple tuple; |
| 767 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 768 | tuple.m_decl = var_decl; |
Sean Callanan | 336a000 | 2010-07-17 00:43:37 +0000 | [diff] [blame] | 769 | tuple.m_value = var_location; |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 770 | tuple.m_user_type = ut; |
| 771 | tuple.m_parser_type = pt; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 772 | |
| 773 | m_tuples.push_back(tuple); |
| 774 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 775 | if (log) |
| 776 | log->PutCString("Found variable"); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 777 | } |
| 778 | |
| 779 | void |
| 780 | ClangExpressionDeclMap::AddOneFunction(NameSearchContext &context, |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 781 | Function* fun, |
| 782 | Symbol* symbol) |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 783 | { |
Sean Callanan | 6184dfe | 2010-06-23 00:47:48 +0000 | [diff] [blame] | 784 | Log *log = lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 785 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 786 | NamedDecl *fun_decl; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 787 | std::auto_ptr<Value> fun_location(new Value); |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 788 | const Address *fun_address; |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 789 | |
Sean Callanan | 0fc7358 | 2010-07-27 00:55:47 +0000 | [diff] [blame] | 790 | // only valid for Functions, not for Symbols |
| 791 | void *fun_opaque_type = NULL; |
| 792 | clang::ASTContext *fun_ast_context = NULL; |
| 793 | |
| 794 | if (fun) |
| 795 | { |
| 796 | Type *fun_type = fun->GetType(); |
| 797 | |
| 798 | if (!fun_type) |
| 799 | { |
| 800 | if (log) |
| 801 | log->PutCString("Skipped a function because it has no type"); |
| 802 | return; |
| 803 | } |
| 804 | |
| 805 | fun_opaque_type = fun_type->GetOpaqueClangQualType(); |
| 806 | |
| 807 | if (!fun_opaque_type) |
| 808 | { |
| 809 | if (log) |
| 810 | log->PutCString("Skipped a function because it has no Clang type"); |
| 811 | return; |
| 812 | } |
| 813 | |
| 814 | fun_address = &fun->GetAddressRange().GetBaseAddress(); |
| 815 | |
| 816 | TypeList *type_list = fun_type->GetTypeList(); |
| 817 | fun_ast_context = type_list->GetClangASTContext().getASTContext(); |
| 818 | void *copied_type = ClangASTContext::CopyType(context.GetASTContext(), fun_ast_context, fun_opaque_type); |
| 819 | |
| 820 | fun_decl = context.AddFunDecl(copied_type); |
| 821 | } |
| 822 | else if (symbol) |
| 823 | { |
| 824 | fun_address = &symbol->GetAddressRangeRef().GetBaseAddress(); |
| 825 | |
| 826 | fun_decl = context.AddGenericFunDecl(); |
| 827 | } |
| 828 | else |
| 829 | { |
| 830 | if (log) |
| 831 | log->PutCString("AddOneFunction called with no function and no symbol"); |
| 832 | return; |
| 833 | } |
| 834 | |
| 835 | lldb::addr_t load_addr = fun_address->GetLoadAddress(m_exe_ctx->process); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 836 | fun_location->SetValueType(Value::eValueTypeLoadAddress); |
| 837 | fun_location->GetScalar() = load_addr; |
| 838 | |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 839 | Tuple tuple; |
| 840 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 841 | tuple.m_decl = fun_decl; |
| 842 | tuple.m_value = fun_location.release(); |
Sean Callanan | f328c9f | 2010-07-20 23:31:16 +0000 | [diff] [blame] | 843 | tuple.m_user_type = TypeFromUser(fun_opaque_type, fun_ast_context); |
Sean Callanan | 8f0dc34 | 2010-06-22 23:46:24 +0000 | [diff] [blame] | 844 | |
| 845 | m_tuples.push_back(tuple); |
| 846 | |
Sean Callanan | 810f22d | 2010-07-16 00:09:46 +0000 | [diff] [blame] | 847 | if (log) |
| 848 | log->PutCString("Found function"); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 849 | } |