blob: 2973457f0d6a795484a1211745ec07aa959d6d86 [file] [log] [blame]
Chris Lattner24943d22010-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
Eli Friedman7a62c8b2010-06-09 07:44:37 +000010#include "lldb/API/SBValue.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000011#include "lldb/API/SBStream.h"
Chris Lattner24943d22010-06-08 16:52:24 +000012
13#include "lldb/Core/DataExtractor.h"
Caroline Tice7826c882010-10-26 03:11:13 +000014#include "lldb/Core/Log.h"
Chris Lattner24943d22010-06-08 16:52:24 +000015#include "lldb/Core/Module.h"
16#include "lldb/Core/Stream.h"
17#include "lldb/Core/StreamFile.h"
18#include "lldb/Core/Value.h"
19#include "lldb/Core/ValueObject.h"
Enrico Granata979e20d2011-07-29 19:53:35 +000020#include "lldb/Core/ValueObjectConstResult.h"
Chris Lattner24943d22010-06-08 16:52:24 +000021#include "lldb/Symbol/Block.h"
22#include "lldb/Symbol/ObjectFile.h"
23#include "lldb/Symbol/Variable.h"
24#include "lldb/Target/ExecutionContext.h"
25#include "lldb/Target/Process.h"
26#include "lldb/Target/StackFrame.h"
Greg Claytonbdcda462010-12-20 20:49:23 +000027#include "lldb/Target/Target.h"
Chris Lattner24943d22010-06-08 16:52:24 +000028#include "lldb/Target/Thread.h"
29
Eli Friedman7a62c8b2010-06-09 07:44:37 +000030#include "lldb/API/SBProcess.h"
31#include "lldb/API/SBTarget.h"
32#include "lldb/API/SBThread.h"
33#include "lldb/API/SBFrame.h"
34#include "lldb/API/SBDebugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000035
36using namespace lldb;
37using namespace lldb_private;
38
39SBValue::SBValue () :
Greg Clayton63094e02010-06-23 01:19:29 +000040 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000041{
42}
43
44SBValue::SBValue (const lldb::ValueObjectSP &value_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000045 m_opaque_sp (value_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000046{
47}
48
Greg Clayton538eb822010-11-05 23:17:00 +000049SBValue::SBValue(const SBValue &rhs) :
50 m_opaque_sp (rhs.m_opaque_sp)
51{
52}
53
54const SBValue &
55SBValue::operator = (const SBValue &rhs)
56{
57 if (this != &rhs)
58 m_opaque_sp = rhs.m_opaque_sp;
59 return *this;
60}
61
Chris Lattner24943d22010-06-08 16:52:24 +000062SBValue::~SBValue()
63{
64}
65
66bool
67SBValue::IsValid () const
68{
Greg Clayton49ce6822010-10-31 03:01:06 +000069 // If this function ever changes to anything that does more than just
70 // check if the opaque shared pointer is non NULL, then we need to update
71 // all "if (m_opaque_sp)" code in this file.
72 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000073}
74
Greg Claytonc5f728c2010-10-06 22:10:17 +000075SBError
76SBValue::GetError()
77{
78 SBError sb_error;
79
80 if (m_opaque_sp.get())
81 sb_error.SetError(m_opaque_sp->GetError());
82
83 return sb_error;
84}
85
Johnny Chen968958c2011-07-07 20:46:23 +000086user_id_t
87SBValue::GetID()
88{
89 if (m_opaque_sp)
90 return m_opaque_sp->GetID();
91 return LLDB_INVALID_UID;
92}
93
Chris Lattner24943d22010-06-08 16:52:24 +000094const char *
95SBValue::GetName()
96{
Greg Clayton49ce6822010-10-31 03:01:06 +000097
98 const char *name = NULL;
99 if (m_opaque_sp)
100 name = m_opaque_sp->GetName().GetCString();
101
Greg Claytone005f2c2010-11-06 01:53:30 +0000102 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000103 if (log)
Greg Clayton49ce6822010-10-31 03:01:06 +0000104 {
105 if (name)
106 log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name);
107 else
108 log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name);
109 }
Caroline Tice7826c882010-10-26 03:11:13 +0000110
Greg Clayton49ce6822010-10-31 03:01:06 +0000111 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000112}
113
114const char *
115SBValue::GetTypeName ()
116{
Greg Clayton49ce6822010-10-31 03:01:06 +0000117 const char *name = NULL;
118 if (m_opaque_sp)
119 name = m_opaque_sp->GetTypeName().GetCString();
Greg Claytone005f2c2010-11-06 01:53:30 +0000120 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000121 if (log)
122 {
123 if (name)
124 log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name);
125 else
126 log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get());
127 }
128
129 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000130}
131
132size_t
133SBValue::GetByteSize ()
134{
135 size_t result = 0;
136
Greg Clayton49ce6822010-10-31 03:01:06 +0000137 if (m_opaque_sp)
Greg Clayton63094e02010-06-23 01:19:29 +0000138 result = m_opaque_sp->GetByteSize();
Chris Lattner24943d22010-06-08 16:52:24 +0000139
Greg Claytone005f2c2010-11-06 01:53:30 +0000140 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000141 if (log)
142 log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result);
143
Chris Lattner24943d22010-06-08 16:52:24 +0000144 return result;
145}
146
147bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000148SBValue::IsInScope (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000149{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000150 return IsInScope();
151}
152
153bool
154SBValue::IsInScope ()
155{
Chris Lattner24943d22010-06-08 16:52:24 +0000156 bool result = false;
157
Greg Clayton49ce6822010-10-31 03:01:06 +0000158 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000159 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000160 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000161 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000162 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000163 result = m_opaque_sp->IsInScope ();
164 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000165 }
Chris Lattner24943d22010-06-08 16:52:24 +0000166
Greg Claytone005f2c2010-11-06 01:53:30 +0000167 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000168 if (log)
169 log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result);
170
Chris Lattner24943d22010-06-08 16:52:24 +0000171 return result;
172}
173
174const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000175SBValue::GetValue (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000176{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000177 return GetValue();
178}
179
180const char *
181SBValue::GetValue ()
182{
Greg Clayton49ce6822010-10-31 03:01:06 +0000183 const char *cstr = NULL;
Greg Claytonbdcda462010-12-20 20:49:23 +0000184 if (m_opaque_sp)
185 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000186 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000187 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000188 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000189 cstr = m_opaque_sp->GetValueAsCString ();
190 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000191 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000192 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000193 if (log)
194 {
195 if (cstr)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000196 log->Printf ("SBValue(%p)::GetValue => \"%s\"", m_opaque_sp.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000197 else
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000198 log->Printf ("SBValue(%p)::GetValue => NULL", m_opaque_sp.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000199 }
200
201 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000202}
203
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000204ValueType
205SBValue::GetValueType ()
206{
Greg Clayton49ce6822010-10-31 03:01:06 +0000207 ValueType result = eValueTypeInvalid;
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000208 if (m_opaque_sp)
Greg Clayton49ce6822010-10-31 03:01:06 +0000209 result = m_opaque_sp->GetValueType();
Greg Claytone005f2c2010-11-06 01:53:30 +0000210 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000211 if (log)
212 {
213 switch (result)
214 {
215 case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break;
216 case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break;
217 case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break;
218 case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break;
219 case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break;
220 case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break;
221 case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break;
222 case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break;
223 default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break;
224 }
225 }
226 return result;
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000227}
228
Jim Ingham4ae51962010-09-10 23:12:17 +0000229const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000230SBValue::GetObjectDescription (const SBFrame &sb_frame)
Jim Ingham4ae51962010-09-10 23:12:17 +0000231{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000232 return GetObjectDescription ();
233}
234
235const char *
236SBValue::GetObjectDescription ()
237{
Greg Clayton49ce6822010-10-31 03:01:06 +0000238 const char *cstr = NULL;
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000239 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000240 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000241 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000242 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000243 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000244 cstr = m_opaque_sp->GetObjectDescription ();
245 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000246 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000247 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000248 if (log)
249 {
250 if (cstr)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000251 log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", m_opaque_sp.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000252 else
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000253 log->Printf ("SBValue(%p)::GetObjectDescription => NULL", m_opaque_sp.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000254 }
255 return cstr;
Jim Ingham4ae51962010-09-10 23:12:17 +0000256}
257
Chris Lattner24943d22010-06-08 16:52:24 +0000258bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000259SBValue::GetValueDidChange (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000260{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000261 return GetValueDidChange ();
262}
263
Enrico Granata979e20d2011-07-29 19:53:35 +0000264SBType
265SBValue::GetType()
266{
267 SBType result;
268 if (m_opaque_sp)
269 {
270 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
271 {
272 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
273 result = SBType(m_opaque_sp->GetClangAST(),
274 m_opaque_sp->GetClangType());
275 }
276 }
277 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
278 if (log)
279 {
280 if (result.IsValid())
281 log->Printf ("SBValue(%p)::GetType => %p", m_opaque_sp.get(), &result);
282 else
283 log->Printf ("SBValue(%p)::GetType => NULL", m_opaque_sp.get());
284 }
285 return result;
286}
287
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000288bool
289SBValue::GetValueDidChange ()
290{
Greg Clayton49ce6822010-10-31 03:01:06 +0000291 bool result = false;
292 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000293 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000294 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000295 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000296 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000297 result = m_opaque_sp->GetValueDidChange ();
298 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000299 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000300 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000301 if (log)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000302 log->Printf ("SBValue(%p)::GetValueDidChange => %i", m_opaque_sp.get(), result);
Greg Clayton49ce6822010-10-31 03:01:06 +0000303
304 return result;
Chris Lattner24943d22010-06-08 16:52:24 +0000305}
306
307const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000308SBValue::GetSummary (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000309{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000310 return GetSummary ();
311}
312
313const char *
314SBValue::GetSummary ()
315{
Greg Clayton49ce6822010-10-31 03:01:06 +0000316 const char *cstr = NULL;
317 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000318 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000319 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000320 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000321 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000322 cstr = m_opaque_sp->GetSummaryAsCString();
323 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000324 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000325 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000326 if (log)
327 {
328 if (cstr)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000329 log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000330 else
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000331 log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000332 }
333 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000334}
335
336const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000337SBValue::GetLocation (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000338{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000339 return GetLocation ();
340}
341
342const char *
343SBValue::GetLocation ()
344{
Greg Clayton49ce6822010-10-31 03:01:06 +0000345 const char *cstr = NULL;
346 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000347 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000348 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000349 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000350 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000351 cstr = m_opaque_sp->GetLocationAsCString();
352 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000353 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000354 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000355 if (log)
356 {
357 if (cstr)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000358 log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000359 else
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000360 log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000361 }
362 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000363}
364
365bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000366SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str)
Chris Lattner24943d22010-06-08 16:52:24 +0000367{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000368 return SetValueFromCString (value_str);
369}
370
371bool
372SBValue::SetValueFromCString (const char *value_str)
373{
Chris Lattner24943d22010-06-08 16:52:24 +0000374 bool success = false;
Greg Clayton49ce6822010-10-31 03:01:06 +0000375 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000376 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000377 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000378 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000379 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000380 success = m_opaque_sp->SetValueFromCString (value_str);
381 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000382 }
Chris Lattner24943d22010-06-08 16:52:24 +0000383 return success;
384}
385
Enrico Granata979e20d2011-07-29 19:53:35 +0000386lldb::SBValue
387SBValue::CreateChildAtOffset (const char *name, uint32_t offset, const SBType& type)
388{
389 lldb::SBValue result;
390 if (m_opaque_sp)
391 {
392 if (type.IsValid())
393 {
394 result = SBValue(m_opaque_sp->GetSyntheticChildAtOffset(offset, *type.m_opaque_ap->GetClangASTType(), true));
395 result.m_opaque_sp->SetName(ConstString(name));
396 }
397 }
398 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
399 if (log)
400 {
401 if (result.IsValid())
402 log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
403 else
404 log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", m_opaque_sp.get());
405 }
406 return result;
407}
408
409lldb::SBValue
410SBValue::Cast(const SBType& type)
411{
412 return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type);
413}
414
415lldb::SBValue
416SBValue::CreateValueFromExpression (const char *name, const char* expression)
417{
418 lldb::SBValue result;
419 if (m_opaque_sp)
420 {
421 ValueObjectSP result_valobj_sp;
422 m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression(expression,
423 m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame(),
424 true, true, eNoDynamicValues,
425 result_valobj_sp);
426 result_valobj_sp->SetName(ConstString(name));
427 result = SBValue(result_valobj_sp);
428 }
429 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
430 if (log)
431 {
432 if (result.IsValid())
433 log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
434 else
435 log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get());
436 }
437 return result;
438}
439
440lldb::SBValue
441SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, const SBType& type)
442{
443 lldb::SBValue result;
444 if (m_opaque_sp)
445 {
446
447 SBType real_type(type.GetPointerType());
448
449 lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t)));
450
451 ValueObjectSP result_valobj_sp(ValueObjectConstResult::Create(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(),
452 real_type.m_opaque_ap->GetASTContext(),
453 real_type.m_opaque_ap->GetOpaqueQualType(),
454 ConstString(name),
455 buffer,
456 lldb::endian::InlHostByteOrder(),
457 GetTarget().GetProcess().GetAddressByteSize()));
458
459 result_valobj_sp->SetName(ConstString(name));
Enrico Granata7dfb1bb2011-08-02 23:12:24 +0000460 result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
Enrico Granata979e20d2011-07-29 19:53:35 +0000461 result = SBValue(result_valobj_sp);
462 }
463 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
464 if (log)
465 {
466 if (result.IsValid())
467 log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
468 else
469 log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get());
470 }
471 return result;
472}
473
Chris Lattner24943d22010-06-08 16:52:24 +0000474SBValue
475SBValue::GetChildAtIndex (uint32_t idx)
476{
Greg Clayton8f64c472011-07-15 19:31:49 +0000477 const bool can_create_synthetic = false;
478 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
Johnny Chen446ccaa2011-06-29 21:19:39 +0000479 if (m_opaque_sp)
Enrico Granata979e20d2011-07-29 19:53:35 +0000480 use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
Greg Clayton8f64c472011-07-15 19:31:49 +0000481 return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
Jim Inghame41494a2011-04-16 00:01:13 +0000482}
483
484SBValue
Greg Clayton8f64c472011-07-15 19:31:49 +0000485SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
Jim Inghame41494a2011-04-16 00:01:13 +0000486{
Chris Lattner24943d22010-06-08 16:52:24 +0000487 lldb::ValueObjectSP child_sp;
488
Greg Clayton49ce6822010-10-31 03:01:06 +0000489 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000490 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000491 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000492 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000493 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Clayton8f64c472011-07-15 19:31:49 +0000494 const bool can_create = true;
495 child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create);
496 if (can_create_synthetic && !child_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000497 {
Greg Clayton8f64c472011-07-15 19:31:49 +0000498 if (m_opaque_sp->IsPointerType())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000499 {
Greg Clayton8f64c472011-07-15 19:31:49 +0000500 child_sp = m_opaque_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
501 }
502 else if (m_opaque_sp->IsArrayType())
503 {
504 child_sp = m_opaque_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
505 }
506 }
507
508 if (child_sp)
509 {
510 if (use_dynamic != lldb::eNoDynamicValues)
511 {
512 lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic));
Greg Claytonb9dcc512011-06-29 18:28:50 +0000513 if (dynamic_sp)
514 child_sp = dynamic_sp;
515 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000516 }
Jim Inghame41494a2011-04-16 00:01:13 +0000517 }
518 }
519
Chris Lattner24943d22010-06-08 16:52:24 +0000520 SBValue sb_value (child_sp);
Greg Claytone005f2c2010-11-06 01:53:30 +0000521 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000522 if (log)
523 log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get());
524
Chris Lattner24943d22010-06-08 16:52:24 +0000525 return sb_value;
526}
527
528uint32_t
529SBValue::GetIndexOfChildWithName (const char *name)
530{
Greg Clayton49ce6822010-10-31 03:01:06 +0000531 uint32_t idx = UINT32_MAX;
532 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000533 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000534 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000535 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000536 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000537
Greg Claytonb9dcc512011-06-29 18:28:50 +0000538 idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
539 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000540 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000541 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000542 if (log)
543 {
544 if (idx == UINT32_MAX)
545 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx);
546 else
547 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx);
548 }
549 return idx;
Chris Lattner24943d22010-06-08 16:52:24 +0000550}
551
552SBValue
553SBValue::GetChildMemberWithName (const char *name)
554{
Johnny Chen446ccaa2011-06-29 21:19:39 +0000555 if (m_opaque_sp)
556 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000557 lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
Johnny Chen446ccaa2011-06-29 21:19:39 +0000558 return GetChildMemberWithName (name, use_dynamic_value);
559 }
560 else
561 return GetChildMemberWithName (name, eNoDynamicValues);
Jim Inghame41494a2011-04-16 00:01:13 +0000562}
563
564SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000565SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value)
Jim Inghame41494a2011-04-16 00:01:13 +0000566{
Chris Lattner24943d22010-06-08 16:52:24 +0000567 lldb::ValueObjectSP child_sp;
568 const ConstString str_name (name);
569
Greg Clayton905acaf2011-05-20 22:07:17 +0000570
Greg Clayton49ce6822010-10-31 03:01:06 +0000571 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000572 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000573 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Jim Inghame41494a2011-04-16 00:01:13 +0000574 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000575 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000576 child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
577 if (use_dynamic_value != lldb::eNoDynamicValues)
Greg Claytonfab305b2011-05-20 23:51:26 +0000578 {
Greg Claytonb9dcc512011-06-29 18:28:50 +0000579 if (child_sp)
580 {
581 lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value);
582 if (dynamic_sp)
583 child_sp = dynamic_sp;
584 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000585 }
Jim Inghame41494a2011-04-16 00:01:13 +0000586 }
587 }
588
Chris Lattner24943d22010-06-08 16:52:24 +0000589 SBValue sb_value (child_sp);
Greg Clayton49ce6822010-10-31 03:01:06 +0000590
Greg Claytone005f2c2010-11-06 01:53:30 +0000591 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000592 if (log)
593 log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get());
594
Chris Lattner24943d22010-06-08 16:52:24 +0000595 return sb_value;
596}
597
Enrico Granataf7a9b142011-07-15 02:26:42 +0000598lldb::SBValue
599SBValue::GetValueForExpressionPath(const char* expr_path)
600{
601 lldb::ValueObjectSP child_sp;
602 if (m_opaque_sp)
603 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000604 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Enrico Granataf7a9b142011-07-15 02:26:42 +0000605 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000606 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Enrico Granataf7a9b142011-07-15 02:26:42 +0000607 // using default values for all the fancy options, just do it if you can
608 child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path);
609 }
610 }
611
612 SBValue sb_value (child_sp);
613
614 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
615 if (log)
616 log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr_path, sb_value.get());
617
618 return sb_value;
619}
Chris Lattner24943d22010-06-08 16:52:24 +0000620
621uint32_t
622SBValue::GetNumChildren ()
623{
624 uint32_t num_children = 0;
625
Greg Clayton49ce6822010-10-31 03:01:06 +0000626 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000627 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000628 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000629 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000630 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000631
Greg Claytonb9dcc512011-06-29 18:28:50 +0000632 num_children = m_opaque_sp->GetNumChildren();
633 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000634 }
Greg Clayton49ce6822010-10-31 03:01:06 +0000635
Greg Claytone005f2c2010-11-06 01:53:30 +0000636 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000637 if (log)
638 log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children);
Chris Lattner24943d22010-06-08 16:52:24 +0000639
640 return num_children;
641}
642
Chris Lattner24943d22010-06-08 16:52:24 +0000643
644SBValue
645SBValue::Dereference ()
646{
Greg Clayton49ce6822010-10-31 03:01:06 +0000647 SBValue sb_value;
648 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000649 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000650 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000651 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000652 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000653
Greg Claytonb9dcc512011-06-29 18:28:50 +0000654 Error error;
655 sb_value = m_opaque_sp->Dereference (error);
656 }
Chris Lattner24943d22010-06-08 16:52:24 +0000657 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000658 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000659 if (log)
660 log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
661
662 return sb_value;
Chris Lattner24943d22010-06-08 16:52:24 +0000663}
664
665bool
Greg Clayton49ce6822010-10-31 03:01:06 +0000666SBValue::TypeIsPointerType ()
Chris Lattner24943d22010-06-08 16:52:24 +0000667{
668 bool is_ptr_type = false;
669
Greg Clayton49ce6822010-10-31 03:01:06 +0000670 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000671 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000672 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000673 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000674 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000675
Greg Claytonb9dcc512011-06-29 18:28:50 +0000676 is_ptr_type = m_opaque_sp->IsPointerType();
677 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000678 }
Greg Clayton49ce6822010-10-31 03:01:06 +0000679
Greg Claytone005f2c2010-11-06 01:53:30 +0000680 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000681 if (log)
682 log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type);
683
Chris Lattner24943d22010-06-08 16:52:24 +0000684
685 return is_ptr_type;
686}
687
Chris Lattner24943d22010-06-08 16:52:24 +0000688void *
689SBValue::GetOpaqueType()
690{
Greg Clayton63094e02010-06-23 01:19:29 +0000691 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000692 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000693 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000694 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000695 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000696
Greg Claytonb9dcc512011-06-29 18:28:50 +0000697 return m_opaque_sp->GetClangType();
698 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000699 }
Chris Lattner24943d22010-06-08 16:52:24 +0000700 return NULL;
701}
702
Enrico Granata979e20d2011-07-29 19:53:35 +0000703lldb::SBTarget
704SBValue::GetTarget()
705{
706 SBTarget result;
707 if (m_opaque_sp)
708 {
709 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
710 {
711 result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()));
712 }
713 }
714 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
715 if (log)
716 {
717 if (result.get() == NULL)
718 log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get());
719 else
720 log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get());
721 }
722 return result;
723}
724
725lldb::SBProcess
726SBValue::GetProcess()
727{
728 SBProcess result;
729 if (m_opaque_sp)
730 {
731 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
732 {
733 result = SBProcess(lldb::ProcessSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetProcessSP()));
734 }
735 }
736 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
737 if (log)
738 {
739 if (result.get() == NULL)
740 log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get());
741 else
742 log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get());
743 }
744 return result;
745}
746
747lldb::SBThread
748SBValue::GetThread()
749{
750 SBThread result;
751 if (m_opaque_sp)
752 {
753 if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
754 {
755 result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()));
756 }
757 }
758 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
759 if (log)
760 {
761 if (result.get() == NULL)
762 log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get());
763 else
764 log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), result.get());
765 }
766 return result;
767}
768
769lldb::SBFrame
770SBValue::GetFrame()
771{
772 SBFrame result;
773 if (m_opaque_sp)
774 {
775 if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
776 {
777 result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()));
778 }
779 }
780 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
781 if (log)
782 {
783 if (result.get() == NULL)
784 log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get());
785 else
786 log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get());
787 }
788 return result;
789}
790
791
Chris Lattner24943d22010-06-08 16:52:24 +0000792// Mimic shared pointer...
793lldb_private::ValueObject *
794SBValue::get() const
795{
Greg Clayton63094e02010-06-23 01:19:29 +0000796 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000797}
798
799lldb_private::ValueObject *
800SBValue::operator->() const
801{
Greg Clayton63094e02010-06-23 01:19:29 +0000802 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000803}
804
805lldb::ValueObjectSP &
806SBValue::operator*()
807{
Greg Clayton63094e02010-06-23 01:19:29 +0000808 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000809}
810
811const lldb::ValueObjectSP &
812SBValue::operator*() const
813{
Greg Clayton63094e02010-06-23 01:19:29 +0000814 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000815}
Caroline Tice98f930f2010-09-20 05:20:02 +0000816
817bool
Greg Clayton49ce6822010-10-31 03:01:06 +0000818SBValue::GetExpressionPath (SBStream &description)
819{
820 if (m_opaque_sp)
821 {
Greg Claytonb01000f2011-01-17 03:46:26 +0000822 m_opaque_sp->GetExpressionPath (description.ref(), false);
823 return true;
824 }
825 return false;
826}
827
828bool
829SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
830{
831 if (m_opaque_sp)
832 {
833 m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
Greg Clayton49ce6822010-10-31 03:01:06 +0000834 return true;
835 }
836 return false;
837}
838
839bool
Caroline Tice98f930f2010-09-20 05:20:02 +0000840SBValue::GetDescription (SBStream &description)
841{
842 if (m_opaque_sp)
843 {
Greg Claytonbafc86e2011-07-06 16:49:27 +0000844 uint32_t ptr_depth = 0;
845 uint32_t curr_depth = 0;
846 uint32_t max_depth = UINT32_MAX;
847 bool show_types = false;
848 bool show_location = false;
849 bool use_objc = false;
850 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
851 bool scope_already_checked = false;
852 bool flat_output = false;
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000853 bool use_synthetic = true;
854 uint32_t no_summary_depth = 0;
Greg Claytonbafc86e2011-07-06 16:49:27 +0000855 ValueObject::DumpValueObject (description.ref(),
856 m_opaque_sp.get(),
857 m_opaque_sp->GetName().GetCString(),
858 ptr_depth,
859 curr_depth,
860 max_depth,
861 show_types, show_location,
862 use_objc,
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000863 use_dynamic,
864 use_synthetic,
Greg Claytonbafc86e2011-07-06 16:49:27 +0000865 scope_already_checked,
Enrico Granata7f163b32011-07-16 01:22:04 +0000866 flat_output,
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000867 no_summary_depth);
Caroline Tice98f930f2010-09-20 05:20:02 +0000868 }
869 else
870 description.Printf ("No value");
871
872 return true;
873}
Greg Claytone179a582011-01-05 18:43:15 +0000874
875lldb::Format
876SBValue::GetFormat () const
877{
878 if (m_opaque_sp)
879 return m_opaque_sp->GetFormat();
880 return eFormatDefault;
881}
882
883void
884SBValue::SetFormat (lldb::Format format)
885{
886 if (m_opaque_sp)
887 m_opaque_sp->SetFormat(format);
888}
889
Enrico Granata979e20d2011-07-29 19:53:35 +0000890lldb::SBValue
891SBValue::AddressOf()
892{
893 SBValue sb_value;
894 if (m_opaque_sp)
895 {
896 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
897 {
898 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
899
900 Error error;
901 sb_value = m_opaque_sp->AddressOf (error);
902 }
903 }
904 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
905 if (log)
906 log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
907
908 return sb_value;
909}