blob: 1b7c48c33b6195fa014050382779d401f191176a [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 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000611 result = value_sp->GetValueDidChange ();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000612 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000613 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000614 log->Printf ("SBValue(%p)::GetValueDidChange() => %i",
615 static_cast<void*>(value_sp.get()), result);
616
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000617 return result;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000618}
619
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000620#ifndef LLDB_DISABLE_PYTHON
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000621const char *
Jim Ingham6035b672011-03-31 00:19:25 +0000622SBValue::GetSummary ()
623{
Greg Clayton5160ce52013-03-27 23:08:40 +0000624 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000625 const char *cstr = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000626 ValueLocker locker;
627 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000628 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000629 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000630 cstr = value_sp->GetSummaryAsCString();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000631 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000632 if (log)
633 {
634 if (cstr)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000635 log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
636 static_cast<void*>(value_sp.get()), cstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000637 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000638 log->Printf ("SBValue(%p)::GetSummary() => NULL",
639 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000640 }
641 return cstr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000642}
Enrico Granatac1247f52014-11-06 21:23:20 +0000643
644const char *
645SBValue::GetSummary (lldb::SBTypeSummaryOptions& options)
646{
647 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
648 const char *cstr = NULL;
649 ValueLocker locker;
650 lldb::ValueObjectSP value_sp(GetSP(locker));
651 if (value_sp)
652 {
653 cstr = value_sp->GetSummaryAsCString(options.ref());
654 }
655 if (log)
656 {
657 if (cstr)
658 log->Printf ("SBValue(%p)::GetSummary() => \"%s\"",
659 static_cast<void*>(value_sp.get()), cstr);
660 else
661 log->Printf ("SBValue(%p)::GetSummary() => NULL",
662 static_cast<void*>(value_sp.get()));
663 }
664 return cstr;
665}
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000666#endif // LLDB_DISABLE_PYTHON
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000667
668const char *
Jim Ingham6035b672011-03-31 00:19:25 +0000669SBValue::GetLocation ()
670{
Greg Clayton5160ce52013-03-27 23:08:40 +0000671 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000672 const char *cstr = NULL;
Jim Ingham362e39a2013-05-15 02:16:21 +0000673 ValueLocker locker;
674 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000675 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000676 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000677 cstr = value_sp->GetLocationAsCString();
Greg Claytonaf67cec2010-12-20 20:49:23 +0000678 }
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000679 if (log)
680 {
681 if (cstr)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000682 log->Printf ("SBValue(%p)::GetLocation() => \"%s\"",
683 static_cast<void*>(value_sp.get()), cstr);
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000684 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000685 log->Printf ("SBValue(%p)::GetLocation() => NULL",
686 static_cast<void*>(value_sp.get()));
Greg Claytoncfd1ace2010-10-31 03:01:06 +0000687 }
688 return cstr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000689}
690
Enrico Granata07a4ac22012-05-08 21:25:06 +0000691// Deprecated - use the one that takes an lldb::SBError
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000692bool
Jim Ingham6035b672011-03-31 00:19:25 +0000693SBValue::SetValueFromCString (const char *value_str)
694{
Enrico Granata07a4ac22012-05-08 21:25:06 +0000695 lldb::SBError dummy;
696 return SetValueFromCString(value_str,dummy);
697}
698
699bool
700SBValue::SetValueFromCString (const char *value_str, lldb::SBError& error)
701{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000702 bool success = false;
Jim Ingham362e39a2013-05-15 02:16:21 +0000703 ValueLocker locker;
704 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton5160ce52013-03-27 23:08:40 +0000705 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton81e871e2012-02-04 02:27:34 +0000706 if (value_sp)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000707 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000708 success = value_sp->SetValueFromCString (value_str,error.ref());
Greg Claytonaf67cec2010-12-20 20:49:23 +0000709 }
Jim Ingham362e39a2013-05-15 02:16:21 +0000710 else
711 error.SetErrorStringWithFormat ("Could not get value: %s", locker.GetError().AsCString());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000712
Greg Claytonc9858e42012-04-06 02:17:47 +0000713 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000714 log->Printf ("SBValue(%p)::SetValueFromCString(\"%s\") => %i",
715 static_cast<void*>(value_sp.get()), value_str, success);
716
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000717 return success;
718}
719
Enrico Granata864e3e82012-02-17 03:18:30 +0000720lldb::SBTypeFormat
721SBValue::GetTypeFormat ()
722{
723 lldb::SBTypeFormat format;
Jim Ingham362e39a2013-05-15 02:16:21 +0000724 ValueLocker locker;
725 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000726 if (value_sp)
727 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000728 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000729 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000730 lldb::TypeFormatImplSP format_sp = value_sp->GetValueFormat();
731 if (format_sp)
732 format.SetSP(format_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000733 }
734 }
735 return format;
736}
737
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000738#ifndef LLDB_DISABLE_PYTHON
Enrico Granata864e3e82012-02-17 03:18:30 +0000739lldb::SBTypeSummary
740SBValue::GetTypeSummary ()
741{
742 lldb::SBTypeSummary summary;
Jim Ingham362e39a2013-05-15 02:16:21 +0000743 ValueLocker locker;
744 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000745 if (value_sp)
746 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000747 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000748 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000749 lldb::TypeSummaryImplSP summary_sp = value_sp->GetSummaryFormat();
750 if (summary_sp)
751 summary.SetSP(summary_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000752 }
753 }
754 return summary;
755}
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000756#endif // LLDB_DISABLE_PYTHON
Enrico Granata864e3e82012-02-17 03:18:30 +0000757
758lldb::SBTypeFilter
759SBValue::GetTypeFilter ()
760{
761 lldb::SBTypeFilter filter;
Jim Ingham362e39a2013-05-15 02:16:21 +0000762 ValueLocker locker;
763 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000764 if (value_sp)
765 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000766 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000767 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000768 lldb::SyntheticChildrenSP synthetic_sp = value_sp->GetSyntheticChildren();
769
770 if (synthetic_sp && !synthetic_sp->IsScripted())
Enrico Granata864e3e82012-02-17 03:18:30 +0000771 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000772 TypeFilterImplSP filter_sp = std::static_pointer_cast<TypeFilterImpl>(synthetic_sp);
773 filter.SetSP(filter_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000774 }
775 }
776 }
777 return filter;
778}
779
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000780#ifndef LLDB_DISABLE_PYTHON
Enrico Granata864e3e82012-02-17 03:18:30 +0000781lldb::SBTypeSynthetic
782SBValue::GetTypeSynthetic ()
783{
784 lldb::SBTypeSynthetic synthetic;
Jim Ingham362e39a2013-05-15 02:16:21 +0000785 ValueLocker locker;
786 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata864e3e82012-02-17 03:18:30 +0000787 if (value_sp)
788 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000789 if (value_sp->UpdateValueIfNeeded(true))
Enrico Granata864e3e82012-02-17 03:18:30 +0000790 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000791 lldb::SyntheticChildrenSP children_sp = value_sp->GetSyntheticChildren();
792
793 if (children_sp && children_sp->IsScripted())
Enrico Granata864e3e82012-02-17 03:18:30 +0000794 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000795 ScriptedSyntheticChildrenSP synth_sp = std::static_pointer_cast<ScriptedSyntheticChildren>(children_sp);
796 synthetic.SetSP(synth_sp);
Enrico Granata864e3e82012-02-17 03:18:30 +0000797 }
798 }
799 }
800 return synthetic;
801}
Jason Molendacf7e2dc2012-02-21 05:33:55 +0000802#endif
Enrico Granata864e3e82012-02-17 03:18:30 +0000803
Enrico Granata6f3533f2011-07-29 19:53:35 +0000804lldb::SBValue
Greg Claytonbf2331c2011-09-09 23:04:00 +0000805SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000806{
Greg Clayton81e871e2012-02-04 02:27:34 +0000807 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000808 ValueLocker locker;
809 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000810 lldb::ValueObjectSP new_value_sp;
811 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000812 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000813 TypeImplSP type_sp (type.GetSP());
814 if (type.IsValid())
Enrico Granata6f3533f2011-07-29 19:53:35 +0000815 {
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000816 sb_value.SetSP(value_sp->GetSyntheticChildAtOffset(offset, type_sp->GetClangASTType(false), true),GetPreferDynamicValue(),GetPreferSyntheticValue(), name);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000817 }
818 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000819 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000820 if (log)
821 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000822 if (new_value_sp)
Jim Ingham35e1bda2012-10-16 21:41:58 +0000823 log->Printf ("SBValue(%p)::CreateChildAtOffset => \"%s\"",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000824 static_cast<void*>(value_sp.get()),
Jim Ingham35e1bda2012-10-16 21:41:58 +0000825 new_value_sp->GetName().AsCString());
Enrico Granata6f3533f2011-07-29 19:53:35 +0000826 else
Jim Ingham35e1bda2012-10-16 21:41:58 +0000827 log->Printf ("SBValue(%p)::CreateChildAtOffset => NULL",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000828 static_cast<void*>(value_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000829 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000830 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000831}
832
833lldb::SBValue
Greg Claytonbf2331c2011-09-09 23:04:00 +0000834SBValue::Cast (SBType type)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000835{
Greg Claytonef496d52012-01-31 04:25:15 +0000836 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000837 ValueLocker locker;
838 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000839 TypeImplSP type_sp (type.GetSP());
840 if (value_sp && type_sp)
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000841 sb_value.SetSP(value_sp->Cast(type_sp->GetClangASTType(false)),GetPreferDynamicValue(),GetPreferSyntheticValue());
Greg Claytonef496d52012-01-31 04:25:15 +0000842 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000843}
844
845lldb::SBValue
846SBValue::CreateValueFromExpression (const char *name, const char* expression)
847{
Jim Ingham35e1bda2012-10-16 21:41:58 +0000848 SBExpressionOptions options;
Greg Claytoncced1562012-10-16 22:58:25 +0000849 options.ref().SetKeepInMemory(true);
Jim Ingham35e1bda2012-10-16 21:41:58 +0000850 return CreateValueFromExpression (name, expression, options);
851}
852
853lldb::SBValue
854SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options)
855{
Greg Clayton5160ce52013-03-27 23:08:40 +0000856 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton81e871e2012-02-04 02:27:34 +0000857 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000858 ValueLocker locker;
859 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000860 lldb::ValueObjectSP new_value_sp;
861 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000862 {
Greg Claytoncc4d0142012-02-17 07:49:44 +0000863 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
Jim Ingham362e39a2013-05-15 02:16:21 +0000864 Target* target = exe_ctx.GetTargetPtr();
865 if (target)
Johnny Chen50660442011-12-20 01:52:44 +0000866 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000867 options.ref().SetKeepInMemory(true);
868 target->EvaluateExpression (expression,
869 exe_ctx.GetFramePtr(),
870 new_value_sp,
871 options.ref());
872 if (new_value_sp)
Greg Claytoncc4d0142012-02-17 07:49:44 +0000873 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000874 new_value_sp->SetName(ConstString(name));
875 sb_value.SetSP(new_value_sp);
Greg Claytoncc4d0142012-02-17 07:49:44 +0000876 }
Johnny Chen50660442011-12-20 01:52:44 +0000877 }
Enrico Granata6f3533f2011-07-29 19:53:35 +0000878 }
Enrico Granata6f3533f2011-07-29 19:53:35 +0000879 if (log)
880 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000881 if (new_value_sp)
Greg Claytoneac87f82012-06-04 20:13:23 +0000882 log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => SBValue (%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000883 static_cast<void*>(value_sp.get()), name, expression,
884 static_cast<void*>(new_value_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000885 else
Greg Claytoneac87f82012-06-04 20:13:23 +0000886 log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => NULL",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000887 static_cast<void*>(value_sp.get()), name, expression);
Enrico Granata6f3533f2011-07-29 19:53:35 +0000888 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000889 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000890}
891
892lldb::SBValue
Greg Clayton81e871e2012-02-04 02:27:34 +0000893SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType sb_type)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000894{
Greg Clayton81e871e2012-02-04 02:27:34 +0000895 lldb::SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +0000896 ValueLocker locker;
897 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000898 lldb::ValueObjectSP new_value_sp;
899 lldb::TypeImplSP type_impl_sp (sb_type.GetSP());
900 if (value_sp && type_impl_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +0000901 {
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000902 ClangASTType pointer_ast_type(type_impl_sp->GetClangASTType(false).GetPointerType ());
Enrico Granata347c2aa2013-10-08 21:49:02 +0000903 if (pointer_ast_type)
Enrico Granata61408e02011-08-04 17:07:02 +0000904 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000905 lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000906
Greg Claytoncc4d0142012-02-17 07:49:44 +0000907 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
908 ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
Enrico Granata347c2aa2013-10-08 21:49:02 +0000909 pointer_ast_type,
Greg Clayton81e871e2012-02-04 02:27:34 +0000910 ConstString(name),
911 buffer,
Enrico Granata347c2aa2013-10-08 21:49:02 +0000912 exe_ctx.GetByteOrder(),
Greg Claytoncc4d0142012-02-17 07:49:44 +0000913 exe_ctx.GetAddressByteSize()));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000914
Greg Clayton81e871e2012-02-04 02:27:34 +0000915 if (ptr_result_valobj_sp)
916 {
917 ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
918 Error err;
919 new_value_sp = ptr_result_valobj_sp->Dereference(err);
920 if (new_value_sp)
921 new_value_sp->SetName(ConstString(name));
922 }
923 sb_value.SetSP(new_value_sp);
Enrico Granata61408e02011-08-04 17:07:02 +0000924 }
Enrico Granata6f3533f2011-07-29 19:53:35 +0000925 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000926 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +0000927 if (log)
928 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000929 if (new_value_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000930 log->Printf ("SBValue(%p)::CreateValueFromAddress => \"%s\"",
931 static_cast<void*>(value_sp.get()),
932 new_value_sp->GetName().AsCString());
Johnny Chen4a871f92011-08-09 22:38:07 +0000933 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000934 log->Printf ("SBValue(%p)::CreateValueFromAddress => NULL",
935 static_cast<void*>(value_sp.get()));
Johnny Chen4a871f92011-08-09 22:38:07 +0000936 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000937 return sb_value;
Enrico Granata6f3533f2011-07-29 19:53:35 +0000938}
939
Enrico Granata9128ee22011-09-06 19:20:51 +0000940lldb::SBValue
Greg Claytonbf2331c2011-09-09 23:04:00 +0000941SBValue::CreateValueFromData (const char* name, SBData data, SBType type)
Enrico Granata9128ee22011-09-06 19:20:51 +0000942{
Greg Clayton81e871e2012-02-04 02:27:34 +0000943 lldb::SBValue sb_value;
944 lldb::ValueObjectSP new_value_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +0000945 ValueLocker locker;
946 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000947 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +0000948 {
Greg Claytoncc4d0142012-02-17 07:49:44 +0000949 ExecutionContext exe_ctx (value_sp->GetExecutionContextRef());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000950
Greg Claytoncc4d0142012-02-17 07:49:44 +0000951 new_value_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(),
Enrico Granatadc4db5a2013-10-29 00:28:35 +0000952 type.m_opaque_sp->GetClangASTType(false),
Greg Clayton81e871e2012-02-04 02:27:34 +0000953 ConstString(name),
954 *data.m_opaque_sp,
955 LLDB_INVALID_ADDRESS);
956 new_value_sp->SetAddressTypeOfChildren(eAddressTypeLoad);
957 sb_value.SetSP(new_value_sp);
Enrico Granata9128ee22011-09-06 19:20:51 +0000958 }
Greg Clayton5160ce52013-03-27 23:08:40 +0000959 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +0000960 if (log)
961 {
Greg Clayton81e871e2012-02-04 02:27:34 +0000962 if (new_value_sp)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000963 log->Printf ("SBValue(%p)::CreateValueFromData => \"%s\"",
964 static_cast<void*>(value_sp.get()),
965 new_value_sp->GetName().AsCString());
Enrico Granata9128ee22011-09-06 19:20:51 +0000966 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000967 log->Printf ("SBValue(%p)::CreateValueFromData => NULL",
968 static_cast<void*>(value_sp.get()));
Enrico Granata9128ee22011-09-06 19:20:51 +0000969 }
Greg Clayton81e871e2012-02-04 02:27:34 +0000970 return sb_value;
Enrico Granata9128ee22011-09-06 19:20:51 +0000971}
972
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000973SBValue
974SBValue::GetChildAtIndex (uint32_t idx)
975{
Greg Claytonf66024822011-07-15 19:31:49 +0000976 const bool can_create_synthetic = false;
977 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
Jim Ingham362e39a2013-05-15 02:16:21 +0000978 TargetSP target_sp;
979 if (m_opaque_sp)
980 target_sp = m_opaque_sp->GetTargetSP();
981
982 if (target_sp)
983 use_dynamic = target_sp->GetPreferDynamicValue();
Daniel Maleae0f8f572013-08-26 23:57:52 +0000984
Greg Claytonf66024822011-07-15 19:31:49 +0000985 return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
Jim Ingham78a685a2011-04-16 00:01:13 +0000986}
987
988SBValue
Greg Claytonf66024822011-07-15 19:31:49 +0000989SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
Jim Ingham78a685a2011-04-16 00:01:13 +0000990{
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000991 lldb::ValueObjectSP child_sp;
Greg Clayton5160ce52013-03-27 23:08:40 +0000992 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000993
Jim Ingham362e39a2013-05-15 02:16:21 +0000994 ValueLocker locker;
995 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +0000996 if (value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000997 {
Jim Ingham362e39a2013-05-15 02:16:21 +0000998 const bool can_create = true;
999 child_sp = value_sp->GetChildAtIndex (idx, can_create);
1000 if (can_create_synthetic && !child_sp)
Greg Clayton626f4a12011-06-29 18:28:50 +00001001 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001002 if (value_sp->IsPointerType())
Greg Clayton21c5ab42011-05-20 23:51:26 +00001003 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001004 child_sp = value_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
1005 }
1006 else if (value_sp->IsArrayType())
1007 {
1008 child_sp = value_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
Greg Clayton21c5ab42011-05-20 23:51:26 +00001009 }
Jim Ingham78a685a2011-04-16 00:01:13 +00001010 }
1011 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001012
Enrico Granatae3e91512012-10-22 18:18:36 +00001013 SBValue sb_value;
1014 sb_value.SetSP (child_sp, use_dynamic, GetPreferSyntheticValue());
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001015 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001016 log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)",
1017 static_cast<void*>(value_sp.get()), idx,
1018 static_cast<void*>(value_sp.get()));
1019
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001020 return sb_value;
1021}
1022
1023uint32_t
1024SBValue::GetIndexOfChildWithName (const char *name)
1025{
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001026 uint32_t idx = UINT32_MAX;
Jim Ingham362e39a2013-05-15 02:16:21 +00001027 ValueLocker locker;
1028 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001029 if (value_sp)
Greg Clayton21c5ab42011-05-20 23:51:26 +00001030 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001031 idx = value_sp->GetIndexOfChildWithName (ConstString(name));
Greg Clayton21c5ab42011-05-20 23:51:26 +00001032 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001033 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001034 if (log)
1035 {
1036 if (idx == UINT32_MAX)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001037 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND",
1038 static_cast<void*>(value_sp.get()), name);
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001039 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001040 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u",
1041 static_cast<void*>(value_sp.get()), name, idx);
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001042 }
1043 return idx;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001044}
1045
1046SBValue
1047SBValue::GetChildMemberWithName (const char *name)
1048{
Jim Ingham362e39a2013-05-15 02:16:21 +00001049 lldb::DynamicValueType use_dynamic_value = eNoDynamicValues;
1050 TargetSP target_sp;
1051 if (m_opaque_sp)
1052 target_sp = m_opaque_sp->GetTargetSP();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001053
Jim Ingham362e39a2013-05-15 02:16:21 +00001054 if (target_sp)
1055 use_dynamic_value = target_sp->GetPreferDynamicValue();
1056 return GetChildMemberWithName (name, use_dynamic_value);
Jim Ingham78a685a2011-04-16 00:01:13 +00001057}
1058
1059SBValue
Jim Ingham2837b762011-05-04 03:43:18 +00001060SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value)
Jim Ingham78a685a2011-04-16 00:01:13 +00001061{
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001062 lldb::ValueObjectSP child_sp;
1063 const ConstString str_name (name);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001064
Greg Clayton5160ce52013-03-27 23:08:40 +00001065 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001066
Jim Ingham362e39a2013-05-15 02:16:21 +00001067 ValueLocker locker;
1068 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001069 if (value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001070 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001071 child_sp = value_sp->GetChildMemberWithName (str_name, true);
Jim Ingham78a685a2011-04-16 00:01:13 +00001072 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001073
Enrico Granatae3e91512012-10-22 18:18:36 +00001074 SBValue sb_value;
1075 sb_value.SetSP(child_sp, use_dynamic_value, GetPreferSyntheticValue());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001076
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001077 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001078 log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)",
1079 static_cast<void*>(value_sp.get()), name,
1080 static_cast<void*>(value_sp.get()));
1081
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001082 return sb_value;
1083}
1084
Enrico Granataf2bbf712011-07-15 02:26:42 +00001085lldb::SBValue
Jim Ingham60dbabb2011-12-08 19:44:08 +00001086SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic)
1087{
Enrico Granatae3e91512012-10-22 18:18:36 +00001088 SBValue value_sb;
1089 if (IsValid())
Jim Ingham60dbabb2011-12-08 19:44:08 +00001090 {
Enrico Granatae3e91512012-10-22 18:18:36 +00001091 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),use_dynamic,m_opaque_sp->GetUseSynthetic()));
1092 value_sb.SetSP(proxy_sp);
Jim Ingham60dbabb2011-12-08 19:44:08 +00001093 }
Enrico Granatae3e91512012-10-22 18:18:36 +00001094 return value_sb;
Jim Ingham60dbabb2011-12-08 19:44:08 +00001095}
1096
1097lldb::SBValue
1098SBValue::GetStaticValue ()
1099{
Enrico Granatae3e91512012-10-22 18:18:36 +00001100 SBValue value_sb;
1101 if (IsValid())
Jim Ingham60dbabb2011-12-08 19:44:08 +00001102 {
Enrico Granatae3e91512012-10-22 18:18:36 +00001103 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),eNoDynamicValues,m_opaque_sp->GetUseSynthetic()));
1104 value_sb.SetSP(proxy_sp);
Jim Ingham60dbabb2011-12-08 19:44:08 +00001105 }
Enrico Granatae3e91512012-10-22 18:18:36 +00001106 return value_sb;
Jim Ingham60dbabb2011-12-08 19:44:08 +00001107}
1108
Enrico Granatac5bc4122012-03-27 02:35:13 +00001109lldb::SBValue
1110SBValue::GetNonSyntheticValue ()
1111{
Enrico Granatae3e91512012-10-22 18:18:36 +00001112 SBValue value_sb;
1113 if (IsValid())
Enrico Granatac5bc4122012-03-27 02:35:13 +00001114 {
Enrico Granatae3e91512012-10-22 18:18:36 +00001115 ValueImplSP proxy_sp(new ValueImpl(m_opaque_sp->GetRootSP(),m_opaque_sp->GetUseDynamic(),false));
1116 value_sb.SetSP(proxy_sp);
Enrico Granatac5bc4122012-03-27 02:35:13 +00001117 }
Enrico Granatae3e91512012-10-22 18:18:36 +00001118 return value_sb;
1119}
1120
1121lldb::DynamicValueType
1122SBValue::GetPreferDynamicValue ()
1123{
1124 if (!IsValid())
1125 return eNoDynamicValues;
1126 return m_opaque_sp->GetUseDynamic();
1127}
1128
1129void
1130SBValue::SetPreferDynamicValue (lldb::DynamicValueType use_dynamic)
1131{
1132 if (IsValid())
1133 return m_opaque_sp->SetUseDynamic (use_dynamic);
1134}
1135
1136bool
1137SBValue::GetPreferSyntheticValue ()
1138{
1139 if (!IsValid())
1140 return false;
1141 return m_opaque_sp->GetUseSynthetic();
1142}
1143
1144void
1145SBValue::SetPreferSyntheticValue (bool use_synthetic)
1146{
1147 if (IsValid())
1148 return m_opaque_sp->SetUseSynthetic (use_synthetic);
Enrico Granatac5bc4122012-03-27 02:35:13 +00001149}
1150
Jim Ingham60dbabb2011-12-08 19:44:08 +00001151bool
1152SBValue::IsDynamic()
1153{
Jim Ingham362e39a2013-05-15 02:16:21 +00001154 ValueLocker locker;
1155 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001156 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001157 return value_sp->IsDynamic();
Jim Ingham60dbabb2011-12-08 19:44:08 +00001158 return false;
1159}
1160
Enrico Granatae3e91512012-10-22 18:18:36 +00001161bool
1162SBValue::IsSynthetic ()
1163{
Jim Ingham362e39a2013-05-15 02:16:21 +00001164 ValueLocker locker;
1165 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granatae3e91512012-10-22 18:18:36 +00001166 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001167 return value_sp->IsSynthetic();
Enrico Granatae3e91512012-10-22 18:18:36 +00001168 return false;
1169}
1170
Jim Ingham60dbabb2011-12-08 19:44:08 +00001171lldb::SBValue
Enrico Granataf2bbf712011-07-15 02:26:42 +00001172SBValue::GetValueForExpressionPath(const char* expr_path)
1173{
Greg Clayton5160ce52013-03-27 23:08:40 +00001174 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granataf2bbf712011-07-15 02:26:42 +00001175 lldb::ValueObjectSP child_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001176 ValueLocker locker;
1177 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001178 if (value_sp)
Enrico Granataf2bbf712011-07-15 02:26:42 +00001179 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001180 // using default values for all the fancy options, just do it if you can
1181 child_sp = value_sp->GetValueForExpressionPath(expr_path);
Enrico Granataf2bbf712011-07-15 02:26:42 +00001182 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001183
Enrico Granatae3e91512012-10-22 18:18:36 +00001184 SBValue sb_value;
1185 sb_value.SetSP(child_sp,GetPreferDynamicValue(),GetPreferSyntheticValue());
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001186
Enrico Granataf2bbf712011-07-15 02:26:42 +00001187 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001188 log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)",
1189 static_cast<void*>(value_sp.get()), expr_path,
1190 static_cast<void*>(value_sp.get()));
1191
Enrico Granataf2bbf712011-07-15 02:26:42 +00001192 return sb_value;
1193}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001194
Greg Claytonfe42ac42011-08-03 22:57:10 +00001195int64_t
Enrico Granata6fd87d52011-08-04 01:41:02 +00001196SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
1197{
Jim Ingham16e0c682011-08-12 23:34:31 +00001198 error.Clear();
Jim Ingham362e39a2013-05-15 02:16:21 +00001199 ValueLocker locker;
1200 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001201 if (value_sp)
Enrico Granata6fd87d52011-08-04 01:41:02 +00001202 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001203 bool success = true;
1204 uint64_t ret_val = fail_value;
1205 ret_val = value_sp->GetValueAsSigned(fail_value, &success);
1206 if (!success)
1207 error.SetErrorString("could not resolve value");
1208 return ret_val;
Enrico Granata6fd87d52011-08-04 01:41:02 +00001209 }
Jim Ingham362e39a2013-05-15 02:16:21 +00001210 else
1211 error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
1212
Enrico Granata6fd87d52011-08-04 01:41:02 +00001213 return fail_value;
1214}
1215
1216uint64_t
1217SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
1218{
Jim Ingham16e0c682011-08-12 23:34:31 +00001219 error.Clear();
Jim Ingham362e39a2013-05-15 02:16:21 +00001220 ValueLocker locker;
1221 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001222 if (value_sp)
Enrico Granata6fd87d52011-08-04 01:41:02 +00001223 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001224 bool success = true;
1225 uint64_t ret_val = fail_value;
1226 ret_val = value_sp->GetValueAsUnsigned(fail_value, &success);
1227 if (!success)
Jim Ingham362e39a2013-05-15 02:16:21 +00001228 error.SetErrorString("could not resolve value");
Enrico Granatad7373f62013-10-31 18:57:50 +00001229 return ret_val;
Enrico Granata6fd87d52011-08-04 01:41:02 +00001230 }
Jim Ingham362e39a2013-05-15 02:16:21 +00001231 else
1232 error.SetErrorStringWithFormat ("could not get SBValue: %s", locker.GetError().AsCString());
1233
Enrico Granata6fd87d52011-08-04 01:41:02 +00001234 return fail_value;
1235}
1236
1237int64_t
Greg Claytonfe42ac42011-08-03 22:57:10 +00001238SBValue::GetValueAsSigned(int64_t fail_value)
1239{
Jim Ingham362e39a2013-05-15 02:16:21 +00001240 ValueLocker locker;
1241 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001242 if (value_sp)
Greg Claytonfe42ac42011-08-03 22:57:10 +00001243 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001244 return value_sp->GetValueAsSigned(fail_value);
Greg Claytonfe42ac42011-08-03 22:57:10 +00001245 }
1246 return fail_value;
1247}
1248
1249uint64_t
1250SBValue::GetValueAsUnsigned(uint64_t fail_value)
1251{
Jim Ingham362e39a2013-05-15 02:16:21 +00001252 ValueLocker locker;
1253 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001254 if (value_sp)
Greg Claytonfe42ac42011-08-03 22:57:10 +00001255 {
Enrico Granatad7373f62013-10-31 18:57:50 +00001256 return value_sp->GetValueAsUnsigned(fail_value);
Greg Claytonfe42ac42011-08-03 22:57:10 +00001257 }
1258 return fail_value;
1259}
1260
Greg Clayton4a792072012-10-23 01:50:10 +00001261bool
1262SBValue::MightHaveChildren ()
1263{
Greg Clayton5160ce52013-03-27 23:08:40 +00001264 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4a792072012-10-23 01:50:10 +00001265 bool has_children = false;
Jim Ingham362e39a2013-05-15 02:16:21 +00001266 ValueLocker locker;
1267 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton4a792072012-10-23 01:50:10 +00001268 if (value_sp)
1269 has_children = value_sp->MightHaveChildren();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001270
Greg Clayton4a792072012-10-23 01:50:10 +00001271 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001272 log->Printf ("SBValue(%p)::MightHaveChildren() => %i",
1273 static_cast<void*>(value_sp.get()), has_children);
Greg Clayton4a792072012-10-23 01:50:10 +00001274 return has_children;
1275}
1276
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001277uint32_t
1278SBValue::GetNumChildren ()
1279{
1280 uint32_t num_children = 0;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001281
Greg Clayton5160ce52013-03-27 23:08:40 +00001282 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham362e39a2013-05-15 02:16:21 +00001283 ValueLocker locker;
1284 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001285 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001286 num_children = value_sp->GetNumChildren();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001287
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001288 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001289 log->Printf ("SBValue(%p)::GetNumChildren () => %u",
1290 static_cast<void*>(value_sp.get()), num_children);
1291
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001292 return num_children;
1293}
1294
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001295
1296SBValue
1297SBValue::Dereference ()
1298{
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001299 SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +00001300 ValueLocker locker;
1301 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001302 if (value_sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001303 {
Daniel Maleae0f8f572013-08-26 23:57:52 +00001304 Error error;
1305 sb_value = value_sp->Dereference (error);
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001306 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001307 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001308 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001309 log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)",
1310 static_cast<void*>(value_sp.get()),
1311 static_cast<void*>(value_sp.get()));
1312
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001313 return sb_value;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001314}
1315
1316bool
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001317SBValue::TypeIsPointerType ()
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001318{
1319 bool is_ptr_type = false;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001320
Jim Ingham362e39a2013-05-15 02:16:21 +00001321 ValueLocker locker;
1322 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001323 if (value_sp)
Jim Ingham362e39a2013-05-15 02:16:21 +00001324 is_ptr_type = value_sp->IsPointerType();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001325
Greg Clayton5160ce52013-03-27 23:08:40 +00001326 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001327 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001328 log->Printf ("SBValue(%p)::TypeIsPointerType () => %i",
1329 static_cast<void*>(value_sp.get()), is_ptr_type);
1330
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001331 return is_ptr_type;
1332}
1333
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001334void *
1335SBValue::GetOpaqueType()
1336{
Jim Ingham362e39a2013-05-15 02:16:21 +00001337 ValueLocker locker;
1338 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001339 if (value_sp)
Greg Clayton57ee3062013-07-11 22:46:58 +00001340 return value_sp->GetClangType().GetOpaqueQualType();
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001341 return NULL;
1342}
1343
Enrico Granata6f3533f2011-07-29 19:53:35 +00001344lldb::SBTarget
1345SBValue::GetTarget()
1346{
Greg Claytonb9556ac2012-01-30 07:41:31 +00001347 SBTarget sb_target;
1348 TargetSP target_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001349 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001350 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001351 target_sp = m_opaque_sp->GetTargetSP();
Greg Claytonb9556ac2012-01-30 07:41:31 +00001352 sb_target.SetSP (target_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001353 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001354 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001355 if (log)
1356 {
Greg Claytonb9556ac2012-01-30 07:41:31 +00001357 if (target_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001358 log->Printf ("SBValue(%p)::GetTarget () => NULL",
1359 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001360 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001361 log->Printf ("SBValue(%p)::GetTarget () => %p",
1362 static_cast<void*>(m_opaque_sp.get()),
1363 static_cast<void*>(target_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001364 }
Greg Claytonb9556ac2012-01-30 07:41:31 +00001365 return sb_target;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001366}
1367
1368lldb::SBProcess
1369SBValue::GetProcess()
1370{
Greg Claytonb9556ac2012-01-30 07:41:31 +00001371 SBProcess sb_process;
1372 ProcessSP process_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001373 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001374 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001375 process_sp = m_opaque_sp->GetProcessSP();
1376 sb_process.SetSP (process_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001377 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001378 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001379 if (log)
1380 {
Greg Claytonb9556ac2012-01-30 07:41:31 +00001381 if (process_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001382 log->Printf ("SBValue(%p)::GetProcess () => NULL",
1383 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001384 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001385 log->Printf ("SBValue(%p)::GetProcess () => %p",
1386 static_cast<void*>(m_opaque_sp.get()),
1387 static_cast<void*>(process_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001388 }
Greg Claytonb9556ac2012-01-30 07:41:31 +00001389 return sb_process;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001390}
1391
1392lldb::SBThread
1393SBValue::GetThread()
1394{
Greg Clayton17a6ad02012-01-30 02:53:15 +00001395 SBThread sb_thread;
1396 ThreadSP thread_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001397 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001398 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001399 thread_sp = m_opaque_sp->GetThreadSP();
Greg Claytoncc4d0142012-02-17 07:49:44 +00001400 sb_thread.SetThread(thread_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001401 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001402 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001403 if (log)
1404 {
Greg Clayton17a6ad02012-01-30 02:53:15 +00001405 if (thread_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001406 log->Printf ("SBValue(%p)::GetThread () => NULL",
1407 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001408 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001409 log->Printf ("SBValue(%p)::GetThread () => %p",
1410 static_cast<void*>(m_opaque_sp.get()),
1411 static_cast<void*>(thread_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001412 }
Greg Clayton17a6ad02012-01-30 02:53:15 +00001413 return sb_thread;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001414}
1415
1416lldb::SBFrame
1417SBValue::GetFrame()
1418{
Greg Claytonb9556ac2012-01-30 07:41:31 +00001419 SBFrame sb_frame;
Jason Molendab57e4a12013-11-04 09:33:30 +00001420 StackFrameSP frame_sp;
Jim Ingham362e39a2013-05-15 02:16:21 +00001421 if (m_opaque_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001422 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001423 frame_sp = m_opaque_sp->GetFrameSP();
Greg Claytoncc4d0142012-02-17 07:49:44 +00001424 sb_frame.SetFrameSP (frame_sp);
Enrico Granata6f3533f2011-07-29 19:53:35 +00001425 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001426 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001427 if (log)
1428 {
Greg Claytonb9556ac2012-01-30 07:41:31 +00001429 if (frame_sp.get() == NULL)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001430 log->Printf ("SBValue(%p)::GetFrame () => NULL",
1431 static_cast<void*>(m_opaque_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001432 else
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001433 log->Printf ("SBValue(%p)::GetFrame () => %p",
1434 static_cast<void*>(m_opaque_sp.get()),
1435 static_cast<void*>(frame_sp.get()));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001436 }
Greg Claytonb9556ac2012-01-30 07:41:31 +00001437 return sb_frame;
Enrico Granata6f3533f2011-07-29 19:53:35 +00001438}
1439
1440
Greg Clayton81e871e2012-02-04 02:27:34 +00001441lldb::ValueObjectSP
Jim Ingham362e39a2013-05-15 02:16:21 +00001442SBValue::GetSP (ValueLocker &locker) const
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001443{
Enrico Granatae3e91512012-10-22 18:18:36 +00001444 if (!m_opaque_sp || !m_opaque_sp->IsValid())
1445 return ValueObjectSP();
Jim Ingham362e39a2013-05-15 02:16:21 +00001446 return locker.GetLockedSP(*m_opaque_sp.get());
1447}
1448
1449lldb::ValueObjectSP
1450SBValue::GetSP () const
1451{
1452 ValueLocker locker;
1453 return GetSP(locker);
Enrico Granatae3e91512012-10-22 18:18:36 +00001454}
1455
1456void
1457SBValue::SetSP (ValueImplSP impl_sp)
1458{
1459 m_opaque_sp = impl_sp;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001460}
1461
Greg Clayton81e871e2012-02-04 02:27:34 +00001462void
1463SBValue::SetSP (const lldb::ValueObjectSP &sp)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001464{
Enrico Granatae3e91512012-10-22 18:18:36 +00001465 if (sp)
1466 {
1467 lldb::TargetSP target_sp(sp->GetTargetSP());
1468 if (target_sp)
1469 {
1470 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1471 bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
1472 m_opaque_sp = ValueImplSP(new ValueImpl(sp, use_dynamic, use_synthetic));
1473 }
1474 else
1475 m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,true));
1476 }
1477 else
1478 m_opaque_sp = ValueImplSP(new ValueImpl(sp,eNoDynamicValues,false));
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001479}
Caroline Ticedde9cff2010-09-20 05:20:02 +00001480
Enrico Granatae3e91512012-10-22 18:18:36 +00001481void
1482SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic)
1483{
1484 if (sp)
1485 {
1486 lldb::TargetSP target_sp(sp->GetTargetSP());
1487 if (target_sp)
1488 {
1489 bool use_synthetic = target_sp->TargetProperties::GetEnableSyntheticValue();
1490 SetSP (sp, use_dynamic, use_synthetic);
1491 }
1492 else
1493 SetSP (sp, use_dynamic, true);
1494 }
1495 else
1496 SetSP (sp, use_dynamic, false);
1497}
1498
1499void
1500SBValue::SetSP (const lldb::ValueObjectSP &sp, bool use_synthetic)
1501{
1502 if (sp)
1503 {
1504 lldb::TargetSP target_sp(sp->GetTargetSP());
1505 if (target_sp)
1506 {
1507 lldb::DynamicValueType use_dynamic = target_sp->GetPreferDynamicValue();
1508 SetSP (sp, use_dynamic, use_synthetic);
1509 }
1510 else
1511 SetSP (sp, eNoDynamicValues, use_synthetic);
1512 }
1513 else
1514 SetSP (sp, eNoDynamicValues, use_synthetic);
1515}
1516
1517void
1518SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic)
1519{
1520 m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic));
1521}
Greg Clayton81e871e2012-02-04 02:27:34 +00001522
Jim Ingham362e39a2013-05-15 02:16:21 +00001523void
1524SBValue::SetSP (const lldb::ValueObjectSP &sp, lldb::DynamicValueType use_dynamic, bool use_synthetic, const char *name)
1525{
1526 m_opaque_sp = ValueImplSP(new ValueImpl(sp,use_dynamic,use_synthetic, name));
1527}
1528
Caroline Ticedde9cff2010-09-20 05:20:02 +00001529bool
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001530SBValue::GetExpressionPath (SBStream &description)
1531{
Jim Ingham362e39a2013-05-15 02:16:21 +00001532 ValueLocker locker;
1533 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001534 if (value_sp)
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001535 {
Greg Clayton81e871e2012-02-04 02:27:34 +00001536 value_sp->GetExpressionPath (description.ref(), false);
Greg Clayton6beaaa62011-01-17 03:46:26 +00001537 return true;
1538 }
1539 return false;
1540}
1541
1542bool
1543SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
1544{
Jim Ingham362e39a2013-05-15 02:16:21 +00001545 ValueLocker locker;
1546 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001547 if (value_sp)
Greg Clayton6beaaa62011-01-17 03:46:26 +00001548 {
Greg Clayton81e871e2012-02-04 02:27:34 +00001549 value_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001550 return true;
1551 }
1552 return false;
1553}
1554
1555bool
Caroline Ticedde9cff2010-09-20 05:20:02 +00001556SBValue::GetDescription (SBStream &description)
1557{
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001558 Stream &strm = description.ref();
Daniel Maleae0f8f572013-08-26 23:57:52 +00001559
Jim Ingham362e39a2013-05-15 02:16:21 +00001560 ValueLocker locker;
1561 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001562 if (value_sp)
Enrico Granata4d93b8c2013-09-30 19:11:51 +00001563 value_sp->Dump(strm);
Caroline Ticedde9cff2010-09-20 05:20:02 +00001564 else
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001565 strm.PutCString ("No value");
Daniel Maleae0f8f572013-08-26 23:57:52 +00001566
Caroline Ticedde9cff2010-09-20 05:20:02 +00001567 return true;
1568}
Greg Claytondc4e9632011-01-05 18:43:15 +00001569
1570lldb::Format
Greg Claytonbf2331c2011-09-09 23:04:00 +00001571SBValue::GetFormat ()
Greg Claytondc4e9632011-01-05 18:43:15 +00001572{
Jim Ingham362e39a2013-05-15 02:16:21 +00001573 ValueLocker locker;
1574 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001575 if (value_sp)
1576 return value_sp->GetFormat();
Greg Claytondc4e9632011-01-05 18:43:15 +00001577 return eFormatDefault;
1578}
1579
1580void
1581SBValue::SetFormat (lldb::Format format)
1582{
Jim Ingham362e39a2013-05-15 02:16:21 +00001583 ValueLocker locker;
1584 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001585 if (value_sp)
1586 value_sp->SetFormat(format);
Greg Claytondc4e9632011-01-05 18:43:15 +00001587}
1588
Enrico Granata6f3533f2011-07-29 19:53:35 +00001589lldb::SBValue
1590SBValue::AddressOf()
1591{
1592 SBValue sb_value;
Jim Ingham362e39a2013-05-15 02:16:21 +00001593 ValueLocker locker;
1594 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001595 if (value_sp)
Enrico Granata6f3533f2011-07-29 19:53:35 +00001596 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001597 Error error;
1598 sb_value.SetSP(value_sp->AddressOf (error),GetPreferDynamicValue(), GetPreferSyntheticValue());
Enrico Granata6f3533f2011-07-29 19:53:35 +00001599 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001600 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata6f3533f2011-07-29 19:53:35 +00001601 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001602 log->Printf ("SBValue(%p)::AddressOf () => SBValue(%p)",
1603 static_cast<void*>(value_sp.get()),
1604 static_cast<void*>(value_sp.get()));
1605
Enrico Granata6f3533f2011-07-29 19:53:35 +00001606 return sb_value;
Johnny Chen4a871f92011-08-09 22:38:07 +00001607}
Enrico Granata9128ee22011-09-06 19:20:51 +00001608
1609lldb::addr_t
1610SBValue::GetLoadAddress()
1611{
1612 lldb::addr_t value = LLDB_INVALID_ADDRESS;
Jim Ingham362e39a2013-05-15 02:16:21 +00001613 ValueLocker locker;
1614 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001615 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001616 {
Greg Claytoncc4d0142012-02-17 07:49:44 +00001617 TargetSP target_sp (value_sp->GetTargetSP());
1618 if (target_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001619 {
Enrico Granata9128ee22011-09-06 19:20:51 +00001620 const bool scalar_is_load_address = true;
1621 AddressType addr_type;
Greg Clayton81e871e2012-02-04 02:27:34 +00001622 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
Enrico Granata9128ee22011-09-06 19:20:51 +00001623 if (addr_type == eAddressTypeFile)
1624 {
Greg Claytone72dfb32012-02-24 01:59:29 +00001625 ModuleSP module_sp (value_sp->GetModule());
1626 if (!module_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001627 value = LLDB_INVALID_ADDRESS;
1628 else
1629 {
1630 Address addr;
Greg Claytone72dfb32012-02-24 01:59:29 +00001631 module_sp->ResolveFileAddress(value, addr);
Greg Claytoncc4d0142012-02-17 07:49:44 +00001632 value = addr.GetLoadAddress(target_sp.get());
Enrico Granata9128ee22011-09-06 19:20:51 +00001633 }
1634 }
1635 else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeInvalid)
1636 value = LLDB_INVALID_ADDRESS;
1637 }
1638 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001639 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001640 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001641 log->Printf ("SBValue(%p)::GetLoadAddress () => (%" PRIu64 ")",
1642 static_cast<void*>(value_sp.get()), value);
1643
Enrico Granata9128ee22011-09-06 19:20:51 +00001644 return value;
1645}
1646
1647lldb::SBAddress
1648SBValue::GetAddress()
1649{
1650 Address addr;
Jim Ingham362e39a2013-05-15 02:16:21 +00001651 ValueLocker locker;
1652 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001653 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001654 {
Greg Claytoncc4d0142012-02-17 07:49:44 +00001655 TargetSP target_sp (value_sp->GetTargetSP());
1656 if (target_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001657 {
1658 lldb::addr_t value = LLDB_INVALID_ADDRESS;
Enrico Granata9128ee22011-09-06 19:20:51 +00001659 const bool scalar_is_load_address = true;
1660 AddressType addr_type;
Greg Clayton81e871e2012-02-04 02:27:34 +00001661 value = value_sp->GetAddressOf(scalar_is_load_address, &addr_type);
Enrico Granata9128ee22011-09-06 19:20:51 +00001662 if (addr_type == eAddressTypeFile)
1663 {
Greg Claytone72dfb32012-02-24 01:59:29 +00001664 ModuleSP module_sp (value_sp->GetModule());
1665 if (module_sp)
1666 module_sp->ResolveFileAddress(value, addr);
Enrico Granata9128ee22011-09-06 19:20:51 +00001667 }
1668 else if (addr_type == eAddressTypeLoad)
1669 {
1670 // no need to check the return value on this.. if it can actually do the resolve
1671 // addr will be in the form (section,offset), otherwise it will simply be returned
1672 // as (NULL, value)
Greg Claytoncc4d0142012-02-17 07:49:44 +00001673 addr.SetLoadAddress(value, target_sp.get());
Enrico Granata9128ee22011-09-06 19:20:51 +00001674 }
1675 }
1676 }
Greg Clayton5160ce52013-03-27 23:08:40 +00001677 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001678 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001679 log->Printf ("SBValue(%p)::GetAddress () => (%s,%" PRIu64 ")",
1680 static_cast<void*>(value_sp.get()),
1681 (addr.GetSection()
1682 ? addr.GetSection()->GetName().GetCString()
1683 : "NULL"),
Jim Ingham35e1bda2012-10-16 21:41:58 +00001684 addr.GetOffset());
Enrico Granata9128ee22011-09-06 19:20:51 +00001685 return SBAddress(new Address(addr));
1686}
1687
1688lldb::SBData
1689SBValue::GetPointeeData (uint32_t item_idx,
1690 uint32_t item_count)
1691{
Greg Clayton5160ce52013-03-27 23:08:40 +00001692 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001693 lldb::SBData sb_data;
Jim Ingham362e39a2013-05-15 02:16:21 +00001694 ValueLocker locker;
1695 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001696 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001697 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001698 TargetSP target_sp (value_sp->GetTargetSP());
1699 if (target_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001700 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001701 DataExtractorSP data_sp(new DataExtractor());
1702 value_sp->GetPointeeData(*data_sp, item_idx, item_count);
1703 if (data_sp->GetByteSize() > 0)
1704 *sb_data = data_sp;
Enrico Granata9128ee22011-09-06 19:20:51 +00001705 }
1706 }
Enrico Granata9128ee22011-09-06 19:20:51 +00001707 if (log)
1708 log->Printf ("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001709 static_cast<void*>(value_sp.get()), item_idx, item_count,
1710 static_cast<void*>(sb_data.get()));
1711
Enrico Granata9128ee22011-09-06 19:20:51 +00001712 return sb_data;
1713}
1714
1715lldb::SBData
1716SBValue::GetData ()
1717{
Greg Clayton5160ce52013-03-27 23:08:40 +00001718 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Enrico Granata9128ee22011-09-06 19:20:51 +00001719 lldb::SBData sb_data;
Jim Ingham362e39a2013-05-15 02:16:21 +00001720 ValueLocker locker;
1721 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001722 if (value_sp)
Enrico Granata9128ee22011-09-06 19:20:51 +00001723 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001724 DataExtractorSP data_sp(new DataExtractor());
Sean Callanan866e91c2014-02-28 22:27:53 +00001725 Error error;
1726 value_sp->GetData(*data_sp, error);
1727 if (error.Success())
Jim Ingham362e39a2013-05-15 02:16:21 +00001728 *sb_data = data_sp;
Enrico Granata9128ee22011-09-06 19:20:51 +00001729 }
Enrico Granata9128ee22011-09-06 19:20:51 +00001730 if (log)
1731 log->Printf ("SBValue(%p)::GetData () => SBData(%p)",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001732 static_cast<void*>(value_sp.get()),
1733 static_cast<void*>(sb_data.get()));
1734
Enrico Granata9128ee22011-09-06 19:20:51 +00001735 return sb_data;
1736}
Greg Clayton1b282f92011-10-13 18:08:26 +00001737
Sean Callanan389823e2013-04-13 01:21:23 +00001738bool
1739SBValue::SetData (lldb::SBData &data, SBError &error)
1740{
1741 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham362e39a2013-05-15 02:16:21 +00001742 ValueLocker locker;
1743 lldb::ValueObjectSP value_sp(GetSP(locker));
Sean Callanan389823e2013-04-13 01:21:23 +00001744 bool ret = true;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001745
Sean Callanan389823e2013-04-13 01:21:23 +00001746 if (value_sp)
1747 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001748 DataExtractor *data_extractor = data.get();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001749
Jim Ingham362e39a2013-05-15 02:16:21 +00001750 if (!data_extractor)
Sean Callanan389823e2013-04-13 01:21:23 +00001751 {
1752 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001753 log->Printf ("SBValue(%p)::SetData() => error: no data to set",
1754 static_cast<void*>(value_sp.get()));
1755
Jim Ingham362e39a2013-05-15 02:16:21 +00001756 error.SetErrorString("No data to set");
Sean Callanan389823e2013-04-13 01:21:23 +00001757 ret = false;
1758 }
1759 else
1760 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001761 Error set_error;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001762
Jim Ingham362e39a2013-05-15 02:16:21 +00001763 value_sp->SetData(*data_extractor, set_error);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001764
Jim Ingham362e39a2013-05-15 02:16:21 +00001765 if (!set_error.Success())
Sean Callanan389823e2013-04-13 01:21:23 +00001766 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001767 error.SetErrorStringWithFormat("Couldn't set data: %s", set_error.AsCString());
Sean Callanan389823e2013-04-13 01:21:23 +00001768 ret = false;
1769 }
Sean Callanan389823e2013-04-13 01:21:23 +00001770 }
1771 }
1772 else
1773 {
Jim Ingham362e39a2013-05-15 02:16:21 +00001774 error.SetErrorStringWithFormat ("Couldn't set data: could not get SBValue: %s", locker.GetError().AsCString());
Sean Callanan389823e2013-04-13 01:21:23 +00001775 ret = false;
1776 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001777
Sean Callanan389823e2013-04-13 01:21:23 +00001778 if (log)
1779 log->Printf ("SBValue(%p)::SetData (%p) => %s",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001780 static_cast<void*>(value_sp.get()),
1781 static_cast<void*>(data.get()), ret ? "true" : "false");
Sean Callanan389823e2013-04-13 01:21:23 +00001782 return ret;
1783}
1784
Enrico Granata10de0902012-10-10 22:54:17 +00001785lldb::SBDeclaration
1786SBValue::GetDeclaration ()
1787{
Jim Ingham362e39a2013-05-15 02:16:21 +00001788 ValueLocker locker;
1789 lldb::ValueObjectSP value_sp(GetSP(locker));
Enrico Granata10de0902012-10-10 22:54:17 +00001790 SBDeclaration decl_sb;
1791 if (value_sp)
1792 {
1793 Declaration decl;
1794 if (value_sp->GetDeclaration(decl))
1795 decl_sb.SetDeclaration(decl);
1796 }
1797 return decl_sb;
1798}
1799
Greg Clayton1b282f92011-10-13 18:08:26 +00001800lldb::SBWatchpoint
Johnny Chenb90827e2012-06-04 23:19:54 +00001801SBValue::Watch (bool resolve_location, bool read, bool write, SBError &error)
Greg Clayton1b282f92011-10-13 18:08:26 +00001802{
Greg Clayton81e871e2012-02-04 02:27:34 +00001803 SBWatchpoint sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001804
Greg Clayton81e871e2012-02-04 02:27:34 +00001805 // If the SBValue is not valid, there's no point in even trying to watch it.
Jim Ingham362e39a2013-05-15 02:16:21 +00001806 ValueLocker locker;
1807 lldb::ValueObjectSP value_sp(GetSP(locker));
Greg Clayton81e871e2012-02-04 02:27:34 +00001808 TargetSP target_sp (GetTarget().GetSP());
1809 if (value_sp && target_sp)
Greg Clayton1b282f92011-10-13 18:08:26 +00001810 {
Greg Clayton81e871e2012-02-04 02:27:34 +00001811 // Read and Write cannot both be false.
1812 if (!read && !write)
1813 return sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001814
Greg Clayton81e871e2012-02-04 02:27:34 +00001815 // If the value is not in scope, don't try and watch and invalid value
1816 if (!IsInScope())
1817 return sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001818
Greg Clayton81e871e2012-02-04 02:27:34 +00001819 addr_t addr = GetLoadAddress();
1820 if (addr == LLDB_INVALID_ADDRESS)
1821 return sb_watchpoint;
1822 size_t byte_size = GetByteSize();
1823 if (byte_size == 0)
1824 return sb_watchpoint;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001825
Greg Clayton81e871e2012-02-04 02:27:34 +00001826 uint32_t watch_type = 0;
1827 if (read)
1828 watch_type |= LLDB_WATCH_TYPE_READ;
1829 if (write)
1830 watch_type |= LLDB_WATCH_TYPE_WRITE;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001831
Johnny Chenb90827e2012-06-04 23:19:54 +00001832 Error rc;
Greg Clayton57ee3062013-07-11 22:46:58 +00001833 ClangASTType type (value_sp->GetClangType());
Jim Inghama7dfb662012-10-23 07:20:06 +00001834 WatchpointSP watchpoint_sp = target_sp->CreateWatchpoint(addr, byte_size, &type, watch_type, rc);
Johnny Chenb90827e2012-06-04 23:19:54 +00001835 error.SetError(rc);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001836
Daniel Maleae0f8f572013-08-26 23:57:52 +00001837 if (watchpoint_sp)
Greg Clayton81e871e2012-02-04 02:27:34 +00001838 {
1839 sb_watchpoint.SetSP (watchpoint_sp);
1840 Declaration decl;
1841 if (value_sp->GetDeclaration (decl))
1842 {
Daniel Maleae0f8f572013-08-26 23:57:52 +00001843 if (decl.GetFile())
Greg Clayton81e871e2012-02-04 02:27:34 +00001844 {
1845 StreamString ss;
1846 // True to show fullpath for declaration file.
1847 decl.DumpStopContext(&ss, true);
1848 watchpoint_sp->SetDeclInfo(ss.GetString());
1849 }
1850 }
1851 }
Greg Clayton1b282f92011-10-13 18:08:26 +00001852 }
Jim Ingham362e39a2013-05-15 02:16:21 +00001853 else if (target_sp)
1854 {
1855 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1856 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001857 log->Printf ("SBValue(%p)::Watch() => error getting SBValue: %s",
1858 static_cast<void*>(value_sp.get()),
1859 locker.GetError().AsCString());
1860
Jim Ingham362e39a2013-05-15 02:16:21 +00001861 error.SetErrorStringWithFormat("could not get SBValue: %s", locker.GetError().AsCString());
1862 }
1863 else
1864 {
1865 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1866 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001867 log->Printf ("SBValue(%p)::Watch() => error getting SBValue: no target",
1868 static_cast<void*>(value_sp.get()));
Jim Ingham362e39a2013-05-15 02:16:21 +00001869 error.SetErrorString("could not set watchpoint, a target is required");
1870 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001871
Greg Clayton1b282f92011-10-13 18:08:26 +00001872 return sb_watchpoint;
1873}
1874
Johnny Chend3761a72012-06-04 23:45:50 +00001875// FIXME: Remove this method impl (as well as the decl in .h) once it is no longer needed.
1876// Backward compatibility fix in the interim.
1877lldb::SBWatchpoint
1878SBValue::Watch (bool resolve_location, bool read, bool write)
1879{
Johnny Chen974759f2012-06-05 00:14:15 +00001880 SBError error;
1881 return Watch(resolve_location, read, write, error);
Johnny Chend3761a72012-06-04 23:45:50 +00001882}
1883
Greg Clayton1b282f92011-10-13 18:08:26 +00001884lldb::SBWatchpoint
Johnny Chenb90827e2012-06-04 23:19:54 +00001885SBValue::WatchPointee (bool resolve_location, bool read, bool write, SBError &error)
Greg Clayton1b282f92011-10-13 18:08:26 +00001886{
Greg Clayton81e871e2012-02-04 02:27:34 +00001887 SBWatchpoint sb_watchpoint;
1888 if (IsInScope() && GetType().IsPointerType())
Johnny Chenb90827e2012-06-04 23:19:54 +00001889 sb_watchpoint = Dereference().Watch (resolve_location, read, write, error);
Greg Clayton1b282f92011-10-13 18:08:26 +00001890 return sb_watchpoint;
1891}