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