LLDB  mainline
SBValue.cpp
Go to the documentation of this file.
1 //===-- SBValue.cpp ---------------------------------------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "lldb/API/SBValue.h"
10 #include "SBReproducerPrivate.h"
11 
12 #include "lldb/API/SBDeclaration.h"
13 #include "lldb/API/SBStream.h"
14 #include "lldb/API/SBTypeFilter.h"
15 #include "lldb/API/SBTypeFormat.h"
16 #include "lldb/API/SBTypeSummary.h"
18 
20 #include "lldb/Core/Module.h"
21 #include "lldb/Core/Section.h"
22 #include "lldb/Core/StreamFile.h"
23 #include "lldb/Core/Value.h"
24 #include "lldb/Core/ValueObject.h"
27 #include "lldb/Symbol/Block.h"
29 #include "lldb/Symbol/ObjectFile.h"
30 #include "lldb/Symbol/Type.h"
31 #include "lldb/Symbol/Variable.h"
34 #include "lldb/Target/Process.h"
35 #include "lldb/Target/StackFrame.h"
36 #include "lldb/Target/Target.h"
37 #include "lldb/Target/Thread.h"
39 #include "lldb/Utility/Scalar.h"
40 #include "lldb/Utility/Stream.h"
41 
42 #include "lldb/API/SBDebugger.h"
44 #include "lldb/API/SBFrame.h"
45 #include "lldb/API/SBProcess.h"
46 #include "lldb/API/SBTarget.h"
47 #include "lldb/API/SBThread.h"
48 
49 #include <memory>
50 
51 using namespace lldb;
52 using namespace lldb_private;
53 
54 class ValueImpl {
55 public:
56  ValueImpl() {}
57 
58  ValueImpl(lldb::ValueObjectSP in_valobj_sp,
59  lldb::DynamicValueType use_dynamic, bool use_synthetic,
60  const char *name = NULL)
61  : m_valobj_sp(), m_use_dynamic(use_dynamic),
62  m_use_synthetic(use_synthetic), m_name(name) {
63  if (in_valobj_sp) {
64  if ((m_valobj_sp = in_valobj_sp->GetQualifiedRepresentationIfAvailable(
65  lldb::eNoDynamicValues, false))) {
66  if (!m_name.IsEmpty())
67  m_valobj_sp->SetName(m_name);
68  }
69  }
70  }
71 
72  ValueImpl(const ValueImpl &rhs)
73  : m_valobj_sp(rhs.m_valobj_sp), m_use_dynamic(rhs.m_use_dynamic),
74  m_use_synthetic(rhs.m_use_synthetic), m_name(rhs.m_name) {}
75 
76  ValueImpl &operator=(const ValueImpl &rhs) {
77  if (this != &rhs) {
78  m_valobj_sp = rhs.m_valobj_sp;
79  m_use_dynamic = rhs.m_use_dynamic;
80  m_use_synthetic = rhs.m_use_synthetic;
81  m_name = rhs.m_name;
82  }
83  return *this;
84  }
85 
86  bool IsValid() {
87  if (m_valobj_sp.get() == NULL)
88  return false;
89  else {
90  // FIXME: This check is necessary but not sufficient. We for sure don't
91  // want to touch SBValues whose owning
92  // targets have gone away. This check is a little weak in that it
93  // enforces that restriction when you call IsValid, but since IsValid
94  // doesn't lock the target, you have no guarantee that the SBValue won't
95  // go invalid after you call this... Also, an SBValue could depend on
96  // data from one of the modules in the target, and those could go away
97  // independently of the target, for instance if a module is unloaded.
98  // But right now, neither SBValues nor ValueObjects know which modules
99  // they depend on. So I have no good way to make that check without
100  // tracking that in all the ValueObject subclasses.
101  TargetSP target_sp = m_valobj_sp->GetTargetSP();
102  return target_sp && target_sp->IsValid();
103  }
104  }
105 
106  lldb::ValueObjectSP GetRootSP() { return m_valobj_sp; }
107 
108  lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker,
109  std::unique_lock<std::recursive_mutex> &lock,
110  Status &error) {
111  if (!m_valobj_sp) {
112  error.SetErrorString("invalid value object");
113  return m_valobj_sp;
114  }
115 
116  lldb::ValueObjectSP value_sp = m_valobj_sp;
117 
118  Target *target = value_sp->GetTargetSP().get();
119  if (!target)
120  return ValueObjectSP();
121 
122  lock = std::unique_lock<std::recursive_mutex>(target->GetAPIMutex());
123 
124  ProcessSP process_sp(value_sp->GetProcessSP());
125  if (process_sp && !stop_locker.TryLock(&process_sp->GetRunLock())) {
126  // We don't allow people to play around with ValueObject if the process
127  // is running. If you want to look at values, pause the process, then
128  // look.
129  error.SetErrorString("process must be stopped.");
130  return ValueObjectSP();
131  }
132 
133  if (m_use_dynamic != eNoDynamicValues) {
134  ValueObjectSP dynamic_sp = value_sp->GetDynamicValue(m_use_dynamic);
135  if (dynamic_sp)
136  value_sp = dynamic_sp;
137  }
138 
139  if (m_use_synthetic) {
140  ValueObjectSP synthetic_sp = value_sp->GetSyntheticValue(m_use_synthetic);
141  if (synthetic_sp)
142  value_sp = synthetic_sp;
143  }
144 
145  if (!value_sp)
146  error.SetErrorString("invalid value object");
147  if (!m_name.IsEmpty())
148  value_sp->SetName(m_name);
149 
150  return value_sp;
151  }
152 
154  m_use_dynamic = use_dynamic;
155  }
156 
157  void SetUseSynthetic(bool use_synthetic) { m_use_synthetic = use_synthetic; }
158 
159  lldb::DynamicValueType GetUseDynamic() { return m_use_dynamic; }
160 
161  bool GetUseSynthetic() { return m_use_synthetic; }
162 
163  // All the derived values that we would make from the m_valobj_sp will share
164  // the ExecutionContext with m_valobj_sp, so we don't need to do the
165  // calculations in GetSP to return the Target, Process, Thread or Frame. It
166  // is convenient to provide simple accessors for these, which I do here.
167  TargetSP GetTargetSP() {
168  if (m_valobj_sp)
169  return m_valobj_sp->GetTargetSP();
170  else
171  return TargetSP();
172  }
173 
174  ProcessSP GetProcessSP() {
175  if (m_valobj_sp)
176  return m_valobj_sp->GetProcessSP();
177  else
178  return ProcessSP();
179  }
180 
181  ThreadSP GetThreadSP() {
182  if (m_valobj_sp)
183  return m_valobj_sp->GetThreadSP();
184  else
185  return ThreadSP();
186  }
187 
188  StackFrameSP GetFrameSP() {
189  if (m_valobj_sp)
190  return m_valobj_sp->GetFrameSP();
191  else
192  return StackFrameSP();
193  }
194 
195 private:
196  lldb::ValueObjectSP m_valobj_sp;
197  lldb::DynamicValueType m_use_dynamic;
198  bool m_use_synthetic;
199  ConstString m_name;
200 };
201 
202 class ValueLocker {
203 public:
205 
206  ValueObjectSP GetLockedSP(ValueImpl &in_value) {
207  return in_value.GetSP(m_stop_locker, m_lock, m_lock_error);
208  }
209 
210  Status &GetError() { return m_lock_error; }
211 
212 private:
213  Process::StopLocker m_stop_locker;
214  std::unique_lock<std::recursive_mutex> m_lock;
215  Status m_lock_error;
216 };
217 
219 
220 SBValue::SBValue(const lldb::ValueObjectSP &value_sp) {
221  LLDB_RECORD_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &), value_sp);
222 
223  SetSP(value_sp);
224 }
225 
228 
229  SetSP(rhs.m_opaque_sp);
230 }
231 
234  SBValue, operator=,(const lldb::SBValue &), rhs);
235 
236  if (this != &rhs) {
237  SetSP(rhs.m_opaque_sp);
238  }
239  return LLDB_RECORD_RESULT(*this);
240 }
241 
243 
246  return this->operator bool();
247 }
248 SBValue::operator bool() const {
249  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBValue, operator bool);
250 
251  // If this function ever changes to anything that does more than just check
252  // if the opaque shared pointer is non NULL, then we need to update all "if
253  // (m_opaque_sp)" code in this file.
254  return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() &&
255  m_opaque_sp->GetRootSP().get() != NULL;
256 }
257 
260 
261  m_opaque_sp.reset();
262 }
263 
266 
267  SBError sb_error;
268 
269  ValueLocker locker;
270  lldb::ValueObjectSP value_sp(GetSP(locker));
271  if (value_sp)
272  sb_error.SetError(value_sp->GetError());
273  else
274  sb_error.SetErrorStringWithFormat("error: %s",
275  locker.GetError().AsCString());
276 
277  return LLDB_RECORD_RESULT(sb_error);
278 }
279 
282 
283  ValueLocker locker;
284  lldb::ValueObjectSP value_sp(GetSP(locker));
285  if (value_sp)
286  return value_sp->GetID();
287  return LLDB_INVALID_UID;
288 }
289 
290 const char *SBValue::GetName() {
292 
293  const char *name = NULL;
294  ValueLocker locker;
295  lldb::ValueObjectSP value_sp(GetSP(locker));
296  if (value_sp)
297  name = value_sp->GetName().GetCString();
298 
299  return name;
300 }
301 
302 const char *SBValue::GetTypeName() {
304 
305  const char *name = NULL;
306  ValueLocker locker;
307  lldb::ValueObjectSP value_sp(GetSP(locker));
308  if (value_sp) {
309  name = value_sp->GetQualifiedTypeName().GetCString();
310  }
311 
312  return name;
313 }
314 
317 
318  const char *name = NULL;
319  ValueLocker locker;
320  lldb::ValueObjectSP value_sp(GetSP(locker));
321  if (value_sp) {
322  name = value_sp->GetDisplayTypeName().GetCString();
323  }
324 
325  return name;
326 }
327 
330 
331  size_t result = 0;
332 
333  ValueLocker locker;
334  lldb::ValueObjectSP value_sp(GetSP(locker));
335  if (value_sp) {
336  result = value_sp->GetByteSize();
337  }
338 
339  return result;
340 }
341 
344 
345  bool result = false;
346 
347  ValueLocker locker;
348  lldb::ValueObjectSP value_sp(GetSP(locker));
349  if (value_sp) {
350  result = value_sp->IsInScope();
351  }
352 
353  return result;
354 }
355 
356 const char *SBValue::GetValue() {
358 
359  const char *cstr = NULL;
360  ValueLocker locker;
361  lldb::ValueObjectSP value_sp(GetSP(locker));
362  if (value_sp) {
363  cstr = value_sp->GetValueAsCString();
364  }
365 
366  return cstr;
367 }
368 
371 
372  ValueType result = eValueTypeInvalid;
373  ValueLocker locker;
374  lldb::ValueObjectSP value_sp(GetSP(locker));
375  if (value_sp)
376  result = value_sp->GetValueType();
377 
378  return result;
379 }
380 
383 
384  const char *cstr = NULL;
385  ValueLocker locker;
386  lldb::ValueObjectSP value_sp(GetSP(locker));
387  if (value_sp) {
388  cstr = value_sp->GetObjectDescription();
389  }
390 
391  return cstr;
392 }
393 
396 
397  const char *cstr = NULL;
398  ValueLocker locker;
399  lldb::ValueObjectSP value_sp(GetSP(locker));
400  if (value_sp) {
401  const auto &validation(value_sp->GetValidationStatus());
402  if (TypeValidatorResult::Failure == validation.first) {
403  if (validation.second.empty())
404  cstr = "unknown error";
405  else
406  cstr = validation.second.c_str();
407  }
408  }
409 
410  return cstr;
411 }
412 
415 
416  SBType sb_type;
417  ValueLocker locker;
418  lldb::ValueObjectSP value_sp(GetSP(locker));
419  TypeImplSP type_sp;
420  if (value_sp) {
421  type_sp = std::make_shared<TypeImpl>(value_sp->GetTypeImpl());
422  sb_type.SetSP(type_sp);
423  }
424 
425  return LLDB_RECORD_RESULT(sb_type);
426 }
427 
430 
431  bool result = false;
432  ValueLocker locker;
433  lldb::ValueObjectSP value_sp(GetSP(locker));
434  if (value_sp) {
435  if (value_sp->UpdateValueIfNeeded(false))
436  result = value_sp->GetValueDidChange();
437  }
438 
439  return result;
440 }
441 
442 const char *SBValue::GetSummary() {
444 
445  const char *cstr = NULL;
446  ValueLocker locker;
447  lldb::ValueObjectSP value_sp(GetSP(locker));
448  if (value_sp) {
449  cstr = value_sp->GetSummaryAsCString();
450  }
451 
452  return cstr;
453 }
454 
456  lldb::SBTypeSummaryOptions &options) {
457  LLDB_RECORD_METHOD(const char *, SBValue, GetSummary,
459  options);
460 
461  ValueLocker locker;
462  lldb::ValueObjectSP value_sp(GetSP(locker));
463  if (value_sp) {
464  std::string buffer;
465  if (value_sp->GetSummaryAsCString(buffer, options.ref()) && !buffer.empty())
466  stream.Printf("%s", buffer.c_str());
467  }
468  const char *cstr = stream.GetData();
469  return cstr;
470 }
471 
472 const char *SBValue::GetLocation() {
474 
475  const char *cstr = NULL;
476  ValueLocker locker;
477  lldb::ValueObjectSP value_sp(GetSP(locker));
478  if (value_sp) {
479  cstr = value_sp->GetLocationAsCString();
480  }
481  return cstr;
482 }
483 
484 // Deprecated - use the one that takes an lldb::SBError
485 bool SBValue::SetValueFromCString(const char *value_str) {
486  LLDB_RECORD_METHOD(bool, SBValue, SetValueFromCString, (const char *),
487  value_str);
488 
489  lldb::SBError dummy;
490  return SetValueFromCString(value_str, dummy);
491 }
492 
493 bool SBValue::SetValueFromCString(const char *value_str, lldb::SBError &error) {
495  (const char *, lldb::SBError &), value_str, error);
496 
497  bool success = false;
498  ValueLocker locker;
499  lldb::ValueObjectSP value_sp(GetSP(locker));
500  if (value_sp) {
501  success = value_sp->SetValueFromCString(value_str, error.ref());
502  } else
503  error.SetErrorStringWithFormat("Could not get value: %s",
504  locker.GetError().AsCString());
505 
506  return success;
507 }
508 
511 
512  lldb::SBTypeFormat format;
513  ValueLocker locker;
514  lldb::ValueObjectSP value_sp(GetSP(locker));
515  if (value_sp) {
516  if (value_sp->UpdateValueIfNeeded(true)) {
517  lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
518  if (format_sp)
519  format.SetSP(format_sp);
520  }
521  }
522  return LLDB_RECORD_RESULT(format);
523 }
524 
527 
528  lldb::SBTypeSummary summary;
529  ValueLocker locker;
530  lldb::ValueObjectSP value_sp(GetSP(locker));
531  if (value_sp) {
532  if (value_sp->UpdateValueIfNeeded(true)) {
533  lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
534  if (summary_sp)
535  summary.SetSP(summary_sp);
536  }
537  }
538  return LLDB_RECORD_RESULT(summary);
539 }
540 
543 
544  lldb::SBTypeFilter filter;
545  ValueLocker locker;
546  lldb::ValueObjectSP value_sp(GetSP(locker));
547  if (value_sp) {
548  if (value_sp->UpdateValueIfNeeded(true)) {
549  lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
550 
551  if (synthetic_sp && !synthetic_sp->IsScripted()) {
552  TypeFilterImplSP filter_sp =
554  filter.SetSP(filter_sp);
555  }
556  }
557  }
558  return LLDB_RECORD_RESULT(filter);
559 }
560 
563 
564  lldb::SBTypeSynthetic synthetic;
565  ValueLocker locker;
566  lldb::ValueObjectSP value_sp(GetSP(locker));
567  if (value_sp) {
568  if (value_sp->UpdateValueIfNeeded(true)) {
569  lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
570 
571  if (children_sp && children_sp->IsScripted()) {
572  ScriptedSyntheticChildrenSP synth_sp =
574  synthetic.SetSP(synth_sp);
575  }
576  }
577  }
578  return LLDB_RECORD_RESULT(synthetic);
579 }
580 
582  SBType type) {
584  (const char *, uint32_t, lldb::SBType), name, offset,
585  type);
586 
587  lldb::SBValue sb_value;
588  ValueLocker locker;
589  lldb::ValueObjectSP value_sp(GetSP(locker));
590  lldb::ValueObjectSP new_value_sp;
591  if (value_sp) {
592  TypeImplSP type_sp(type.GetSP());
593  if (type.IsValid()) {
594  sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(
595  offset, type_sp->GetCompilerType(false), true),
597  }
598  }
599  return LLDB_RECORD_RESULT(sb_value);
600 }
601 
604 
605  lldb::SBValue sb_value;
606  ValueLocker locker;
607  lldb::ValueObjectSP value_sp(GetSP(locker));
608  TypeImplSP type_sp(type.GetSP());
609  if (value_sp && type_sp)
610  sb_value.SetSP(value_sp->Cast(type_sp->GetCompilerType(false)),
612  return LLDB_RECORD_RESULT(sb_value);
613 }
614 
616  const char *expression) {
618  (const char *, const char *), name, expression);
619 
620  SBExpressionOptions options;
621  options.ref().SetKeepInMemory(true);
622  return LLDB_RECORD_RESULT(
623  CreateValueFromExpression(name, expression, options));
624 }
625 
627  const char *expression,
628  SBExpressionOptions &options) {
630  (const char *, const char *, lldb::SBExpressionOptions &),
631  name, expression, options);
632 
633  lldb::SBValue sb_value;
634  ValueLocker locker;
635  lldb::ValueObjectSP value_sp(GetSP(locker));
636  lldb::ValueObjectSP new_value_sp;
637  if (value_sp) {
638  ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
639  new_value_sp = ValueObject::CreateValueObjectFromExpression(
640  name, expression, exe_ctx, options.ref());
641  if (new_value_sp)
642  new_value_sp->SetName(ConstString(name));
643  }
644  sb_value.SetSP(new_value_sp);
645  return LLDB_RECORD_RESULT(sb_value);
646 }
647 
649  lldb::addr_t address,
650  SBType sb_type) {
652  (const char *, lldb::addr_t, lldb::SBType), name, address,
653  sb_type);
654 
655  lldb::SBValue sb_value;
656  ValueLocker locker;
657  lldb::ValueObjectSP value_sp(GetSP(locker));
658  lldb::ValueObjectSP new_value_sp;
659  lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
660  if (value_sp && type_impl_sp) {
661  CompilerType ast_type(type_impl_sp->GetCompilerType(true));
662  ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
663  new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address,
664  exe_ctx, ast_type);
665  }
666  sb_value.SetSP(new_value_sp);
667  return LLDB_RECORD_RESULT(sb_value);
668 }
669 
671  SBType sb_type) {
673  (const char *, lldb::SBData, lldb::SBType), name, data,
674  sb_type);
675 
676  lldb::SBValue sb_value;
677  lldb::ValueObjectSP new_value_sp;
678  ValueLocker locker;
679  lldb::ValueObjectSP value_sp(GetSP(locker));
680  lldb::TypeImplSP type_impl_sp(sb_type.GetSP());
681  if (value_sp && type_impl_sp) {
682  ExecutionContext exe_ctx(value_sp->GetExecutionContextRef());
683  new_value_sp = ValueObject::CreateValueObjectFromData(
684  name, **data, exe_ctx, type_impl_sp->GetCompilerType(true));
685  new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
686  }
687  sb_value.SetSP(new_value_sp);
688  return LLDB_RECORD_RESULT(sb_value);
689 }
690 
693 
694  const bool can_create_synthetic = false;
696  TargetSP target_sp;
697  if (m_opaque_sp)
698  target_sp = m_opaque_sp->GetTargetSP();
699 
700  if (target_sp)
701  use_dynamic = target_sp->GetPreferDynamicValue();
702 
703  return LLDB_RECORD_RESULT(
704  GetChildAtIndex(idx, use_dynamic, can_create_synthetic));
705 }
706 
708  lldb::DynamicValueType use_dynamic,
709  bool can_create_synthetic) {
711  (uint32_t, lldb::DynamicValueType, bool), idx, use_dynamic,
712  can_create_synthetic);
713 
714  lldb::ValueObjectSP child_sp;
715 
716  ValueLocker locker;
717  lldb::ValueObjectSP value_sp(GetSP(locker));
718  if (value_sp) {
719  const bool can_create = true;
720  child_sp = value_sp->GetChildAtIndex(idx, can_create);
721  if (can_create_synthetic && !child_sp) {
722  child_sp = value_sp->GetSyntheticArrayMember(idx, can_create);
723  }
724  }
725 
726  SBValue sb_value;
727  sb_value.SetSP(child_sp, use_dynamic, GetPreferSyntheticValue());
728 
729  return LLDB_RECORD_RESULT(sb_value);
730 }
731 
734  name);
735 
736  uint32_t idx = UINT32_MAX;
737  ValueLocker locker;
738  lldb::ValueObjectSP value_sp(GetSP(locker));
739  if (value_sp) {
740  idx = value_sp->GetIndexOfChildWithName(ConstString(name));
741  }
742  return idx;
743 }
744 
747  (const char *), name);
748 
749  lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
750  TargetSP target_sp;
751  if (m_opaque_sp)
752  target_sp = m_opaque_sp->GetTargetSP();
753 
754  if (target_sp)
755  use_dynamic_value = target_sp->GetPreferDynamicValue();
756  return LLDB_RECORD_RESULT(GetChildMemberWithName(name, use_dynamic_value));
757 }
758 
759 SBValue
761  lldb::DynamicValueType use_dynamic_value) {
763  (const char *, lldb::DynamicValueType), name,
764  use_dynamic_value);
765 
766  lldb::ValueObjectSP child_sp;
767  const ConstString str_name(name);
768 
769  ValueLocker locker;
770  lldb::ValueObjectSP value_sp(GetSP(locker));
771  if (value_sp) {
772  child_sp = value_sp->GetChildMemberWithName(str_name, true);
773  }
774 
775  SBValue sb_value;
776  sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
777 
778  return LLDB_RECORD_RESULT(sb_value);
779 }
780 
783  (lldb::DynamicValueType), use_dynamic);
784 
785  SBValue value_sb;
786  if (IsValid()) {
787  ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(), use_dynamic,
788  m_opaque_sp->GetUseSynthetic()));
789  value_sb.SetSP(proxy_sp);
790  }
791  return LLDB_RECORD_RESULT(value_sb);
792 }
793 
796 
797  SBValue value_sb;
798  if (IsValid()) {
799  ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
801  m_opaque_sp->GetUseSynthetic()));
802  value_sb.SetSP(proxy_sp);
803  }
804  return LLDB_RECORD_RESULT(value_sb);
805 }
806 
809 
810  SBValue value_sb;
811  if (IsValid()) {
812  ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),
813  m_opaque_sp->GetUseDynamic(), false));
814  value_sb.SetSP(proxy_sp);
815  }
816  return LLDB_RECORD_RESULT(value_sb);
817 }
818 
822 
823  if (!IsValid())
824  return eNoDynamicValues;
825  return m_opaque_sp->GetUseDynamic();
826 }
827 
830  (lldb::DynamicValueType), use_dynamic);
831 
832  if (IsValid())
833  return m_opaque_sp->SetUseDynamic(use_dynamic);
834 }
835 
838 
839  if (!IsValid())
840  return false;
841  return m_opaque_sp->GetUseSynthetic();
842 }
843 
844 void SBValue::SetPreferSyntheticValue(bool use_synthetic) {
846  use_synthetic);
847 
848  if (IsValid())
849  return m_opaque_sp->SetUseSynthetic(use_synthetic);
850 }
851 
854 
855  ValueLocker locker;
856  lldb::ValueObjectSP value_sp(GetSP(locker));
857  if (value_sp)
858  return value_sp->IsDynamic();
859  return false;
860 }
861 
864 
865  ValueLocker locker;
866  lldb::ValueObjectSP value_sp(GetSP(locker));
867  if (value_sp)
868  return value_sp->IsSynthetic();
869  return false;
870 }
871 
874 
875  ValueLocker locker;
876  lldb::ValueObjectSP value_sp(GetSP(locker));
877  if (value_sp)
878  return value_sp->IsSyntheticChildrenGenerated();
879  return false;
880 }
881 
884 
885  ValueLocker locker;
886  lldb::ValueObjectSP value_sp(GetSP(locker));
887  if (value_sp)
888  return value_sp->SetSyntheticChildrenGenerated(is);
889 }
890 
893  (const char *), expr_path);
894 
895  lldb::ValueObjectSP child_sp;
896  ValueLocker locker;
897  lldb::ValueObjectSP value_sp(GetSP(locker));
898  if (value_sp) {
899  // using default values for all the fancy options, just do it if you can
900  child_sp = value_sp->GetValueForExpressionPath(expr_path);
901  }
902 
903  SBValue sb_value;
904  sb_value.SetSP(child_sp, GetPreferDynamicValue(), GetPreferSyntheticValue());
905 
906  return LLDB_RECORD_RESULT(sb_value);
907 }
908 
909 int64_t SBValue::GetValueAsSigned(SBError &error, int64_t fail_value) {
911  (lldb::SBError &, int64_t), error, fail_value);
912 
913  error.Clear();
914  ValueLocker locker;
915  lldb::ValueObjectSP value_sp(GetSP(locker));
916  if (value_sp) {
917  bool success = true;
918  uint64_t ret_val = fail_value;
919  ret_val = value_sp->GetValueAsSigned(fail_value, &success);
920  if (!success)
921  error.SetErrorString("could not resolve value");
922  return ret_val;
923  } else
924  error.SetErrorStringWithFormat("could not get SBValue: %s",
925  locker.GetError().AsCString());
926 
927  return fail_value;
928 }
929 
930 uint64_t SBValue::GetValueAsUnsigned(SBError &error, uint64_t fail_value) {
932  (lldb::SBError &, uint64_t), error, fail_value);
933 
934  error.Clear();
935  ValueLocker locker;
936  lldb::ValueObjectSP value_sp(GetSP(locker));
937  if (value_sp) {
938  bool success = true;
939  uint64_t ret_val = fail_value;
940  ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
941  if (!success)
942  error.SetErrorString("could not resolve value");
943  return ret_val;
944  } else
945  error.SetErrorStringWithFormat("could not get SBValue: %s",
946  locker.GetError().AsCString());
947 
948  return fail_value;
949 }
950 
951 int64_t SBValue::GetValueAsSigned(int64_t fail_value) {
952  LLDB_RECORD_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t), fail_value);
953 
954  ValueLocker locker;
955  lldb::ValueObjectSP value_sp(GetSP(locker));
956  if (value_sp) {
957  return value_sp->GetValueAsSigned(fail_value);
958  }
959  return fail_value;
960 }
961 
962 uint64_t SBValue::GetValueAsUnsigned(uint64_t fail_value) {
963  LLDB_RECORD_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t),
964  fail_value);
965 
966  ValueLocker locker;
967  lldb::ValueObjectSP value_sp(GetSP(locker));
968  if (value_sp) {
969  return value_sp->GetValueAsUnsigned(fail_value);
970  }
971  return fail_value;
972 }
973 
976 
977  bool has_children = false;
978  ValueLocker locker;
979  lldb::ValueObjectSP value_sp(GetSP(locker));
980  if (value_sp)
981  has_children = value_sp->MightHaveChildren();
982 
983  return has_children;
984 }
985 
988 
989  bool is_support = false;
990  ValueLocker locker;
991  lldb::ValueObjectSP value_sp(GetSP(locker));
992  if (value_sp)
993  is_support = value_sp->IsRuntimeSupportValue();
994 
995  return is_support;
996 }
997 
1000 
1001  return GetNumChildren(UINT32_MAX);
1002 }
1003 
1006 
1007  uint32_t num_children = 0;
1008 
1009  ValueLocker locker;
1010  lldb::ValueObjectSP value_sp(GetSP(locker));
1011  if (value_sp)
1012  num_children = value_sp->GetNumChildren(max);
1013 
1014  return num_children;
1015 }
1016 
1019 
1020  SBValue sb_value;
1021  ValueLocker locker;
1022  lldb::ValueObjectSP value_sp(GetSP(locker));
1023  if (value_sp) {
1024  Status error;
1025  sb_value = value_sp->Dereference(error);
1026  }
1027 
1028  return LLDB_RECORD_RESULT(sb_value);
1029 }
1030 
1031 // Deprecated - please use GetType().IsPointerType() instead.
1034 
1035  return GetType().IsPointerType();
1036 }
1037 
1040 
1041  ValueLocker locker;
1042  lldb::ValueObjectSP value_sp(GetSP(locker));
1043  if (value_sp)
1044  return value_sp->GetCompilerType().GetOpaqueQualType();
1045  return NULL;
1046 }
1047 
1050 
1051  SBTarget sb_target;
1052  TargetSP target_sp;
1053  if (m_opaque_sp) {
1054  target_sp = m_opaque_sp->GetTargetSP();
1055  sb_target.SetSP(target_sp);
1056  }
1057 
1058  return LLDB_RECORD_RESULT(sb_target);
1059 }
1060 
1063 
1064  SBProcess sb_process;
1065  ProcessSP process_sp;
1066  if (m_opaque_sp) {
1067  process_sp = m_opaque_sp->GetProcessSP();
1068  sb_process.SetSP(process_sp);
1069  }
1070 
1071  return LLDB_RECORD_RESULT(sb_process);
1072 }
1073 
1076 
1077  SBThread sb_thread;
1078  ThreadSP thread_sp;
1079  if (m_opaque_sp) {
1080  thread_sp = m_opaque_sp->GetThreadSP();
1081  sb_thread.SetThread(thread_sp);
1082  }
1083 
1084  return LLDB_RECORD_RESULT(sb_thread);
1085 }
1086 
1089 
1090  SBFrame sb_frame;
1091  StackFrameSP frame_sp;
1092  if (m_opaque_sp) {
1093  frame_sp = m_opaque_sp->GetFrameSP();
1094  sb_frame.SetFrameSP(frame_sp);
1095  }
1096 
1097  return LLDB_RECORD_RESULT(sb_frame);
1098 }
1099 
1100 lldb::ValueObjectSP SBValue::GetSP(ValueLocker &locker) const {
1101  if (!m_opaque_sp || !m_opaque_sp->IsValid()) {
1102  locker.GetError().SetErrorString("No value");
1103  return ValueObjectSP();
1104  }
1105  return locker.GetLockedSP(*m_opaque_sp.get());
1106 }
1107 
1108 lldb::ValueObjectSP SBValue::GetSP() const {
1109  LLDB_RECORD_METHOD_CONST_NO_ARGS(lldb::ValueObjectSP, SBValue, GetSP);
1110 
1111  ValueLocker locker;
1112  return LLDB_RECORD_RESULT(GetSP(locker));
1113 }
1114 
1115 void SBValue::SetSP(ValueImplSP impl_sp) { m_opaque_sp = impl_sp; }
1116 
1117 void SBValue::SetSP(const lldb::ValueObjectSP &sp) {
1118  if (sp) {
1119  lldb::TargetSP target_sp(sp->GetTargetSP());
1120  if (target_sp) {
1121  lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1122  bool use_synthetic =
1123  target_sp->TargetProperties::GetEnableSyntheticValue();
1124  m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1125  } else
1126  m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, true));
1127  } else
1128  m_opaque_sp = ValueImplSP(new ValueImpl(sp, eNoDynamicValues, false));
1129 }
1130 
1131 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1132  lldb::DynamicValueType use_dynamic) {
1133  if (sp) {
1134  lldb::TargetSP target_sp(sp->GetTargetSP());
1135  if (target_sp) {
1136  bool use_synthetic =
1137  target_sp->TargetProperties::GetEnableSyntheticValue();
1138  SetSP(sp, use_dynamic, use_synthetic);
1139  } else
1140  SetSP(sp, use_dynamic, true);
1141  } else
1142  SetSP(sp, use_dynamic, false);
1143 }
1144 
1145 void SBValue::SetSP(const lldb::ValueObjectSP &sp, bool use_synthetic) {
1146  if (sp) {
1147  lldb::TargetSP target_sp(sp->GetTargetSP());
1148  if (target_sp) {
1149  lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1150  SetSP(sp, use_dynamic, use_synthetic);
1151  } else
1152  SetSP(sp, eNoDynamicValues, use_synthetic);
1153  } else
1154  SetSP(sp, eNoDynamicValues, use_synthetic);
1155 }
1156 
1157 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1158  lldb::DynamicValueType use_dynamic, bool use_synthetic) {
1159  m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1160 }
1161 
1162 void SBValue::SetSP(const lldb::ValueObjectSP &sp,
1163  lldb::DynamicValueType use_dynamic, bool use_synthetic,
1164  const char *name) {
1165  m_opaque_sp =
1166  ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic, name));
1167 }
1168 
1171  description);
1172 
1173  ValueLocker locker;
1174  lldb::ValueObjectSP value_sp(GetSP(locker));
1175  if (value_sp) {
1176  value_sp->GetExpressionPath(description.ref(), false);
1177  return true;
1178  }
1179  return false;
1180 }
1181 
1183  bool qualify_cxx_base_classes) {
1185  description, qualify_cxx_base_classes);
1186 
1187  ValueLocker locker;
1188  lldb::ValueObjectSP value_sp(GetSP(locker));
1189  if (value_sp) {
1190  value_sp->GetExpressionPath(description.ref(), qualify_cxx_base_classes);
1191  return true;
1192  }
1193  return false;
1194 }
1195 
1198  (const char *), expr);
1199 
1200  ValueLocker locker;
1201  lldb::ValueObjectSP value_sp(GetSP(locker));
1202  if (!value_sp)
1203  return LLDB_RECORD_RESULT(SBValue());
1204 
1205  lldb::TargetSP target_sp = value_sp->GetTargetSP();
1206  if (!target_sp)
1207  return LLDB_RECORD_RESULT(SBValue());
1208 
1209  lldb::SBExpressionOptions options;
1210  options.SetFetchDynamicValue(target_sp->GetPreferDynamicValue());
1211  options.SetUnwindOnError(true);
1212  options.SetIgnoreBreakpoints(true);
1213 
1214  return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr));
1215 }
1216 
1219  const SBExpressionOptions &options) const {
1221  (const char *, const lldb::SBExpressionOptions &),
1222  expr, options);
1223 
1224  return LLDB_RECORD_RESULT(EvaluateExpression(expr, options, nullptr));
1225 }
1226 
1228  const SBExpressionOptions &options,
1229  const char *name) const {
1232  (const char *, const lldb::SBExpressionOptions &, const char *), expr,
1233  options, name);
1234 
1235 
1236  if (!expr || expr[0] == '\0') {
1237  return LLDB_RECORD_RESULT(SBValue());
1238  }
1239 
1240 
1241  ValueLocker locker;
1242  lldb::ValueObjectSP value_sp(GetSP(locker));
1243  if (!value_sp) {
1244  return LLDB_RECORD_RESULT(SBValue());
1245  }
1246 
1247  lldb::TargetSP target_sp = value_sp->GetTargetSP();
1248  if (!target_sp) {
1249  return LLDB_RECORD_RESULT(SBValue());
1250  }
1251 
1252  std::lock_guard<std::recursive_mutex> guard(target_sp->GetAPIMutex());
1253  ExecutionContext exe_ctx(target_sp.get());
1254 
1255  StackFrame *frame = exe_ctx.GetFramePtr();
1256  if (!frame) {
1257  return LLDB_RECORD_RESULT(SBValue());
1258  }
1259 
1260  ValueObjectSP res_val_sp;
1261  target_sp->EvaluateExpression(expr, frame, res_val_sp, options.ref(), nullptr,
1262  value_sp.get());
1263 
1264  if (name)
1265  res_val_sp->SetName(ConstString(name));
1266 
1267  SBValue result;
1268  result.SetSP(res_val_sp, options.GetFetchDynamicValue());
1269  return LLDB_RECORD_RESULT(result);
1270 }
1271 
1272 bool SBValue::GetDescription(SBStream &description) {
1274  description);
1275 
1276  Stream &strm = description.ref();
1277 
1278  ValueLocker locker;
1279  lldb::ValueObjectSP value_sp(GetSP(locker));
1280  if (value_sp)
1281  value_sp->Dump(strm);
1282  else
1283  strm.PutCString("No value");
1284 
1285  return true;
1286 }
1287 
1290 
1291  ValueLocker locker;
1292  lldb::ValueObjectSP value_sp(GetSP(locker));
1293  if (value_sp)
1294  return value_sp->GetFormat();
1295  return eFormatDefault;
1296 }
1297 
1299  LLDB_RECORD_METHOD(void, SBValue, SetFormat, (lldb::Format), format);
1300 
1301  ValueLocker locker;
1302  lldb::ValueObjectSP value_sp(GetSP(locker));
1303  if (value_sp)
1304  value_sp->SetFormat(format);
1305 }
1306 
1309 
1310  SBValue sb_value;
1311  ValueLocker locker;
1312  lldb::ValueObjectSP value_sp(GetSP(locker));
1313  if (value_sp) {
1314  Status error;
1315  sb_value.SetSP(value_sp->AddressOf(error), GetPreferDynamicValue(),
1317  }
1318 
1319  return LLDB_RECORD_RESULT(sb_value);
1320 }
1321 
1324 
1326  ValueLocker locker;
1327  lldb::ValueObjectSP value_sp(GetSP(locker));
1328  if (value_sp) {
1329  TargetSP target_sp(value_sp->GetTargetSP());
1330  if (target_sp) {
1331  const bool scalar_is_load_address = true;
1332  AddressType addr_type;
1333  value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1334  if (addr_type == eAddressTypeFile) {
1335  ModuleSP module_sp(value_sp->GetModule());
1336  if (!module_sp)
1337  value = LLDB_INVALID_ADDRESS;
1338  else {
1339  Address addr;
1340  module_sp->ResolveFileAddress(value, addr);
1341  value = addr.GetLoadAddress(target_sp.get());
1342  }
1343  } else if (addr_type == eAddressTypeHost ||
1344  addr_type == eAddressTypeInvalid)
1345  value = LLDB_INVALID_ADDRESS;
1346  }
1347  }
1348 
1349  return value;
1350 }
1351 
1354 
1355  Address addr;
1356  ValueLocker locker;
1357  lldb::ValueObjectSP value_sp(GetSP(locker));
1358  if (value_sp) {
1359  TargetSP target_sp(value_sp->GetTargetSP());
1360  if (target_sp) {
1362  const bool scalar_is_load_address = true;
1363  AddressType addr_type;
1364  value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
1365  if (addr_type == eAddressTypeFile) {
1366  ModuleSP module_sp(value_sp->GetModule());
1367  if (module_sp)
1368  module_sp->ResolveFileAddress(value, addr);
1369  } else if (addr_type == eAddressTypeLoad) {
1370  // no need to check the return value on this.. if it can actually do
1371  // the resolve addr will be in the form (section,offset), otherwise it
1372  // will simply be returned as (NULL, value)
1373  addr.SetLoadAddress(value, target_sp.get());
1374  }
1375  }
1376  }
1377 
1378  return LLDB_RECORD_RESULT(SBAddress(new Address(addr)));
1379 }
1380 
1383  (uint32_t, uint32_t), item_idx, item_count);
1384 
1385  lldb::SBData sb_data;
1386  ValueLocker locker;
1387  lldb::ValueObjectSP value_sp(GetSP(locker));
1388  if (value_sp) {
1389  TargetSP target_sp(value_sp->GetTargetSP());
1390  if (target_sp) {
1391  DataExtractorSP data_sp(new DataExtractor());
1392  value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1393  if (data_sp->GetByteSize() > 0)
1394  *sb_data = data_sp;
1395  }
1396  }
1397 
1398  return LLDB_RECORD_RESULT(sb_data);
1399 }
1400 
1403 
1404  lldb::SBData sb_data;
1405  ValueLocker locker;
1406  lldb::ValueObjectSP value_sp(GetSP(locker));
1407  if (value_sp) {
1408  DataExtractorSP data_sp(new DataExtractor());
1409  Status error;
1410  value_sp->GetData(*data_sp, error);
1411  if (error.Success())
1412  *sb_data = data_sp;
1413  }
1414 
1415  return LLDB_RECORD_RESULT(sb_data);
1416 }
1417 
1420  data, error);
1421 
1422  ValueLocker locker;
1423  lldb::ValueObjectSP value_sp(GetSP(locker));
1424  bool ret = true;
1425 
1426  if (value_sp) {
1427  DataExtractor *data_extractor = data.get();
1428 
1429  if (!data_extractor) {
1430  error.SetErrorString("No data to set");
1431  ret = false;
1432  } else {
1433  Status set_error;
1434 
1435  value_sp->SetData(*data_extractor, set_error);
1436 
1437  if (!set_error.Success()) {
1438  error.SetErrorStringWithFormat("Couldn't set data: %s",
1439  set_error.AsCString());
1440  ret = false;
1441  }
1442  }
1443  } else {
1445  "Couldn't set data: could not get SBValue: %s",
1446  locker.GetError().AsCString());
1447  ret = false;
1448  }
1449 
1450  return ret;
1451 }
1452 
1455 
1456  ValueLocker locker;
1457  lldb::ValueObjectSP value_sp(GetSP(locker));
1458  SBDeclaration decl_sb;
1459  if (value_sp) {
1460  Declaration decl;
1461  if (value_sp->GetDeclaration(decl))
1462  decl_sb.SetDeclaration(decl);
1463  }
1464  return LLDB_RECORD_RESULT(decl_sb);
1465 }
1466 
1467 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read, bool write,
1468  SBError &error) {
1470  (bool, bool, bool, lldb::SBError &), resolve_location,
1471  read, write, error);
1472 
1473  SBWatchpoint sb_watchpoint;
1474 
1475  // If the SBValue is not valid, there's no point in even trying to watch it.
1476  ValueLocker locker;
1477  lldb::ValueObjectSP value_sp(GetSP(locker));
1478  TargetSP target_sp(GetTarget().GetSP());
1479  if (value_sp && target_sp) {
1480  // Read and Write cannot both be false.
1481  if (!read && !write)
1482  return LLDB_RECORD_RESULT(sb_watchpoint);
1483 
1484  // If the value is not in scope, don't try and watch and invalid value
1485  if (!IsInScope())
1486  return LLDB_RECORD_RESULT(sb_watchpoint);
1487 
1488  addr_t addr = GetLoadAddress();
1489  if (addr == LLDB_INVALID_ADDRESS)
1490  return LLDB_RECORD_RESULT(sb_watchpoint);
1491  size_t byte_size = GetByteSize();
1492  if (byte_size == 0)
1493  return LLDB_RECORD_RESULT(sb_watchpoint);
1494 
1495  uint32_t watch_type = 0;
1496  if (read)
1497  watch_type |= LLDB_WATCH_TYPE_READ;
1498  if (write)
1499  watch_type |= LLDB_WATCH_TYPE_WRITE;
1500 
1501  Status rc;
1502  CompilerType type(value_sp->GetCompilerType());
1503  WatchpointSP watchpoint_sp =
1504  target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
1505  error.SetError(rc);
1506 
1507  if (watchpoint_sp) {
1508  sb_watchpoint.SetSP(watchpoint_sp);
1509  Declaration decl;
1510  if (value_sp->GetDeclaration(decl)) {
1511  if (decl.GetFile()) {
1512  StreamString ss;
1513  // True to show fullpath for declaration file.
1514  decl.DumpStopContext(&ss, true);
1515  watchpoint_sp->SetDeclInfo(ss.GetString());
1516  }
1517  }
1518  }
1519  } else if (target_sp) {
1520  error.SetErrorStringWithFormat("could not get SBValue: %s",
1521  locker.GetError().AsCString());
1522  } else {
1523  error.SetErrorString("could not set watchpoint, a target is required");
1524  }
1525 
1526  return LLDB_RECORD_RESULT(sb_watchpoint);
1527 }
1528 
1529 // FIXME: Remove this method impl (as well as the decl in .h) once it is no
1530 // longer needed.
1531 // Backward compatibility fix in the interim.
1532 lldb::SBWatchpoint SBValue::Watch(bool resolve_location, bool read,
1533  bool write) {
1534  LLDB_RECORD_METHOD(lldb::SBWatchpoint, SBValue, Watch, (bool, bool, bool),
1535  resolve_location, read, write);
1536 
1537  SBError error;
1538  return LLDB_RECORD_RESULT(Watch(resolve_location, read, write, error));
1539 }
1540 
1541 lldb::SBWatchpoint SBValue::WatchPointee(bool resolve_location, bool read,
1542  bool write, SBError &error) {
1544  (bool, bool, bool, lldb::SBError &), resolve_location,
1545  read, write, error);
1546 
1547  SBWatchpoint sb_watchpoint;
1548  if (IsInScope() && GetType().IsPointerType())
1549  sb_watchpoint = Dereference().Watch(resolve_location, read, write, error);
1550  return LLDB_RECORD_RESULT(sb_watchpoint);
1551 }
1552 
1555 
1556  ValueLocker locker;
1557  lldb::ValueObjectSP value_sp(GetSP(locker));
1558  SBValue persisted_sb;
1559  if (value_sp) {
1560  persisted_sb.SetSP(value_sp->Persist());
1561  }
1562  return LLDB_RECORD_RESULT(persisted_sb);
1563 }
1564 
1565 namespace lldb_private {
1566 namespace repro {
1567 
1568 template <>
1571  LLDB_REGISTER_CONSTRUCTOR(SBValue, (const lldb::ValueObjectSP &));
1574  SBValue, operator=,(const lldb::SBValue &));
1575  LLDB_REGISTER_METHOD(bool, SBValue, IsValid, ());
1576  LLDB_REGISTER_METHOD_CONST(bool, SBValue, operator bool, ());
1577  LLDB_REGISTER_METHOD(void, SBValue, Clear, ());
1580  LLDB_REGISTER_METHOD(const char *, SBValue, GetName, ());
1581  LLDB_REGISTER_METHOD(const char *, SBValue, GetTypeName, ());
1582  LLDB_REGISTER_METHOD(const char *, SBValue, GetDisplayTypeName, ());
1585  LLDB_REGISTER_METHOD(const char *, SBValue, GetValue, ());
1591  LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary, ());
1592  LLDB_REGISTER_METHOD(const char *, SBValue, GetSummary,
1594  LLDB_REGISTER_METHOD(const char *, SBValue, GetLocation, ());
1595  LLDB_REGISTER_METHOD(bool, SBValue, SetValueFromCString, (const char *));
1597  (const char *, lldb::SBError &));
1603  (const char *, uint32_t, lldb::SBType));
1606  (const char *, const char *));
1609  (const char *, const char *, lldb::SBExpressionOptions &));
1611  (const char *, lldb::addr_t, lldb::SBType));
1613  (const char *, lldb::SBData, lldb::SBType));
1616  (uint32_t, lldb::DynamicValueType, bool));
1618  (const char *));
1620  (const char *));
1622  (const char *, lldb::DynamicValueType));
1628  ());
1638  (const char *));
1640  (lldb::SBError &, int64_t));
1642  (lldb::SBError &, uint64_t));
1643  LLDB_REGISTER_METHOD(int64_t, SBValue, GetValueAsSigned, (int64_t));
1644  LLDB_REGISTER_METHOD(uint64_t, SBValue, GetValueAsUnsigned, (uint64_t));
1656  LLDB_REGISTER_METHOD_CONST(lldb::ValueObjectSP, SBValue, GetSP, ());
1659  (lldb::SBStream &, bool));
1661  (const char *));
1664  (const char *, const lldb::SBExpressionOptions &));
1667  (const char *, const lldb::SBExpressionOptions &, const char *));
1675  (uint32_t, uint32_t));
1678  (lldb::SBData &, lldb::SBError &));
1681  (bool, bool, bool, lldb::SBError &));
1683  (bool, bool, bool));
1685  (bool, bool, bool, lldb::SBError &));
1687 }
1688 
1689 }
1690 }
lldb::SBValue GetValueForExpressionPath(const char *expr_path)
Definition: SBValue.cpp:891
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:61
const char * GetTypeName()
Definition: SBValue.cpp:302
#define LLDB_WATCH_TYPE_READ
Definition: lldb-defines.h:57
lldb::SBAddress GetAddress()
Definition: SBValue.cpp:1352
bool IsInScope()
Definition: SBValue.cpp:342
The registry contains a unique mapping between functions and their ID.
An data extractor class.
Definition: DataExtractor.h:47
ValueImpl(lldb::ValueObjectSP in_valobj_sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name=NULL)
Definition: SBValue.cpp:58
lldb_private::EvaluateExpressionOptions & ref() const
Enumerations for broadcasting.
Definition: SBLaunchInfo.h:14
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
lldb::SBValue AddressOf()
Definition: SBValue.cpp:1307
lldb::SBValue Persist()
Definition: SBValue.cpp:1553
A stream class that can stream formatted output to a file.
Definition: Stream.h:28
Address is an address as found in an object or symbol file.
lldb::SBValue CreateValueFromData(const char *name, lldb::SBData data, lldb::SBType type)
Definition: SBValue.cpp:670
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition: SBFrame.cpp:88
void SetSP(const lldb::ProcessSP &process_sp)
Definition: SBProcess.cpp:108
lldb::addr_t GetLoadAddress(Target *target) const
Get the load address.
Definition: Address.cpp:292
void SetSP(const lldb::TypeFilterImplSP &typefilter_impl_sp)
StackFrameSP GetFrameSP()
Definition: SBValue.cpp:188
lldb::SBValue Dereference()
Definition: SBValue.cpp:1017
bool TypeIsPointerType()
Definition: SBValue.cpp:1032
int SetErrorStringWithFormat(const char *format,...) __attribute__((format(printf
Definition: SBError.cpp:131
const char * GetName()
Definition: SBValue.cpp:290
lldb_private::TypeSummaryOptions & ref()
uint32_t GetIndexOfChildWithName(const char *name)
Definition: SBValue.cpp:732
const char * GetDisplayTypeName()
Definition: SBValue.cpp:315
bool IsSyntheticChildrenGenerated()
Definition: SBValue.cpp:872
lldb::ValueObjectSP GetSP(Process::StopLocker &stop_locker, std::unique_lock< std::recursive_mutex > &lock, Status &error)
Definition: SBValue.cpp:108
void Clear()
Definition: SBError.cpp:47
bool IsValid()
Definition: SBValue.cpp:244
ValueImpl & operator=(const ValueImpl &rhs)
Definition: SBValue.cpp:76
void SetUseSynthetic(bool use_synthetic)
Definition: SBValue.cpp:157
lldb::SBValue CreateValueFromExpression(const char *name, const char *expression)
Definition: SBValue.cpp:615
void SetError(uint32_t err, lldb::ErrorType type)
Definition: SBError.cpp:97
"lldb/Target/ExecutionContext.h" A class that contains an execution context.
void SetUseDynamic(lldb::DynamicValueType use_dynamic)
Definition: SBValue.cpp:153
std::recursive_mutex & GetAPIMutex()
Definition: Target.h:539
bool IsDynamic()
Definition: SBValue.cpp:852
#define LLDB_INVALID_UID
Definition: lldb-defines.h:91
lldb::SBData GetData()
Get an SBData wrapping the contents of this SBValue.
Definition: SBValue.cpp:1401
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1117
bool SetLoadAddress(lldb::addr_t load_addr, Target *target, bool allow_section_end=false)
Set the address to represent load_addr.
Definition: Address.cpp:998
lldb::SBTypeFormat GetTypeFormat()
Definition: SBValue.cpp:509
void SetErrorString(const char *err_str)
Definition: SBError.cpp:124
lldb::SBType GetType()
Definition: SBValue.cpp:413
bool GetPreferSyntheticValue()
Definition: SBValue.cpp:836
bool IsSynthetic()
Definition: SBValue.cpp:862
ValueImpl()
Definition: SBValue.cpp:56
lldb::ValueObjectSP GetSP() const
Same as the protected version of GetSP that takes a locker, except that we make the locker locally in...
Definition: SBValue.cpp:1108
void SetSP(const lldb::TargetSP &target_sp)
Definition: SBTarget.cpp:602
bool GetValueDidChange()
Definition: SBValue.cpp:428
ValueImpl(const ValueImpl &rhs)
Definition: SBValue.cpp:72
bool IsRuntimeSupportValue()
Definition: SBValue.cpp:986
void SetKeepInMemory(bool keep=true)
Definition: Target.h:295
ValueObjectSP GetLockedSP(ValueImpl &in_value)
Definition: SBValue.cpp:206
#define UINT32_MAX
Definition: lldb-defines.h:31
FileSpec & GetFile()
Get accessor for file specification.
Definition: Declaration.h:148
const char * GetData()
Definition: SBStream.cpp:42
lldb::SBTypeSummary GetTypeSummary()
Definition: SBValue.cpp:525
uint64_t GetValueAsUnsigned(lldb::SBError &error, uint64_t fail_value=0)
Definition: SBValue.cpp:930
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
#define LLDB_INVALID_ADDRESS
Invalid value definitions.
Definition: lldb-defines.h:85
lldb::SBValue GetDynamicValue(lldb::DynamicValueType use_dynamic)
Definition: SBValue.cpp:781
uint64_t user_id_t
Definition: lldb-types.h:84
lldb::SBWatchpoint Watch(bool resolve_location, bool read, bool write, SBError &error)
Watch this value if it resides in memory.
Definition: SBValue.cpp:1467
void Clear()
Definition: SBValue.cpp:258
lldb::ValueObjectSP GetRootSP()
Definition: SBValue.cpp:106
Address is an address in the process that is running this code.
bool IsPointerType()
Definition: SBType.cpp:131
bool DumpStopContext(Stream *s, bool show_fullpaths) const
Definition: Declaration.cpp:42
lldb_private::Status & ref()
Definition: SBError.cpp:159
lldb::SBTarget GetTarget()
Definition: SBValue.cpp:1048
void SetFormat(lldb::Format format)
Definition: SBValue.cpp:1298
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
ProcessSP GetProcessSP()
Definition: SBValue.cpp:174
void Printf(const char *format,...) __attribute__((format(printf
Definition: SBStream.cpp:62
lldb_private::DataExtractor * get() const
Definition: SBData.cpp:50
lldb::SBValue GetChildAtIndex(uint32_t idx)
Definition: SBValue.cpp:691
lldb::SBTypeSynthetic GetTypeSynthetic()
Definition: SBValue.cpp:561
lldb::TypeImplSP GetSP()
Definition: SBType.cpp:76
lldb::SBTypeFilter GetTypeFilter()
Definition: SBValue.cpp:541
llvm::StringRef GetString() const
ValueType GetValueType()
Definition: SBValue.cpp:369
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
void SetErrorString(llvm::StringRef err_str)
Set the current error string to err_str.
Definition: Status.cpp:241
lldb::DynamicValueType GetFetchDynamicValue() const
bool GetDescription(lldb::SBStream &description)
Definition: SBValue.cpp:1272
void SetSyntheticChildrenGenerated(bool)
Definition: SBValue.cpp:882
void SetSP(const lldb::TypeSummaryImplSP &typefilter_impl_sp)
void SetSP(const lldb::WatchpointSP &sp)
int64_t GetValueAsSigned(lldb::SBError &error, int64_t fail_value=0)
Definition: SBValue.cpp:909
bool GetExpressionPath(lldb::SBStream &description)
Definition: SBValue.cpp:1169
bool Success() const
Test for success condition.
Definition: Status.cpp:287
lldb::addr_t GetLoadAddress()
Definition: SBValue.cpp:1322
A section + offset based address class.
Definition: Address.h:80
class LLDB_API SBAddress
Definition: SBDefines.h:22
lldb::SBWatchpoint WatchPointee(bool resolve_location, bool read, bool write, SBError &error)
Watch this value that this value points to in memory.
Definition: SBValue.cpp:1541
lldb_private::Stream & ref()
Definition: SBStream.cpp:162
size_t GetByteSize()
Definition: SBValue.cpp:328
bool SetValueFromCString(const char *value_str)
Definition: SBValue.cpp:485
bool MightHaveChildren()
Find out if a SBValue might have children.
Definition: SBValue.cpp:974
lldb::SBData GetPointeeData(uint32_t item_idx=0, uint32_t item_count=1)
Get an SBData wrapping what this SBValue points to.
Definition: SBValue.cpp:1381
const char * GetTypeValidatorResult()
Definition: SBValue.cpp:394
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
lldb::SBValue EvaluateExpression(const char *expr) const
Definition: SBValue.cpp:1196
const char * GetSummary()
Definition: SBValue.cpp:442
void SetPreferSyntheticValue(bool use_synthetic)
Definition: SBValue.cpp:844
lldb::SBProcess GetProcess()
Definition: SBValue.cpp:1061
lldb::SBValue Cast(lldb::SBType type)
Definition: SBValue.cpp:602
ThreadSP GetThreadSP()
Definition: SBValue.cpp:181
const char * GetLocation()
Definition: SBValue.cpp:472
uint64_t addr_t
Definition: lldb-types.h:83
A uniqued constant string class.
Definition: ConstString.h:38
lldb::SBDeclaration GetDeclaration()
Definition: SBValue.cpp:1453
Definition: SBAddress.h:15
void * GetOpaqueType()
Definition: SBValue.cpp:1038
const char * GetObjectDescription()
Definition: SBValue.cpp:381
void SetPreferDynamicValue(lldb::DynamicValueType use_dynamic)
Definition: SBValue.cpp:828
void SetIgnoreBreakpoints(bool ignore=true)
SharingPtr< T > static_pointer_cast(const SharingPtr< U > &r)
Definition: SharingPtr.h:355
lldb::Format GetFormat()
Definition: SBValue.cpp:1288
lldb::DynamicValueType GetUseDynamic()
Definition: SBValue.cpp:159
bool SetData(lldb::SBData &data, lldb::SBError &error)
Definition: SBValue.cpp:1418
#define LLDB_WATCH_TYPE_WRITE
Definition: lldb-defines.h:58
void SetSP(const lldb::TypeFormatImplSP &typeformat_impl_sp)
TargetSP GetTargetSP()
Definition: SBValue.cpp:167
bool GetUseSynthetic()
Definition: SBValue.cpp:161
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
lldb::SBValue GetNonSyntheticValue()
Definition: SBValue.cpp:807
lldb::SBValue CreateChildAtOffset(const char *name, uint32_t offset, lldb::SBType type)
Definition: SBValue.cpp:581
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
void SetSP(const lldb::ScriptedSyntheticChildrenSP &typefilter_impl_sp)
lldb::SBValue GetChildMemberWithName(const char *name)
Definition: SBValue.cpp:745
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
lldb::DynamicValueType GetPreferDynamicValue()
Definition: SBValue.cpp:819
Status & GetError()
Definition: SBValue.cpp:210
const char * AsCString(const char *default_error_str="unknown error") const
Get the error string associated with the current error.
Definition: Status.cpp:130
Address is an address as in the current target inferior process.
bool IsValid() const
Definition: SBType.cpp:108
lldb::SBValue & operator=(const lldb::SBValue &rhs)
Definition: SBValue.cpp:232
lldb::SBThread GetThread()
Definition: SBValue.cpp:1074
A class that describes the declaration location of a lldb object.
Definition: Declaration.h:24
uint32_t GetNumChildren()
Definition: SBValue.cpp:998
lldb::SBValue GetStaticValue()
Definition: SBValue.cpp:794
lldb::user_id_t GetID()
Definition: SBValue.cpp:280
#define LLDB_RECORD_RESULT(Result)
void SetSP(const lldb::TypeImplSP &type_impl_sp)
Definition: SBType.cpp:78
void RegisterMethods< SBValue >(Registry &R)
Definition: SBValue.cpp:1569
This base class provides an interface to stack frames.
Definition: StackFrame.h:40
const char * GetValue()
Definition: SBValue.cpp:356
SBError GetError()
Definition: SBValue.cpp:264
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
void SetUnwindOnError(bool unwind=true)
An error handling class.
Definition: Status.h:44
bool IsValid()
Definition: SBValue.cpp:86
lldb::SBFrame GetFrame()
Definition: SBValue.cpp:1087
lldb::SBValue CreateValueFromAddress(const char *name, lldb::addr_t address, lldb::SBType type)
Definition: SBValue.cpp:648