blob: a58957b9a9b56db816d9ef62301f38eee7b07138 [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"
Greg Clayton0fb0bcc2011-08-03 22:57:10 +000016#include "lldb/Core/Scalar.h"
Chris Lattner24943d22010-06-08 16:52:24 +000017#include "lldb/Core/Stream.h"
18#include "lldb/Core/StreamFile.h"
19#include "lldb/Core/Value.h"
20#include "lldb/Core/ValueObject.h"
Enrico Granata979e20d2011-07-29 19:53:35 +000021#include "lldb/Core/ValueObjectConstResult.h"
Chris Lattner24943d22010-06-08 16:52:24 +000022#include "lldb/Symbol/Block.h"
23#include "lldb/Symbol/ObjectFile.h"
24#include "lldb/Symbol/Variable.h"
25#include "lldb/Target/ExecutionContext.h"
26#include "lldb/Target/Process.h"
27#include "lldb/Target/StackFrame.h"
Greg Claytonbdcda462010-12-20 20:49:23 +000028#include "lldb/Target/Target.h"
Chris Lattner24943d22010-06-08 16:52:24 +000029#include "lldb/Target/Thread.h"
30
Eli Friedman7a62c8b2010-06-09 07:44:37 +000031#include "lldb/API/SBProcess.h"
32#include "lldb/API/SBTarget.h"
33#include "lldb/API/SBThread.h"
34#include "lldb/API/SBFrame.h"
35#include "lldb/API/SBDebugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000036
37using namespace lldb;
38using namespace lldb_private;
39
40SBValue::SBValue () :
Greg Clayton63094e02010-06-23 01:19:29 +000041 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000042{
43}
44
45SBValue::SBValue (const lldb::ValueObjectSP &value_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000046 m_opaque_sp (value_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000047{
48}
49
Greg Clayton538eb822010-11-05 23:17:00 +000050SBValue::SBValue(const SBValue &rhs) :
51 m_opaque_sp (rhs.m_opaque_sp)
52{
53}
54
55const SBValue &
56SBValue::operator = (const SBValue &rhs)
57{
58 if (this != &rhs)
59 m_opaque_sp = rhs.m_opaque_sp;
60 return *this;
61}
62
Chris Lattner24943d22010-06-08 16:52:24 +000063SBValue::~SBValue()
64{
65}
66
67bool
68SBValue::IsValid () const
69{
Greg Clayton49ce6822010-10-31 03:01:06 +000070 // If this function ever changes to anything that does more than just
71 // check if the opaque shared pointer is non NULL, then we need to update
72 // all "if (m_opaque_sp)" code in this file.
73 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000074}
75
Greg Claytonc5f728c2010-10-06 22:10:17 +000076SBError
77SBValue::GetError()
78{
79 SBError sb_error;
80
81 if (m_opaque_sp.get())
82 sb_error.SetError(m_opaque_sp->GetError());
83
84 return sb_error;
85}
86
Johnny Chen968958c2011-07-07 20:46:23 +000087user_id_t
88SBValue::GetID()
89{
90 if (m_opaque_sp)
91 return m_opaque_sp->GetID();
92 return LLDB_INVALID_UID;
93}
94
Chris Lattner24943d22010-06-08 16:52:24 +000095const char *
96SBValue::GetName()
97{
Greg Clayton49ce6822010-10-31 03:01:06 +000098
99 const char *name = NULL;
100 if (m_opaque_sp)
101 name = m_opaque_sp->GetName().GetCString();
102
Greg Claytone005f2c2010-11-06 01:53:30 +0000103 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000104 if (log)
Greg Clayton49ce6822010-10-31 03:01:06 +0000105 {
106 if (name)
107 log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name);
108 else
109 log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name);
110 }
Caroline Tice7826c882010-10-26 03:11:13 +0000111
Greg Clayton49ce6822010-10-31 03:01:06 +0000112 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000113}
114
115const char *
116SBValue::GetTypeName ()
117{
Greg Clayton49ce6822010-10-31 03:01:06 +0000118 const char *name = NULL;
119 if (m_opaque_sp)
120 name = m_opaque_sp->GetTypeName().GetCString();
Greg Claytone005f2c2010-11-06 01:53:30 +0000121 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000122 if (log)
123 {
124 if (name)
125 log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name);
126 else
127 log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get());
128 }
129
130 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000131}
132
133size_t
134SBValue::GetByteSize ()
135{
136 size_t result = 0;
137
Greg Clayton49ce6822010-10-31 03:01:06 +0000138 if (m_opaque_sp)
Greg Clayton63094e02010-06-23 01:19:29 +0000139 result = m_opaque_sp->GetByteSize();
Chris Lattner24943d22010-06-08 16:52:24 +0000140
Greg Claytone005f2c2010-11-06 01:53:30 +0000141 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000142 if (log)
143 log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result);
144
Chris Lattner24943d22010-06-08 16:52:24 +0000145 return result;
146}
147
148bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000149SBValue::IsInScope (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000150{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000151 return IsInScope();
152}
153
154bool
155SBValue::IsInScope ()
156{
Chris Lattner24943d22010-06-08 16:52:24 +0000157 bool result = false;
158
Greg Clayton49ce6822010-10-31 03:01:06 +0000159 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000160 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000161 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000162 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000163 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000164 result = m_opaque_sp->IsInScope ();
165 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000166 }
Chris Lattner24943d22010-06-08 16:52:24 +0000167
Greg Claytone005f2c2010-11-06 01:53:30 +0000168 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000169 if (log)
170 log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result);
171
Chris Lattner24943d22010-06-08 16:52:24 +0000172 return result;
173}
174
175const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000176SBValue::GetValue (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000177{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000178 return GetValue();
179}
180
181const char *
182SBValue::GetValue ()
183{
Greg Clayton49ce6822010-10-31 03:01:06 +0000184 const char *cstr = NULL;
Greg Claytonbdcda462010-12-20 20:49:23 +0000185 if (m_opaque_sp)
186 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000187 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000188 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000189 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000190 cstr = m_opaque_sp->GetValueAsCString ();
191 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000192 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000193 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000194 if (log)
195 {
196 if (cstr)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000197 log->Printf ("SBValue(%p)::GetValue => \"%s\"", m_opaque_sp.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000198 else
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000199 log->Printf ("SBValue(%p)::GetValue => NULL", m_opaque_sp.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000200 }
201
202 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000203}
204
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000205ValueType
206SBValue::GetValueType ()
207{
Greg Clayton49ce6822010-10-31 03:01:06 +0000208 ValueType result = eValueTypeInvalid;
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000209 if (m_opaque_sp)
Greg Clayton49ce6822010-10-31 03:01:06 +0000210 result = m_opaque_sp->GetValueType();
Greg Claytone005f2c2010-11-06 01:53:30 +0000211 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000212 if (log)
213 {
214 switch (result)
215 {
216 case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break;
217 case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break;
218 case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break;
219 case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break;
220 case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break;
221 case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break;
222 case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break;
223 case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break;
224 default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break;
225 }
226 }
227 return result;
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000228}
229
Jim Ingham4ae51962010-09-10 23:12:17 +0000230const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000231SBValue::GetObjectDescription (const SBFrame &sb_frame)
Jim Ingham4ae51962010-09-10 23:12:17 +0000232{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000233 return GetObjectDescription ();
234}
235
236const char *
237SBValue::GetObjectDescription ()
238{
Greg Clayton49ce6822010-10-31 03:01:06 +0000239 const char *cstr = NULL;
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000240 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000241 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000242 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000243 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000244 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000245 cstr = m_opaque_sp->GetObjectDescription ();
246 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000247 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000248 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000249 if (log)
250 {
251 if (cstr)
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000252 log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", m_opaque_sp.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000253 else
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000254 log->Printf ("SBValue(%p)::GetObjectDescription => NULL", m_opaque_sp.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000255 }
256 return cstr;
Jim Ingham4ae51962010-09-10 23:12:17 +0000257}
258
Chris Lattner24943d22010-06-08 16:52:24 +0000259bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000260SBValue::GetValueDidChange (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000261{
Jim Inghamfa3a16a2011-03-31 00:19:25 +0000262 return GetValueDidChange ();
263}
264
Enrico Granata979e20d2011-07-29 19:53:35 +0000265SBType
266SBValue::GetType()
267{
268 SBType result;
269 if (m_opaque_sp)
270 {
271 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
272 {
273 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Clayton0fb0bcc2011-08-03 22:57:10 +0000274 result = SBType(ClangASTType (m_opaque_sp->GetClangAST(), m_opaque_sp->GetClangType()));
Enrico Granata979e20d2011-07-29 19:53:35 +0000275 }
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 {
Greg Clayton0fb0bcc2011-08-03 22:57:10 +0000394 result = SBValue(m_opaque_sp->GetSyntheticChildAtOffset(offset, type.m_opaque_sp->GetClangASTType(), true));
Enrico Granata979e20d2011-07-29 19:53:35 +0000395 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
Enrico Granatac9310302011-08-04 17:07:02 +0000451 ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope(),
452 real_type.m_opaque_sp->GetASTContext(),
453 real_type.m_opaque_sp->GetOpaqueQualType(),
454 ConstString(name),
455 buffer,
456 lldb::endian::InlHostByteOrder(),
457 GetTarget().GetProcess().GetAddressByteSize()));
Enrico Granata979e20d2011-07-29 19:53:35 +0000458
Enrico Granatac9310302011-08-04 17:07:02 +0000459 ValueObjectSP result_valobj_sp;
460
461 ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress);
462 if (ptr_result_valobj_sp)
463 {
464 Error err;
465 result_valobj_sp = ptr_result_valobj_sp->Dereference(err);
466 if (result_valobj_sp)
467 result_valobj_sp->SetName(ConstString(name));
468 }
Enrico Granata979e20d2011-07-29 19:53:35 +0000469 result = SBValue(result_valobj_sp);
470 }
471 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
472 if (log)
473 {
474 if (result.IsValid())
475 log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get());
Johnny Chena713b862011-08-09 22:38:07 +0000476 else
477 log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get());
478 }
Enrico Granata979e20d2011-07-29 19:53:35 +0000479 return result;
480}
481
Chris Lattner24943d22010-06-08 16:52:24 +0000482SBValue
483SBValue::GetChildAtIndex (uint32_t idx)
484{
Greg Clayton8f64c472011-07-15 19:31:49 +0000485 const bool can_create_synthetic = false;
486 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
Johnny Chen446ccaa2011-06-29 21:19:39 +0000487 if (m_opaque_sp)
Enrico Granata979e20d2011-07-29 19:53:35 +0000488 use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
Greg Clayton8f64c472011-07-15 19:31:49 +0000489 return GetChildAtIndex (idx, use_dynamic, can_create_synthetic);
Jim Inghame41494a2011-04-16 00:01:13 +0000490}
491
492SBValue
Greg Clayton8f64c472011-07-15 19:31:49 +0000493SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic)
Jim Inghame41494a2011-04-16 00:01:13 +0000494{
Chris Lattner24943d22010-06-08 16:52:24 +0000495 lldb::ValueObjectSP child_sp;
496
Greg Clayton49ce6822010-10-31 03:01:06 +0000497 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000498 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000499 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000500 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000501 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Clayton8f64c472011-07-15 19:31:49 +0000502 const bool can_create = true;
503 child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create);
504 if (can_create_synthetic && !child_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000505 {
Greg Clayton8f64c472011-07-15 19:31:49 +0000506 if (m_opaque_sp->IsPointerType())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000507 {
Greg Clayton8f64c472011-07-15 19:31:49 +0000508 child_sp = m_opaque_sp->GetSyntheticArrayMemberFromPointer(idx, can_create);
509 }
510 else if (m_opaque_sp->IsArrayType())
511 {
512 child_sp = m_opaque_sp->GetSyntheticArrayMemberFromArray(idx, can_create);
513 }
514 }
515
516 if (child_sp)
517 {
518 if (use_dynamic != lldb::eNoDynamicValues)
519 {
520 lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic));
Greg Claytonb9dcc512011-06-29 18:28:50 +0000521 if (dynamic_sp)
522 child_sp = dynamic_sp;
523 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000524 }
Jim Inghame41494a2011-04-16 00:01:13 +0000525 }
526 }
527
Chris Lattner24943d22010-06-08 16:52:24 +0000528 SBValue sb_value (child_sp);
Greg Claytone005f2c2010-11-06 01:53:30 +0000529 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000530 if (log)
531 log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get());
532
Chris Lattner24943d22010-06-08 16:52:24 +0000533 return sb_value;
534}
535
536uint32_t
537SBValue::GetIndexOfChildWithName (const char *name)
538{
Greg Clayton49ce6822010-10-31 03:01:06 +0000539 uint32_t idx = UINT32_MAX;
540 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000541 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000542 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000543 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000544 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000545
Greg Claytonb9dcc512011-06-29 18:28:50 +0000546 idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
547 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000548 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000549 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000550 if (log)
551 {
552 if (idx == UINT32_MAX)
553 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx);
554 else
555 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx);
556 }
557 return idx;
Chris Lattner24943d22010-06-08 16:52:24 +0000558}
559
560SBValue
561SBValue::GetChildMemberWithName (const char *name)
562{
Johnny Chen446ccaa2011-06-29 21:19:39 +0000563 if (m_opaque_sp)
564 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000565 lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue();
Johnny Chen446ccaa2011-06-29 21:19:39 +0000566 return GetChildMemberWithName (name, use_dynamic_value);
567 }
568 else
569 return GetChildMemberWithName (name, eNoDynamicValues);
Jim Inghame41494a2011-04-16 00:01:13 +0000570}
571
572SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000573SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value)
Jim Inghame41494a2011-04-16 00:01:13 +0000574{
Chris Lattner24943d22010-06-08 16:52:24 +0000575 lldb::ValueObjectSP child_sp;
576 const ConstString str_name (name);
577
Greg Clayton905acaf2011-05-20 22:07:17 +0000578
Greg Clayton49ce6822010-10-31 03:01:06 +0000579 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000580 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000581 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Jim Inghame41494a2011-04-16 00:01:13 +0000582 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000583 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonb9dcc512011-06-29 18:28:50 +0000584 child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
585 if (use_dynamic_value != lldb::eNoDynamicValues)
Greg Claytonfab305b2011-05-20 23:51:26 +0000586 {
Greg Claytonb9dcc512011-06-29 18:28:50 +0000587 if (child_sp)
588 {
589 lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value);
590 if (dynamic_sp)
591 child_sp = dynamic_sp;
592 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000593 }
Jim Inghame41494a2011-04-16 00:01:13 +0000594 }
595 }
596
Chris Lattner24943d22010-06-08 16:52:24 +0000597 SBValue sb_value (child_sp);
Greg Clayton49ce6822010-10-31 03:01:06 +0000598
Greg Claytone005f2c2010-11-06 01:53:30 +0000599 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000600 if (log)
601 log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get());
602
Chris Lattner24943d22010-06-08 16:52:24 +0000603 return sb_value;
604}
605
Enrico Granataf7a9b142011-07-15 02:26:42 +0000606lldb::SBValue
607SBValue::GetValueForExpressionPath(const char* expr_path)
608{
609 lldb::ValueObjectSP child_sp;
610 if (m_opaque_sp)
611 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000612 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Enrico Granataf7a9b142011-07-15 02:26:42 +0000613 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000614 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Enrico Granataf7a9b142011-07-15 02:26:42 +0000615 // using default values for all the fancy options, just do it if you can
616 child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path);
617 }
618 }
619
620 SBValue sb_value (child_sp);
621
622 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
623 if (log)
624 log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr_path, sb_value.get());
625
626 return sb_value;
627}
Chris Lattner24943d22010-06-08 16:52:24 +0000628
Greg Clayton0fb0bcc2011-08-03 22:57:10 +0000629int64_t
Enrico Granatac92eb402011-08-04 01:41:02 +0000630SBValue::GetValueAsSigned(SBError& error, int64_t fail_value)
631{
Jim Ingham574c3d62011-08-12 23:34:31 +0000632 error.Clear();
Enrico Granatac92eb402011-08-04 01:41:02 +0000633 if (m_opaque_sp)
634 {
635 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
636 {
637 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
638 Scalar scalar;
639 if (m_opaque_sp->ResolveValue (scalar))
640 return scalar.GetRawBits64(fail_value);
641 else
642 error.SetErrorString("could not get value");
643 }
644 else
645 error.SetErrorString("could not get target");
646 }
647 error.SetErrorString("invalid SBValue");
648 return fail_value;
649}
650
651uint64_t
652SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value)
653{
Jim Ingham574c3d62011-08-12 23:34:31 +0000654 error.Clear();
Enrico Granatac92eb402011-08-04 01:41:02 +0000655 if (m_opaque_sp)
656 {
657 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
658 {
659 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
660 Scalar scalar;
661 if (m_opaque_sp->ResolveValue (scalar))
662 return scalar.GetRawBits64(fail_value);
663 else
664 error.SetErrorString("could not get value");
665 }
666 else
667 error.SetErrorString("could not get target");
668 }
669 error.SetErrorString("invalid SBValue");
670 return fail_value;
671}
672
673int64_t
Greg Clayton0fb0bcc2011-08-03 22:57:10 +0000674SBValue::GetValueAsSigned(int64_t fail_value)
675{
676 if (m_opaque_sp)
677 {
678 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
679 {
680 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
681 Scalar scalar;
682 if (m_opaque_sp->ResolveValue (scalar))
683 return scalar.GetRawBits64(fail_value);
684 }
685 }
686 return fail_value;
687}
688
689uint64_t
690SBValue::GetValueAsUnsigned(uint64_t fail_value)
691{
692 if (m_opaque_sp)
693 {
694 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
695 {
696 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
697 Scalar scalar;
698 if (m_opaque_sp->ResolveValue (scalar))
699 return scalar.GetRawBits64(fail_value);
700 }
701 }
702 return fail_value;
703}
704
Chris Lattner24943d22010-06-08 16:52:24 +0000705uint32_t
706SBValue::GetNumChildren ()
707{
708 uint32_t num_children = 0;
709
Greg Clayton49ce6822010-10-31 03:01:06 +0000710 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000711 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000712 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000713 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000714 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000715
Greg Claytonb9dcc512011-06-29 18:28:50 +0000716 num_children = m_opaque_sp->GetNumChildren();
717 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000718 }
Greg Clayton49ce6822010-10-31 03:01:06 +0000719
Greg Claytone005f2c2010-11-06 01:53:30 +0000720 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000721 if (log)
722 log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children);
Chris Lattner24943d22010-06-08 16:52:24 +0000723
724 return num_children;
725}
726
Chris Lattner24943d22010-06-08 16:52:24 +0000727
728SBValue
729SBValue::Dereference ()
730{
Greg Clayton49ce6822010-10-31 03:01:06 +0000731 SBValue sb_value;
732 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000733 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000734 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000735 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000736 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000737
Greg Claytonb9dcc512011-06-29 18:28:50 +0000738 Error error;
739 sb_value = m_opaque_sp->Dereference (error);
740 }
Chris Lattner24943d22010-06-08 16:52:24 +0000741 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000742 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000743 if (log)
744 log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
745
746 return sb_value;
Chris Lattner24943d22010-06-08 16:52:24 +0000747}
748
749bool
Greg Clayton49ce6822010-10-31 03:01:06 +0000750SBValue::TypeIsPointerType ()
Chris Lattner24943d22010-06-08 16:52:24 +0000751{
752 bool is_ptr_type = false;
753
Greg Clayton49ce6822010-10-31 03:01:06 +0000754 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000755 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000756 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000757 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000758 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000759
Greg Claytonb9dcc512011-06-29 18:28:50 +0000760 is_ptr_type = m_opaque_sp->IsPointerType();
761 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000762 }
Greg Clayton49ce6822010-10-31 03:01:06 +0000763
Greg Claytone005f2c2010-11-06 01:53:30 +0000764 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000765 if (log)
766 log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type);
767
Chris Lattner24943d22010-06-08 16:52:24 +0000768
769 return is_ptr_type;
770}
771
Chris Lattner24943d22010-06-08 16:52:24 +0000772void *
773SBValue::GetOpaqueType()
774{
Greg Clayton63094e02010-06-23 01:19:29 +0000775 if (m_opaque_sp)
Greg Claytonfab305b2011-05-20 23:51:26 +0000776 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000777 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
Greg Claytonb9dcc512011-06-29 18:28:50 +0000778 {
Enrico Granata979e20d2011-07-29 19:53:35 +0000779 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
Greg Claytonfab305b2011-05-20 23:51:26 +0000780
Greg Claytonb9dcc512011-06-29 18:28:50 +0000781 return m_opaque_sp->GetClangType();
782 }
Greg Claytonfab305b2011-05-20 23:51:26 +0000783 }
Chris Lattner24943d22010-06-08 16:52:24 +0000784 return NULL;
785}
786
Enrico Granata979e20d2011-07-29 19:53:35 +0000787lldb::SBTarget
788SBValue::GetTarget()
789{
790 SBTarget result;
791 if (m_opaque_sp)
792 {
793 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
794 {
795 result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()));
796 }
797 }
798 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
799 if (log)
800 {
801 if (result.get() == NULL)
802 log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get());
803 else
804 log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get());
805 }
806 return result;
807}
808
809lldb::SBProcess
810SBValue::GetProcess()
811{
812 SBProcess result;
813 if (m_opaque_sp)
814 {
815 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
816 {
817 result = SBProcess(lldb::ProcessSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetProcessSP()));
818 }
819 }
820 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
821 if (log)
822 {
823 if (result.get() == NULL)
824 log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get());
825 else
826 log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get());
827 }
828 return result;
829}
830
831lldb::SBThread
832SBValue::GetThread()
833{
834 SBThread result;
835 if (m_opaque_sp)
836 {
837 if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
838 {
839 result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread()));
840 }
841 }
842 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
843 if (log)
844 {
845 if (result.get() == NULL)
846 log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get());
847 else
848 log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), result.get());
849 }
850 return result;
851}
852
853lldb::SBFrame
854SBValue::GetFrame()
855{
856 SBFrame result;
857 if (m_opaque_sp)
858 {
859 if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope())
860 {
861 result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame()));
862 }
863 }
864 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
865 if (log)
866 {
867 if (result.get() == NULL)
868 log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get());
869 else
870 log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get());
871 }
872 return result;
873}
874
875
Chris Lattner24943d22010-06-08 16:52:24 +0000876// Mimic shared pointer...
877lldb_private::ValueObject *
878SBValue::get() const
879{
Greg Clayton63094e02010-06-23 01:19:29 +0000880 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000881}
882
883lldb_private::ValueObject *
884SBValue::operator->() const
885{
Greg Clayton63094e02010-06-23 01:19:29 +0000886 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000887}
888
889lldb::ValueObjectSP &
890SBValue::operator*()
891{
Greg Clayton63094e02010-06-23 01:19:29 +0000892 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000893}
894
895const lldb::ValueObjectSP &
896SBValue::operator*() const
897{
Greg Clayton63094e02010-06-23 01:19:29 +0000898 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000899}
Caroline Tice98f930f2010-09-20 05:20:02 +0000900
901bool
Greg Clayton49ce6822010-10-31 03:01:06 +0000902SBValue::GetExpressionPath (SBStream &description)
903{
904 if (m_opaque_sp)
905 {
Greg Claytonb01000f2011-01-17 03:46:26 +0000906 m_opaque_sp->GetExpressionPath (description.ref(), false);
907 return true;
908 }
909 return false;
910}
911
912bool
913SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes)
914{
915 if (m_opaque_sp)
916 {
917 m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes);
Greg Clayton49ce6822010-10-31 03:01:06 +0000918 return true;
919 }
920 return false;
921}
922
923bool
Caroline Tice98f930f2010-09-20 05:20:02 +0000924SBValue::GetDescription (SBStream &description)
925{
926 if (m_opaque_sp)
927 {
Enrico Granata19030d82011-08-15 18:01:31 +0000928 /*uint32_t ptr_depth = 0;
Greg Claytonbafc86e2011-07-06 16:49:27 +0000929 uint32_t curr_depth = 0;
930 uint32_t max_depth = UINT32_MAX;
931 bool show_types = false;
932 bool show_location = false;
933 bool use_objc = false;
934 lldb::DynamicValueType use_dynamic = eNoDynamicValues;
935 bool scope_already_checked = false;
936 bool flat_output = false;
Enrico Granatae4e3e2c2011-07-22 00:16:08 +0000937 bool use_synthetic = true;
938 uint32_t no_summary_depth = 0;
Enrico Granata19030d82011-08-15 18:01:31 +0000939 bool ignore_cap = false;*/
Greg Claytonbafc86e2011-07-06 16:49:27 +0000940 ValueObject::DumpValueObject (description.ref(),
Enrico Granata19030d82011-08-15 18:01:31 +0000941 m_opaque_sp.get());
Caroline Tice98f930f2010-09-20 05:20:02 +0000942 }
943 else
944 description.Printf ("No value");
945
946 return true;
947}
Greg Claytone179a582011-01-05 18:43:15 +0000948
949lldb::Format
950SBValue::GetFormat () const
951{
952 if (m_opaque_sp)
953 return m_opaque_sp->GetFormat();
954 return eFormatDefault;
955}
956
957void
958SBValue::SetFormat (lldb::Format format)
959{
960 if (m_opaque_sp)
961 m_opaque_sp->SetFormat(format);
962}
963
Enrico Granata979e20d2011-07-29 19:53:35 +0000964lldb::SBValue
965SBValue::AddressOf()
966{
967 SBValue sb_value;
968 if (m_opaque_sp)
969 {
970 if (m_opaque_sp->GetUpdatePoint().GetTargetSP())
971 {
972 Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex());
973
974 Error error;
975 sb_value = m_opaque_sp->AddressOf (error);
976 }
977 }
978 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
979 if (log)
980 log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
981
982 return sb_value;
Johnny Chena713b862011-08-09 22:38:07 +0000983}