1 //===-- SBValue.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/SBValue.h" 11 12 #include "lldb/API/SBStream.h" 13 #include "lldb/API/SBTypeFilter.h" 14 #include "lldb/API/SBTypeFormat.h" 15 #include "lldb/API/SBTypeSummary.h" 16 #include "lldb/API/SBTypeSynthetic.h" 17 18 #include "lldb/Breakpoint/Watchpoint.h" 19 #include "lldb/Core/DataExtractor.h" 20 #include "lldb/Core/DataVisualization.h" 21 #include "lldb/Core/Log.h" 22 #include "lldb/Core/Module.h" 23 #include "lldb/Core/Scalar.h" 24 #include "lldb/Core/Stream.h" 25 #include "lldb/Core/StreamFile.h" 26 #include "lldb/Core/Value.h" 27 #include "lldb/Core/ValueObject.h" 28 #include "lldb/Core/ValueObjectConstResult.h" 29 #include "lldb/Symbol/Block.h" 30 #include "lldb/Symbol/ObjectFile.h" 31 #include "lldb/Symbol/Type.h" 32 #include "lldb/Symbol/Variable.h" 33 #include "lldb/Symbol/VariableList.h" 34 #include "lldb/Target/ExecutionContext.h" 35 #include "lldb/Target/Process.h" 36 #include "lldb/Target/StackFrame.h" 37 #include "lldb/Target/Target.h" 38 #include "lldb/Target/Thread.h" 39 40 #include "lldb/API/SBProcess.h" 41 #include "lldb/API/SBTarget.h" 42 #include "lldb/API/SBThread.h" 43 #include "lldb/API/SBFrame.h" 44 #include "lldb/API/SBDebugger.h" 45 46 using namespace lldb; 47 using namespace lldb_private; 48 49 SBValue::SBValue () : 50 m_opaque_sp () 51 { 52 } 53 54 SBValue::SBValue (const lldb::ValueObjectSP &value_sp) 55 { 56 SetSP(value_sp); // whenever setting the SP call SetSP() since it knows how to deal with synthetic values properly 57 } 58 59 SBValue::SBValue(const SBValue &rhs) 60 { 61 SetSP(rhs.m_opaque_sp); // whenever setting the SP call SetSP() since it knows how to deal with synthetic values properly 62 } 63 64 SBValue & 65 SBValue::operator = (const SBValue &rhs) 66 { 67 if (this != &rhs) 68 { 69 SetSP(rhs.m_opaque_sp); // whenever setting the SP call SetSP() since it knows how to deal with synthetic values properly 70 } 71 return *this; 72 } 73 74 SBValue::~SBValue() 75 { 76 } 77 78 bool 79 SBValue::IsValid () 80 { 81 // If this function ever changes to anything that does more than just 82 // check if the opaque shared pointer is non NULL, then we need to update 83 // all "if (m_opaque_sp)" code in this file. 84 return m_opaque_sp.get() != NULL; 85 } 86 87 void 88 SBValue::Clear() 89 { 90 m_opaque_sp.reset(); 91 } 92 93 SBError 94 SBValue::GetError() 95 { 96 SBError sb_error; 97 98 lldb::ValueObjectSP value_sp(GetSP()); 99 if (value_sp) 100 sb_error.SetError(value_sp->GetError()); 101 else 102 sb_error.SetErrorString("error: invalid value"); 103 104 return sb_error; 105 } 106 107 user_id_t 108 SBValue::GetID() 109 { 110 lldb::ValueObjectSP value_sp(GetSP()); 111 if (value_sp) 112 return value_sp->GetID(); 113 return LLDB_INVALID_UID; 114 } 115 116 const char * 117 SBValue::GetName() 118 { 119 120 const char *name = NULL; 121 lldb::ValueObjectSP value_sp(GetSP()); 122 if (value_sp) 123 name = value_sp->GetName().GetCString(); 124 125 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 126 if (log) 127 { 128 if (name) 129 log->Printf ("SBValue(%p)::GetName () => \"%s\"", value_sp.get(), name); 130 else 131 log->Printf ("SBValue(%p)::GetName () => NULL", value_sp.get()); 132 } 133 134 return name; 135 } 136 137 const char * 138 SBValue::GetTypeName () 139 { 140 const char *name = NULL; 141 lldb::ValueObjectSP value_sp(GetSP()); 142 if (value_sp) 143 //name = value_sp->GetTypeName().GetCString(); 144 name = value_sp->GetQualifiedTypeName().GetCString(); 145 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 146 if (log) 147 { 148 if (name) 149 log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", value_sp.get(), name); 150 else 151 log->Printf ("SBValue(%p)::GetTypeName () => NULL", value_sp.get()); 152 } 153 154 return name; 155 } 156 157 size_t 158 SBValue::GetByteSize () 159 { 160 size_t result = 0; 161 162 lldb::ValueObjectSP value_sp(GetSP()); 163 if (value_sp) 164 result = value_sp->GetByteSize(); 165 166 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 167 if (log) 168 log->Printf ("SBValue(%p)::GetByteSize () => %zu", value_sp.get(), result); 169 170 return result; 171 } 172 173 bool 174 SBValue::IsInScope () 175 { 176 bool result = false; 177 178 lldb::ValueObjectSP value_sp(GetSP()); 179 if (value_sp) 180 { 181 TargetSP target_sp(value_sp->GetTargetSP()); 182 if (target_sp) 183 { 184 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 185 result = value_sp->IsInScope (); 186 } 187 } 188 189 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 190 if (log) 191 log->Printf ("SBValue(%p)::IsInScope () => %i", value_sp.get(), result); 192 193 return result; 194 } 195 196 const char * 197 SBValue::GetValue () 198 { 199 const char *cstr = NULL; 200 lldb::ValueObjectSP value_sp(GetSP()); 201 if (value_sp) 202 { 203 TargetSP target_sp(value_sp->GetTargetSP()); 204 if (target_sp) 205 { 206 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 207 cstr = value_sp->GetValueAsCString (); 208 } 209 } 210 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 211 if (log) 212 { 213 if (cstr) 214 log->Printf ("SBValue(%p)::GetValue => \"%s\"", value_sp.get(), cstr); 215 else 216 log->Printf ("SBValue(%p)::GetValue => NULL", value_sp.get()); 217 } 218 219 return cstr; 220 } 221 222 ValueType 223 SBValue::GetValueType () 224 { 225 ValueType result = eValueTypeInvalid; 226 lldb::ValueObjectSP value_sp(GetSP()); 227 if (value_sp) 228 result = value_sp->GetValueType(); 229 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 230 if (log) 231 { 232 switch (result) 233 { 234 case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", value_sp.get()); break; 235 case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", value_sp.get()); break; 236 case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", value_sp.get()); break; 237 case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", value_sp.get()); break; 238 case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", value_sp.get()); break; 239 case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", value_sp.get()); break; 240 case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", value_sp.get()); break; 241 case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", value_sp.get()); break; 242 default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", value_sp.get(), result); break; 243 } 244 } 245 return result; 246 } 247 248 const char * 249 SBValue::GetObjectDescription () 250 { 251 const char *cstr = NULL; 252 lldb::ValueObjectSP value_sp(GetSP()); 253 if (value_sp) 254 { 255 TargetSP target_sp(value_sp->GetTargetSP()); 256 if (target_sp) 257 { 258 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 259 cstr = value_sp->GetObjectDescription (); 260 } 261 } 262 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 263 if (log) 264 { 265 if (cstr) 266 log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", value_sp.get(), cstr); 267 else 268 log->Printf ("SBValue(%p)::GetObjectDescription => NULL", value_sp.get()); 269 } 270 return cstr; 271 } 272 273 SBType 274 SBValue::GetType() 275 { 276 SBType sb_type; 277 lldb::ValueObjectSP value_sp(GetSP()); 278 TypeImplSP type_sp; 279 if (value_sp) 280 { 281 type_sp.reset (new TypeImpl(ClangASTType (value_sp->GetClangAST(), value_sp->GetClangType()))); 282 sb_type.SetSP(type_sp); 283 } 284 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 285 if (log) 286 { 287 if (type_sp) 288 log->Printf ("SBValue(%p)::GetType => SBType(%p)", value_sp.get(), type_sp.get()); 289 else 290 log->Printf ("SBValue(%p)::GetType => NULL", value_sp.get()); 291 } 292 return sb_type; 293 } 294 295 bool 296 SBValue::GetValueDidChange () 297 { 298 bool result = false; 299 lldb::ValueObjectSP value_sp(GetSP()); 300 if (value_sp) 301 { 302 TargetSP target_sp(value_sp->GetTargetSP()); 303 if (target_sp) 304 { 305 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 306 result = value_sp->GetValueDidChange (); 307 } 308 } 309 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 310 if (log) 311 log->Printf ("SBValue(%p)::GetValueDidChange => %i", value_sp.get(), result); 312 313 return result; 314 } 315 316 #ifndef LLDB_DISABLE_PYTHON 317 const char * 318 SBValue::GetSummary () 319 { 320 const char *cstr = NULL; 321 lldb::ValueObjectSP value_sp(GetSP()); 322 if (value_sp) 323 { 324 TargetSP target_sp(value_sp->GetTargetSP()); 325 if (target_sp) 326 { 327 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 328 cstr = value_sp->GetSummaryAsCString(); 329 } 330 } 331 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 332 if (log) 333 { 334 if (cstr) 335 log->Printf ("SBValue(%p)::GetSummary => \"%s\"", value_sp.get(), cstr); 336 else 337 log->Printf ("SBValue(%p)::GetSummary => NULL", value_sp.get()); 338 } 339 return cstr; 340 } 341 #endif // LLDB_DISABLE_PYTHON 342 343 const char * 344 SBValue::GetLocation () 345 { 346 const char *cstr = NULL; 347 lldb::ValueObjectSP value_sp(GetSP()); 348 if (value_sp) 349 { 350 TargetSP target_sp(value_sp->GetTargetSP()); 351 if (target_sp) 352 { 353 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 354 cstr = value_sp->GetLocationAsCString(); 355 } 356 } 357 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 358 if (log) 359 { 360 if (cstr) 361 log->Printf ("SBValue(%p)::GetSummary => \"%s\"", value_sp.get(), cstr); 362 else 363 log->Printf ("SBValue(%p)::GetSummary => NULL", value_sp.get()); 364 } 365 return cstr; 366 } 367 368 bool 369 SBValue::SetValueFromCString (const char *value_str) 370 { 371 bool success = false; 372 lldb::ValueObjectSP value_sp(GetSP()); 373 if (value_sp) 374 { 375 TargetSP target_sp(value_sp->GetTargetSP()); 376 if (target_sp) 377 { 378 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 379 success = value_sp->SetValueFromCString (value_str); 380 } 381 } 382 return success; 383 } 384 385 lldb::SBTypeFormat 386 SBValue::GetTypeFormat () 387 { 388 lldb::SBTypeFormat format; 389 lldb::ValueObjectSP value_sp(GetSP()); 390 if (value_sp) 391 { 392 TargetSP target_sp(value_sp->GetTargetSP()); 393 if (target_sp) 394 { 395 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 396 if (value_sp->UpdateValueIfNeeded(true)) 397 { 398 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat(); 399 if (format_sp) 400 format.SetSP(format_sp); 401 } 402 } 403 } 404 return format; 405 } 406 407 #ifndef LLDB_DISABLE_PYTHON 408 lldb::SBTypeSummary 409 SBValue::GetTypeSummary () 410 { 411 lldb::SBTypeSummary summary; 412 lldb::ValueObjectSP value_sp(GetSP()); 413 if (value_sp) 414 { 415 TargetSP target_sp(value_sp->GetTargetSP()); 416 if (target_sp) 417 { 418 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 419 if (value_sp->UpdateValueIfNeeded(true)) 420 { 421 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat(); 422 if (summary_sp) 423 summary.SetSP(summary_sp); 424 } 425 } 426 } 427 return summary; 428 } 429 #endif // LLDB_DISABLE_PYTHON 430 431 lldb::SBTypeFilter 432 SBValue::GetTypeFilter () 433 { 434 lldb::SBTypeFilter filter; 435 lldb::ValueObjectSP value_sp(GetSP()); 436 if (value_sp) 437 { 438 TargetSP target_sp(value_sp->GetTargetSP()); 439 if (target_sp) 440 { 441 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 442 if (value_sp->UpdateValueIfNeeded(true)) 443 { 444 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren(); 445 446 if (synthetic_sp && !synthetic_sp->IsScripted()) 447 { 448 TypeFilterImplSP filter_sp = STD_STATIC_POINTER_CAST(TypeFilterImpl,synthetic_sp); 449 filter.SetSP(filter_sp); 450 } 451 } 452 } 453 } 454 return filter; 455 } 456 457 #ifndef LLDB_DISABLE_PYTHON 458 lldb::SBTypeSynthetic 459 SBValue::GetTypeSynthetic () 460 { 461 lldb::SBTypeSynthetic synthetic; 462 lldb::ValueObjectSP value_sp(GetSP()); 463 if (value_sp) 464 { 465 TargetSP target_sp(value_sp->GetTargetSP()); 466 if (target_sp) 467 { 468 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 469 if (value_sp->UpdateValueIfNeeded(true)) 470 { 471 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren(); 472 473 if (children_sp && children_sp->IsScripted()) 474 { 475 TypeSyntheticImplSP synth_sp = STD_STATIC_POINTER_CAST(TypeSyntheticImpl,children_sp); 476 synthetic.SetSP(synth_sp); 477 } 478 } 479 } 480 } 481 return synthetic; 482 } 483 #endif 484 485 lldb::SBValue 486 SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type) 487 { 488 lldb::SBValue sb_value; 489 lldb::ValueObjectSP value_sp(GetSP()); 490 lldb::ValueObjectSP new_value_sp; 491 if (value_sp) 492 { 493 TypeImplSP type_sp (type.GetSP()); 494 if (type.IsValid()) 495 { 496 sb_value = SBValue(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(), true)); 497 new_value_sp = sb_value.GetSP(); 498 if (new_value_sp) 499 new_value_sp->SetName(ConstString(name)); 500 } 501 } 502 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 503 if (log) 504 { 505 if (new_value_sp) 506 log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", value_sp.get(), new_value_sp->GetName().AsCString()); 507 else 508 log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", value_sp.get()); 509 } 510 return sb_value; 511 } 512 513 lldb::SBValue 514 SBValue::Cast (SBType type) 515 { 516 lldb::SBValue sb_value; 517 lldb::ValueObjectSP value_sp(GetSP()); 518 TypeImplSP type_sp (type.GetSP()); 519 if (value_sp && type_sp) 520 sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType())); 521 return sb_value; 522 } 523 524 lldb::SBValue 525 SBValue::CreateValueFromExpression (const char *name, const char* expression) 526 { 527 lldb::SBValue sb_value; 528 lldb::ValueObjectSP value_sp(GetSP()); 529 lldb::ValueObjectSP new_value_sp; 530 if (value_sp) 531 { 532 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef()); 533 Target* target = exe_ctx.GetTargetPtr(); 534 if (target) 535 { 536 target->EvaluateExpression (expression, 537 exe_ctx.GetFramePtr(), 538 eExecutionPolicyOnlyWhenNeeded, 539 false, // coerce to id 540 true, // unwind on error 541 true, // keep in memory 542 eNoDynamicValues, 543 new_value_sp); 544 if (new_value_sp) 545 { 546 new_value_sp->SetName(ConstString(name)); 547 sb_value.SetSP(new_value_sp); 548 } 549 } 550 } 551 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 552 if (log) 553 { 554 if (new_value_sp) 555 log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", value_sp.get(), new_value_sp->GetName().AsCString()); 556 else 557 log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", value_sp.get()); 558 } 559 return sb_value; 560 } 561 562 lldb::SBValue 563 SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType sb_type) 564 { 565 lldb::SBValue sb_value; 566 lldb::ValueObjectSP value_sp(GetSP()); 567 lldb::ValueObjectSP new_value_sp; 568 lldb::TypeImplSP type_impl_sp (sb_type.GetSP()); 569 if (value_sp && type_impl_sp) 570 { 571 ClangASTType pointee_ast_type(type_impl_sp->GetASTContext(), type_impl_sp->GetClangASTType().GetPointerType ()); 572 lldb::TypeImplSP pointee_type_impl_sp (new TypeImpl(pointee_ast_type)); 573 if (pointee_type_impl_sp) 574 { 575 576 lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t))); 577 578 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef()); 579 ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), 580 pointee_type_impl_sp->GetASTContext(), 581 pointee_type_impl_sp->GetOpaqueQualType(), 582 ConstString(name), 583 buffer, 584 lldb::endian::InlHostByteOrder(), 585 exe_ctx.GetAddressByteSize())); 586 587 if (ptr_result_valobj_sp) 588 { 589 ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress); 590 Error err; 591 new_value_sp = ptr_result_valobj_sp->Dereference(err); 592 if (new_value_sp) 593 new_value_sp->SetName(ConstString(name)); 594 } 595 sb_value.SetSP(new_value_sp); 596 } 597 } 598 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 599 if (log) 600 { 601 if (new_value_sp) 602 log->Printf ("SBValue(%p)::CreateValueFromAddress => \"%s\"", value_sp.get(), new_value_sp->GetName().AsCString()); 603 else 604 log->Printf ("SBValue(%p)::CreateValueFromAddress => NULL", value_sp.get()); 605 } 606 return sb_value; 607 } 608 609 lldb::SBValue 610 SBValue::CreateValueFromData (const char* name, SBData data, SBType type) 611 { 612 lldb::SBValue sb_value; 613 lldb::ValueObjectSP new_value_sp; 614 lldb::ValueObjectSP value_sp(GetSP()); 615 if (value_sp) 616 { 617 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef()); 618 619 new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), 620 type.m_opaque_sp->GetASTContext() , 621 type.m_opaque_sp->GetOpaqueQualType(), 622 ConstString(name), 623 *data.m_opaque_sp, 624 LLDB_INVALID_ADDRESS); 625 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad); 626 sb_value.SetSP(new_value_sp); 627 } 628 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 629 if (log) 630 { 631 if (new_value_sp) 632 log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", value_sp.get(), new_value_sp->GetName().AsCString()); 633 else 634 log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", value_sp.get()); 635 } 636 return sb_value; 637 } 638 639 SBValue 640 SBValue::GetChildAtIndex (uint32_t idx) 641 { 642 const bool can_create_synthetic = false; 643 lldb::DynamicValueType use_dynamic = eNoDynamicValues; 644 lldb::ValueObjectSP value_sp(GetSP()); 645 if (value_sp) 646 { 647 TargetSP target_sp(value_sp->GetTargetSP()); 648 if (target_sp) 649 use_dynamic = target_sp->GetPreferDynamicValue(); 650 } 651 return GetChildAtIndex (idx, use_dynamic, can_create_synthetic); 652 } 653 654 SBValue 655 SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic) 656 { 657 lldb::ValueObjectSP child_sp; 658 659 lldb::ValueObjectSP value_sp(GetSP()); 660 if (value_sp) 661 { 662 TargetSP target_sp(value_sp->GetTargetSP()); 663 if (target_sp) 664 { 665 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 666 const bool can_create = true; 667 child_sp = value_sp->GetChildAtIndex (idx, can_create); 668 if (can_create_synthetic && !child_sp) 669 { 670 if (value_sp->IsPointerType()) 671 { 672 child_sp = value_sp->GetSyntheticArrayMemberFromPointer(idx, can_create); 673 } 674 else if (value_sp->IsArrayType()) 675 { 676 child_sp = value_sp->GetSyntheticArrayMemberFromArray(idx, can_create); 677 } 678 } 679 680 if (child_sp) 681 { 682 if (use_dynamic != lldb::eNoDynamicValues) 683 { 684 lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic)); 685 if (dynamic_sp) 686 child_sp = dynamic_sp; 687 } 688 } 689 } 690 } 691 692 SBValue sb_value (child_sp); 693 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 694 if (log) 695 log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", value_sp.get(), idx, value_sp.get()); 696 697 return sb_value; 698 } 699 700 uint32_t 701 SBValue::GetIndexOfChildWithName (const char *name) 702 { 703 uint32_t idx = UINT32_MAX; 704 lldb::ValueObjectSP value_sp(GetSP()); 705 if (value_sp) 706 { 707 TargetSP target_sp(value_sp->GetTargetSP()); 708 if (target_sp) 709 { 710 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 711 712 idx = value_sp->GetIndexOfChildWithName (ConstString(name)); 713 } 714 } 715 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 716 if (log) 717 { 718 if (idx == UINT32_MAX) 719 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", value_sp.get(), name); 720 else 721 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", value_sp.get(), name, idx); 722 } 723 return idx; 724 } 725 726 SBValue 727 SBValue::GetChildMemberWithName (const char *name) 728 { 729 lldb::ValueObjectSP value_sp(GetSP()); 730 if (value_sp) 731 { 732 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues; 733 TargetSP target_sp(value_sp->GetTargetSP()); 734 if (target_sp) 735 { 736 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 737 use_dynamic_value = target_sp->GetPreferDynamicValue(); 738 } 739 return GetChildMemberWithName (name, use_dynamic_value); 740 } 741 return SBValue(); 742 } 743 744 SBValue 745 SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value) 746 { 747 lldb::ValueObjectSP child_sp; 748 const ConstString str_name (name); 749 750 751 lldb::ValueObjectSP value_sp(GetSP()); 752 if (value_sp) 753 { 754 TargetSP target_sp(value_sp->GetTargetSP()); 755 if (target_sp) 756 { 757 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 758 child_sp = value_sp->GetChildMemberWithName (str_name, true); 759 if (use_dynamic_value != lldb::eNoDynamicValues) 760 { 761 if (child_sp) 762 { 763 lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value); 764 if (dynamic_sp) 765 child_sp = dynamic_sp; 766 } 767 } 768 } 769 } 770 771 SBValue sb_value (child_sp); 772 773 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 774 if (log) 775 log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", value_sp.get(), name, value_sp.get()); 776 777 return sb_value; 778 } 779 780 lldb::SBValue 781 SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic) 782 { 783 lldb::ValueObjectSP value_sp(GetSP()); 784 if (value_sp) 785 { 786 TargetSP target_sp(value_sp->GetTargetSP()); 787 if (target_sp) 788 { 789 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 790 return SBValue (value_sp->GetDynamicValue(use_dynamic)); 791 } 792 } 793 794 return SBValue(); 795 } 796 797 lldb::SBValue 798 SBValue::GetStaticValue () 799 { 800 lldb::ValueObjectSP value_sp(GetSP()); 801 if (value_sp) 802 { 803 TargetSP target_sp(value_sp->GetTargetSP()); 804 if (target_sp) 805 { 806 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 807 return SBValue(value_sp->GetStaticValue()); 808 } 809 } 810 811 return SBValue(); 812 } 813 814 lldb::SBValue 815 SBValue::GetNonSyntheticValue () 816 { 817 SBValue sb_value; 818 lldb::ValueObjectSP value_sp(GetSP()); 819 if (value_sp) 820 { 821 if (value_sp->IsSynthetic()) 822 { 823 TargetSP target_sp(value_sp->GetTargetSP()); 824 if (target_sp) 825 { 826 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 827 // deliberately breaking the rules here to optimize the case where we DO NOT want 828 // the synthetic value to be returned to the user - if we did not do this, we would have to tell 829 // the target to suppress the synthetic value, and then return the flag to its original value 830 if (value_sp->GetParent()) 831 sb_value.m_opaque_sp = value_sp->GetParent()->GetSP(); 832 } 833 } 834 } 835 return sb_value; 836 } 837 838 bool 839 SBValue::IsDynamic() 840 { 841 lldb::ValueObjectSP value_sp(GetSP()); 842 if (value_sp) 843 { 844 TargetSP target_sp(value_sp->GetTargetSP()); 845 if (target_sp) 846 { 847 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 848 return value_sp->IsDynamic(); 849 } 850 } 851 return false; 852 } 853 854 lldb::SBValue 855 SBValue::GetValueForExpressionPath(const char* expr_path) 856 { 857 lldb::ValueObjectSP child_sp; 858 lldb::ValueObjectSP value_sp(GetSP()); 859 if (value_sp) 860 { 861 TargetSP target_sp(value_sp->GetTargetSP()); 862 if (target_sp) 863 { 864 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 865 // using default values for all the fancy options, just do it if you can 866 child_sp = value_sp->GetValueForExpressionPath(expr_path); 867 } 868 } 869 870 SBValue sb_value (child_sp); 871 872 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 873 if (log) 874 log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", value_sp.get(), expr_path, value_sp.get()); 875 876 return sb_value; 877 } 878 879 int64_t 880 SBValue::GetValueAsSigned(SBError& error, int64_t fail_value) 881 { 882 error.Clear(); 883 lldb::ValueObjectSP value_sp(GetSP()); 884 if (value_sp) 885 { 886 TargetSP target_sp(value_sp->GetTargetSP()); 887 if (target_sp) 888 { 889 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 890 Scalar scalar; 891 if (value_sp->ResolveValue (scalar)) 892 return scalar.GetRawBits64(fail_value); 893 else 894 error.SetErrorString("could not get value"); 895 } 896 else 897 error.SetErrorString("could not get target"); 898 } 899 error.SetErrorString("invalid SBValue"); 900 return fail_value; 901 } 902 903 uint64_t 904 SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value) 905 { 906 error.Clear(); 907 lldb::ValueObjectSP value_sp(GetSP()); 908 if (value_sp) 909 { 910 TargetSP target_sp(value_sp->GetTargetSP()); 911 if (target_sp) 912 { 913 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 914 Scalar scalar; 915 if (value_sp->ResolveValue (scalar)) 916 return scalar.GetRawBits64(fail_value); 917 else 918 error.SetErrorString("could not get value"); 919 } 920 else 921 error.SetErrorString("could not get target"); 922 } 923 error.SetErrorString("invalid SBValue"); 924 return fail_value; 925 } 926 927 int64_t 928 SBValue::GetValueAsSigned(int64_t fail_value) 929 { 930 lldb::ValueObjectSP value_sp(GetSP()); 931 if (value_sp) 932 { 933 TargetSP target_sp(value_sp->GetTargetSP()); 934 if (target_sp) 935 { 936 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 937 Scalar scalar; 938 if (value_sp->ResolveValue (scalar)) 939 return scalar.GetRawBits64(fail_value); 940 } 941 } 942 return fail_value; 943 } 944 945 uint64_t 946 SBValue::GetValueAsUnsigned(uint64_t fail_value) 947 { 948 lldb::ValueObjectSP value_sp(GetSP()); 949 if (value_sp) 950 { 951 TargetSP target_sp(value_sp->GetTargetSP()); 952 if (target_sp) 953 { 954 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 955 Scalar scalar; 956 if (value_sp->ResolveValue (scalar)) 957 return scalar.GetRawBits64(fail_value); 958 } 959 } 960 return fail_value; 961 } 962 963 uint32_t 964 SBValue::GetNumChildren () 965 { 966 uint32_t num_children = 0; 967 968 lldb::ValueObjectSP value_sp(GetSP()); 969 if (value_sp) 970 { 971 TargetSP target_sp(value_sp->GetTargetSP()); 972 if (target_sp) 973 { 974 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 975 976 num_children = value_sp->GetNumChildren(); 977 } 978 } 979 980 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 981 if (log) 982 log->Printf ("SBValue(%p)::GetNumChildren () => %u", value_sp.get(), num_children); 983 984 return num_children; 985 } 986 987 988 SBValue 989 SBValue::Dereference () 990 { 991 SBValue sb_value; 992 lldb::ValueObjectSP value_sp(GetSP()); 993 if (value_sp) 994 { 995 TargetSP target_sp(value_sp->GetTargetSP()); 996 if (target_sp) 997 { 998 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 999 1000 Error error; 1001 sb_value = value_sp->Dereference (error); 1002 } 1003 } 1004 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1005 if (log) 1006 log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", value_sp.get(), value_sp.get()); 1007 1008 return sb_value; 1009 } 1010 1011 bool 1012 SBValue::TypeIsPointerType () 1013 { 1014 bool is_ptr_type = false; 1015 1016 lldb::ValueObjectSP value_sp(GetSP()); 1017 if (value_sp) 1018 { 1019 TargetSP target_sp(value_sp->GetTargetSP()); 1020 if (target_sp) 1021 { 1022 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1023 1024 is_ptr_type = value_sp->IsPointerType(); 1025 } 1026 } 1027 1028 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1029 if (log) 1030 log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", value_sp.get(), is_ptr_type); 1031 1032 1033 return is_ptr_type; 1034 } 1035 1036 void * 1037 SBValue::GetOpaqueType() 1038 { 1039 lldb::ValueObjectSP value_sp(GetSP()); 1040 if (value_sp) 1041 { 1042 TargetSP target_sp(value_sp->GetTargetSP()); 1043 if (target_sp) 1044 { 1045 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1046 1047 return value_sp->GetClangType(); 1048 } 1049 } 1050 return NULL; 1051 } 1052 1053 lldb::SBTarget 1054 SBValue::GetTarget() 1055 { 1056 SBTarget sb_target; 1057 TargetSP target_sp; 1058 lldb::ValueObjectSP value_sp(GetSP()); 1059 if (value_sp) 1060 { 1061 target_sp = value_sp->GetTargetSP(); 1062 sb_target.SetSP (target_sp); 1063 } 1064 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1065 if (log) 1066 { 1067 if (target_sp.get() == NULL) 1068 log->Printf ("SBValue(%p)::GetTarget () => NULL", value_sp.get()); 1069 else 1070 log->Printf ("SBValue(%p)::GetTarget () => %p", value_sp.get(), target_sp.get()); 1071 } 1072 return sb_target; 1073 } 1074 1075 lldb::SBProcess 1076 SBValue::GetProcess() 1077 { 1078 SBProcess sb_process; 1079 ProcessSP process_sp; 1080 lldb::ValueObjectSP value_sp(GetSP()); 1081 if (value_sp) 1082 { 1083 process_sp = value_sp->GetProcessSP(); 1084 if (process_sp) 1085 sb_process.SetSP (process_sp); 1086 } 1087 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1088 if (log) 1089 { 1090 if (process_sp.get() == NULL) 1091 log->Printf ("SBValue(%p)::GetProcess () => NULL", value_sp.get()); 1092 else 1093 log->Printf ("SBValue(%p)::GetProcess () => %p", value_sp.get(), process_sp.get()); 1094 } 1095 return sb_process; 1096 } 1097 1098 lldb::SBThread 1099 SBValue::GetThread() 1100 { 1101 SBThread sb_thread; 1102 ThreadSP thread_sp; 1103 lldb::ValueObjectSP value_sp(GetSP()); 1104 if (value_sp) 1105 { 1106 thread_sp = value_sp->GetThreadSP(); 1107 sb_thread.SetThread(thread_sp); 1108 } 1109 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1110 if (log) 1111 { 1112 if (thread_sp.get() == NULL) 1113 log->Printf ("SBValue(%p)::GetThread () => NULL", value_sp.get()); 1114 else 1115 log->Printf ("SBValue(%p)::GetThread () => %p", value_sp.get(), thread_sp.get()); 1116 } 1117 return sb_thread; 1118 } 1119 1120 lldb::SBFrame 1121 SBValue::GetFrame() 1122 { 1123 SBFrame sb_frame; 1124 StackFrameSP frame_sp; 1125 lldb::ValueObjectSP value_sp(GetSP()); 1126 if (value_sp) 1127 { 1128 frame_sp = value_sp->GetFrameSP(); 1129 sb_frame.SetFrameSP (frame_sp); 1130 } 1131 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1132 if (log) 1133 { 1134 if (frame_sp.get() == NULL) 1135 log->Printf ("SBValue(%p)::GetFrame () => NULL", value_sp.get()); 1136 else 1137 log->Printf ("SBValue(%p)::GetFrame () => %p", value_sp.get(), frame_sp.get()); 1138 } 1139 return sb_frame; 1140 } 1141 1142 1143 lldb::ValueObjectSP 1144 SBValue::GetSP () const 1145 { 1146 return m_opaque_sp; 1147 } 1148 1149 void 1150 SBValue::SetSP (const lldb::ValueObjectSP &sp) 1151 { 1152 m_opaque_sp = sp; 1153 if (IsValid() && m_opaque_sp->HasSyntheticValue()) 1154 m_opaque_sp = m_opaque_sp->GetSyntheticValue(); 1155 } 1156 1157 1158 bool 1159 SBValue::GetExpressionPath (SBStream &description) 1160 { 1161 lldb::ValueObjectSP value_sp(GetSP()); 1162 if (value_sp) 1163 { 1164 value_sp->GetExpressionPath (description.ref(), false); 1165 return true; 1166 } 1167 return false; 1168 } 1169 1170 bool 1171 SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes) 1172 { 1173 lldb::ValueObjectSP value_sp(GetSP()); 1174 if (value_sp) 1175 { 1176 value_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes); 1177 return true; 1178 } 1179 return false; 1180 } 1181 1182 bool 1183 SBValue::GetDescription (SBStream &description) 1184 { 1185 Stream &strm = description.ref(); 1186 1187 lldb::ValueObjectSP value_sp(GetSP()); 1188 if (value_sp) 1189 { 1190 ValueObject::DumpValueObject (strm, value_sp.get()); 1191 } 1192 else 1193 strm.PutCString ("No value"); 1194 1195 return true; 1196 } 1197 1198 lldb::Format 1199 SBValue::GetFormat () 1200 { 1201 lldb::ValueObjectSP value_sp(GetSP()); 1202 if (value_sp) 1203 return value_sp->GetFormat(); 1204 return eFormatDefault; 1205 } 1206 1207 void 1208 SBValue::SetFormat (lldb::Format format) 1209 { 1210 lldb::ValueObjectSP value_sp(GetSP()); 1211 if (value_sp) 1212 value_sp->SetFormat(format); 1213 } 1214 1215 lldb::SBValue 1216 SBValue::AddressOf() 1217 { 1218 SBValue sb_value; 1219 lldb::ValueObjectSP value_sp(GetSP()); 1220 if (value_sp) 1221 { 1222 TargetSP target_sp (value_sp->GetTargetSP()); 1223 if (target_sp) 1224 { 1225 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1226 Error error; 1227 sb_value = value_sp->AddressOf (error); 1228 } 1229 } 1230 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1231 if (log) 1232 log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", value_sp.get(), value_sp.get()); 1233 1234 return sb_value; 1235 } 1236 1237 lldb::addr_t 1238 SBValue::GetLoadAddress() 1239 { 1240 lldb::addr_t value = LLDB_INVALID_ADDRESS; 1241 lldb::ValueObjectSP value_sp(GetSP()); 1242 if (value_sp) 1243 { 1244 TargetSP target_sp (value_sp->GetTargetSP()); 1245 if (target_sp) 1246 { 1247 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1248 const bool scalar_is_load_address = true; 1249 AddressType addr_type; 1250 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type); 1251 if (addr_type == eAddressTypeFile) 1252 { 1253 ModuleSP module_sp (value_sp->GetModule()); 1254 if (!module_sp) 1255 value = LLDB_INVALID_ADDRESS; 1256 else 1257 { 1258 Address addr; 1259 module_sp->ResolveFileAddress(value, addr); 1260 value = addr.GetLoadAddress(target_sp.get()); 1261 } 1262 } 1263 else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeInvalid) 1264 value = LLDB_INVALID_ADDRESS; 1265 } 1266 } 1267 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1268 if (log) 1269 log->Printf ("SBValue(%p)::GetLoadAddress () => (%llu)", value_sp.get(), value); 1270 1271 return value; 1272 } 1273 1274 lldb::SBAddress 1275 SBValue::GetAddress() 1276 { 1277 Address addr; 1278 lldb::ValueObjectSP value_sp(GetSP()); 1279 if (value_sp) 1280 { 1281 TargetSP target_sp (value_sp->GetTargetSP()); 1282 if (target_sp) 1283 { 1284 lldb::addr_t value = LLDB_INVALID_ADDRESS; 1285 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1286 const bool scalar_is_load_address = true; 1287 AddressType addr_type; 1288 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type); 1289 if (addr_type == eAddressTypeFile) 1290 { 1291 ModuleSP module_sp (value_sp->GetModule()); 1292 if (module_sp) 1293 module_sp->ResolveFileAddress(value, addr); 1294 } 1295 else if (addr_type == eAddressTypeLoad) 1296 { 1297 // no need to check the return value on this.. if it can actually do the resolve 1298 // addr will be in the form (section,offset), otherwise it will simply be returned 1299 // as (NULL, value) 1300 addr.SetLoadAddress(value, target_sp.get()); 1301 } 1302 } 1303 } 1304 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1305 if (log) 1306 log->Printf ("SBValue(%p)::GetAddress () => (%s,%llu)", value_sp.get(), (addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"), addr.GetOffset()); 1307 return SBAddress(new Address(addr)); 1308 } 1309 1310 lldb::SBData 1311 SBValue::GetPointeeData (uint32_t item_idx, 1312 uint32_t item_count) 1313 { 1314 lldb::SBData sb_data; 1315 lldb::ValueObjectSP value_sp(GetSP()); 1316 if (value_sp) 1317 { 1318 TargetSP target_sp (value_sp->GetTargetSP()); 1319 if (target_sp) 1320 { 1321 DataExtractorSP data_sp(new DataExtractor()); 1322 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1323 value_sp->GetPointeeData(*data_sp, item_idx, item_count); 1324 if (data_sp->GetByteSize() > 0) 1325 *sb_data = data_sp; 1326 } 1327 } 1328 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1329 if (log) 1330 log->Printf ("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)", 1331 value_sp.get(), 1332 item_idx, 1333 item_count, 1334 sb_data.get()); 1335 1336 return sb_data; 1337 } 1338 1339 lldb::SBData 1340 SBValue::GetData () 1341 { 1342 lldb::SBData sb_data; 1343 lldb::ValueObjectSP value_sp(GetSP()); 1344 if (value_sp) 1345 { 1346 TargetSP target_sp (value_sp->GetTargetSP()); 1347 if (target_sp) 1348 { 1349 Mutex::Locker api_locker (target_sp->GetAPIMutex()); 1350 DataExtractorSP data_sp(new DataExtractor()); 1351 value_sp->GetData(*data_sp); 1352 if (data_sp->GetByteSize() > 0) 1353 *sb_data = data_sp; 1354 } 1355 } 1356 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); 1357 if (log) 1358 log->Printf ("SBValue(%p)::GetData () => SBData(%p)", 1359 value_sp.get(), 1360 sb_data.get()); 1361 1362 return sb_data; 1363 } 1364 1365 lldb::SBWatchpoint 1366 SBValue::Watch (bool resolve_location, bool read, bool write) 1367 { 1368 SBWatchpoint sb_watchpoint; 1369 1370 // If the SBValue is not valid, there's no point in even trying to watch it. 1371 lldb::ValueObjectSP value_sp(GetSP()); 1372 TargetSP target_sp (GetTarget().GetSP()); 1373 if (value_sp && target_sp) 1374 { 1375 // Read and Write cannot both be false. 1376 if (!read && !write) 1377 return sb_watchpoint; 1378 1379 // If the value is not in scope, don't try and watch and invalid value 1380 if (!IsInScope()) 1381 return sb_watchpoint; 1382 1383 addr_t addr = GetLoadAddress(); 1384 if (addr == LLDB_INVALID_ADDRESS) 1385 return sb_watchpoint; 1386 size_t byte_size = GetByteSize(); 1387 if (byte_size == 0) 1388 return sb_watchpoint; 1389 1390 uint32_t watch_type = 0; 1391 if (read) 1392 watch_type |= LLDB_WATCH_TYPE_READ; 1393 if (write) 1394 watch_type |= LLDB_WATCH_TYPE_WRITE; 1395 1396 WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, watch_type); 1397 1398 if (watchpoint_sp) 1399 { 1400 sb_watchpoint.SetSP (watchpoint_sp); 1401 Declaration decl; 1402 if (value_sp->GetDeclaration (decl)) 1403 { 1404 if (decl.GetFile()) 1405 { 1406 StreamString ss; 1407 // True to show fullpath for declaration file. 1408 decl.DumpStopContext(&ss, true); 1409 watchpoint_sp->SetDeclInfo(ss.GetString()); 1410 } 1411 } 1412 } 1413 } 1414 return sb_watchpoint; 1415 } 1416 1417 lldb::SBWatchpoint 1418 SBValue::WatchPointee (bool resolve_location, bool read, bool write) 1419 { 1420 SBWatchpoint sb_watchpoint; 1421 if (IsInScope() && GetType().IsPointerType()) 1422 sb_watchpoint = Dereference().Watch (resolve_location, read, write); 1423 return sb_watchpoint; 1424 } 1425 1426