blob: e383f4ca9194e91b4d17ac7e6ae3d8f7b3b3d0d0 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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
Daniel Malea93a64302012-12-05 00:20:57 +000010#include "lldb/lldb-python.h"
11
Eli Friedman4c5de692010-06-09 07:44:37 +000012#include "lldb/API/SBValue.h"
Enrico Granata864e3e82012-02-17 03:18:30 +000013
Enrico Granata10de0902012-10-10 22:54:17 +000014#include "lldb/API/SBDeclaration.h"
Caroline Ticedde9cff2010-09-20 05:20:02 +000015#include "lldb/API/SBStream.h"
Enrico Granata864e3e82012-02-17 03:18:30 +000016#include "lldb/API/SBTypeFilter.h"
17#include "lldb/API/SBTypeFormat.h"
18#include "lldb/API/SBTypeSummary.h"
19#include "lldb/API/SBTypeSynthetic.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020
Johnny Chen01a67862011-10-14 00:42:25 +000021#include "lldb/Breakpoint/Watchpoint.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000022#include "lldb/Core/DataExtractor.h"
Caroline Ticeceb6b132010-10-26 03:11:13 +000023#include "lldb/Core/Log.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000024#include "lldb/Core/Module.h"
Greg Claytonfe42ac42011-08-03 22:57:10 +000025#include "lldb/Core/Scalar.h"
Greg Clayton1f746072012-08-29 21:13:06 +000026#include "lldb/Core/Section.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000027#include "lldb/Core/Stream.h"
28#include "lldb/Core/StreamFile.h"
29#include "lldb/Core/Value.h"
30#include "lldb/Core/ValueObject.h"
Enrico Granata6f3533f2011-07-29 19:53:35 +000031#include "lldb/Core/ValueObjectConstResult.h"
Enrico Granata5548cb52013-01-28 23:47:25 +000032#include "lldb/DataFormatters/DataVisualization.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000033#include "lldb/Symbol/Block.h"
Enrico Granata10de0902012-10-10 22:54:17 +000034#include "lldb/Symbol/Declaration.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000035#include "lldb/Symbol/ObjectFile.h"
Greg Clayton81e871e2012-02-04 02:27:34 +000036#include "lldb/Symbol/Type.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000037#include "lldb/Symbol/Variable.h"
Johnny Chen01a67862011-10-14 00:42:25 +000038#include "lldb/Symbol/VariableList.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000039#include "lldb/Target/ExecutionContext.h"
40#include "lldb/Target/Process.h"
Jason Molendab57e4a12013-11-04 09:33:30 +000041#include "lldb/Target/StackFrame.h"
Greg Claytonaf67cec2010-12-20 20:49:23 +000042#include "lldb/Target/Target.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000043#include "lldb/Target/Thread.h"
44
Jim Ingham35e1bda2012-10-16 21:41:58 +000045#include "lldb/API/SBDebugger.h"
46#include "lldb/API/SBExpressionOptions.h"
47#include "lldb/API/SBFrame.h"
Eli Friedman4c5de692010-06-09 07:44:37 +000048#include "lldb/API/SBProcess.h"
49#include "lldb/API/SBTarget.h"
50#include "lldb/API/SBThread.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000051
52using namespace lldb;
53using namespace lldb_private;
54
Enrico Granata19f0e8c2013-04-22 22:57:56 +000055class ValueImpl
56{
57public:
58 ValueImpl ()
Enrico Granatae3e91512012-10-22 18:18:36 +000059 {
Enrico Granata19f0e8c2013-04-22 22:57:56 +000060 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +000061
Jim Ingham362e39a2013-05-15 02:16:21 +000062 ValueImpl (lldb::ValueObjectSP in_valobj_sp,
Enrico Granata19f0e8c2013-04-22 22:57:56 +000063 lldb::DynamicValueType use_dynamic,
Jim Ingham362e39a2013-05-15 02:16:21 +000064 bool use_synthetic,
65 const char *name = NULL) :
Daniel Maleae0f8f572013-08-26 23:57:52 +000066 m_valobj_sp(in_valobj_sp),
67 m_use_dynamic(use_dynamic),
68 m_use_synthetic(use_synthetic),
69 m_name (name)
Enrico Granata19f0e8c2013-04-22 22:57:56 +000070 {
Jim Ingham362e39a2013-05-15 02:16:21 +000071 if (!m_name.IsEmpty() && m_valobj_sp)
72 m_valobj_sp->SetName(m_name);
Enrico Granata19f0e8c2013-04-22 22:57:56 +000073 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +000074
Enrico Granata19f0e8c2013-04-22 22:57:56 +000075 ValueImpl (const ValueImpl& rhs) :
Daniel Maleae0f8f572013-08-26 23:57:52 +000076 m_valobj_sp(rhs.m_valobj_sp),
77 m_use_dynamic(rhs.m_use_dynamic),
78 m_use_synthetic(rhs.m_use_synthetic),
79 m_name (rhs.m_name)
Enrico Granata19f0e8c2013-04-22 22:57:56 +000080 {
81 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +000082
Enrico Granata19f0e8c2013-04-22 22:57:56 +000083 ValueImpl &
84 operator = (const ValueImpl &rhs)
85 {
86 if (this != &rhs)
Enrico Granatae3e91512012-10-22 18:18:36 +000087 {
Jim Ingham362e39a2013-05-15 02:16:21 +000088 m_valobj_sp = rhs.m_valobj_sp;
Enrico Granata19f0e8c2013-04-22 22:57:56 +000089 m_use_dynamic = rhs.m_use_dynamic;
90 m_use_synthetic = rhs.m_use_synthetic;
Jim Ingham362e39a2013-05-15 02:16:21 +000091 m_name = rhs.m_name;
Enrico Granatae3e91512012-10-22 18:18:36 +000092 }
Enrico Granata19f0e8c2013-04-22 22:57:56 +000093 return *this;
94 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +000095
Enrico Granata19f0e8c2013-04-22 22:57:56 +000096 bool
97 IsValid ()
98 {
Jim Ingham793d8d92013-12-06 22:21:04 +000099 if (m_valobj_sp.get() == NULL)
100 return false;
101 else
102 {
103 // FIXME: This check is necessary but not sufficient. We for sure don't want to touch SBValues whose owning
104 // targets have gone away. This check is a little weak in that it enforces that restriction when you call
105 // IsValid, but since IsValid doesn't lock the target, you have no guarantee that the SBValue won't go
106 // invalid after you call this...
107 // Also, an SBValue could depend on data from one of the modules in the target, and those could go away
108 // independently of the target, for instance if a module is unloaded. But right now, neither SBValues
109 // nor ValueObjects know which modules they depend on. So I have no good way to make that check without
110 // tracking that in all the ValueObject subclasses.
111 TargetSP target_sp = m_valobj_sp->GetTargetSP();
112 if (target_sp && target_sp->IsValid())
113 return true;
114 else
115 return false;
116 }
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000117 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000118
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000119 lldb::ValueObjectSP
120 GetRootSP ()
121 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000122 return m_valobj_sp;
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000123 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000124
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000125 lldb::ValueObjectSP
Jim Ingham362e39a2013-05-15 02:16:21 +0000126 GetSP (Process::StopLocker &stop_locker, Mutex::Locker &api_locker, Error &error)
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000127 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000128 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
129 if (!m_valobj_sp)
130 {
131 error.SetErrorString("invalid value object");
132 return m_valobj_sp;
133 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000134
Jim Ingham362e39a2013-05-15 02:16:21 +0000135 lldb::ValueObjectSP value_sp = m_valobj_sp;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000136
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000137 Target *target = value_sp->GetTargetSP().get();
138 if (target)
Jim Ingham362e39a2013-05-15 02:16:21 +0000139 api_locker.Lock(target->GetAPIMutex());
Jim Ingham793d8d92013-12-06 22:21:04 +0000140 else
141 return ValueObjectSP();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000142
Jim Ingham362e39a2013-05-15 02:16:21 +0000143 ProcessSP process_sp(value_sp->GetProcessSP());
144 if (process_sp && !stop_locker.TryLock (&process_sp->GetRunLock()))
145 {
146 // We don't allow people to play around with ValueObject if the process is running.
147 // If you want to look at values, pause the process, then look.
148 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000149 log->Printf ("SBValue(%p)::GetSP() => error: process is running",
150 static_cast<void*>(value_sp.get()));
Jim Ingham362e39a2013-05-15 02:16:21 +0000151 error.SetErrorString ("process must be stopped.");
152 return ValueObjectSP();
153 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000154
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000155 if (value_sp->GetDynamicValue(m_use_dynamic))
156 value_sp = value_sp->GetDynamicValue(m_use_dynamic);
157 if (value_sp->GetSyntheticValue(m_use_synthetic))
158 value_sp = value_sp->GetSyntheticValue(m_use_synthetic);
Jim Ingham362e39a2013-05-15 02:16:21 +0000159 if (!value_sp)
160 error.SetErrorString("invalid value object");
161 if (!m_name.IsEmpty())
162 value_sp->SetName(m_name);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000163
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000164 return value_sp;
165 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000166
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000167 void
168 SetUseDynamic (lldb::DynamicValueType use_dynamic)
169 {
170 m_use_dynamic = use_dynamic;
171 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000172
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000173 void
174 SetUseSynthetic (bool use_synthetic)
175 {
176 m_use_synthetic = use_synthetic;
177 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000178
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000179 lldb::DynamicValueType
180 GetUseDynamic ()
181 {
182 return m_use_dynamic;
183 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000184
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000185 bool
186 GetUseSynthetic ()
187 {
188 return m_use_synthetic;
189 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000190
Jim Ingham362e39a2013-05-15 02:16:21 +0000191 // All the derived values that we would make from the m_valobj_sp will share
192 // the ExecutionContext with m_valobj_sp, so we don't need to do the calculations
193 // in GetSP to return the Target, Process, Thread or Frame. It is convenient to
194 // provide simple accessors for these, which I do here.
195 TargetSP
196 GetTargetSP ()
197 {
198 if (m_valobj_sp)
199 return m_valobj_sp->GetTargetSP();
200 else
201 return TargetSP();
202 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000203
Jim Ingham362e39a2013-05-15 02:16:21 +0000204 ProcessSP
205 GetProcessSP ()
206 {
207 if (m_valobj_sp)
208 return m_valobj_sp->GetProcessSP();
209 else
210 return ProcessSP();
211 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000212
Jim Ingham362e39a2013-05-15 02:16:21 +0000213 ThreadSP
214 GetThreadSP ()
215 {
216 if (m_valobj_sp)
217 return m_valobj_sp->GetThreadSP();
218 else
219 return ThreadSP();
220 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000221
Jason Molendab57e4a12013-11-04 09:33:30 +0000222 StackFrameSP
Jim Ingham362e39a2013-05-15 02:16:21 +0000223 GetFrameSP ()
224 {
225 if (m_valobj_sp)
226 return m_valobj_sp->GetFrameSP();
227 else
Jason Molendab57e4a12013-11-04 09:33:30 +0000228 return StackFrameSP();
Jim Ingham362e39a2013-05-15 02:16:21 +0000229 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000230
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000231private:
Jim Ingham362e39a2013-05-15 02:16:21 +0000232 lldb::ValueObjectSP m_valobj_sp;
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000233 lldb::DynamicValueType m_use_dynamic;
234 bool m_use_synthetic;
Jim Ingham362e39a2013-05-15 02:16:21 +0000235 ConstString m_name;
236};
237
238class ValueLocker
239{
240public:
241 ValueLocker ()
242 {
243 }
244
245 ValueObjectSP
246 GetLockedSP(ValueImpl &in_value)
247 {
248 return in_value.GetSP(m_stop_locker, m_api_locker, m_lock_error);
249 }
Daniel Maleae0f8f572013-08-26 23:57:52 +0000250
Jim Ingham362e39a2013-05-15 02:16:21 +0000251 Error &
252 GetError()
253 {
254 return m_lock_error;
255 }
256
257private:
258 Process::StopLocker m_stop_locker;
259 Mutex::Locker m_api_locker;
260 Error m_lock_error;
Daniel Maleae0f8f572013-08-26 23:57:52 +0000261
Enrico Granata19f0e8c2013-04-22 22:57:56 +0000262};
Enrico Granatae3e91512012-10-22 18:18:36 +0000263
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000264SBValue::SBValue () :
Daniel Maleae0f8f572013-08-26 23:57:52 +0000265m_opaque_sp ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000266{
267}
268
Enrico Granatac5bc4122012-03-27 02:35:13 +0000269SBValue::SBValue (const lldb::ValueObjectSP &value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000270{
Enrico Granatae3e91512012-10-22 18:18:36 +0000271 SetSP(value_sp);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000272}
273
Enrico Granatac5bc4122012-03-27 02:35:13 +0000274SBValue::SBValue(const SBValue &rhs)
Greg Claytonefabb122010-11-05 23:17:00 +0000275{
Enrico Granatae3e91512012-10-22 18:18:36 +0000276 SetSP(rhs.m_opaque_sp);
Greg Claytonefabb122010-11-05 23:17:00 +0000277}
278
Greg Claytonbf2331c2011-09-09 23:04:00 +0000279SBValue &
Greg Claytonefabb122010-11-05 23:17:00 +0000280SBValue::operator = (const SBValue &rhs)
281{
282 if (this != &rhs)
Enrico Granatac5bc4122012-03-27 02:35:13 +0000283 {
Enrico Granatae3e91512012-10-22 18:18:36 +0000284 SetSP(rhs.m_opaque_sp);
Enrico Granatac5bc4122012-03-27 02:35:13 +0000285 }
Greg Claytonefabb122010-11-05 23:17:00 +0000286 return *this;
287}
288
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000289SBValue::~SBValue()
290{
291}
292
293bool
Greg Claytonbf2331c2011-09-09 23:04:00 +0000294SBValue::IsValid ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000295{
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000296 // If this function ever changes to anything that does more than just
297 // check if the opaque shared pointer is non NULL, then we need to update
298 // all "if (m_opaque_sp)" code in this file.
Jim Ingham793d8d92013-12-06 22:21:04 +0000299 return m_opaque_sp.get() != NULL && m_opaque_sp->IsValid() && m_opaque_sp->GetRootSP().get() != NULL;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000300}
301
Jim Ingham5d3bca42011-12-19 20:39:44 +0000302void
303SBValue::Clear()
304{
305 m_opaque_sp.reset();
306}
307
Greg Clayton524e60b2010-10-06 22:10:17 +0000308SBError
309SBValue::GetError()
310{
311 SBError sb_error;
312
Jim Ingham362e39a2013-05-15 02:16:21 +0000313 ValueLocker locker;
314 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000315 if (value_sp)
316 sb_error.SetError(value_sp->GetError());
Greg Claytonb9556ac2012-01-30 07:41:31 +0000317 else
Jim Ingham362e39a2013-05-15 02:16:21 +0000318 sb_error.SetErrorStringWithFormat ("error: %s", locker.GetError().AsCString());
Greg Clayton524e60b2010-10-06 22:10:17 +0000319
320 return sb_error;
321}
322
Johnny Chenb0b8be72011-07-07 20:46:23 +0000323user_id_t
324SBValue::GetID()
325{
Jim Ingham362e39a2013-05-15 02:16:21 +0000326 ValueLocker locker;
327 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000328 if (value_sp)
329 return value_sp->GetID();
Johnny Chenb0b8be72011-07-07 20:46:23 +0000330 return LLDB_INVALID_UID;
331}
332
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000333const char *
334SBValue::GetName()
335{
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000336 const char *name = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000337 ValueLocker locker;
338 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000339 if (value_sp)
340 name = value_sp->GetName().GetCString();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000341
Greg Clayton5160ce52013-03-27 23:08:40 +0000342 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton93aa84e2010-10-29 04:59:35 +0000343 if (log)
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000344 {
345 if (name)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000346 log->Printf ("SBValue(%p)::GetName () => \"%s\"",
347 static_cast<void*>(value_sp.get()), name);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000348 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000349 log->Printf ("SBValue(%p)::GetName () => NULL",
350 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000351 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000352
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000353 return name;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000354}
355
356const char *
357SBValue::GetTypeName ()
358{
Greg Clayton5160ce52013-03-27 23:08:40 +0000359 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000360 const char *name = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000361 ValueLocker locker;
362 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000363 if (value_sp)
Jim Ingham48cdc582012-08-21 01:46:35 +0000364 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000365 name = value_sp->GetQualifiedTypeName().GetCString();
Jim Ingham48cdc582012-08-21 01:46:35 +0000366 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000367
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000368 if (log)
369 {
370 if (name)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000371 log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"",
372 static_cast<void*>(value_sp.get()), name);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000373 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000374 log->Printf ("SBValue(%p)::GetTypeName () => NULL",
375 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000376 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000377
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000378 return name;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000379}
380
Enrico Granatae8daa2f2014-05-17 19:14:17 +0000381const char *
382SBValue::GetDisplayTypeName ()
383{
384 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
385 const char *name = NULL;
386 ValueLocker locker;
387 lldb::ValueObjectSP value_sp(GetSP(locker));
388 if (value_sp)
389 {
390 name = value_sp->GetDisplayTypeName().GetCString();
391 }
392
393 if (log)
394 {
395 if (name)
396 log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"",
397 static_cast<void*>(value_sp.get()), name);
398 else
399 log->Printf ("SBValue(%p)::GetTypeName () => NULL",
400 static_cast<void*>(value_sp.get()));
401 }
402
403 return name;
404}
405
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000406size_t
407SBValue::GetByteSize ()
408{
Greg Clayton5160ce52013-03-27 23:08:40 +0000409 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000410 size_t result = 0;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000411
Jim Ingham362e39a2013-05-15 02:16:21 +0000412 ValueLocker locker;
413 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000414 if (value_sp)
Jim Ingham48cdc582012-08-21 01:46:35 +0000415 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000416 result = value_sp->GetByteSize();
Jim Ingham48cdc582012-08-21 01:46:35 +0000417 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000418
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000419 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000420 log->Printf ("SBValue(%p)::GetByteSize () => %" PRIu64,
421 static_cast<void*>(value_sp.get()),
422 static_cast<uint64_t>(result));
423
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000424 return result;
425}
426
427bool
Jim Ingham6035b672011-03-31 00:19:25 +0000428SBValue::IsInScope ()
429{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000430 bool result = false;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000431
Jim Ingham362e39a2013-05-15 02:16:21 +0000432 ValueLocker locker;
433 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000434 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000435 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000436 result = value_sp->IsInScope ();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000437 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000438
Greg Clayton5160ce52013-03-27 23:08:40 +0000439 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000440 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000441 log->Printf ("SBValue(%p)::IsInScope () => %i",
442 static_cast<void*>(value_sp.get()), result);
443
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000444 return result;
445}
446
447const char *
Jim Ingham6035b672011-03-31 00:19:25 +0000448SBValue::GetValue ()
449{
Greg Clayton5160ce52013-03-27 23:08:40 +0000450 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000451
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000452 const char *cstr = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000453 ValueLocker locker;
454 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000455 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000456 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000457 cstr = value_sp->GetValueAsCString ();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000458 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000459 if (log)
460 {
461 if (cstr)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000462 log->Printf ("SBValue(%p)::GetValue() => \"%s\"",
463 static_cast<void*>(value_sp.get()), cstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000464 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000465 log->Printf ("SBValue(%p)::GetValue() => NULL",
466 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000467 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000468
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000469 return cstr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000470}
471
Greg Clayton73b472d2010-10-27 03:32:59 +0000472ValueType
473SBValue::GetValueType ()
474{
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000475 ValueType result = eValueTypeInvalid;
Jim Ingham362e39a2013-05-15 02:16:21 +0000476 ValueLocker locker;
477 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000478 if (value_sp)
479 result = value_sp->GetValueType();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000480
Greg Clayton5160ce52013-03-27 23:08:40 +0000481 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000482 if (log)
483 {
484 switch (result)
485 {
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000486 case eValueTypeInvalid:
487 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid",
488 static_cast<void*>(value_sp.get()));
489 break;
490 case eValueTypeVariableGlobal:
491 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal",
492 static_cast<void*>(value_sp.get()));
493 break;
494 case eValueTypeVariableStatic:
495 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic",
496 static_cast<void*>(value_sp.get()));
497 break;
498 case eValueTypeVariableArgument:
499 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument",
500 static_cast<void*>(value_sp.get()));
501 break;
502 case eValueTypeVariableLocal:
503 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal",
504 static_cast<void*>(value_sp.get()));
505 break;
506 case eValueTypeRegister:
507 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister",
508 static_cast<void*>(value_sp.get()));
509 break;
510 case eValueTypeRegisterSet:
511 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet",
512 static_cast<void*>(value_sp.get()));
513 break;
514 case eValueTypeConstResult:
515 log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult",
516 static_cast<void*>(value_sp.get()));
517 break;
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000518 }
519 }
520 return result;
Greg Clayton73b472d2010-10-27 03:32:59 +0000521}
522
Jim Ingham53c47f12010-09-10 23:12:17 +0000523const char *
Jim Ingham6035b672011-03-31 00:19:25 +0000524SBValue::GetObjectDescription ()
525{
Greg Clayton5160ce52013-03-27 23:08:40 +0000526 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000527 const char *cstr = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000528 ValueLocker locker;
529 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000530 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000531 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000532 cstr = value_sp->GetObjectDescription ();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000533 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000534 if (log)
535 {
536 if (cstr)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000537 log->Printf ("SBValue(%p)::GetObjectDescription() => \"%s\"",
538 static_cast<void*>(value_sp.get()), cstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000539 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000540 log->Printf ("SBValue(%p)::GetObjectDescription() => NULL",
541 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000542 }
543 return cstr;
Jim Ingham53c47f12010-09-10 23:12:17 +0000544}
545
Enrico Granataedc44142014-09-06 01:30:04 +0000546const char *
547SBValue::GetTypeValidatorResult ()
548{
549 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
550 const char *cstr = NULL;
551 ValueLocker locker;
552 lldb::ValueObjectSP value_sp(GetSP(locker));
553 if (value_sp)
554 {
555 const auto& validation(value_sp->GetValidationStatus());
556 if (TypeValidatorResult::Failure == validation.first)
557 {
558 if (validation.second.empty())
559 cstr = "unknown error";
560 else
561 cstr = validation.second.c_str();
562 }
563 }
564 if (log)
565 {
566 if (cstr)
567 log->Printf ("SBValue(%p)::GetTypeValidatorResult() => \"%s\"",
568 static_cast<void*>(value_sp.get()), cstr);
569 else
570 log->Printf ("SBValue(%p)::GetTypeValidatorResult() => NULL",
571 static_cast<void*>(value_sp.get()));
572 }
573 return cstr;
574}
575
Enrico Granata6f3533f2011-07-29 19:53:35 +0000576SBType
577SBValue::GetType()
578{
Greg Clayton5160ce52013-03-27 23:08:40 +0000579 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton81e871e2012-02-04 02:27:34 +0000580 SBType sb_type;
Jim Ingham362e39a2013-05-15 02:16:21 +0000581 ValueLocker locker;
582 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000583 TypeImplSP type_sp;
584 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000585 {
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000586 type_sp.reset (new TypeImpl(value_sp->GetTypeImpl()));
Jim Ingham362e39a2013-05-15 02:16:21 +0000587 sb_type.SetSP(type_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000588 }
Enrico Granata6f3533f2011-07-29 19:53:35 +0000589 if (log)
590 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000591 if (type_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000592 log->Printf ("SBValue(%p)::GetType => SBType(%p)",
593 static_cast<void*>(value_sp.get()),
594 static_cast<void*>(type_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000595 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000596 log->Printf ("SBValue(%p)::GetType => NULL",
597 static_cast<void*>(value_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000598 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000599 return sb_type;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000600}
601
Jim Ingham6035b672011-03-31 00:19:25 +0000602bool
603SBValue::GetValueDidChange ()
604{
Greg Clayton5160ce52013-03-27 23:08:40 +0000605 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000606 bool result = false;
Jim Ingham362e39a2013-05-15 02:16:21 +0000607 ValueLocker locker;
608 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000609 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000610 {
Ilia K761a7a42015-02-06 18:10:30 +0000611 if (value_sp->UpdateValueIfNeeded(false))
612 result = value_sp->GetValueDidChange ();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000613 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000614 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000615 log->Printf ("SBValue(%p)::GetValueDidChange() => %i",
616 static_cast<void*>(value_sp.get()), result);
617
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000618 return result;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000619}
620
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000621#ifndef LLDB_DISABLE_PYTHON
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000622const char *
Jim Ingham6035b672011-03-31 00:19:25 +0000623SBValue::GetSummary ()
624{
Greg Clayton5160ce52013-03-27 23:08:40 +0000625 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000626 const char *cstr = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000627 ValueLocker locker;
628 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000629 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000630 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000631 cstr = value_sp->GetSummaryAsCString();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000632 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000633 if (log)
634 {
635 if (cstr)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000636 log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
637 static_cast<void*>(value_sp.get()), cstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000638 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000639 log->Printf ("SBValue(%p)::GetSummary() => NULL",
640 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000641 }
642 return cstr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000643}
Enrico Granatac1247f52014-11-06 21:23:20 +0000644
645const char *
Enrico Granata49bfafb2014-11-18 23:36:25 +0000646SBValue::GetSummary (lldb::SBStream& stream,
647 lldb::SBTypeSummaryOptions& options)
Enrico Granatac1247f52014-11-06 21:23:20 +0000648{
649 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granatac1247f52014-11-06 21:23:20 +0000650 ValueLocker locker;
651 lldb::ValueObjectSP value_sp(GetSP(locker));
652 if (value_sp)
653 {
Enrico Granata49bfafb2014-11-18 23:36:25 +0000654 std::string buffer;
655 if (value_sp->GetSummaryAsCString(buffer,options.ref()) && !buffer.empty())
656 stream.Printf("%s",buffer.c_str());
Enrico Granatac1247f52014-11-06 21:23:20 +0000657 }
Enrico Granata49bfafb2014-11-18 23:36:25 +0000658 const char* cstr = stream.GetData();
Enrico Granatac1247f52014-11-06 21:23:20 +0000659 if (log)
660 {
661 if (cstr)
662 log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
663 static_cast<void*>(value_sp.get()), cstr);
664 else
665 log->Printf ("SBValue(%p)::GetSummary() => NULL",
666 static_cast<void*>(value_sp.get()));
667 }
668 return cstr;
669}
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000670#endif // LLDB_DISABLE_PYTHON
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000671
672const char *
Jim Ingham6035b672011-03-31 00:19:25 +0000673SBValue::GetLocation ()
674{
Greg Clayton5160ce52013-03-27 23:08:40 +0000675 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000676 const char *cstr = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000677 ValueLocker locker;
678 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000679 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000680 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000681 cstr = value_sp->GetLocationAsCString();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000682 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000683 if (log)
684 {
685 if (cstr)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000686 log->Printf ("SBValue(%p)::GetLocation() => \"%s\"",
687 static_cast<void*>(value_sp.get()), cstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000688 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000689 log->Printf ("SBValue(%p)::GetLocation() => NULL",
690 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000691 }
692 return cstr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000693}
694
Enrico Granata07a4ac22012-05-08 21:25:06 +0000695// Deprecated - use the one that takes an lldb::SBError
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000696bool
Jim Ingham6035b672011-03-31 00:19:25 +0000697SBValue::SetValueFromCString (const char *value_str)
698{
Enrico Granata07a4ac22012-05-08 21:25:06 +0000699 lldb::SBError dummy;
700 return SetValueFromCString(value_str,dummy);
701}
702
703bool
704SBValue::SetValueFromCString (const char *value_str, lldb::SBError& error)
705{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000706 bool success = false;
Jim Ingham362e39a2013-05-15 02:16:21 +0000707 ValueLocker locker;
708 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton5160ce52013-03-27 23:08:40 +0000709 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton81e871e2012-02-04 02:27:34 +0000710 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000711 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000712 success = value_sp->SetValueFromCString (value_str,error.ref());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000713 }
Jim Ingham362e39a2013-05-15 02:16:21 +0000714 else
715 error.SetErrorStringWithFormat ("Could not get value: %s", locker.GetError().AsCString());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000716
Greg Claytonc9858e42012-04-06 02:17:47 +0000717 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000718 log->Printf ("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
719 static_cast<void*>(value_sp.get()), value_str, success);
720
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000721 return success;
722}
723
Enrico Granata864e3e82012-02-17 03:18:30 +0000724lldb::SBTypeFormat
725SBValue::GetTypeFormat ()
726{
727 lldb::SBTypeFormat format;
Jim Ingham362e39a2013-05-15 02:16:21 +0000728 ValueLocker locker;
729 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000730 if (value_sp)
731 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000732 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000733 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000734 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
735 if (format_sp)
736 format.SetSP(format_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000737 }
738 }
739 return format;
740}
741
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000742#ifndef LLDB_DISABLE_PYTHON
Enrico Granata864e3e82012-02-17 03:18:30 +0000743lldb::SBTypeSummary
744SBValue::GetTypeSummary ()
745{
746 lldb::SBTypeSummary summary;
Jim Ingham362e39a2013-05-15 02:16:21 +0000747 ValueLocker locker;
748 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000749 if (value_sp)
750 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000751 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000752 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000753 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
754 if (summary_sp)
755 summary.SetSP(summary_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000756 }
757 }
758 return summary;
759}
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000760#endif // LLDB_DISABLE_PYTHON
Enrico Granata864e3e82012-02-17 03:18:30 +0000761
762lldb::SBTypeFilter
763SBValue::GetTypeFilter ()
764{
765 lldb::SBTypeFilter filter;
Jim Ingham362e39a2013-05-15 02:16:21 +0000766 ValueLocker locker;
767 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000768 if (value_sp)
769 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000770 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000771 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000772 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
773
774 if (synthetic_sp && !synthetic_sp->IsScripted())
Enrico Granata864e3e82012-02-17 03:18:30 +0000775 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000776 TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
777 filter.SetSP(filter_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000778 }
779 }
780 }
781 return filter;
782}
783
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000784#ifndef LLDB_DISABLE_PYTHON
Enrico Granata864e3e82012-02-17 03:18:30 +0000785lldb::SBTypeSynthetic
786SBValue::GetTypeSynthetic ()
787{
788 lldb::SBTypeSynthetic synthetic;
Jim Ingham362e39a2013-05-15 02:16:21 +0000789 ValueLocker locker;
790 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000791 if (value_sp)
792 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000793 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000794 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000795 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
796
797 if (children_sp && children_sp->IsScripted())
Enrico Granata864e3e82012-02-17 03:18:30 +0000798 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000799 ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
800 synthetic.SetSP(synth_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000801 }
802 }
803 }
804 return synthetic;
805}
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000806#endif
Enrico Granata864e3e82012-02-17 03:18:30 +0000807
Enrico Granata6f3533f2011-07-29 19:53:35 +0000808lldb::SBValue
Greg Claytonbf2331c2011-09-09 23:04:00 +0000809SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000810{
Greg Clayton81e871e2012-02-04 02:27:34 +0000811 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000812 ValueLocker locker;
813 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000814 lldb::ValueObjectSP new_value_sp;
815 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000816 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000817 TypeImplSP type_sp (type.GetSP());
818 if (type.IsValid())
Enrico Granata6f3533f2011-07-29 19:53:35 +0000819 {
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000820 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000821 }
822 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000823 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000824 if (log)
825 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000826 if (new_value_sp)
Jim Ingham35e1bda2012-10-16 21:41:58 +0000827 log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000828 static_cast<void*>(value_sp.get()),
Jim Ingham35e1bda2012-10-16 21:41:58 +0000829 new_value_sp->GetName().AsCString());
Enrico Granata6f3533f2011-07-29 19:53:35 +0000830 else
Jim Ingham35e1bda2012-10-16 21:41:58 +0000831 log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000832 static_cast<void*>(value_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000833 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000834 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000835}
836
837lldb::SBValue
Greg Claytonbf2331c2011-09-09 23:04:00 +0000838SBValue::Cast (SBType type)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000839{
Greg Claytonef496d52012-01-31 04:25:15 +0000840 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000841 ValueLocker locker;
842 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000843 TypeImplSP type_sp (type.GetSP());
844 if (value_sp && type_sp)
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000845 sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue());
Greg Claytonef496d52012-01-31 04:25:15 +0000846 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000847}
848
849lldb::SBValue
850SBValue::CreateValueFromExpression (const char *name, const char* expression)
851{
Jim Ingham35e1bda2012-10-16 21:41:58 +0000852 SBExpressionOptions options;
Greg Claytoncced1562012-10-16 22:58:25 +0000853 options.ref().SetKeepInMemory(true);
Jim Ingham35e1bda2012-10-16 21:41:58 +0000854 return CreateValueFromExpression (name, expression, options);
855}
856
857lldb::SBValue
858SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options)
859{
Greg Clayton5160ce52013-03-27 23:08:40 +0000860 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton81e871e2012-02-04 02:27:34 +0000861 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000862 ValueLocker locker;
863 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000864 lldb::ValueObjectSP new_value_sp;
865 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000866 {
Greg Claytoncc4d0142012-02-17 07:49:44 +0000867 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
Enrico Granata972be532014-12-17 21:18:43 +0000868 new_value_sp = ValueObject::CreateValueObjectFromExpression(name, expression, exe_ctx, options.ref());
869 if (new_value_sp)
870 new_value_sp->SetName(ConstString(name));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000871 }
Enrico Granata972be532014-12-17 21:18:43 +0000872 sb_value.SetSP(new_value_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000873 if (log)
874 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000875 if (new_value_sp)
Greg Claytoneac87f82012-06-04 20:13:23 +0000876 log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => SBValue (%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000877 static_cast<void*>(value_sp.get()), name, expression,
878 static_cast<void*>(new_value_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000879 else
Greg Claytoneac87f82012-06-04 20:13:23 +0000880 log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => NULL",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000881 static_cast<void*>(value_sp.get()), name, expression);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000882 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000883 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000884}
885
886lldb::SBValue
Greg Clayton81e871e2012-02-04 02:27:34 +0000887SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType sb_type)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000888{
Greg Clayton81e871e2012-02-04 02:27:34 +0000889 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000890 ValueLocker locker;
891 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000892 lldb::ValueObjectSP new_value_sp;
893 lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
894 if (value_sp && type_impl_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000895 {
Enrico Granata972be532014-12-17 21:18:43 +0000896 ClangASTType ast_type(type_impl_sp->GetClangASTType(true));
897 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
898 new_value_sp = ValueObject::CreateValueObjectFromAddress(name, address, exe_ctx, ast_type);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000899 }
Enrico Granata972be532014-12-17 21:18:43 +0000900 sb_value.SetSP(new_value_sp);
Greg Clayton5160ce52013-03-27 23:08:40 +0000901 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000902 if (log)
903 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000904 if (new_value_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000905 log->Printf ("SBValue(%p)::CreateValueFromAddress => \"%s\"",
906 static_cast<void*>(value_sp.get()),
907 new_value_sp->GetName().AsCString());
Johnny Chen4a871f92011-08-09 22:38:07 +0000908 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000909 log->Printf ("SBValue(%p)::CreateValueFromAddress => NULL",
910 static_cast<void*>(value_sp.get()));
Johnny Chen4a871f92011-08-09 22:38:07 +0000911 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000912 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000913}
914
Enrico Granata9128ee22011-09-06 19:20:51 +0000915lldb::SBValue
Greg Claytonbf2331c2011-09-09 23:04:00 +0000916SBValue::CreateValueFromData (const char* name, SBData data, SBType type)
Enrico Granata9128ee22011-09-06 19:20:51 +0000917{
Greg Clayton81e871e2012-02-04 02:27:34 +0000918 lldb::SBValue sb_value;
919 lldb::ValueObjectSP new_value_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +0000920 ValueLocker locker;
921 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000922 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +0000923 {
Greg Claytoncc4d0142012-02-17 07:49:44 +0000924 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
Enrico Granata972be532014-12-17 21:18:43 +0000925 new_value_sp = ValueObject::CreateValueObjectFromData(name, **data, exe_ctx, type.GetSP()->GetClangASTType(true));
Greg Clayton81e871e2012-02-04 02:27:34 +0000926 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
Enrico Granata9128ee22011-09-06 19:20:51 +0000927 }
Enrico Granata972be532014-12-17 21:18:43 +0000928 sb_value.SetSP(new_value_sp);
Greg Clayton5160ce52013-03-27 23:08:40 +0000929 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +0000930 if (log)
931 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000932 if (new_value_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000933 log->Printf ("SBValue(%p)::CreateValueFromData => \"%s\"",
934 static_cast<void*>(value_sp.get()),
935 new_value_sp->GetName().AsCString());
Enrico Granata9128ee22011-09-06 19:20:51 +0000936 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000937 log->Printf ("SBValue(%p)::CreateValueFromData => NULL",
938 static_cast<void*>(value_sp.get()));
Enrico Granata9128ee22011-09-06 19:20:51 +0000939 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000940 return sb_value;
Enrico Granata9128ee22011-09-06 19:20:51 +0000941}
942
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000943SBValue
944SBValue::GetChildAtIndex (uint32_t idx)
945{
Greg Claytonf66024822011-07-15 19:31:49 +0000946 const bool can_create_synthetic = false;
947 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
Jim Ingham362e39a2013-05-15 02:16:21 +0000948 TargetSP target_sp;
949 if (m_opaque_sp)
950 target_sp = m_opaque_sp->GetTargetSP();
951
952 if (target_sp)
953 use_dynamic = target_sp->GetPreferDynamicValue();
Daniel Maleae0f8f572013-08-26 23:57:52 +0000954
Greg Claytonf66024822011-07-15 19:31:49 +0000955 return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
Jim Ingham78a685a2011-04-16 00:01:13 +0000956}
957
958SBValue
Greg Claytonf66024822011-07-15 19:31:49 +0000959SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
Jim Ingham78a685a2011-04-16 00:01:13 +0000960{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000961 lldb::ValueObjectSP child_sp;
Greg Clayton5160ce52013-03-27 23:08:40 +0000962 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000963
Jim Ingham362e39a2013-05-15 02:16:21 +0000964 ValueLocker locker;
965 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000966 if (value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000967 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000968 const bool can_create = true;
969 child_sp = value_sp->GetChildAtIndex (idx, can_create);
970 if (can_create_synthetic && !child_sp)
Greg Clayton626f4a12011-06-29 18:28:50 +0000971 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000972 if (value_sp->IsPointerType())
Greg Clayton21c5ab42011-05-20 23:51:26 +0000973 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000974 child_sp = value_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
975 }
976 else if (value_sp->IsArrayType())
977 {
978 child_sp = value_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
Greg Clayton21c5ab42011-05-20 23:51:26 +0000979 }
Jim Ingham78a685a2011-04-16 00:01:13 +0000980 }
981 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000982
Enrico Granatae3e91512012-10-22 18:18:36 +0000983 SBValue sb_value;
984 sb_value.SetSP (child_sp, use_dynamic, GetPreferSyntheticValue());
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000985 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000986 log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
987 static_cast<void*>(value_sp.get()), idx,
988 static_cast<void*>(value_sp.get()));
989
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000990 return sb_value;
991}
992
993uint32_t
994SBValue::GetIndexOfChildWithName (const char *name)
995{
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000996 uint32_t idx = UINT32_MAX;
Jim Ingham362e39a2013-05-15 02:16:21 +0000997 ValueLocker locker;
998 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000999 if (value_sp)
Greg Clayton21c5ab42011-05-20 23:51:26 +00001000 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001001 idx = value_sp->GetIndexOfChildWithName (ConstString(name));
Greg Clayton21c5ab42011-05-20 23:51:26 +00001002 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001003 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001004 if (log)
1005 {
1006 if (idx == UINT32_MAX)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001007 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
1008 static_cast<void*>(value_sp.get()), name);
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001009 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001010 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
1011 static_cast<void*>(value_sp.get()), name, idx);
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001012 }
1013 return idx;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001014}
1015
1016SBValue
1017SBValue::GetChildMemberWithName (const char *name)
1018{
Jim Ingham362e39a2013-05-15 02:16:21 +00001019 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
1020 TargetSP target_sp;
1021 if (m_opaque_sp)
1022 target_sp = m_opaque_sp->GetTargetSP();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001023
Jim Ingham362e39a2013-05-15 02:16:21 +00001024 if (target_sp)
1025 use_dynamic_value = target_sp->GetPreferDynamicValue();
1026 return GetChildMemberWithName (name, use_dynamic_value);
Jim Ingham78a685a2011-04-16 00:01:13 +00001027}
1028
1029SBValue
Jim Ingham2837b762011-05-04 03:43:18 +00001030SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value)
Jim Ingham78a685a2011-04-16 00:01:13 +00001031{
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001032 lldb::ValueObjectSP child_sp;
1033 const ConstString str_name (name);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001034
Greg Clayton5160ce52013-03-27 23:08:40 +00001035 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001036
Jim Ingham362e39a2013-05-15 02:16:21 +00001037 ValueLocker locker;
1038 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001039 if (value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001040 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001041 child_sp = value_sp->GetChildMemberWithName (str_name, true);
Jim Ingham78a685a2011-04-16 00:01:13 +00001042 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001043
Enrico Granatae3e91512012-10-22 18:18:36 +00001044 SBValue sb_value;
1045 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001046
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001047 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001048 log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
1049 static_cast<void*>(value_sp.get()), name,
1050 static_cast<void*>(value_sp.get()));
1051
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001052 return sb_value;
1053}
1054
Enrico Granataf2bbf712011-07-15 02:26:42 +00001055lldb::SBValue
Jim Ingham60dbabb2011-12-08 19:44:08 +00001056SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic)
1057{
Enrico Granatae3e91512012-10-22 18:18:36 +00001058 SBValue value_sb;
1059 if (IsValid())
Jim Ingham60dbabb2011-12-08 19:44:08 +00001060 {
Enrico Granatae3e91512012-10-22 18:18:36 +00001061 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),use_dynamic,m_opaque_sp->GetUseSynthetic()));
1062 value_sb.SetSP(proxy_sp);
Jim Ingham60dbabb2011-12-08 19:44:08 +00001063 }
Enrico Granatae3e91512012-10-22 18:18:36 +00001064 return value_sb;
Jim Ingham60dbabb2011-12-08 19:44:08 +00001065}
1066
1067lldb::SBValue
1068SBValue::GetStaticValue ()
1069{
Enrico Granatae3e91512012-10-22 18:18:36 +00001070 SBValue value_sb;
1071 if (IsValid())
Jim Ingham60dbabb2011-12-08 19:44:08 +00001072 {
Enrico Granatae3e91512012-10-22 18:18:36 +00001073 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),eNoDynamicValues,m_opaque_sp->GetUseSynthetic()));
1074 value_sb.SetSP(proxy_sp);
Jim Ingham60dbabb2011-12-08 19:44:08 +00001075 }
Enrico Granatae3e91512012-10-22 18:18:36 +00001076 return value_sb;
Jim Ingham60dbabb2011-12-08 19:44:08 +00001077}
1078
Enrico Granatac5bc4122012-03-27 02:35:13 +00001079lldb::SBValue
1080SBValue::GetNonSyntheticValue ()
1081{
Enrico Granatae3e91512012-10-22 18:18:36 +00001082 SBValue value_sb;
1083 if (IsValid())
Enrico Granatac5bc4122012-03-27 02:35:13 +00001084 {
Enrico Granatae3e91512012-10-22 18:18:36 +00001085 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),m_opaque_sp->GetUseDynamic(),false));
1086 value_sb.SetSP(proxy_sp);
Enrico Granatac5bc4122012-03-27 02:35:13 +00001087 }
Enrico Granatae3e91512012-10-22 18:18:36 +00001088 return value_sb;
1089}
1090
1091lldb::DynamicValueType
1092SBValue::GetPreferDynamicValue ()
1093{
1094 if (!IsValid())
1095 return eNoDynamicValues;
1096 return m_opaque_sp->GetUseDynamic();
1097}
1098
1099void
1100SBValue::SetPreferDynamicValue (lldb::DynamicValueType use_dynamic)
1101{
1102 if (IsValid())
1103 return m_opaque_sp->SetUseDynamic (use_dynamic);
1104}
1105
1106bool
1107SBValue::GetPreferSyntheticValue ()
1108{
1109 if (!IsValid())
1110 return false;
1111 return m_opaque_sp->GetUseSynthetic();
1112}
1113
1114void
1115SBValue::SetPreferSyntheticValue (bool use_synthetic)
1116{
1117 if (IsValid())
1118 return m_opaque_sp->SetUseSynthetic (use_synthetic);
Enrico Granatac5bc4122012-03-27 02:35:13 +00001119}
1120
Jim Ingham60dbabb2011-12-08 19:44:08 +00001121bool
1122SBValue::IsDynamic()
1123{
Jim Ingham362e39a2013-05-15 02:16:21 +00001124 ValueLocker locker;
1125 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001126 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001127 return value_sp->IsDynamic();
Jim Ingham60dbabb2011-12-08 19:44:08 +00001128 return false;
1129}
1130
Enrico Granatae3e91512012-10-22 18:18:36 +00001131bool
1132SBValue::IsSynthetic ()
1133{
Jim Ingham362e39a2013-05-15 02:16:21 +00001134 ValueLocker locker;
1135 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granatae3e91512012-10-22 18:18:36 +00001136 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001137 return value_sp->IsSynthetic();
Enrico Granatae3e91512012-10-22 18:18:36 +00001138 return false;
1139}
1140
Jim Ingham60dbabb2011-12-08 19:44:08 +00001141lldb::SBValue
Enrico Granataf2bbf712011-07-15 02:26:42 +00001142SBValue::GetValueForExpressionPath(const char* expr_path)
1143{
Greg Clayton5160ce52013-03-27 23:08:40 +00001144 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granataf2bbf712011-07-15 02:26:42 +00001145 lldb::ValueObjectSP child_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001146 ValueLocker locker;
1147 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001148 if (value_sp)
Enrico Granataf2bbf712011-07-15 02:26:42 +00001149 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001150 // using default values for all the fancy options, just do it if you can
1151 child_sp = value_sp->GetValueForExpressionPath(expr_path);
Enrico Granataf2bbf712011-07-15 02:26:42 +00001152 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001153
Enrico Granatae3e91512012-10-22 18:18:36 +00001154 SBValue sb_value;
1155 sb_value.SetSP(child_sp,GetPreferDynamicValue(),GetPreferSyntheticValue());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001156
Enrico Granataf2bbf712011-07-15 02:26:42 +00001157 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001158 log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)",
1159 static_cast<void*>(value_sp.get()), expr_path,
1160 static_cast<void*>(value_sp.get()));
1161
Enrico Granataf2bbf712011-07-15 02:26:42 +00001162 return sb_value;
1163}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001164
Greg Claytonfe42ac42011-08-03 22:57:10 +00001165int64_t
Enrico Granata6fd87d52011-08-04 01:41:02 +00001166SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
1167{
Jim Ingham16e0c682011-08-12 23:34:31 +00001168 error.Clear();
Jim Ingham362e39a2013-05-15 02:16:21 +00001169 ValueLocker locker;
1170 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001171 if (value_sp)
Enrico Granata6fd87d52011-08-04 01:41:02 +00001172 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001173 bool success = true;
1174 uint64_t ret_val = fail_value;
1175 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
1176 if (!success)
1177 error.SetErrorString("could not resolve value");
1178 return ret_val;
Enrico Granata6fd87d52011-08-04 01:41:02 +00001179 }
Jim Ingham362e39a2013-05-15 02:16:21 +00001180 else
1181 error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
1182
Enrico Granata6fd87d52011-08-04 01:41:02 +00001183 return fail_value;
1184}
1185
1186uint64_t
1187SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
1188{
Jim Ingham16e0c682011-08-12 23:34:31 +00001189 error.Clear();
Jim Ingham362e39a2013-05-15 02:16:21 +00001190 ValueLocker locker;
1191 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001192 if (value_sp)
Enrico Granata6fd87d52011-08-04 01:41:02 +00001193 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001194 bool success = true;
1195 uint64_t ret_val = fail_value;
1196 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
1197 if (!success)
Jim Ingham362e39a2013-05-15 02:16:21 +00001198 error.SetErrorString("could not resolve value");
Enrico Granatad7373f62013-10-31 18:57:50 +00001199 return ret_val;
Enrico Granata6fd87d52011-08-04 01:41:02 +00001200 }
Jim Ingham362e39a2013-05-15 02:16:21 +00001201 else
1202 error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
1203
Enrico Granata6fd87d52011-08-04 01:41:02 +00001204 return fail_value;
1205}
1206
1207int64_t
Greg Claytonfe42ac42011-08-03 22:57:10 +00001208SBValue::GetValueAsSigned(int64_t fail_value)
1209{
Jim Ingham362e39a2013-05-15 02:16:21 +00001210 ValueLocker locker;
1211 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001212 if (value_sp)
Greg Claytonfe42ac42011-08-03 22:57:10 +00001213 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001214 return value_sp->GetValueAsSigned(fail_value);
Greg Claytonfe42ac42011-08-03 22:57:10 +00001215 }
1216 return fail_value;
1217}
1218
1219uint64_t
1220SBValue::GetValueAsUnsigned(uint64_t fail_value)
1221{
Jim Ingham362e39a2013-05-15 02:16:21 +00001222 ValueLocker locker;
1223 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001224 if (value_sp)
Greg Claytonfe42ac42011-08-03 22:57:10 +00001225 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001226 return value_sp->GetValueAsUnsigned(fail_value);
Greg Claytonfe42ac42011-08-03 22:57:10 +00001227 }
1228 return fail_value;
1229}
1230
Greg Clayton4a792072012-10-23 01:50:10 +00001231bool
1232SBValue::MightHaveChildren ()
1233{
Greg Clayton5160ce52013-03-27 23:08:40 +00001234 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4a792072012-10-23 01:50:10 +00001235 bool has_children = false;
Jim Ingham362e39a2013-05-15 02:16:21 +00001236 ValueLocker locker;
1237 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton4a792072012-10-23 01:50:10 +00001238 if (value_sp)
1239 has_children = value_sp->MightHaveChildren();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001240
Greg Clayton4a792072012-10-23 01:50:10 +00001241 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001242 log->Printf ("SBValue(%p)::MightHaveChildren() => %i",
1243 static_cast<void*>(value_sp.get()), has_children);
Greg Clayton4a792072012-10-23 01:50:10 +00001244 return has_children;
1245}
1246
Enrico Granata560558e2015-02-11 02:35:39 +00001247bool
1248SBValue::IsRuntimeSupportValue ()
1249{
1250 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1251 bool is_support = false;
1252 ValueLocker locker;
1253 lldb::ValueObjectSP value_sp(GetSP(locker));
1254 if (value_sp)
1255 is_support = value_sp->IsRuntimeSupportValue();
1256
1257 if (log)
1258 log->Printf ("SBValue(%p)::IsRuntimeSupportValue() => %i",
1259 static_cast<void*>(value_sp.get()), is_support);
1260 return is_support;
1261}
1262
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001263uint32_t
1264SBValue::GetNumChildren ()
1265{
1266 uint32_t num_children = 0;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001267
Greg Clayton5160ce52013-03-27 23:08:40 +00001268 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham362e39a2013-05-15 02:16:21 +00001269 ValueLocker locker;
1270 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001271 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001272 num_children = value_sp->GetNumChildren();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001273
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001274 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001275 log->Printf ("SBValue(%p)::GetNumChildren () => %u",
1276 static_cast<void*>(value_sp.get()), num_children);
1277
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001278 return num_children;
1279}
1280
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001281
1282SBValue
1283SBValue::Dereference ()
1284{
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001285 SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +00001286 ValueLocker locker;
1287 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001288 if (value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001289 {
Daniel Maleae0f8f572013-08-26 23:57:52 +00001290 Error error;
1291 sb_value = value_sp->Dereference (error);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001292 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001293 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001294 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001295 log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)",
1296 static_cast<void*>(value_sp.get()),
1297 static_cast<void*>(value_sp.get()));
1298
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001299 return sb_value;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001300}
1301
1302bool
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001303SBValue::TypeIsPointerType ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001304{
1305 bool is_ptr_type = false;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001306
Jim Ingham362e39a2013-05-15 02:16:21 +00001307 ValueLocker locker;
1308 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001309 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001310 is_ptr_type = value_sp->IsPointerType();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001311
Greg Clayton5160ce52013-03-27 23:08:40 +00001312 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001313 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001314 log->Printf ("SBValue(%p)::TypeIsPointerType () => %i",
1315 static_cast<void*>(value_sp.get()), is_ptr_type);
1316
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001317 return is_ptr_type;
1318}
1319
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001320void *
1321SBValue::GetOpaqueType()
1322{
Jim Ingham362e39a2013-05-15 02:16:21 +00001323 ValueLocker locker;
1324 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001325 if (value_sp)
Greg Clayton57ee3062013-07-11 22:46:58 +00001326 return value_sp->GetClangType().GetOpaqueQualType();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001327 return NULL;
1328}
1329
Enrico Granata6f3533f2011-07-29 19:53:35 +00001330lldb::SBTarget
1331SBValue::GetTarget()
1332{
Greg Claytonb9556ac2012-01-30 07:41:31 +00001333 SBTarget sb_target;
1334 TargetSP target_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001335 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001336 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001337 target_sp = m_opaque_sp->GetTargetSP();
Greg Claytonb9556ac2012-01-30 07:41:31 +00001338 sb_target.SetSP (target_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001339 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001340 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001341 if (log)
1342 {
Greg Claytonb9556ac2012-01-30 07:41:31 +00001343 if (target_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001344 log->Printf ("SBValue(%p)::GetTarget () => NULL",
1345 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001346 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001347 log->Printf ("SBValue(%p)::GetTarget () => %p",
1348 static_cast<void*>(m_opaque_sp.get()),
1349 static_cast<void*>(target_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001350 }
Greg Claytonb9556ac2012-01-30 07:41:31 +00001351 return sb_target;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001352}
1353
1354lldb::SBProcess
1355SBValue::GetProcess()
1356{
Greg Claytonb9556ac2012-01-30 07:41:31 +00001357 SBProcess sb_process;
1358 ProcessSP process_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001359 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001360 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001361 process_sp = m_opaque_sp->GetProcessSP();
1362 sb_process.SetSP (process_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001363 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001364 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001365 if (log)
1366 {
Greg Claytonb9556ac2012-01-30 07:41:31 +00001367 if (process_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001368 log->Printf ("SBValue(%p)::GetProcess () => NULL",
1369 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001370 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001371 log->Printf ("SBValue(%p)::GetProcess () => %p",
1372 static_cast<void*>(m_opaque_sp.get()),
1373 static_cast<void*>(process_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001374 }
Greg Claytonb9556ac2012-01-30 07:41:31 +00001375 return sb_process;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001376}
1377
1378lldb::SBThread
1379SBValue::GetThread()
1380{
Greg Clayton17a6ad02012-01-30 02:53:15 +00001381 SBThread sb_thread;
1382 ThreadSP thread_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001383 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001384 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001385 thread_sp = m_opaque_sp->GetThreadSP();
Greg Claytoncc4d0142012-02-17 07:49:44 +00001386 sb_thread.SetThread(thread_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001387 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001388 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001389 if (log)
1390 {
Greg Clayton17a6ad02012-01-30 02:53:15 +00001391 if (thread_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001392 log->Printf ("SBValue(%p)::GetThread () => NULL",
1393 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001394 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001395 log->Printf ("SBValue(%p)::GetThread () => %p",
1396 static_cast<void*>(m_opaque_sp.get()),
1397 static_cast<void*>(thread_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001398 }
Greg Clayton17a6ad02012-01-30 02:53:15 +00001399 return sb_thread;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001400}
1401
1402lldb::SBFrame
1403SBValue::GetFrame()
1404{
Greg Claytonb9556ac2012-01-30 07:41:31 +00001405 SBFrame sb_frame;
Jason Molendab57e4a12013-11-04 09:33:30 +00001406 StackFrameSP frame_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001407 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001408 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001409 frame_sp = m_opaque_sp->GetFrameSP();
Greg Claytoncc4d0142012-02-17 07:49:44 +00001410 sb_frame.SetFrameSP (frame_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001411 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001412 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001413 if (log)
1414 {
Greg Claytonb9556ac2012-01-30 07:41:31 +00001415 if (frame_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001416 log->Printf ("SBValue(%p)::GetFrame () => NULL",
1417 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001418 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001419 log->Printf ("SBValue(%p)::GetFrame () => %p",
1420 static_cast<void*>(m_opaque_sp.get()),
1421 static_cast<void*>(frame_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001422 }
Greg Claytonb9556ac2012-01-30 07:41:31 +00001423 return sb_frame;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001424}
1425
1426
Greg Clayton81e871e2012-02-04 02:27:34 +00001427lldb::ValueObjectSP
Jim Ingham362e39a2013-05-15 02:16:21 +00001428SBValue::GetSP (ValueLocker &locker) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001429{
Enrico Granatae3e91512012-10-22 18:18:36 +00001430 if (!m_opaque_sp || !m_opaque_sp->IsValid())
1431 return ValueObjectSP();
Jim Ingham362e39a2013-05-15 02:16:21 +00001432 return locker.GetLockedSP(*m_opaque_sp.get());
1433}
1434
1435lldb::ValueObjectSP
1436SBValue::GetSP () const
1437{
1438 ValueLocker locker;
1439 return GetSP(locker);
Enrico Granatae3e91512012-10-22 18:18:36 +00001440}
1441
1442void
1443SBValue::SetSP (ValueImplSP impl_sp)
1444{
1445 m_opaque_sp = impl_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001446}
1447
Greg Clayton81e871e2012-02-04 02:27:34 +00001448void
1449SBValue::SetSP (const lldb::ValueObjectSP &sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001450{
Enrico Granatae3e91512012-10-22 18:18:36 +00001451 if (sp)
1452 {
1453 lldb::TargetSP target_sp(sp->GetTargetSP());
1454 if (target_sp)
1455 {
1456 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1457 bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
1458 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1459 }
1460 else
1461 m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,true));
1462 }
1463 else
1464 m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,false));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001465}
Caroline Ticedde9cff2010-09-20 05:20:02 +00001466
Enrico Granatae3e91512012-10-22 18:18:36 +00001467void
1468SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic)
1469{
1470 if (sp)
1471 {
1472 lldb::TargetSP target_sp(sp->GetTargetSP());
1473 if (target_sp)
1474 {
1475 bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
1476 SetSP (sp, use_dynamic, use_synthetic);
1477 }
1478 else
1479 SetSP (sp, use_dynamic, true);
1480 }
1481 else
1482 SetSP (sp, use_dynamic, false);
1483}
1484
1485void
1486SBValue::SetSP (const lldb::ValueObjectSP &sp, bool use_synthetic)
1487{
1488 if (sp)
1489 {
1490 lldb::TargetSP target_sp(sp->GetTargetSP());
1491 if (target_sp)
1492 {
1493 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1494 SetSP (sp, use_dynamic, use_synthetic);
1495 }
1496 else
1497 SetSP (sp, eNoDynamicValues, use_synthetic);
1498 }
1499 else
1500 SetSP (sp, eNoDynamicValues, use_synthetic);
1501}
1502
1503void
1504SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic)
1505{
1506 m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic));
1507}
Greg Clayton81e871e2012-02-04 02:27:34 +00001508
Jim Ingham362e39a2013-05-15 02:16:21 +00001509void
1510SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name)
1511{
1512 m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic, name));
1513}
1514
Caroline Ticedde9cff2010-09-20 05:20:02 +00001515bool
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001516SBValue::GetExpressionPath (SBStream &description)
1517{
Jim Ingham362e39a2013-05-15 02:16:21 +00001518 ValueLocker locker;
1519 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001520 if (value_sp)
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001521 {
Greg Clayton81e871e2012-02-04 02:27:34 +00001522 value_sp->GetExpressionPath (description.ref(), false);
Greg Clayton6beaaa62011-01-17 03:46:26 +00001523 return true;
1524 }
1525 return false;
1526}
1527
1528bool
1529SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
1530{
Jim Ingham362e39a2013-05-15 02:16:21 +00001531 ValueLocker locker;
1532 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001533 if (value_sp)
Greg Clayton6beaaa62011-01-17 03:46:26 +00001534 {
Greg Clayton81e871e2012-02-04 02:27:34 +00001535 value_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001536 return true;
1537 }
1538 return false;
1539}
1540
1541bool
Caroline Ticedde9cff2010-09-20 05:20:02 +00001542SBValue::GetDescription (SBStream &description)
1543{
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001544 Stream &strm = description.ref();
Daniel Maleae0f8f572013-08-26 23:57:52 +00001545
Jim Ingham362e39a2013-05-15 02:16:21 +00001546 ValueLocker locker;
1547 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001548 if (value_sp)
Enrico Granata4d93b8c2013-09-30 19:11:51 +00001549 value_sp->Dump(strm);
Caroline Ticedde9cff2010-09-20 05:20:02 +00001550 else
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001551 strm.PutCString ("No value");
Daniel Maleae0f8f572013-08-26 23:57:52 +00001552
Caroline Ticedde9cff2010-09-20 05:20:02 +00001553 return true;
1554}
Greg Claytondc4e9632011-01-05 18:43:15 +00001555
1556lldb::Format
Greg Claytonbf2331c2011-09-09 23:04:00 +00001557SBValue::GetFormat ()
Greg Claytondc4e9632011-01-05 18:43:15 +00001558{
Jim Ingham362e39a2013-05-15 02:16:21 +00001559 ValueLocker locker;
1560 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001561 if (value_sp)
1562 return value_sp->GetFormat();
Greg Claytondc4e9632011-01-05 18:43:15 +00001563 return eFormatDefault;
1564}
1565
1566void
1567SBValue::SetFormat (lldb::Format format)
1568{
Jim Ingham362e39a2013-05-15 02:16:21 +00001569 ValueLocker locker;
1570 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001571 if (value_sp)
1572 value_sp->SetFormat(format);
Greg Claytondc4e9632011-01-05 18:43:15 +00001573}
1574
Enrico Granata6f3533f2011-07-29 19:53:35 +00001575lldb::SBValue
1576SBValue::AddressOf()
1577{
1578 SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +00001579 ValueLocker locker;
1580 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001581 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001582 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001583 Error error;
1584 sb_value.SetSP(value_sp->AddressOf (error),GetPreferDynamicValue(), GetPreferSyntheticValue());
Enrico Granata6f3533f2011-07-29 19:53:35 +00001585 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001586 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001587 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001588 log->Printf ("SBValue(%p)::AddressOf () => SBValue(%p)",
1589 static_cast<void*>(value_sp.get()),
1590 static_cast<void*>(value_sp.get()));
1591
Enrico Granata6f3533f2011-07-29 19:53:35 +00001592 return sb_value;
Johnny Chen4a871f92011-08-09 22:38:07 +00001593}
Enrico Granata9128ee22011-09-06 19:20:51 +00001594
1595lldb::addr_t
1596SBValue::GetLoadAddress()
1597{
1598 lldb::addr_t value = LLDB_INVALID_ADDRESS;
Jim Ingham362e39a2013-05-15 02:16:21 +00001599 ValueLocker locker;
1600 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001601 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001602 {
Greg Claytoncc4d0142012-02-17 07:49:44 +00001603 TargetSP target_sp (value_sp->GetTargetSP());
1604 if (target_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001605 {
Enrico Granata9128ee22011-09-06 19:20:51 +00001606 const bool scalar_is_load_address = true;
1607 AddressType addr_type;
Greg Clayton81e871e2012-02-04 02:27:34 +00001608 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
Enrico Granata9128ee22011-09-06 19:20:51 +00001609 if (addr_type == eAddressTypeFile)
1610 {
Greg Claytone72dfb32012-02-24 01:59:29 +00001611 ModuleSP module_sp (value_sp->GetModule());
1612 if (!module_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001613 value = LLDB_INVALID_ADDRESS;
1614 else
1615 {
1616 Address addr;
Greg Claytone72dfb32012-02-24 01:59:29 +00001617 module_sp->ResolveFileAddress(value, addr);
Greg Claytoncc4d0142012-02-17 07:49:44 +00001618 value = addr.GetLoadAddress(target_sp.get());
Enrico Granata9128ee22011-09-06 19:20:51 +00001619 }
1620 }
1621 else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeInvalid)
1622 value = LLDB_INVALID_ADDRESS;
1623 }
1624 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001625 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001626 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001627 log->Printf ("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
1628 static_cast<void*>(value_sp.get()), value);
1629
Enrico Granata9128ee22011-09-06 19:20:51 +00001630 return value;
1631}
1632
1633lldb::SBAddress
1634SBValue::GetAddress()
1635{
1636 Address addr;
Jim Ingham362e39a2013-05-15 02:16:21 +00001637 ValueLocker locker;
1638 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001639 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001640 {
Greg Claytoncc4d0142012-02-17 07:49:44 +00001641 TargetSP target_sp (value_sp->GetTargetSP());
1642 if (target_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001643 {
1644 lldb::addr_t value = LLDB_INVALID_ADDRESS;
Enrico Granata9128ee22011-09-06 19:20:51 +00001645 const bool scalar_is_load_address = true;
1646 AddressType addr_type;
Greg Clayton81e871e2012-02-04 02:27:34 +00001647 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
Enrico Granata9128ee22011-09-06 19:20:51 +00001648 if (addr_type == eAddressTypeFile)
1649 {
Greg Claytone72dfb32012-02-24 01:59:29 +00001650 ModuleSP module_sp (value_sp->GetModule());
1651 if (module_sp)
1652 module_sp->ResolveFileAddress(value, addr);
Enrico Granata9128ee22011-09-06 19:20:51 +00001653 }
1654 else if (addr_type == eAddressTypeLoad)
1655 {
1656 // no need to check the return value on this.. if it can actually do the resolve
1657 // addr will be in the form (section,offset), otherwise it will simply be returned
1658 // as (NULL, value)
Greg Claytoncc4d0142012-02-17 07:49:44 +00001659 addr.SetLoadAddress(value, target_sp.get());
Enrico Granata9128ee22011-09-06 19:20:51 +00001660 }
1661 }
1662 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001663 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001664 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001665 log->Printf ("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
1666 static_cast<void*>(value_sp.get()),
1667 (addr.GetSection()
1668 ? addr.GetSection()->GetName().GetCString()
1669 : "NULL"),
Jim Ingham35e1bda2012-10-16 21:41:58 +00001670 addr.GetOffset());
Enrico Granata9128ee22011-09-06 19:20:51 +00001671 return SBAddress(new Address(addr));
1672}
1673
1674lldb::SBData
1675SBValue::GetPointeeData (uint32_t item_idx,
1676 uint32_t item_count)
1677{
Greg Clayton5160ce52013-03-27 23:08:40 +00001678 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001679 lldb::SBData sb_data;
Jim Ingham362e39a2013-05-15 02:16:21 +00001680 ValueLocker locker;
1681 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001682 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001683 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001684 TargetSP target_sp (value_sp->GetTargetSP());
1685 if (target_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001686 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001687 DataExtractorSP data_sp(new DataExtractor());
1688 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1689 if (data_sp->GetByteSize() > 0)
1690 *sb_data = data_sp;
Enrico Granata9128ee22011-09-06 19:20:51 +00001691 }
1692 }
Enrico Granata9128ee22011-09-06 19:20:51 +00001693 if (log)
1694 log->Printf ("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001695 static_cast<void*>(value_sp.get()), item_idx, item_count,
1696 static_cast<void*>(sb_data.get()));
1697
Enrico Granata9128ee22011-09-06 19:20:51 +00001698 return sb_data;
1699}
1700
1701lldb::SBData
1702SBValue::GetData ()
1703{
Greg Clayton5160ce52013-03-27 23:08:40 +00001704 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001705 lldb::SBData sb_data;
Jim Ingham362e39a2013-05-15 02:16:21 +00001706 ValueLocker locker;
1707 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001708 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001709 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001710 DataExtractorSP data_sp(new DataExtractor());
Sean Callanan866e91c2014-02-28 22:27:53 +00001711 Error error;
1712 value_sp->GetData(*data_sp, error);
1713 if (error.Success())
Jim Ingham362e39a2013-05-15 02:16:21 +00001714 *sb_data = data_sp;
Enrico Granata9128ee22011-09-06 19:20:51 +00001715 }
Enrico Granata9128ee22011-09-06 19:20:51 +00001716 if (log)
1717 log->Printf ("SBValue(%p)::GetData () => SBData(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001718 static_cast<void*>(value_sp.get()),
1719 static_cast<void*>(sb_data.get()));
1720
Enrico Granata9128ee22011-09-06 19:20:51 +00001721 return sb_data;
1722}
Greg Clayton1b282f92011-10-13 18:08:26 +00001723
Sean Callanan389823e2013-04-13 01:21:23 +00001724bool
1725SBValue::SetData (lldb::SBData &data, SBError &error)
1726{
1727 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham362e39a2013-05-15 02:16:21 +00001728 ValueLocker locker;
1729 lldb::ValueObjectSP value_sp(GetSP(locker));
Sean Callanan389823e2013-04-13 01:21:23 +00001730 bool ret = true;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001731
Sean Callanan389823e2013-04-13 01:21:23 +00001732 if (value_sp)
1733 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001734 DataExtractor *data_extractor = data.get();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001735
Jim Ingham362e39a2013-05-15 02:16:21 +00001736 if (!data_extractor)
Sean Callanan389823e2013-04-13 01:21:23 +00001737 {
1738 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001739 log->Printf ("SBValue(%p)::SetData() => error: no data to set",
1740 static_cast<void*>(value_sp.get()));
1741
Jim Ingham362e39a2013-05-15 02:16:21 +00001742 error.SetErrorString("No data to set");
Sean Callanan389823e2013-04-13 01:21:23 +00001743 ret = false;
1744 }
1745 else
1746 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001747 Error set_error;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001748
Jim Ingham362e39a2013-05-15 02:16:21 +00001749 value_sp->SetData(*data_extractor, set_error);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001750
Jim Ingham362e39a2013-05-15 02:16:21 +00001751 if (!set_error.Success())
Sean Callanan389823e2013-04-13 01:21:23 +00001752 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001753 error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
Sean Callanan389823e2013-04-13 01:21:23 +00001754 ret = false;
1755 }
Sean Callanan389823e2013-04-13 01:21:23 +00001756 }
1757 }
1758 else
1759 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001760 error.SetErrorStringWithFormat ("Couldn't set data: could not get SBValue: %s", locker.GetError().AsCString());
Sean Callanan389823e2013-04-13 01:21:23 +00001761 ret = false;
1762 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001763
Sean Callanan389823e2013-04-13 01:21:23 +00001764 if (log)
1765 log->Printf ("SBValue(%p)::SetData (%p) => %s",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001766 static_cast<void*>(value_sp.get()),
1767 static_cast<void*>(data.get()), ret ? "true" : "false");
Sean Callanan389823e2013-04-13 01:21:23 +00001768 return ret;
1769}
1770
Enrico Granata10de0902012-10-10 22:54:17 +00001771lldb::SBDeclaration
1772SBValue::GetDeclaration ()
1773{
Jim Ingham362e39a2013-05-15 02:16:21 +00001774 ValueLocker locker;
1775 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata10de0902012-10-10 22:54:17 +00001776 SBDeclaration decl_sb;
1777 if (value_sp)
1778 {
1779 Declaration decl;
1780 if (value_sp->GetDeclaration(decl))
1781 decl_sb.SetDeclaration(decl);
1782 }
1783 return decl_sb;
1784}
1785
Greg Clayton1b282f92011-10-13 18:08:26 +00001786lldb::SBWatchpoint
Johnny Chenb90827e2012-06-04 23:19:54 +00001787SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error)
Greg Clayton1b282f92011-10-13 18:08:26 +00001788{
Greg Clayton81e871e2012-02-04 02:27:34 +00001789 SBWatchpoint sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001790
Greg Clayton81e871e2012-02-04 02:27:34 +00001791 // If the SBValue is not valid, there's no point in even trying to watch it.
Jim Ingham362e39a2013-05-15 02:16:21 +00001792 ValueLocker locker;
1793 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001794 TargetSP target_sp (GetTarget().GetSP());
1795 if (value_sp && target_sp)
Greg Clayton1b282f92011-10-13 18:08:26 +00001796 {
Greg Clayton81e871e2012-02-04 02:27:34 +00001797 // Read and Write cannot both be false.
1798 if (!read && !write)
1799 return sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001800
Greg Clayton81e871e2012-02-04 02:27:34 +00001801 // If the value is not in scope, don't try and watch and invalid value
1802 if (!IsInScope())
1803 return sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001804
Greg Clayton81e871e2012-02-04 02:27:34 +00001805 addr_t addr = GetLoadAddress();
1806 if (addr == LLDB_INVALID_ADDRESS)
1807 return sb_watchpoint;
1808 size_t byte_size = GetByteSize();
1809 if (byte_size == 0)
1810 return sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001811
Greg Clayton81e871e2012-02-04 02:27:34 +00001812 uint32_t watch_type = 0;
1813 if (read)
1814 watch_type |= LLDB_WATCH_TYPE_READ;
1815 if (write)
1816 watch_type |= LLDB_WATCH_TYPE_WRITE;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001817
Johnny Chenb90827e2012-06-04 23:19:54 +00001818 Error rc;
Greg Clayton57ee3062013-07-11 22:46:58 +00001819 ClangASTType type (value_sp->GetClangType());
Jim Inghama7dfb662012-10-23 07:20:06 +00001820 WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
Johnny Chenb90827e2012-06-04 23:19:54 +00001821 error.SetError(rc);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001822
Daniel Maleae0f8f572013-08-26 23:57:52 +00001823 if (watchpoint_sp)
Greg Clayton81e871e2012-02-04 02:27:34 +00001824 {
1825 sb_watchpoint.SetSP (watchpoint_sp);
1826 Declaration decl;
1827 if (value_sp->GetDeclaration (decl))
1828 {
Daniel Maleae0f8f572013-08-26 23:57:52 +00001829 if (decl.GetFile())
Greg Clayton81e871e2012-02-04 02:27:34 +00001830 {
1831 StreamString ss;
1832 // True to show fullpath for declaration file.
1833 decl.DumpStopContext(&ss, true);
1834 watchpoint_sp->SetDeclInfo(ss.GetString());
1835 }
1836 }
1837 }
Greg Clayton1b282f92011-10-13 18:08:26 +00001838 }
Jim Ingham362e39a2013-05-15 02:16:21 +00001839 else if (target_sp)
1840 {
1841 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1842 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001843 log->Printf ("SBValue(%p)::Watch() => error getting SBValue: %s",
1844 static_cast<void*>(value_sp.get()),
1845 locker.GetError().AsCString());
1846
Jim Ingham362e39a2013-05-15 02:16:21 +00001847 error.SetErrorStringWithFormat("could not get SBValue: %s", locker.GetError().AsCString());
1848 }
1849 else
1850 {
1851 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1852 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001853 log->Printf ("SBValue(%p)::Watch() => error getting SBValue: no target",
1854 static_cast<void*>(value_sp.get()));
Jim Ingham362e39a2013-05-15 02:16:21 +00001855 error.SetErrorString("could not set watchpoint, a target is required");
1856 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001857
Greg Clayton1b282f92011-10-13 18:08:26 +00001858 return sb_watchpoint;
1859}
1860
Johnny Chend3761a72012-06-04 23:45:50 +00001861// FIXME: Remove this method impl (as well as the decl in .h) once it is no longer needed.
1862// Backward compatibility fix in the interim.
1863lldb::SBWatchpoint
1864SBValue::Watch (bool resolve_location, bool read, bool write)
1865{
Johnny Chen974759f2012-06-05 00:14:15 +00001866 SBError error;
1867 return Watch(resolve_location, read, write, error);
Johnny Chend3761a72012-06-04 23:45:50 +00001868}
1869
Greg Clayton1b282f92011-10-13 18:08:26 +00001870lldb::SBWatchpoint
Johnny Chenb90827e2012-06-04 23:19:54 +00001871SBValue::WatchPointee (bool resolve_location, bool read, bool write, SBError &error)
Greg Clayton1b282f92011-10-13 18:08:26 +00001872{
Greg Clayton81e871e2012-02-04 02:27:34 +00001873 SBWatchpoint sb_watchpoint;
1874 if (IsInScope() && GetType().IsPointerType())
Johnny Chenb90827e2012-06-04 23:19:54 +00001875 sb_watchpoint = Dereference().Watch (resolve_location, read, write, error);
Greg Clayton1b282f92011-10-13 18:08:26 +00001876 return sb_watchpoint;
1877}
Enrico Granata0c10a852014-12-08 23:13:56 +00001878
1879lldb::SBValue
1880SBValue::Persist ()
1881{
1882 ValueLocker locker;
1883 lldb::ValueObjectSP value_sp(GetSP(locker));
1884 SBValue persisted_sb;
1885 if (value_sp)
1886 {
1887 persisted_sb.SetSP(value_sp->Persist());
1888 }
1889 return persisted_sb;
1890}