1 //===-- SBFrame.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/API/SBFrame.h" 11 12 #include <string> 13 #include <algorithm> 14 15 #include "lldb/lldb-types.h" 16 17 #include "lldb/Core/Address.h" 18 #include "lldb/Core/ConstString.h" 19 #include "lldb/Core/Log.h" 20 #include "lldb/Core/Stream.h" 21 #include "lldb/Core/StreamFile.h" 22 #include "lldb/Core/ValueObjectRegister.h" 23 #include "lldb/Core/ValueObjectVariable.h" 24 #include "lldb/Expression/ClangUserExpression.h" 25 #include "lldb/Symbol/Block.h" 26 #include "lldb/Symbol/SymbolContext.h" 27 #include "lldb/Symbol/VariableList.h" 28 #include "lldb/Symbol/Variable.h" 29 #include "lldb/Target/ExecutionContext.h" 30 #include "lldb/Target/Target.h" 31 #include "lldb/Target/Process.h" 32 #include "lldb/Target/RegisterContext.h" 33 #include "lldb/Target/StackFrame.h" 34 #include "lldb/Target/Thread.h" 35 36 #include "lldb/API/SBDebugger.h" 37 #include "lldb/API/SBValue.h" 38 #include "lldb/API/SBAddress.h" 39 #include "lldb/API/SBStream.h" 40 #include "lldb/API/SBSymbolContext.h" 41 #include "lldb/API/SBThread.h" 42 43 using namespace lldb; 44 using namespace lldb_private; 45 46 SBFrame::SBFrame () : 47 m_opaque_sp () 48 { 49 } 50 51 SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) : 52 m_opaque_sp (lldb_object_sp) 53 { 54 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 55 56 if (log) 57 { 58 SBStream sstr; 59 GetDescription (sstr); 60 log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s", 61 lldb_object_sp.get(), m_opaque_sp.get(), sstr.GetData()); 62 63 } 64 } 65 66 SBFrame::SBFrame(const SBFrame &rhs) : 67 m_opaque_sp (rhs.m_opaque_sp) 68 { 69 } 70 71 const SBFrame & 72 SBFrame::operator = (const SBFrame &rhs) 73 { 74 if (this != &rhs) 75 m_opaque_sp = rhs.m_opaque_sp; 76 return *this; 77 } 78 79 SBFrame::~SBFrame() 80 { 81 } 82 83 84 void 85 SBFrame::SetFrame (const StackFrameSP &lldb_object_sp) 86 { 87 void *old_ptr = m_opaque_sp.get(); 88 m_opaque_sp = lldb_object_sp; 89 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 90 91 if (log) 92 { 93 log->Printf ("SBFrame(%p)::SetFrame(sp=%p) := SBFrame(%p)", 94 old_ptr, lldb_object_sp.get(), m_opaque_sp.get()); 95 } 96 97 } 98 99 100 bool 101 SBFrame::IsValid() const 102 { 103 return (m_opaque_sp.get() != NULL); 104 } 105 106 SBSymbolContext 107 SBFrame::GetSymbolContext (uint32_t resolve_scope) const 108 { 109 110 SBSymbolContext sb_sym_ctx; 111 if (m_opaque_sp) 112 { 113 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 114 sb_sym_ctx.SetSymbolContext(&m_opaque_sp->GetSymbolContext (resolve_scope)); 115 } 116 117 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 118 if (log) 119 log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)", 120 m_opaque_sp.get(), resolve_scope, sb_sym_ctx.get()); 121 122 return sb_sym_ctx; 123 } 124 125 SBModule 126 SBFrame::GetModule () const 127 { 128 SBModule sb_module; 129 if (m_opaque_sp) 130 { 131 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 132 *sb_module = m_opaque_sp->GetSymbolContext (eSymbolContextModule).module_sp; 133 } 134 135 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 136 if (log) 137 log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", 138 m_opaque_sp.get(), sb_module.get()); 139 140 return sb_module; 141 } 142 143 SBCompileUnit 144 SBFrame::GetCompileUnit () const 145 { 146 SBCompileUnit sb_comp_unit; 147 if (m_opaque_sp) 148 { 149 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 150 sb_comp_unit.reset (m_opaque_sp->GetSymbolContext (eSymbolContextCompUnit).comp_unit); 151 } 152 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 153 if (log) 154 log->Printf ("SBFrame(%p)::GetModule () => SBCompileUnit(%p)", 155 m_opaque_sp.get(), sb_comp_unit.get()); 156 157 return sb_comp_unit; 158 } 159 160 SBFunction 161 SBFrame::GetFunction () const 162 { 163 SBFunction sb_function; 164 if (m_opaque_sp) 165 { 166 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 167 sb_function.reset(m_opaque_sp->GetSymbolContext (eSymbolContextFunction).function); 168 } 169 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 170 if (log) 171 log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", 172 m_opaque_sp.get(), sb_function.get()); 173 174 return sb_function; 175 } 176 177 SBSymbol 178 SBFrame::GetSymbol () const 179 { 180 SBSymbol sb_symbol; 181 if (m_opaque_sp) 182 { 183 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 184 sb_symbol.reset(m_opaque_sp->GetSymbolContext (eSymbolContextSymbol).symbol); 185 } 186 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 187 if (log) 188 log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", 189 m_opaque_sp.get(), sb_symbol.get()); 190 return sb_symbol; 191 } 192 193 SBBlock 194 SBFrame::GetBlock () const 195 { 196 SBBlock sb_block; 197 if (m_opaque_sp) 198 { 199 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 200 sb_block.reset (m_opaque_sp->GetSymbolContext (eSymbolContextBlock).block); 201 } 202 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 203 if (log) 204 log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", 205 m_opaque_sp.get(), sb_block.get()); 206 return sb_block; 207 } 208 209 SBBlock 210 SBFrame::GetFrameBlock () const 211 { 212 SBBlock sb_block; 213 if (m_opaque_sp) 214 { 215 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 216 sb_block.reset(m_opaque_sp->GetFrameBlock ()); 217 } 218 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 219 if (log) 220 log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", 221 m_opaque_sp.get(), sb_block.get()); 222 return sb_block; 223 } 224 225 SBLineEntry 226 SBFrame::GetLineEntry () const 227 { 228 SBLineEntry sb_line_entry; 229 if (m_opaque_sp) 230 { 231 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 232 sb_line_entry.SetLineEntry (m_opaque_sp->GetSymbolContext (eSymbolContextLineEntry).line_entry); 233 } 234 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 235 if (log) 236 log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", 237 m_opaque_sp.get(), sb_line_entry.get()); 238 return sb_line_entry; 239 } 240 241 uint32_t 242 SBFrame::GetFrameID () const 243 { 244 uint32_t frame_idx = m_opaque_sp ? m_opaque_sp->GetFrameIndex () : UINT32_MAX; 245 246 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 247 if (log) 248 log->Printf ("SBFrame(%p)::GetFrameID () => %u", 249 m_opaque_sp.get(), frame_idx); 250 return frame_idx; 251 } 252 253 addr_t 254 SBFrame::GetPC () const 255 { 256 addr_t addr = LLDB_INVALID_ADDRESS; 257 if (m_opaque_sp) 258 { 259 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 260 addr = m_opaque_sp->GetFrameCodeAddress().GetLoadAddress (&m_opaque_sp->GetThread().GetProcess().GetTarget()); 261 } 262 263 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 264 if (log) 265 log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", m_opaque_sp.get(), addr); 266 267 return addr; 268 } 269 270 bool 271 SBFrame::SetPC (addr_t new_pc) 272 { 273 bool ret_val = false; 274 if (m_opaque_sp) 275 { 276 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 277 ret_val = m_opaque_sp->GetRegisterContext()->SetPC (new_pc); 278 } 279 280 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 281 if (log) 282 log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i", 283 m_opaque_sp.get(), new_pc, ret_val); 284 285 return ret_val; 286 } 287 288 addr_t 289 SBFrame::GetSP () const 290 { 291 addr_t addr = LLDB_INVALID_ADDRESS; 292 if (m_opaque_sp) 293 { 294 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 295 addr = m_opaque_sp->GetRegisterContext()->GetSP(); 296 } 297 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 298 if (log) 299 log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", m_opaque_sp.get(), addr); 300 301 return addr; 302 } 303 304 305 addr_t 306 SBFrame::GetFP () const 307 { 308 addr_t addr = LLDB_INVALID_ADDRESS; 309 if (m_opaque_sp) 310 { 311 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 312 addr = m_opaque_sp->GetRegisterContext()->GetFP(); 313 } 314 315 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 316 if (log) 317 log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", m_opaque_sp.get(), addr); 318 return addr; 319 } 320 321 322 SBAddress 323 SBFrame::GetPCAddress () const 324 { 325 SBAddress sb_addr; 326 if (m_opaque_sp) 327 { 328 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 329 sb_addr.SetAddress (&m_opaque_sp->GetFrameCodeAddress()); 330 } 331 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 332 if (log) 333 log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", m_opaque_sp.get(), sb_addr.get()); 334 return sb_addr; 335 } 336 337 void 338 SBFrame::Clear() 339 { 340 m_opaque_sp.reset(); 341 } 342 343 SBValue 344 SBFrame::FindVariable (const char *name) 345 { 346 lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); 347 return FindVariable (name, use_dynamic); 348 } 349 350 SBValue 351 SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) 352 { 353 VariableSP var_sp; 354 SBValue sb_value; 355 356 if (m_opaque_sp && name && name[0]) 357 { 358 VariableList variable_list; 359 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 360 SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); 361 362 if (sc.block) 363 { 364 const bool can_create = true; 365 const bool get_parent_variables = true; 366 const bool stop_if_block_is_inlined_function = true; 367 368 if (sc.block->AppendVariables (can_create, 369 get_parent_variables, 370 stop_if_block_is_inlined_function, 371 &variable_list)) 372 { 373 var_sp = variable_list.FindVariable (ConstString(name)); 374 } 375 } 376 } 377 378 if (var_sp) 379 *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(var_sp, use_dynamic)); 380 381 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 382 if (log) 383 log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", 384 m_opaque_sp.get(), name, sb_value.get()); 385 386 return sb_value; 387 } 388 389 SBValue 390 SBFrame::FindValue (const char *name, ValueType value_type) 391 { 392 lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); 393 return FindValue (name, value_type, use_dynamic); 394 } 395 396 SBValue 397 SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) 398 { 399 SBValue sb_value; 400 if (m_opaque_sp && name && name[0]) 401 { 402 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 403 404 switch (value_type) 405 { 406 case eValueTypeVariableGlobal: // global variable 407 case eValueTypeVariableStatic: // static variable 408 case eValueTypeVariableArgument: // function argument variables 409 case eValueTypeVariableLocal: // function local variables 410 { 411 VariableList *variable_list = m_opaque_sp->GetVariableList(true); 412 413 SymbolContext sc (m_opaque_sp->GetSymbolContext (eSymbolContextBlock)); 414 415 const bool can_create = true; 416 const bool get_parent_variables = true; 417 const bool stop_if_block_is_inlined_function = true; 418 419 if (sc.block && sc.block->AppendVariables (can_create, 420 get_parent_variables, 421 stop_if_block_is_inlined_function, 422 variable_list)) 423 { 424 ConstString const_name(name); 425 const uint32_t num_variables = variable_list->GetSize(); 426 for (uint32_t i = 0; i < num_variables; ++i) 427 { 428 VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); 429 if (variable_sp && 430 variable_sp->GetScope() == value_type && 431 variable_sp->GetName() == const_name) 432 { 433 *sb_value = ValueObjectSP (m_opaque_sp->GetValueObjectForFrameVariable(variable_sp, 434 use_dynamic)); 435 break; 436 } 437 } 438 } 439 } 440 break; 441 442 case eValueTypeRegister: // stack frame register value 443 { 444 RegisterContextSP reg_ctx (m_opaque_sp->GetRegisterContext()); 445 if (reg_ctx) 446 { 447 const uint32_t num_regs = reg_ctx->GetRegisterCount(); 448 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) 449 { 450 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); 451 if (reg_info && 452 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) || 453 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0))) 454 { 455 *sb_value = ValueObjectRegister::Create (m_opaque_sp.get(), reg_ctx, reg_idx); 456 } 457 } 458 } 459 } 460 break; 461 462 case eValueTypeRegisterSet: // A collection of stack frame register values 463 { 464 RegisterContextSP reg_ctx (m_opaque_sp->GetRegisterContext()); 465 if (reg_ctx) 466 { 467 const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); 468 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) 469 { 470 const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx); 471 if (reg_set && 472 ((reg_set->name && strcasecmp (reg_set->name, name) == 0) || 473 (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0))) 474 { 475 *sb_value = ValueObjectRegisterSet::Create (m_opaque_sp.get(), reg_ctx, set_idx); 476 } 477 } 478 } 479 } 480 break; 481 482 case eValueTypeConstResult: // constant result variables 483 { 484 ConstString const_name(name); 485 ClangExpressionVariableSP expr_var_sp (m_opaque_sp->GetThread().GetProcess().GetTarget().GetPersistentVariables().GetVariable (const_name)); 486 if (expr_var_sp) 487 *sb_value = expr_var_sp->GetValueObject(); 488 } 489 break; 490 491 default: 492 break; 493 } 494 } 495 496 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 497 if (log) 498 log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)", 499 m_opaque_sp.get(), name, value_type, sb_value.get()); 500 501 502 return sb_value; 503 } 504 505 bool 506 SBFrame::operator == (const SBFrame &rhs) const 507 { 508 return m_opaque_sp.get() == rhs.m_opaque_sp.get(); 509 } 510 511 bool 512 SBFrame::operator != (const SBFrame &rhs) const 513 { 514 return m_opaque_sp.get() != rhs.m_opaque_sp.get(); 515 } 516 517 lldb_private::StackFrame * 518 SBFrame::operator->() const 519 { 520 return m_opaque_sp.get(); 521 } 522 523 lldb_private::StackFrame * 524 SBFrame::get() const 525 { 526 return m_opaque_sp.get(); 527 } 528 529 const lldb::StackFrameSP & 530 SBFrame::get_sp() const 531 { 532 return m_opaque_sp; 533 } 534 535 SBThread 536 SBFrame::GetThread () const 537 { 538 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 539 540 SBThread sb_thread; 541 if (m_opaque_sp) 542 { 543 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 544 sb_thread.SetThread (m_opaque_sp->GetThread().GetSP()); 545 } 546 547 if (log) 548 { 549 SBStream sstr; 550 sb_thread.GetDescription (sstr); 551 log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", m_opaque_sp.get(), 552 sb_thread.get(), sstr.GetData()); 553 } 554 555 return sb_thread; 556 } 557 558 const char * 559 SBFrame::Disassemble () const 560 { 561 const char *disassembly = NULL; 562 if (m_opaque_sp) 563 { 564 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 565 disassembly = m_opaque_sp->Disassemble(); 566 } 567 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 568 569 if (log) 570 log->Printf ("SBFrame(%p)::Disassemble () => %s", m_opaque_sp.get(), disassembly); 571 572 return disassembly; 573 } 574 575 576 SBValueList 577 SBFrame::GetVariables (bool arguments, 578 bool locals, 579 bool statics, 580 bool in_scope_only) 581 { 582 lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); 583 return GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); 584 } 585 586 SBValueList 587 SBFrame::GetVariables (bool arguments, 588 bool locals, 589 bool statics, 590 bool in_scope_only, 591 lldb::DynamicValueType use_dynamic) 592 { 593 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 594 595 if (log) 596 log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)", 597 m_opaque_sp.get(), 598 arguments, 599 locals, 600 statics, 601 in_scope_only); 602 603 SBValueList value_list; 604 if (m_opaque_sp) 605 { 606 607 size_t i; 608 VariableList *variable_list = NULL; 609 // Scope for locker 610 { 611 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 612 variable_list = m_opaque_sp->GetVariableList(true); 613 } 614 if (variable_list) 615 { 616 const size_t num_variables = variable_list->GetSize(); 617 if (num_variables) 618 { 619 for (i = 0; i < num_variables; ++i) 620 { 621 VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); 622 if (variable_sp) 623 { 624 bool add_variable = false; 625 switch (variable_sp->GetScope()) 626 { 627 case eValueTypeVariableGlobal: 628 case eValueTypeVariableStatic: 629 add_variable = statics; 630 break; 631 632 case eValueTypeVariableArgument: 633 add_variable = arguments; 634 break; 635 636 case eValueTypeVariableLocal: 637 add_variable = locals; 638 break; 639 640 default: 641 break; 642 } 643 if (add_variable) 644 { 645 if (in_scope_only && !variable_sp->IsInScope(m_opaque_sp.get())) 646 continue; 647 648 value_list.Append(m_opaque_sp->GetValueObjectForFrameVariable (variable_sp, use_dynamic)); 649 } 650 } 651 } 652 } 653 } 654 } 655 656 if (log) 657 { 658 log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", m_opaque_sp.get(), 659 value_list.get()); 660 } 661 662 return value_list; 663 } 664 665 SBValueList 666 SBFrame::GetRegisters () 667 { 668 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 669 670 SBValueList value_list; 671 if (m_opaque_sp) 672 { 673 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 674 RegisterContextSP reg_ctx (m_opaque_sp->GetRegisterContext()); 675 if (reg_ctx) 676 { 677 const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); 678 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) 679 { 680 value_list.Append(ValueObjectRegisterSet::Create (m_opaque_sp.get(), reg_ctx, set_idx)); 681 } 682 } 683 } 684 685 if (log) 686 log->Printf ("SBFrame(%p)::Registers () => SBValueList(%p)", m_opaque_sp.get(), value_list.get()); 687 688 return value_list; 689 } 690 691 bool 692 SBFrame::GetDescription (SBStream &description) 693 { 694 if (m_opaque_sp) 695 { 696 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 697 Stream &s = description.ref(); 698 m_opaque_sp->DumpUsingSettingsFormat (&s); 699 } 700 else 701 description.Printf ("No value"); 702 703 return true; 704 } 705 706 SBValue 707 SBFrame::EvaluateExpression (const char *expr) 708 { 709 lldb::DynamicValueType use_dynamic = m_opaque_sp->CalculateTarget()->GetPreferDynamicValue(); 710 return EvaluateExpression (expr, use_dynamic); 711 } 712 713 SBValue 714 SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) 715 { 716 Mutex::Locker api_locker (m_opaque_sp->GetThread().GetProcess().GetTarget().GetAPIMutex()); 717 718 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 719 720 LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); 721 722 SBValue expr_result; 723 if (log) 724 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", m_opaque_sp.get(), expr); 725 726 if (m_opaque_sp) 727 { 728 ExecutionResults exe_results; 729 const bool unwind_on_error = true; 730 const bool keep_in_memory = false; 731 732 exe_results = m_opaque_sp->GetThread().GetProcess().GetTarget().EvaluateExpression(expr, 733 m_opaque_sp.get(), 734 unwind_on_error, 735 keep_in_memory, 736 fetch_dynamic_value, 737 *expr_result); 738 } 739 740 if (expr_log) 741 expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", 742 expr_result.GetValue(*this), 743 expr_result.GetSummary(*this)); 744 745 if (log) 746 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p)", m_opaque_sp.get(), 747 expr, 748 expr_result.get()); 749 750 return expr_result; 751 } 752