blob: 8161c95ee58ab3ffde96dfe15281df3ffb0bc77f [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"
20#include "lldb/Symbol/Block.h"
21#include "lldb/Symbol/ObjectFile.h"
22#include "lldb/Symbol/Variable.h"
23#include "lldb/Target/ExecutionContext.h"
24#include "lldb/Target/Process.h"
25#include "lldb/Target/StackFrame.h"
Greg Claytonbdcda462010-12-20 20:49:23 +000026#include "lldb/Target/Target.h"
Chris Lattner24943d22010-06-08 16:52:24 +000027#include "lldb/Target/Thread.h"
28
Eli Friedman7a62c8b2010-06-09 07:44:37 +000029#include "lldb/API/SBProcess.h"
30#include "lldb/API/SBTarget.h"
31#include "lldb/API/SBThread.h"
32#include "lldb/API/SBFrame.h"
33#include "lldb/API/SBDebugger.h"
Chris Lattner24943d22010-06-08 16:52:24 +000034
35using namespace lldb;
36using namespace lldb_private;
37
38SBValue::SBValue () :
Greg Clayton63094e02010-06-23 01:19:29 +000039 m_opaque_sp ()
Chris Lattner24943d22010-06-08 16:52:24 +000040{
41}
42
43SBValue::SBValue (const lldb::ValueObjectSP &value_sp) :
Greg Clayton63094e02010-06-23 01:19:29 +000044 m_opaque_sp (value_sp)
Chris Lattner24943d22010-06-08 16:52:24 +000045{
46}
47
Greg Clayton538eb822010-11-05 23:17:00 +000048SBValue::SBValue(const SBValue &rhs) :
49 m_opaque_sp (rhs.m_opaque_sp)
50{
51}
52
53const SBValue &
54SBValue::operator = (const SBValue &rhs)
55{
56 if (this != &rhs)
57 m_opaque_sp = rhs.m_opaque_sp;
58 return *this;
59}
60
Chris Lattner24943d22010-06-08 16:52:24 +000061SBValue::~SBValue()
62{
63}
64
65bool
66SBValue::IsValid () const
67{
Greg Clayton49ce6822010-10-31 03:01:06 +000068 // If this function ever changes to anything that does more than just
69 // check if the opaque shared pointer is non NULL, then we need to update
70 // all "if (m_opaque_sp)" code in this file.
71 return m_opaque_sp.get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +000072}
73
Greg Claytonc5f728c2010-10-06 22:10:17 +000074SBError
75SBValue::GetError()
76{
77 SBError sb_error;
78
79 if (m_opaque_sp.get())
80 sb_error.SetError(m_opaque_sp->GetError());
81
82 return sb_error;
83}
84
Chris Lattner24943d22010-06-08 16:52:24 +000085const char *
86SBValue::GetName()
87{
Greg Clayton49ce6822010-10-31 03:01:06 +000088
89 const char *name = NULL;
90 if (m_opaque_sp)
91 name = m_opaque_sp->GetName().GetCString();
92
Greg Claytone005f2c2010-11-06 01:53:30 +000093 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton3f5ee7f2010-10-29 04:59:35 +000094 if (log)
Greg Clayton49ce6822010-10-31 03:01:06 +000095 {
96 if (name)
97 log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name);
98 else
99 log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get(), name);
100 }
Caroline Tice7826c882010-10-26 03:11:13 +0000101
Greg Clayton49ce6822010-10-31 03:01:06 +0000102 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000103}
104
105const char *
106SBValue::GetTypeName ()
107{
Greg Clayton49ce6822010-10-31 03:01:06 +0000108 const char *name = NULL;
109 if (m_opaque_sp)
110 name = m_opaque_sp->GetTypeName().GetCString();
Greg Claytone005f2c2010-11-06 01:53:30 +0000111 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000112 if (log)
113 {
114 if (name)
115 log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name);
116 else
117 log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get());
118 }
119
120 return name;
Chris Lattner24943d22010-06-08 16:52:24 +0000121}
122
123size_t
124SBValue::GetByteSize ()
125{
126 size_t result = 0;
127
Greg Clayton49ce6822010-10-31 03:01:06 +0000128 if (m_opaque_sp)
Greg Clayton63094e02010-06-23 01:19:29 +0000129 result = m_opaque_sp->GetByteSize();
Chris Lattner24943d22010-06-08 16:52:24 +0000130
Greg Claytone005f2c2010-11-06 01:53:30 +0000131 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000132 if (log)
133 log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result);
134
Chris Lattner24943d22010-06-08 16:52:24 +0000135 return result;
136}
137
138bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000139SBValue::IsInScope (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000140{
141 bool result = false;
142
Greg Clayton49ce6822010-10-31 03:01:06 +0000143 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000144 {
145 StackFrame *frame = sb_frame.get();
146 if (frame)
147 {
148 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
149 result = m_opaque_sp->IsInScope (frame);
150 }
151 }
Chris Lattner24943d22010-06-08 16:52:24 +0000152
Greg Claytone005f2c2010-11-06 01:53:30 +0000153 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000154 if (log)
155 log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result);
156
Chris Lattner24943d22010-06-08 16:52:24 +0000157 return result;
158}
159
160const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000161SBValue::GetValue (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000162{
Greg Clayton49ce6822010-10-31 03:01:06 +0000163 const char *cstr = NULL;
Greg Claytonbdcda462010-12-20 20:49:23 +0000164 if (m_opaque_sp)
165 {
166 StackFrame *frame = sb_frame.get();
167 if (frame)
168 {
169 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
170 cstr = m_opaque_sp->GetValueAsCString (frame);
171 }
172 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000173 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000174 if (log)
175 {
176 if (cstr)
Greg Claytonbdcda462010-12-20 20:49:23 +0000177 log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000178 else
Greg Claytonbdcda462010-12-20 20:49:23 +0000179 log->Printf ("SBValue(%p)::GetValue (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000180 }
181
182 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000183}
184
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000185ValueType
186SBValue::GetValueType ()
187{
Greg Clayton49ce6822010-10-31 03:01:06 +0000188 ValueType result = eValueTypeInvalid;
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000189 if (m_opaque_sp)
Greg Clayton49ce6822010-10-31 03:01:06 +0000190 result = m_opaque_sp->GetValueType();
Greg Claytone005f2c2010-11-06 01:53:30 +0000191 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000192 if (log)
193 {
194 switch (result)
195 {
196 case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break;
197 case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break;
198 case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break;
199 case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break;
200 case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break;
201 case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break;
202 case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break;
203 case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break;
204 default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break;
205 }
206 }
207 return result;
Greg Claytonf3d0b0c2010-10-27 03:32:59 +0000208}
209
Jim Ingham4ae51962010-09-10 23:12:17 +0000210const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000211SBValue::GetObjectDescription (const SBFrame &sb_frame)
Jim Ingham4ae51962010-09-10 23:12:17 +0000212{
Greg Clayton49ce6822010-10-31 03:01:06 +0000213 const char *cstr = NULL;
Jim Ingham4ae51962010-09-10 23:12:17 +0000214 if ( m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000215 {
216 StackFrame *frame = sb_frame.get();
217 if (frame)
218 {
219 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
220 cstr = m_opaque_sp->GetObjectDescription (frame);
221 }
222 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000223 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000224 if (log)
225 {
226 if (cstr)
Greg Claytonbdcda462010-12-20 20:49:23 +0000227 log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000228 else
Greg Claytonbdcda462010-12-20 20:49:23 +0000229 log->Printf ("SBValue(%p)::GetObjectDescription (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000230 }
231 return cstr;
Jim Ingham4ae51962010-09-10 23:12:17 +0000232}
233
Chris Lattner24943d22010-06-08 16:52:24 +0000234bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000235SBValue::GetValueDidChange (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000236{
Greg Clayton49ce6822010-10-31 03:01:06 +0000237 bool result = false;
238 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000239 {
240 StackFrame *frame = sb_frame.get();
241 if (frame)
242 {
243 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
244 result = m_opaque_sp->GetValueDidChange (frame);
245 }
246 }
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)
Greg Claytonbdcda462010-12-20 20:49:23 +0000249 log->Printf ("SBValue(%p)::GetValueDidChange (SBFrame(%p)) => %i", m_opaque_sp.get(), sb_frame.get(), result);
Greg Clayton49ce6822010-10-31 03:01:06 +0000250
251 return result;
Chris Lattner24943d22010-06-08 16:52:24 +0000252}
253
254const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000255SBValue::GetSummary (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000256{
Greg Clayton49ce6822010-10-31 03:01:06 +0000257 const char *cstr = NULL;
258 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000259 {
260 StackFrame *frame = sb_frame.get();
261 if (frame)
262 {
263 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
264 cstr = m_opaque_sp->GetSummaryAsCString(frame);
265 }
266 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000267 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000268 if (log)
269 {
270 if (cstr)
Greg Claytonbdcda462010-12-20 20:49:23 +0000271 log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000272 else
Greg Claytonbdcda462010-12-20 20:49:23 +0000273 log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000274 }
275 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000276}
277
278const char *
Greg Claytonbdcda462010-12-20 20:49:23 +0000279SBValue::GetLocation (const SBFrame &sb_frame)
Chris Lattner24943d22010-06-08 16:52:24 +0000280{
Greg Clayton49ce6822010-10-31 03:01:06 +0000281 const char *cstr = NULL;
282 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000283 {
284 StackFrame *frame = sb_frame.get();
285 if (frame)
286 {
287 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
288 cstr = m_opaque_sp->GetLocationAsCString(frame);
289 }
290 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000291 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000292 if (log)
293 {
294 if (cstr)
Greg Claytonbdcda462010-12-20 20:49:23 +0000295 log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => \"%s\"", m_opaque_sp.get(), sb_frame.get(), cstr);
Greg Clayton49ce6822010-10-31 03:01:06 +0000296 else
Greg Claytonbdcda462010-12-20 20:49:23 +0000297 log->Printf ("SBValue(%p)::GetSummary (SBFrame(%p)) => NULL", m_opaque_sp.get(), sb_frame.get());
Greg Clayton49ce6822010-10-31 03:01:06 +0000298 }
299 return cstr;
Chris Lattner24943d22010-06-08 16:52:24 +0000300}
301
302bool
Greg Claytonbdcda462010-12-20 20:49:23 +0000303SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str)
Chris Lattner24943d22010-06-08 16:52:24 +0000304{
305 bool success = false;
Greg Clayton49ce6822010-10-31 03:01:06 +0000306 if (m_opaque_sp)
Greg Claytonbdcda462010-12-20 20:49:23 +0000307 {
308 StackFrame *frame = sb_frame.get();
309 if (frame)
310 {
311 Mutex::Locker api_locker (frame->GetThread().GetProcess().GetTarget().GetAPIMutex());
312 success = m_opaque_sp->SetValueFromCString (frame, value_str);
313 }
314 }
Chris Lattner24943d22010-06-08 16:52:24 +0000315 return success;
316}
317
318SBValue
319SBValue::GetChildAtIndex (uint32_t idx)
320{
321 lldb::ValueObjectSP child_sp;
322
Greg Clayton49ce6822010-10-31 03:01:06 +0000323 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000324 {
Greg Clayton63094e02010-06-23 01:19:29 +0000325 child_sp = m_opaque_sp->GetChildAtIndex (idx, true);
Chris Lattner24943d22010-06-08 16:52:24 +0000326 }
327
328 SBValue sb_value (child_sp);
Greg Claytone005f2c2010-11-06 01:53:30 +0000329 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000330 if (log)
331 log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get());
332
Chris Lattner24943d22010-06-08 16:52:24 +0000333 return sb_value;
334}
335
336uint32_t
337SBValue::GetIndexOfChildWithName (const char *name)
338{
Greg Clayton49ce6822010-10-31 03:01:06 +0000339 uint32_t idx = UINT32_MAX;
340 if (m_opaque_sp)
341 idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name));
Greg Claytone005f2c2010-11-06 01:53:30 +0000342 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000343 if (log)
344 {
345 if (idx == UINT32_MAX)
346 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx);
347 else
348 log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx);
349 }
350 return idx;
Chris Lattner24943d22010-06-08 16:52:24 +0000351}
352
353SBValue
354SBValue::GetChildMemberWithName (const char *name)
355{
356 lldb::ValueObjectSP child_sp;
357 const ConstString str_name (name);
358
Greg Clayton49ce6822010-10-31 03:01:06 +0000359 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000360 {
Greg Clayton63094e02010-06-23 01:19:29 +0000361 child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true);
Chris Lattner24943d22010-06-08 16:52:24 +0000362 }
363
364 SBValue sb_value (child_sp);
Greg Clayton49ce6822010-10-31 03:01:06 +0000365
Greg Claytone005f2c2010-11-06 01:53:30 +0000366 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000367 if (log)
368 log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get());
369
Chris Lattner24943d22010-06-08 16:52:24 +0000370 return sb_value;
371}
372
373
374uint32_t
375SBValue::GetNumChildren ()
376{
377 uint32_t num_children = 0;
378
Greg Clayton49ce6822010-10-31 03:01:06 +0000379 if (m_opaque_sp)
Greg Clayton63094e02010-06-23 01:19:29 +0000380 num_children = m_opaque_sp->GetNumChildren();
Greg Clayton49ce6822010-10-31 03:01:06 +0000381
Greg Claytone005f2c2010-11-06 01:53:30 +0000382 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000383 if (log)
384 log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children);
Chris Lattner24943d22010-06-08 16:52:24 +0000385
386 return num_children;
387}
388
Chris Lattner24943d22010-06-08 16:52:24 +0000389
390SBValue
391SBValue::Dereference ()
392{
Greg Clayton49ce6822010-10-31 03:01:06 +0000393 SBValue sb_value;
394 if (m_opaque_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000395 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000396 Error error;
397 sb_value = m_opaque_sp->Dereference (error);
Chris Lattner24943d22010-06-08 16:52:24 +0000398 }
Greg Claytone005f2c2010-11-06 01:53:30 +0000399 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000400 if (log)
401 log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get());
402
403 return sb_value;
Chris Lattner24943d22010-06-08 16:52:24 +0000404}
405
406bool
Greg Clayton49ce6822010-10-31 03:01:06 +0000407SBValue::TypeIsPointerType ()
Chris Lattner24943d22010-06-08 16:52:24 +0000408{
409 bool is_ptr_type = false;
410
Greg Clayton49ce6822010-10-31 03:01:06 +0000411 if (m_opaque_sp)
Greg Clayton63094e02010-06-23 01:19:29 +0000412 is_ptr_type = m_opaque_sp->IsPointerType();
Greg Clayton49ce6822010-10-31 03:01:06 +0000413
Greg Claytone005f2c2010-11-06 01:53:30 +0000414 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton49ce6822010-10-31 03:01:06 +0000415 if (log)
416 log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type);
417
Chris Lattner24943d22010-06-08 16:52:24 +0000418
419 return is_ptr_type;
420}
421
Chris Lattner24943d22010-06-08 16:52:24 +0000422void *
423SBValue::GetOpaqueType()
424{
Greg Clayton63094e02010-06-23 01:19:29 +0000425 if (m_opaque_sp)
Greg Clayton462d4142010-09-29 01:12:09 +0000426 return m_opaque_sp->GetClangType();
Chris Lattner24943d22010-06-08 16:52:24 +0000427 return NULL;
428}
429
430// Mimic shared pointer...
431lldb_private::ValueObject *
432SBValue::get() const
433{
Greg Clayton63094e02010-06-23 01:19:29 +0000434 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000435}
436
437lldb_private::ValueObject *
438SBValue::operator->() const
439{
Greg Clayton63094e02010-06-23 01:19:29 +0000440 return m_opaque_sp.get();
Chris Lattner24943d22010-06-08 16:52:24 +0000441}
442
443lldb::ValueObjectSP &
444SBValue::operator*()
445{
Greg Clayton63094e02010-06-23 01:19:29 +0000446 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000447}
448
449const lldb::ValueObjectSP &
450SBValue::operator*() const
451{
Greg Clayton63094e02010-06-23 01:19:29 +0000452 return m_opaque_sp;
Chris Lattner24943d22010-06-08 16:52:24 +0000453}
Caroline Tice98f930f2010-09-20 05:20:02 +0000454
455bool
Greg Clayton49ce6822010-10-31 03:01:06 +0000456SBValue::GetExpressionPath (SBStream &description)
457{
458 if (m_opaque_sp)
459 {
460 m_opaque_sp->GetExpressionPath (description.ref());
461 return true;
462 }
463 return false;
464}
465
466bool
Caroline Tice98f930f2010-09-20 05:20:02 +0000467SBValue::GetDescription (SBStream &description)
468{
469 if (m_opaque_sp)
470 {
Greg Clayton3f5ee7f2010-10-29 04:59:35 +0000471 // Don't call all these APIs and cause more logging!
472// const char *name = GetName();
473// const char *type_name = GetTypeName ();
474// size_t byte_size = GetByteSize ();
475// uint32_t num_children = GetNumChildren ();
476// bool is_stale = ValueIsStale ();
477// description.Printf ("name: '%s', type: %s, size: %d", (name != NULL ? name : "<unknown name>"),
478// (type_name != NULL ? type_name : "<unknown type name>"), (int) byte_size);
479// if (num_children > 0)
480// description.Printf (", num_children: %d", num_children);
481//
482// if (is_stale)
483// description.Printf (" [value is stale]");
484
485 description.Printf ("name: '%s'", m_opaque_sp->GetName().GetCString());
Caroline Tice98f930f2010-09-20 05:20:02 +0000486 }
487 else
488 description.Printf ("No value");
489
490 return true;
491}