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/Host/Host.h" 26 #include "lldb/Symbol/Block.h" 27 #include "lldb/Symbol/Function.h" 28 #include "lldb/Symbol/Symbol.h" 29 #include "lldb/Symbol/SymbolContext.h" 30 #include "lldb/Symbol/VariableList.h" 31 #include "lldb/Symbol/Variable.h" 32 #include "lldb/Target/ExecutionContext.h" 33 #include "lldb/Target/Target.h" 34 #include "lldb/Target/Process.h" 35 #include "lldb/Target/RegisterContext.h" 36 #include "lldb/Target/StackFrame.h" 37 #include "lldb/Target/StackID.h" 38 #include "lldb/Target/Thread.h" 39 40 #include "lldb/API/SBDebugger.h" 41 #include "lldb/API/SBValue.h" 42 #include "lldb/API/SBAddress.h" 43 #include "lldb/API/SBExpressionOptions.h" 44 #include "lldb/API/SBStream.h" 45 #include "lldb/API/SBSymbolContext.h" 46 #include "lldb/API/SBThread.h" 47 48 using namespace lldb; 49 using namespace lldb_private; 50 51 52 SBFrame::SBFrame () : 53 m_opaque_sp (new ExecutionContextRef()) 54 { 55 } 56 57 SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) : 58 m_opaque_sp (new ExecutionContextRef (lldb_object_sp)) 59 { 60 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 61 62 if (log) 63 { 64 SBStream sstr; 65 GetDescription (sstr); 66 log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s", 67 static_cast<void*>(lldb_object_sp.get()), 68 static_cast<void*>(lldb_object_sp.get()), sstr.GetData()); 69 } 70 } 71 72 SBFrame::SBFrame(const SBFrame &rhs) : 73 m_opaque_sp (new ExecutionContextRef (*rhs.m_opaque_sp)) 74 { 75 } 76 77 const SBFrame & 78 SBFrame::operator = (const SBFrame &rhs) 79 { 80 if (this != &rhs) 81 *m_opaque_sp = *rhs.m_opaque_sp; 82 return *this; 83 } 84 85 SBFrame::~SBFrame() 86 { 87 } 88 89 StackFrameSP 90 SBFrame::GetFrameSP() const 91 { 92 if (m_opaque_sp) 93 return m_opaque_sp->GetFrameSP(); 94 return StackFrameSP(); 95 } 96 97 void 98 SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp) 99 { 100 return m_opaque_sp->SetFrameSP(lldb_object_sp); 101 } 102 103 bool 104 SBFrame::IsValid() const 105 { 106 return GetFrameSP().get() != NULL; 107 } 108 109 SBSymbolContext 110 SBFrame::GetSymbolContext (uint32_t resolve_scope) const 111 { 112 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 113 SBSymbolContext sb_sym_ctx; 114 Mutex::Locker api_locker; 115 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 116 117 StackFrame *frame = NULL; 118 Target *target = exe_ctx.GetTargetPtr(); 119 Process *process = exe_ctx.GetProcessPtr(); 120 if (target && process) 121 { 122 Process::StopLocker stop_locker; 123 if (stop_locker.TryLock(&process->GetRunLock())) 124 { 125 frame = exe_ctx.GetFramePtr(); 126 if (frame) 127 { 128 sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext (resolve_scope)); 129 } 130 else 131 { 132 if (log) 133 log->Printf ("SBFrame::GetVariables () => error: could not reconstruct frame object for this SBFrame."); 134 } 135 } 136 else 137 { 138 if (log) 139 log->Printf ("SBFrame::GetSymbolContext () => error: process is running"); 140 } 141 } 142 143 if (log) 144 log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)", 145 static_cast<void*>(frame), resolve_scope, 146 static_cast<void*>(sb_sym_ctx.get())); 147 148 return sb_sym_ctx; 149 } 150 151 SBModule 152 SBFrame::GetModule () const 153 { 154 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 155 SBModule sb_module; 156 ModuleSP module_sp; 157 Mutex::Locker api_locker; 158 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 159 160 StackFrame *frame = NULL; 161 Target *target = exe_ctx.GetTargetPtr(); 162 Process *process = exe_ctx.GetProcessPtr(); 163 if (target && process) 164 { 165 Process::StopLocker stop_locker; 166 if (stop_locker.TryLock(&process->GetRunLock())) 167 { 168 frame = exe_ctx.GetFramePtr(); 169 if (frame) 170 { 171 module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp; 172 sb_module.SetSP (module_sp); 173 } 174 else 175 { 176 if (log) 177 log->Printf ("SBFrame::GetModule () => error: could not reconstruct frame object for this SBFrame."); 178 } 179 } 180 else 181 { 182 if (log) 183 log->Printf ("SBFrame::GetModule () => error: process is running"); 184 } 185 } 186 187 if (log) 188 log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", 189 static_cast<void*>(frame), 190 static_cast<void*>(module_sp.get())); 191 192 return sb_module; 193 } 194 195 SBCompileUnit 196 SBFrame::GetCompileUnit () const 197 { 198 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 199 SBCompileUnit sb_comp_unit; 200 Mutex::Locker api_locker; 201 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 202 203 StackFrame *frame = NULL; 204 Target *target = exe_ctx.GetTargetPtr(); 205 Process *process = exe_ctx.GetProcessPtr(); 206 if (target && process) 207 { 208 Process::StopLocker stop_locker; 209 if (stop_locker.TryLock(&process->GetRunLock())) 210 { 211 frame = exe_ctx.GetFramePtr(); 212 if (frame) 213 { 214 sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit); 215 } 216 else 217 { 218 if (log) 219 log->Printf ("SBFrame::GetCompileUnit () => error: could not reconstruct frame object for this SBFrame."); 220 } 221 } 222 else 223 { 224 if (log) 225 log->Printf ("SBFrame::GetCompileUnit () => error: process is running"); 226 } 227 } 228 if (log) 229 log->Printf ("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)", 230 static_cast<void*>(frame), 231 static_cast<void*>(sb_comp_unit.get())); 232 233 return sb_comp_unit; 234 } 235 236 SBFunction 237 SBFrame::GetFunction () const 238 { 239 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 240 SBFunction sb_function; 241 Mutex::Locker api_locker; 242 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 243 244 StackFrame *frame = NULL; 245 Target *target = exe_ctx.GetTargetPtr(); 246 Process *process = exe_ctx.GetProcessPtr(); 247 if (target && process) 248 { 249 Process::StopLocker stop_locker; 250 if (stop_locker.TryLock(&process->GetRunLock())) 251 { 252 frame = exe_ctx.GetFramePtr(); 253 if (frame) 254 { 255 sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function); 256 } 257 else 258 { 259 if (log) 260 log->Printf ("SBFrame::GetFunction () => error: could not reconstruct frame object for this SBFrame."); 261 } 262 } 263 else 264 { 265 if (log) 266 log->Printf ("SBFrame::GetFunction () => error: process is running"); 267 } 268 } 269 if (log) 270 log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", 271 static_cast<void*>(frame), 272 static_cast<void*>(sb_function.get())); 273 274 return sb_function; 275 } 276 277 SBSymbol 278 SBFrame::GetSymbol () const 279 { 280 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 281 SBSymbol sb_symbol; 282 Mutex::Locker api_locker; 283 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 284 285 StackFrame *frame = NULL; 286 Target *target = exe_ctx.GetTargetPtr(); 287 Process *process = exe_ctx.GetProcessPtr(); 288 if (target && process) 289 { 290 Process::StopLocker stop_locker; 291 if (stop_locker.TryLock(&process->GetRunLock())) 292 { 293 frame = exe_ctx.GetFramePtr(); 294 if (frame) 295 { 296 sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol); 297 } 298 else 299 { 300 if (log) 301 log->Printf ("SBFrame::GetSymbol () => error: could not reconstruct frame object for this SBFrame."); 302 } 303 } 304 else 305 { 306 if (log) 307 log->Printf ("SBFrame::GetSymbol () => error: process is running"); 308 } 309 } 310 if (log) 311 log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", 312 static_cast<void*>(frame), 313 static_cast<void*>(sb_symbol.get())); 314 return sb_symbol; 315 } 316 317 SBBlock 318 SBFrame::GetBlock () const 319 { 320 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 321 SBBlock sb_block; 322 Mutex::Locker api_locker; 323 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 324 325 StackFrame *frame = NULL; 326 Target *target = exe_ctx.GetTargetPtr(); 327 Process *process = exe_ctx.GetProcessPtr(); 328 if (target && process) 329 { 330 Process::StopLocker stop_locker; 331 if (stop_locker.TryLock(&process->GetRunLock())) 332 { 333 frame = exe_ctx.GetFramePtr(); 334 if (frame) 335 { 336 sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block); 337 } 338 else 339 { 340 if (log) 341 log->Printf ("SBFrame::GetBlock () => error: could not reconstruct frame object for this SBFrame."); 342 } 343 } 344 else 345 { 346 if (log) 347 log->Printf ("SBFrame(%p)::GetBlock () => error: process is running", 348 static_cast<void*>(frame)); 349 } 350 } 351 if (log) 352 log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", 353 static_cast<void*>(frame), 354 static_cast<void*>(sb_block.GetPtr())); 355 return sb_block; 356 } 357 358 SBBlock 359 SBFrame::GetFrameBlock () const 360 { 361 SBBlock sb_block; 362 Mutex::Locker api_locker; 363 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 364 365 StackFrame *frame = NULL; 366 Target *target = exe_ctx.GetTargetPtr(); 367 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 368 Process *process = exe_ctx.GetProcessPtr(); 369 if (target && process) 370 { 371 Process::StopLocker stop_locker; 372 if (stop_locker.TryLock(&process->GetRunLock())) 373 { 374 frame = exe_ctx.GetFramePtr(); 375 if (frame) 376 { 377 sb_block.SetPtr(frame->GetFrameBlock ()); 378 } 379 else 380 { 381 if (log) 382 log->Printf ("SBFrame::GetFrameBlock () => error: could not reconstruct frame object for this SBFrame."); 383 } 384 } 385 else 386 { 387 if (log) 388 log->Printf ("SBFrame::GetFrameBlock () => error: process is running"); 389 } 390 } 391 if (log) 392 log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", 393 static_cast<void*>(frame), 394 static_cast<void*>(sb_block.GetPtr())); 395 return sb_block; 396 } 397 398 SBLineEntry 399 SBFrame::GetLineEntry () const 400 { 401 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 402 SBLineEntry sb_line_entry; 403 Mutex::Locker api_locker; 404 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 405 406 StackFrame *frame = NULL; 407 Target *target = exe_ctx.GetTargetPtr(); 408 Process *process = exe_ctx.GetProcessPtr(); 409 if (target && process) 410 { 411 Process::StopLocker stop_locker; 412 if (stop_locker.TryLock(&process->GetRunLock())) 413 { 414 frame = exe_ctx.GetFramePtr(); 415 if (frame) 416 { 417 sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry); 418 } 419 else 420 { 421 if (log) 422 log->Printf ("SBFrame::GetLineEntry () => error: could not reconstruct frame object for this SBFrame."); 423 } 424 } 425 else 426 { 427 if (log) 428 log->Printf ("SBFrame::GetLineEntry () => error: process is running"); 429 } 430 } 431 if (log) 432 log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", 433 static_cast<void*>(frame), 434 static_cast<void*>(sb_line_entry.get())); 435 return sb_line_entry; 436 } 437 438 uint32_t 439 SBFrame::GetFrameID () const 440 { 441 uint32_t frame_idx = UINT32_MAX; 442 443 ExecutionContext exe_ctx(m_opaque_sp.get()); 444 StackFrame *frame = exe_ctx.GetFramePtr(); 445 if (frame) 446 frame_idx = frame->GetFrameIndex (); 447 448 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 449 if (log) 450 log->Printf ("SBFrame(%p)::GetFrameID () => %u", 451 static_cast<void*>(frame), frame_idx); 452 return frame_idx; 453 } 454 455 addr_t 456 SBFrame::GetPC () const 457 { 458 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 459 addr_t addr = LLDB_INVALID_ADDRESS; 460 Mutex::Locker api_locker; 461 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 462 463 StackFrame *frame = NULL; 464 Target *target = exe_ctx.GetTargetPtr(); 465 Process *process = exe_ctx.GetProcessPtr(); 466 if (target && process) 467 { 468 Process::StopLocker stop_locker; 469 if (stop_locker.TryLock(&process->GetRunLock())) 470 { 471 frame = exe_ctx.GetFramePtr(); 472 if (frame) 473 { 474 addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target); 475 } 476 else 477 { 478 if (log) 479 log->Printf ("SBFrame::GetPC () => error: could not reconstruct frame object for this SBFrame."); 480 } 481 } 482 else 483 { 484 if (log) 485 log->Printf ("SBFrame::GetPC () => error: process is running"); 486 } 487 } 488 489 if (log) 490 log->Printf ("SBFrame(%p)::GetPC () => 0x%" PRIx64, 491 static_cast<void*>(frame), addr); 492 493 return addr; 494 } 495 496 bool 497 SBFrame::SetPC (addr_t new_pc) 498 { 499 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 500 bool ret_val = false; 501 Mutex::Locker api_locker; 502 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 503 504 StackFrame *frame = NULL; 505 Target *target = exe_ctx.GetTargetPtr(); 506 Process *process = exe_ctx.GetProcessPtr(); 507 if (target && process) 508 { 509 Process::StopLocker stop_locker; 510 if (stop_locker.TryLock(&process->GetRunLock())) 511 { 512 frame = exe_ctx.GetFramePtr(); 513 if (frame) 514 { 515 ret_val = frame->GetRegisterContext()->SetPC (new_pc); 516 } 517 else 518 { 519 if (log) 520 log->Printf ("SBFrame::SetPC () => error: could not reconstruct frame object for this SBFrame."); 521 } 522 } 523 else 524 { 525 if (log) 526 log->Printf ("SBFrame::SetPC () => error: process is running"); 527 } 528 } 529 530 if (log) 531 log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%" PRIx64 ") => %i", 532 static_cast<void*>(frame), new_pc, ret_val); 533 534 return ret_val; 535 } 536 537 addr_t 538 SBFrame::GetSP () const 539 { 540 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 541 addr_t addr = LLDB_INVALID_ADDRESS; 542 Mutex::Locker api_locker; 543 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 544 545 StackFrame *frame = NULL; 546 Target *target = exe_ctx.GetTargetPtr(); 547 Process *process = exe_ctx.GetProcessPtr(); 548 if (target && process) 549 { 550 Process::StopLocker stop_locker; 551 if (stop_locker.TryLock(&process->GetRunLock())) 552 { 553 frame = exe_ctx.GetFramePtr(); 554 if (frame) 555 { 556 addr = frame->GetRegisterContext()->GetSP(); 557 } 558 else 559 { 560 if (log) 561 log->Printf ("SBFrame::GetSP () => error: could not reconstruct frame object for this SBFrame."); 562 } 563 } 564 else 565 { 566 if (log) 567 log->Printf ("SBFrame::GetSP () => error: process is running"); 568 } 569 } 570 if (log) 571 log->Printf ("SBFrame(%p)::GetSP () => 0x%" PRIx64, 572 static_cast<void*>(frame), addr); 573 574 return addr; 575 } 576 577 578 addr_t 579 SBFrame::GetFP () const 580 { 581 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 582 addr_t addr = LLDB_INVALID_ADDRESS; 583 Mutex::Locker api_locker; 584 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 585 586 StackFrame *frame = NULL; 587 Target *target = exe_ctx.GetTargetPtr(); 588 Process *process = exe_ctx.GetProcessPtr(); 589 if (target && process) 590 { 591 Process::StopLocker stop_locker; 592 if (stop_locker.TryLock(&process->GetRunLock())) 593 { 594 frame = exe_ctx.GetFramePtr(); 595 if (frame) 596 { 597 addr = frame->GetRegisterContext()->GetFP(); 598 } 599 else 600 { 601 if (log) 602 log->Printf ("SBFrame::GetFP () => error: could not reconstruct frame object for this SBFrame."); 603 } 604 } 605 else 606 { 607 if (log) 608 log->Printf ("SBFrame::GetFP () => error: process is running"); 609 } 610 } 611 612 if (log) 613 log->Printf ("SBFrame(%p)::GetFP () => 0x%" PRIx64, 614 static_cast<void*>(frame), addr); 615 return addr; 616 } 617 618 619 SBAddress 620 SBFrame::GetPCAddress () const 621 { 622 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 623 SBAddress sb_addr; 624 Mutex::Locker api_locker; 625 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 626 627 StackFrame *frame = exe_ctx.GetFramePtr(); 628 Target *target = exe_ctx.GetTargetPtr(); 629 Process *process = exe_ctx.GetProcessPtr(); 630 if (target && process) 631 { 632 Process::StopLocker stop_locker; 633 if (stop_locker.TryLock(&process->GetRunLock())) 634 { 635 frame = exe_ctx.GetFramePtr(); 636 if (frame) 637 { 638 sb_addr.SetAddress (&frame->GetFrameCodeAddress()); 639 } 640 else 641 { 642 if (log) 643 log->Printf ("SBFrame::GetPCAddress () => error: could not reconstruct frame object for this SBFrame."); 644 } 645 } 646 else 647 { 648 if (log) 649 log->Printf ("SBFrame::GetPCAddress () => error: process is running"); 650 } 651 } 652 if (log) 653 log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", 654 static_cast<void*>(frame), 655 static_cast<void*>(sb_addr.get())); 656 return sb_addr; 657 } 658 659 void 660 SBFrame::Clear() 661 { 662 m_opaque_sp->Clear(); 663 } 664 665 lldb::SBValue 666 SBFrame::GetValueForVariablePath (const char *var_path) 667 { 668 SBValue sb_value; 669 ExecutionContext exe_ctx(m_opaque_sp.get()); 670 StackFrame *frame = exe_ctx.GetFramePtr(); 671 Target *target = exe_ctx.GetTargetPtr(); 672 if (frame && target) 673 { 674 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); 675 sb_value = GetValueForVariablePath (var_path, use_dynamic); 676 } 677 return sb_value; 678 } 679 680 lldb::SBValue 681 SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic) 682 { 683 SBValue sb_value; 684 Mutex::Locker api_locker; 685 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 686 if (var_path == NULL || var_path[0] == '\0') 687 { 688 if (log) 689 log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path."); 690 return sb_value; 691 } 692 693 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 694 695 StackFrame *frame = NULL; 696 Target *target = exe_ctx.GetTargetPtr(); 697 Process *process = exe_ctx.GetProcessPtr(); 698 if (target && process) 699 { 700 Process::StopLocker stop_locker; 701 if (stop_locker.TryLock(&process->GetRunLock())) 702 { 703 frame = exe_ctx.GetFramePtr(); 704 if (frame) 705 { 706 VariableSP var_sp; 707 Error error; 708 ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path, 709 eNoDynamicValues, 710 StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, 711 var_sp, 712 error)); 713 sb_value.SetSP(value_sp, use_dynamic); 714 } 715 else 716 { 717 if (log) 718 log->Printf ("SBFrame::GetValueForVariablePath () => error: could not reconstruct frame object for this SBFrame."); 719 } 720 } 721 else 722 { 723 if (log) 724 log->Printf ("SBFrame::GetValueForVariablePath () => error: process is running"); 725 } 726 } 727 return sb_value; 728 } 729 730 SBValue 731 SBFrame::FindVariable (const char *name) 732 { 733 SBValue value; 734 ExecutionContext exe_ctx(m_opaque_sp.get()); 735 StackFrame *frame = exe_ctx.GetFramePtr(); 736 Target *target = exe_ctx.GetTargetPtr(); 737 if (frame && target) 738 { 739 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); 740 value = FindVariable (name, use_dynamic); 741 } 742 return value; 743 } 744 745 SBValue 746 SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) 747 { 748 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 749 VariableSP var_sp; 750 SBValue sb_value; 751 752 if (name == NULL || name[0] == '\0') 753 { 754 if (log) 755 log->Printf ("SBFrame::FindVariable called with empty name"); 756 return sb_value; 757 } 758 759 ValueObjectSP value_sp; 760 Mutex::Locker api_locker; 761 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 762 763 StackFrame *frame = NULL; 764 Target *target = exe_ctx.GetTargetPtr(); 765 Process *process = exe_ctx.GetProcessPtr(); 766 if (target && process) 767 { 768 Process::StopLocker stop_locker; 769 if (stop_locker.TryLock(&process->GetRunLock())) 770 { 771 frame = exe_ctx.GetFramePtr(); 772 if (frame) 773 { 774 VariableList variable_list; 775 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock)); 776 777 if (sc.block) 778 { 779 const bool can_create = true; 780 const bool get_parent_variables = true; 781 const bool stop_if_block_is_inlined_function = true; 782 783 if (sc.block->AppendVariables (can_create, 784 get_parent_variables, 785 stop_if_block_is_inlined_function, 786 &variable_list)) 787 { 788 var_sp = variable_list.FindVariable (ConstString(name)); 789 } 790 } 791 792 if (var_sp) 793 { 794 value_sp = frame->GetValueObjectForFrameVariable(var_sp, eNoDynamicValues); 795 sb_value.SetSP(value_sp, use_dynamic); 796 } 797 } 798 else 799 { 800 if (log) 801 log->Printf ("SBFrame::FindVariable () => error: could not reconstruct frame object for this SBFrame."); 802 } 803 } 804 else 805 { 806 if (log) 807 log->Printf ("SBFrame::FindVariable () => error: process is running"); 808 } 809 } 810 811 if (log) 812 log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", 813 static_cast<void*>(frame), name, 814 static_cast<void*>(value_sp.get())); 815 816 return sb_value; 817 } 818 819 SBValue 820 SBFrame::FindValue (const char *name, ValueType value_type) 821 { 822 SBValue value; 823 ExecutionContext exe_ctx(m_opaque_sp.get()); 824 StackFrame *frame = exe_ctx.GetFramePtr(); 825 Target *target = exe_ctx.GetTargetPtr(); 826 if (frame && target) 827 { 828 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); 829 value = FindValue (name, value_type, use_dynamic); 830 } 831 return value; 832 } 833 834 SBValue 835 SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) 836 { 837 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 838 SBValue sb_value; 839 840 if (name == NULL || name[0] == '\0') 841 { 842 if (log) 843 log->Printf ("SBFrame::FindValue called with empty name."); 844 return sb_value; 845 } 846 847 ValueObjectSP value_sp; 848 Mutex::Locker api_locker; 849 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 850 851 StackFrame *frame = NULL; 852 Target *target = exe_ctx.GetTargetPtr(); 853 Process *process = exe_ctx.GetProcessPtr(); 854 if (target && process) 855 { 856 Process::StopLocker stop_locker; 857 if (stop_locker.TryLock(&process->GetRunLock())) 858 { 859 frame = exe_ctx.GetFramePtr(); 860 if (frame) 861 { 862 VariableList variable_list; 863 864 switch (value_type) 865 { 866 case eValueTypeVariableGlobal: // global variable 867 case eValueTypeVariableStatic: // static variable 868 case eValueTypeVariableArgument: // function argument variables 869 case eValueTypeVariableLocal: // function local variables 870 { 871 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock)); 872 873 const bool can_create = true; 874 const bool get_parent_variables = true; 875 const bool stop_if_block_is_inlined_function = true; 876 877 if (sc.block && sc.block->AppendVariables (can_create, 878 get_parent_variables, 879 stop_if_block_is_inlined_function, 880 &variable_list)) 881 { 882 if (value_type == eValueTypeVariableGlobal) 883 { 884 const bool get_file_globals = true; 885 VariableList* frame_vars = frame->GetVariableList(get_file_globals); 886 if (frame_vars) 887 frame_vars->AppendVariablesIfUnique(variable_list); 888 } 889 ConstString const_name(name); 890 VariableSP variable_sp(variable_list.FindVariable(const_name,value_type)); 891 if (variable_sp) 892 { 893 value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues); 894 sb_value.SetSP (value_sp, use_dynamic); 895 break; 896 } 897 } 898 } 899 break; 900 901 case eValueTypeRegister: // stack frame register value 902 { 903 RegisterContextSP reg_ctx (frame->GetRegisterContext()); 904 if (reg_ctx) 905 { 906 const uint32_t num_regs = reg_ctx->GetRegisterCount(); 907 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) 908 { 909 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); 910 if (reg_info && 911 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) || 912 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0))) 913 { 914 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx); 915 sb_value.SetSP (value_sp); 916 break; 917 } 918 } 919 } 920 } 921 break; 922 923 case eValueTypeRegisterSet: // A collection of stack frame register values 924 { 925 RegisterContextSP reg_ctx (frame->GetRegisterContext()); 926 if (reg_ctx) 927 { 928 const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); 929 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) 930 { 931 const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx); 932 if (reg_set && 933 ((reg_set->name && strcasecmp (reg_set->name, name) == 0) || 934 (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0))) 935 { 936 value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx); 937 sb_value.SetSP (value_sp); 938 break; 939 } 940 } 941 } 942 } 943 break; 944 945 case eValueTypeConstResult: // constant result variables 946 { 947 ConstString const_name(name); 948 ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name)); 949 if (expr_var_sp) 950 { 951 value_sp = expr_var_sp->GetValueObject(); 952 sb_value.SetSP (value_sp, use_dynamic); 953 } 954 } 955 break; 956 957 default: 958 break; 959 } 960 } 961 else 962 { 963 if (log) 964 log->Printf ("SBFrame::FindValue () => error: could not reconstruct frame object for this SBFrame."); 965 } 966 } 967 else 968 { 969 if (log) 970 log->Printf ("SBFrame::FindValue () => error: process is running"); 971 } 972 } 973 974 if (log) 975 log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)", 976 static_cast<void*>(frame), name, value_type, 977 static_cast<void*>(value_sp.get())); 978 979 return sb_value; 980 } 981 982 bool 983 SBFrame::IsEqual (const SBFrame &that) const 984 { 985 lldb::StackFrameSP this_sp = GetFrameSP(); 986 lldb::StackFrameSP that_sp = that.GetFrameSP(); 987 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID()); 988 } 989 990 bool 991 SBFrame::operator == (const SBFrame &rhs) const 992 { 993 return IsEqual(rhs); 994 } 995 996 bool 997 SBFrame::operator != (const SBFrame &rhs) const 998 { 999 return !IsEqual(rhs); 1000 } 1001 1002 SBThread 1003 SBFrame::GetThread () const 1004 { 1005 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1006 1007 ExecutionContext exe_ctx(m_opaque_sp.get()); 1008 ThreadSP thread_sp (exe_ctx.GetThreadSP()); 1009 SBThread sb_thread (thread_sp); 1010 1011 if (log) 1012 { 1013 SBStream sstr; 1014 sb_thread.GetDescription (sstr); 1015 log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", 1016 static_cast<void*>(exe_ctx.GetFramePtr()), 1017 static_cast<void*>(thread_sp.get()), sstr.GetData()); 1018 } 1019 1020 return sb_thread; 1021 } 1022 1023 const char * 1024 SBFrame::Disassemble () const 1025 { 1026 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1027 const char *disassembly = NULL; 1028 Mutex::Locker api_locker; 1029 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 1030 1031 StackFrame *frame = NULL; 1032 Target *target = exe_ctx.GetTargetPtr(); 1033 Process *process = exe_ctx.GetProcessPtr(); 1034 if (target && process) 1035 { 1036 Process::StopLocker stop_locker; 1037 if (stop_locker.TryLock(&process->GetRunLock())) 1038 { 1039 frame = exe_ctx.GetFramePtr(); 1040 if (frame) 1041 { 1042 disassembly = frame->Disassemble(); 1043 } 1044 else 1045 { 1046 if (log) 1047 log->Printf ("SBFrame::Disassemble () => error: could not reconstruct frame object for this SBFrame."); 1048 } 1049 } 1050 else 1051 { 1052 if (log) 1053 log->Printf ("SBFrame::Disassemble () => error: process is running"); 1054 } 1055 } 1056 1057 if (log) 1058 log->Printf ("SBFrame(%p)::Disassemble () => %s", 1059 static_cast<void*>(frame), disassembly); 1060 1061 return disassembly; 1062 } 1063 1064 1065 SBValueList 1066 SBFrame::GetVariables (bool arguments, 1067 bool locals, 1068 bool statics, 1069 bool in_scope_only) 1070 { 1071 SBValueList value_list; 1072 ExecutionContext exe_ctx(m_opaque_sp.get()); 1073 StackFrame *frame = exe_ctx.GetFramePtr(); 1074 Target *target = exe_ctx.GetTargetPtr(); 1075 if (frame && target) 1076 { 1077 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); 1078 value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); 1079 } 1080 return value_list; 1081 } 1082 1083 lldb::SBValueList 1084 SBFrame::GetVariables (bool arguments, 1085 bool locals, 1086 bool statics, 1087 bool in_scope_only, 1088 lldb::DynamicValueType use_dynamic) 1089 { 1090 ExecutionContext exe_ctx(m_opaque_sp.get()); 1091 Target *target = exe_ctx.GetTargetPtr(); 1092 bool include_runtime_support_values = target ? target->GetDisplayRuntimeSupportValues() : false; 1093 return GetVariables(arguments, 1094 locals, 1095 statics, 1096 in_scope_only, 1097 include_runtime_support_values, 1098 use_dynamic); 1099 } 1100 1101 SBValueList 1102 SBFrame::GetVariables (bool arguments, 1103 bool locals, 1104 bool statics, 1105 bool in_scope_only, 1106 bool include_runtime_support_values, 1107 lldb::DynamicValueType use_dynamic) 1108 { 1109 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1110 1111 SBValueList value_list; 1112 Mutex::Locker api_locker; 1113 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 1114 1115 StackFrame *frame = NULL; 1116 Target *target = exe_ctx.GetTargetPtr(); 1117 1118 if (log) 1119 log->Printf ("SBFrame::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)", 1120 arguments, locals, statics, in_scope_only); 1121 1122 Process *process = exe_ctx.GetProcessPtr(); 1123 if (target && process) 1124 { 1125 Process::StopLocker stop_locker; 1126 if (stop_locker.TryLock(&process->GetRunLock())) 1127 { 1128 frame = exe_ctx.GetFramePtr(); 1129 if (frame) 1130 { 1131 size_t i; 1132 VariableList *variable_list = NULL; 1133 variable_list = frame->GetVariableList(true); 1134 if (variable_list) 1135 { 1136 const size_t num_variables = variable_list->GetSize(); 1137 if (num_variables) 1138 { 1139 for (i = 0; i < num_variables; ++i) 1140 { 1141 VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); 1142 if (variable_sp) 1143 { 1144 bool add_variable = false; 1145 switch (variable_sp->GetScope()) 1146 { 1147 case eValueTypeVariableGlobal: 1148 case eValueTypeVariableStatic: 1149 add_variable = statics; 1150 break; 1151 1152 case eValueTypeVariableArgument: 1153 add_variable = arguments; 1154 break; 1155 1156 case eValueTypeVariableLocal: 1157 add_variable = locals; 1158 break; 1159 1160 default: 1161 break; 1162 } 1163 if (add_variable) 1164 { 1165 if (in_scope_only && !variable_sp->IsInScope(frame)) 1166 continue; 1167 1168 ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues)); 1169 1170 if (false == include_runtime_support_values && 1171 valobj_sp && 1172 true == valobj_sp->IsRuntimeSupportValue()) 1173 continue; 1174 1175 SBValue value_sb; 1176 value_sb.SetSP(valobj_sp,use_dynamic); 1177 value_list.Append(value_sb); 1178 } 1179 } 1180 } 1181 } 1182 } 1183 } 1184 else 1185 { 1186 if (log) 1187 log->Printf ("SBFrame::GetVariables () => error: could not reconstruct frame object for this SBFrame."); 1188 } 1189 } 1190 else 1191 { 1192 if (log) 1193 log->Printf ("SBFrame::GetVariables () => error: process is running"); 1194 } 1195 } 1196 1197 if (log) 1198 log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", 1199 static_cast<void*>(frame), 1200 static_cast<void*>(value_list.opaque_ptr())); 1201 1202 return value_list; 1203 } 1204 1205 SBValueList 1206 SBFrame::GetRegisters () 1207 { 1208 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1209 1210 SBValueList value_list; 1211 Mutex::Locker api_locker; 1212 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 1213 1214 StackFrame *frame = NULL; 1215 Target *target = exe_ctx.GetTargetPtr(); 1216 Process *process = exe_ctx.GetProcessPtr(); 1217 if (target && process) 1218 { 1219 Process::StopLocker stop_locker; 1220 if (stop_locker.TryLock(&process->GetRunLock())) 1221 { 1222 frame = exe_ctx.GetFramePtr(); 1223 if (frame) 1224 { 1225 RegisterContextSP reg_ctx (frame->GetRegisterContext()); 1226 if (reg_ctx) 1227 { 1228 const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); 1229 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) 1230 { 1231 value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx)); 1232 } 1233 } 1234 } 1235 else 1236 { 1237 if (log) 1238 log->Printf ("SBFrame::GetRegisters () => error: could not reconstruct frame object for this SBFrame."); 1239 } 1240 } 1241 else 1242 { 1243 if (log) 1244 log->Printf ("SBFrame::GetRegisters () => error: process is running"); 1245 } 1246 } 1247 1248 if (log) 1249 log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", 1250 static_cast<void*>(frame), 1251 static_cast<void*>(value_list.opaque_ptr())); 1252 1253 return value_list; 1254 } 1255 1256 SBValue 1257 SBFrame::FindRegister (const char *name) 1258 { 1259 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1260 1261 SBValue result; 1262 ValueObjectSP value_sp; 1263 Mutex::Locker api_locker; 1264 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 1265 1266 StackFrame *frame = NULL; 1267 Target *target = exe_ctx.GetTargetPtr(); 1268 Process *process = exe_ctx.GetProcessPtr(); 1269 if (target && process) 1270 { 1271 Process::StopLocker stop_locker; 1272 if (stop_locker.TryLock(&process->GetRunLock())) 1273 { 1274 frame = exe_ctx.GetFramePtr(); 1275 if (frame) 1276 { 1277 RegisterContextSP reg_ctx (frame->GetRegisterContext()); 1278 if (reg_ctx) 1279 { 1280 const uint32_t num_regs = reg_ctx->GetRegisterCount(); 1281 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) 1282 { 1283 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); 1284 if (reg_info && 1285 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) || 1286 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0))) 1287 { 1288 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx); 1289 result.SetSP (value_sp); 1290 break; 1291 } 1292 } 1293 } 1294 } 1295 else 1296 { 1297 if (log) 1298 log->Printf ("SBFrame::FindRegister () => error: could not reconstruct frame object for this SBFrame."); 1299 } 1300 } 1301 else 1302 { 1303 if (log) 1304 log->Printf ("SBFrame::FindRegister () => error: process is running"); 1305 } 1306 } 1307 1308 if (log) 1309 log->Printf ("SBFrame(%p)::FindRegister () => SBValue(%p)", 1310 static_cast<void*>(frame), 1311 static_cast<void*>(value_sp.get())); 1312 1313 return result; 1314 } 1315 1316 bool 1317 SBFrame::GetDescription (SBStream &description) 1318 { 1319 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1320 Stream &strm = description.ref(); 1321 1322 Mutex::Locker api_locker; 1323 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 1324 1325 StackFrame *frame; 1326 Target *target = exe_ctx.GetTargetPtr(); 1327 Process *process = exe_ctx.GetProcessPtr(); 1328 if (target && process) 1329 { 1330 Process::StopLocker stop_locker; 1331 if (stop_locker.TryLock(&process->GetRunLock())) 1332 { 1333 frame = exe_ctx.GetFramePtr(); 1334 if (frame) 1335 { 1336 frame->DumpUsingSettingsFormat (&strm); 1337 } 1338 else 1339 { 1340 if (log) 1341 log->Printf ("SBFrame::GetDescription () => error: could not reconstruct frame object for this SBFrame."); 1342 } 1343 } 1344 else 1345 { 1346 if (log) 1347 log->Printf ("SBFrame::GetDescription () => error: process is running"); 1348 } 1349 1350 } 1351 else 1352 strm.PutCString ("No value"); 1353 1354 return true; 1355 } 1356 1357 SBValue 1358 SBFrame::EvaluateExpression (const char *expr) 1359 { 1360 SBValue result; 1361 ExecutionContext exe_ctx(m_opaque_sp.get()); 1362 StackFrame *frame = exe_ctx.GetFramePtr(); 1363 Target *target = exe_ctx.GetTargetPtr(); 1364 if (frame && target) 1365 { 1366 SBExpressionOptions options; 1367 lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); 1368 options.SetFetchDynamicValue (fetch_dynamic_value); 1369 options.SetUnwindOnError (true); 1370 return EvaluateExpression (expr, options); 1371 } 1372 return result; 1373 } 1374 1375 SBValue 1376 SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) 1377 { 1378 SBExpressionOptions options; 1379 options.SetFetchDynamicValue (fetch_dynamic_value); 1380 options.SetUnwindOnError (true); 1381 return EvaluateExpression (expr, options); 1382 } 1383 1384 SBValue 1385 SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) 1386 { 1387 SBExpressionOptions options; 1388 options.SetFetchDynamicValue (fetch_dynamic_value); 1389 options.SetUnwindOnError (unwind_on_error); 1390 return EvaluateExpression (expr, options); 1391 } 1392 1393 lldb::SBValue 1394 SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &options) 1395 { 1396 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1397 1398 Log *expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); 1399 1400 ExpressionResults exe_results = eExpressionSetupError; 1401 SBValue expr_result; 1402 1403 if (expr == NULL || expr[0] == '\0') 1404 { 1405 if (log) 1406 log->Printf ("SBFrame::EvaluateExpression called with an empty expression"); 1407 return expr_result; 1408 } 1409 1410 ValueObjectSP expr_value_sp; 1411 1412 Mutex::Locker api_locker; 1413 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); 1414 1415 if (log) 1416 log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); 1417 1418 StackFrame *frame = NULL; 1419 Target *target = exe_ctx.GetTargetPtr(); 1420 Process *process = exe_ctx.GetProcessPtr(); 1421 1422 if (target && process) 1423 { 1424 Process::StopLocker stop_locker; 1425 if (stop_locker.TryLock(&process->GetRunLock())) 1426 { 1427 frame = exe_ctx.GetFramePtr(); 1428 if (frame) 1429 { 1430 if (target->GetDisplayExpressionsInCrashlogs()) 1431 { 1432 StreamString frame_description; 1433 frame->DumpUsingSettingsFormat (&frame_description); 1434 Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", 1435 expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); 1436 } 1437 1438 exe_results = target->EvaluateExpression (expr, 1439 frame, 1440 expr_value_sp, 1441 options.ref()); 1442 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); 1443 1444 if (target->GetDisplayExpressionsInCrashlogs()) 1445 Host::SetCrashDescription (NULL); 1446 } 1447 else 1448 { 1449 if (log) 1450 log->Printf ("SBFrame::EvaluateExpression () => error: could not reconstruct frame object for this SBFrame."); 1451 } 1452 } 1453 else 1454 { 1455 if (log) 1456 log->Printf ("SBFrame::EvaluateExpression () => error: process is running"); 1457 } 1458 } 1459 1460 #ifndef LLDB_DISABLE_PYTHON 1461 if (expr_log) 1462 expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", 1463 expr_result.GetValue(), expr_result.GetSummary()); 1464 1465 if (log) 1466 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", 1467 static_cast<void*>(frame), expr, 1468 static_cast<void*>(expr_value_sp.get()), exe_results); 1469 #endif 1470 1471 return expr_result; 1472 } 1473 1474 bool 1475 SBFrame::IsInlined() 1476 { 1477 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1478 ExecutionContext exe_ctx(m_opaque_sp.get()); 1479 StackFrame *frame = NULL; 1480 Target *target = exe_ctx.GetTargetPtr(); 1481 Process *process = exe_ctx.GetProcessPtr(); 1482 if (target && process) 1483 { 1484 Process::StopLocker stop_locker; 1485 if (stop_locker.TryLock(&process->GetRunLock())) 1486 { 1487 frame = exe_ctx.GetFramePtr(); 1488 if (frame) 1489 { 1490 1491 Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; 1492 if (block) 1493 return block->GetContainingInlinedBlock () != NULL; 1494 } 1495 else 1496 { 1497 if (log) 1498 log->Printf ("SBFrame::IsInlined () => error: could not reconstruct frame object for this SBFrame."); 1499 } 1500 } 1501 else 1502 { 1503 if (log) 1504 log->Printf ("SBFrame::IsInlined () => error: process is running"); 1505 } 1506 1507 } 1508 return false; 1509 } 1510 1511 const char * 1512 SBFrame::GetFunctionName() 1513 { 1514 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1515 const char *name = NULL; 1516 ExecutionContext exe_ctx(m_opaque_sp.get()); 1517 StackFrame *frame = NULL; 1518 Target *target = exe_ctx.GetTargetPtr(); 1519 Process *process = exe_ctx.GetProcessPtr(); 1520 if (target && process) 1521 { 1522 Process::StopLocker stop_locker; 1523 if (stop_locker.TryLock(&process->GetRunLock())) 1524 { 1525 frame = exe_ctx.GetFramePtr(); 1526 if (frame) 1527 { 1528 SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol)); 1529 if (sc.block) 1530 { 1531 Block *inlined_block = sc.block->GetContainingInlinedBlock (); 1532 if (inlined_block) 1533 { 1534 const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo(); 1535 name = inlined_info->GetName().AsCString(); 1536 } 1537 } 1538 1539 if (name == NULL) 1540 { 1541 if (sc.function) 1542 name = sc.function->GetName().GetCString(); 1543 } 1544 1545 if (name == NULL) 1546 { 1547 if (sc.symbol) 1548 name = sc.symbol->GetName().GetCString(); 1549 } 1550 } 1551 else 1552 { 1553 if (log) 1554 log->Printf ("SBFrame::GetFunctionName () => error: could not reconstruct frame object for this SBFrame."); 1555 } 1556 } 1557 else 1558 { 1559 if (log) 1560 log->Printf ("SBFrame::GetFunctionName() => error: process is running"); 1561 1562 } 1563 } 1564 return name; 1565 } 1566 1567