Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- 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 Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 10 | #include "lldb/API/SBValue.h" |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 11 | #include "lldb/API/SBStream.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 12 | |
| 13 | #include "lldb/Core/DataExtractor.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 14 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 15 | #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 Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 20 | #include "lldb/Core/ValueObjectConstResult.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 21 | #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 Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 27 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 28 | #include "lldb/Target/Thread.h" |
| 29 | |
Eli Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 30 | #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 Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 35 | |
| 36 | using namespace lldb; |
| 37 | using namespace lldb_private; |
| 38 | |
| 39 | SBValue::SBValue () : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 40 | m_opaque_sp () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 41 | { |
| 42 | } |
| 43 | |
| 44 | SBValue::SBValue (const lldb::ValueObjectSP &value_sp) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 45 | m_opaque_sp (value_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 46 | { |
| 47 | } |
| 48 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 49 | SBValue::SBValue(const SBValue &rhs) : |
| 50 | m_opaque_sp (rhs.m_opaque_sp) |
| 51 | { |
| 52 | } |
| 53 | |
| 54 | const SBValue & |
| 55 | SBValue::operator = (const SBValue &rhs) |
| 56 | { |
| 57 | if (this != &rhs) |
| 58 | m_opaque_sp = rhs.m_opaque_sp; |
| 59 | return *this; |
| 60 | } |
| 61 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 62 | SBValue::~SBValue() |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | bool |
| 67 | SBValue::IsValid () const |
| 68 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 69 | // 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 Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 73 | } |
| 74 | |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 75 | SBError |
| 76 | SBValue::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 Chen | 968958c | 2011-07-07 20:46:23 +0000 | [diff] [blame] | 86 | user_id_t |
| 87 | SBValue::GetID() |
| 88 | { |
| 89 | if (m_opaque_sp) |
| 90 | return m_opaque_sp->GetID(); |
| 91 | return LLDB_INVALID_UID; |
| 92 | } |
| 93 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 94 | const char * |
| 95 | SBValue::GetName() |
| 96 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 97 | |
| 98 | const char *name = NULL; |
| 99 | if (m_opaque_sp) |
| 100 | name = m_opaque_sp->GetName().GetCString(); |
| 101 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 102 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 103 | if (log) |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 104 | { |
| 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 Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 110 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 111 | return name; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 112 | } |
| 113 | |
| 114 | const char * |
| 115 | SBValue::GetTypeName () |
| 116 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 117 | const char *name = NULL; |
| 118 | if (m_opaque_sp) |
| 119 | name = m_opaque_sp->GetTypeName().GetCString(); |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 120 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 121 | 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 Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 130 | } |
| 131 | |
| 132 | size_t |
| 133 | SBValue::GetByteSize () |
| 134 | { |
| 135 | size_t result = 0; |
| 136 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 137 | if (m_opaque_sp) |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 138 | result = m_opaque_sp->GetByteSize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 139 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 140 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 141 | if (log) |
| 142 | log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result); |
| 143 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 144 | return result; |
| 145 | } |
| 146 | |
| 147 | bool |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 148 | SBValue::IsInScope (const SBFrame &sb_frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 149 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 150 | return IsInScope(); |
| 151 | } |
| 152 | |
| 153 | bool |
| 154 | SBValue::IsInScope () |
| 155 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 156 | bool result = false; |
| 157 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 158 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 159 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 160 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 161 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 162 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 163 | result = m_opaque_sp->IsInScope (); |
| 164 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 165 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 166 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 167 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 168 | if (log) |
| 169 | log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result); |
| 170 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 171 | return result; |
| 172 | } |
| 173 | |
| 174 | const char * |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 175 | SBValue::GetValue (const SBFrame &sb_frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 176 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 177 | return GetValue(); |
| 178 | } |
| 179 | |
| 180 | const char * |
| 181 | SBValue::GetValue () |
| 182 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 183 | const char *cstr = NULL; |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 184 | if (m_opaque_sp) |
| 185 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 186 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 187 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 188 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 189 | cstr = m_opaque_sp->GetValueAsCString (); |
| 190 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 191 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 192 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 193 | if (log) |
| 194 | { |
| 195 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 196 | log->Printf ("SBValue(%p)::GetValue => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 197 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 198 | log->Printf ("SBValue(%p)::GetValue => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | return cstr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 202 | } |
| 203 | |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 204 | ValueType |
| 205 | SBValue::GetValueType () |
| 206 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 207 | ValueType result = eValueTypeInvalid; |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 208 | if (m_opaque_sp) |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 209 | result = m_opaque_sp->GetValueType(); |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 210 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 211 | 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 Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Jim Ingham | 4ae5196 | 2010-09-10 23:12:17 +0000 | [diff] [blame] | 229 | const char * |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 230 | SBValue::GetObjectDescription (const SBFrame &sb_frame) |
Jim Ingham | 4ae5196 | 2010-09-10 23:12:17 +0000 | [diff] [blame] | 231 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 232 | return GetObjectDescription (); |
| 233 | } |
| 234 | |
| 235 | const char * |
| 236 | SBValue::GetObjectDescription () |
| 237 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 238 | const char *cstr = NULL; |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 239 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 240 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 241 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 242 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 243 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 244 | cstr = m_opaque_sp->GetObjectDescription (); |
| 245 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 246 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 247 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 248 | if (log) |
| 249 | { |
| 250 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 251 | log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 252 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 253 | log->Printf ("SBValue(%p)::GetObjectDescription => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 254 | } |
| 255 | return cstr; |
Jim Ingham | 4ae5196 | 2010-09-10 23:12:17 +0000 | [diff] [blame] | 256 | } |
| 257 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 258 | bool |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 259 | SBValue::GetValueDidChange (const SBFrame &sb_frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 260 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 261 | return GetValueDidChange (); |
| 262 | } |
| 263 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 264 | SBType |
| 265 | SBValue::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 Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 288 | bool |
| 289 | SBValue::GetValueDidChange () |
| 290 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 291 | bool result = false; |
| 292 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 293 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 294 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 295 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 296 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 297 | result = m_opaque_sp->GetValueDidChange (); |
| 298 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 299 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 300 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 301 | if (log) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 302 | log->Printf ("SBValue(%p)::GetValueDidChange => %i", m_opaque_sp.get(), result); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 303 | |
| 304 | return result; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | const char * |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 308 | SBValue::GetSummary (const SBFrame &sb_frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 309 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 310 | return GetSummary (); |
| 311 | } |
| 312 | |
| 313 | const char * |
| 314 | SBValue::GetSummary () |
| 315 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 316 | const char *cstr = NULL; |
| 317 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 318 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 319 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 320 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 321 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 322 | cstr = m_opaque_sp->GetSummaryAsCString(); |
| 323 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 324 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 325 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 326 | if (log) |
| 327 | { |
| 328 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 329 | log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 330 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 331 | log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 332 | } |
| 333 | return cstr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 334 | } |
| 335 | |
| 336 | const char * |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 337 | SBValue::GetLocation (const SBFrame &sb_frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 338 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 339 | return GetLocation (); |
| 340 | } |
| 341 | |
| 342 | const char * |
| 343 | SBValue::GetLocation () |
| 344 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 345 | const char *cstr = NULL; |
| 346 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 347 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 348 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 349 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 350 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 351 | cstr = m_opaque_sp->GetLocationAsCString(); |
| 352 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 353 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 354 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 355 | if (log) |
| 356 | { |
| 357 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 358 | log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 359 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 360 | log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 361 | } |
| 362 | return cstr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 363 | } |
| 364 | |
| 365 | bool |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 366 | SBValue::SetValueFromCString (const SBFrame &sb_frame, const char *value_str) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 367 | { |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 368 | return SetValueFromCString (value_str); |
| 369 | } |
| 370 | |
| 371 | bool |
| 372 | SBValue::SetValueFromCString (const char *value_str) |
| 373 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 374 | bool success = false; |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 375 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 376 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 377 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 378 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 379 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 380 | success = m_opaque_sp->SetValueFromCString (value_str); |
| 381 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 382 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 383 | return success; |
| 384 | } |
| 385 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 386 | lldb::SBValue |
| 387 | SBValue::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 | |
| 409 | lldb::SBValue |
| 410 | SBValue::Cast(const SBType& type) |
| 411 | { |
| 412 | return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type); |
| 413 | } |
| 414 | |
| 415 | lldb::SBValue |
| 416 | SBValue::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 | |
| 440 | lldb::SBValue |
| 441 | SBValue::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)); |
| 460 | result = SBValue(result_valobj_sp); |
| 461 | } |
| 462 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 463 | if (log) |
| 464 | { |
| 465 | if (result.IsValid()) |
| 466 | log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp.get()); |
| 467 | else |
| 468 | log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get()); |
| 469 | } |
| 470 | return result; |
| 471 | } |
| 472 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 473 | SBValue |
| 474 | SBValue::GetChildAtIndex (uint32_t idx) |
| 475 | { |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 476 | const bool can_create_synthetic = false; |
| 477 | lldb::DynamicValueType use_dynamic = eNoDynamicValues; |
Johnny Chen | 446ccaa | 2011-06-29 21:19:39 +0000 | [diff] [blame] | 478 | if (m_opaque_sp) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 479 | use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue(); |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 480 | return GetChildAtIndex (idx, use_dynamic, can_create_synthetic); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 481 | } |
| 482 | |
| 483 | SBValue |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 484 | SBValue::GetChildAtIndex (uint32_t idx, lldb::DynamicValueType use_dynamic, bool can_create_synthetic) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 485 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 486 | lldb::ValueObjectSP child_sp; |
| 487 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 488 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 489 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 490 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 491 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 492 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 493 | const bool can_create = true; |
| 494 | child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create); |
| 495 | if (can_create_synthetic && !child_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 496 | { |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 497 | if (m_opaque_sp->IsPointerType()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 498 | { |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 499 | child_sp = m_opaque_sp->GetSyntheticArrayMemberFromPointer(idx, can_create); |
| 500 | } |
| 501 | else if (m_opaque_sp->IsArrayType()) |
| 502 | { |
| 503 | child_sp = m_opaque_sp->GetSyntheticArrayMemberFromArray(idx, can_create); |
| 504 | } |
| 505 | } |
| 506 | |
| 507 | if (child_sp) |
| 508 | { |
| 509 | if (use_dynamic != lldb::eNoDynamicValues) |
| 510 | { |
| 511 | lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic)); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 512 | if (dynamic_sp) |
| 513 | child_sp = dynamic_sp; |
| 514 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 515 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 516 | } |
| 517 | } |
| 518 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 519 | SBValue sb_value (child_sp); |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 520 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 521 | if (log) |
| 522 | log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get()); |
| 523 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 524 | return sb_value; |
| 525 | } |
| 526 | |
| 527 | uint32_t |
| 528 | SBValue::GetIndexOfChildWithName (const char *name) |
| 529 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 530 | uint32_t idx = UINT32_MAX; |
| 531 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 532 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 533 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 534 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 535 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 536 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 537 | idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); |
| 538 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 539 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 540 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 541 | if (log) |
| 542 | { |
| 543 | if (idx == UINT32_MAX) |
| 544 | log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name, idx); |
| 545 | else |
| 546 | log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx); |
| 547 | } |
| 548 | return idx; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 549 | } |
| 550 | |
| 551 | SBValue |
| 552 | SBValue::GetChildMemberWithName (const char *name) |
| 553 | { |
Johnny Chen | 446ccaa | 2011-06-29 21:19:39 +0000 | [diff] [blame] | 554 | if (m_opaque_sp) |
| 555 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 556 | lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue(); |
Johnny Chen | 446ccaa | 2011-06-29 21:19:39 +0000 | [diff] [blame] | 557 | return GetChildMemberWithName (name, use_dynamic_value); |
| 558 | } |
| 559 | else |
| 560 | return GetChildMemberWithName (name, eNoDynamicValues); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 561 | } |
| 562 | |
| 563 | SBValue |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 564 | SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 565 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 566 | lldb::ValueObjectSP child_sp; |
| 567 | const ConstString str_name (name); |
| 568 | |
Greg Clayton | 905acaf | 2011-05-20 22:07:17 +0000 | [diff] [blame] | 569 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 570 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 571 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 572 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 573 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 574 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 575 | child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); |
| 576 | if (use_dynamic_value != lldb::eNoDynamicValues) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 577 | { |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 578 | if (child_sp) |
| 579 | { |
| 580 | lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value); |
| 581 | if (dynamic_sp) |
| 582 | child_sp = dynamic_sp; |
| 583 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 584 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 585 | } |
| 586 | } |
| 587 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 588 | SBValue sb_value (child_sp); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 589 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 590 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 591 | if (log) |
| 592 | log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get()); |
| 593 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 594 | return sb_value; |
| 595 | } |
| 596 | |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 597 | lldb::SBValue |
| 598 | SBValue::GetValueForExpressionPath(const char* expr_path) |
| 599 | { |
| 600 | lldb::ValueObjectSP child_sp; |
| 601 | if (m_opaque_sp) |
| 602 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 603 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 604 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 605 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 606 | // using default values for all the fancy options, just do it if you can |
| 607 | child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path); |
| 608 | } |
| 609 | } |
| 610 | |
| 611 | SBValue sb_value (child_sp); |
| 612 | |
| 613 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 614 | if (log) |
| 615 | log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr_path, sb_value.get()); |
| 616 | |
| 617 | return sb_value; |
| 618 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 619 | |
| 620 | uint32_t |
| 621 | SBValue::GetNumChildren () |
| 622 | { |
| 623 | uint32_t num_children = 0; |
| 624 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 625 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 626 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 627 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 628 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 629 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 630 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 631 | num_children = m_opaque_sp->GetNumChildren(); |
| 632 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 633 | } |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 634 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 635 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 636 | if (log) |
| 637 | log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 638 | |
| 639 | return num_children; |
| 640 | } |
| 641 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 642 | |
| 643 | SBValue |
| 644 | SBValue::Dereference () |
| 645 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 646 | SBValue sb_value; |
| 647 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 648 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 649 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 650 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 651 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 652 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 653 | Error error; |
| 654 | sb_value = m_opaque_sp->Dereference (error); |
| 655 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 656 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 657 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 658 | if (log) |
| 659 | log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); |
| 660 | |
| 661 | return sb_value; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 662 | } |
| 663 | |
| 664 | bool |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 665 | SBValue::TypeIsPointerType () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 666 | { |
| 667 | bool is_ptr_type = false; |
| 668 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 669 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 670 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 671 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 672 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 673 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 674 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 675 | is_ptr_type = m_opaque_sp->IsPointerType(); |
| 676 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 677 | } |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 678 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 679 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 680 | if (log) |
| 681 | log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type); |
| 682 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 683 | |
| 684 | return is_ptr_type; |
| 685 | } |
| 686 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 687 | void * |
| 688 | SBValue::GetOpaqueType() |
| 689 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 690 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 691 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 692 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 693 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 694 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 695 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 696 | return m_opaque_sp->GetClangType(); |
| 697 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 698 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 699 | return NULL; |
| 700 | } |
| 701 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 702 | lldb::SBTarget |
| 703 | SBValue::GetTarget() |
| 704 | { |
| 705 | SBTarget result; |
| 706 | if (m_opaque_sp) |
| 707 | { |
| 708 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 709 | { |
| 710 | result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP())); |
| 711 | } |
| 712 | } |
| 713 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 714 | if (log) |
| 715 | { |
| 716 | if (result.get() == NULL) |
| 717 | log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get()); |
| 718 | else |
| 719 | log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get()); |
| 720 | } |
| 721 | return result; |
| 722 | } |
| 723 | |
| 724 | lldb::SBProcess |
| 725 | SBValue::GetProcess() |
| 726 | { |
| 727 | SBProcess result; |
| 728 | if (m_opaque_sp) |
| 729 | { |
| 730 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 731 | { |
| 732 | result = SBProcess(lldb::ProcessSP(m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetProcessSP())); |
| 733 | } |
| 734 | } |
| 735 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 736 | if (log) |
| 737 | { |
| 738 | if (result.get() == NULL) |
| 739 | log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get()); |
| 740 | else |
| 741 | log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get()); |
| 742 | } |
| 743 | return result; |
| 744 | } |
| 745 | |
| 746 | lldb::SBThread |
| 747 | SBValue::GetThread() |
| 748 | { |
| 749 | SBThread result; |
| 750 | if (m_opaque_sp) |
| 751 | { |
| 752 | if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()) |
| 753 | { |
| 754 | result = SBThread(lldb::ThreadSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateThread())); |
| 755 | } |
| 756 | } |
| 757 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 758 | if (log) |
| 759 | { |
| 760 | if (result.get() == NULL) |
| 761 | log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get()); |
| 762 | else |
| 763 | log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), result.get()); |
| 764 | } |
| 765 | return result; |
| 766 | } |
| 767 | |
| 768 | lldb::SBFrame |
| 769 | SBValue::GetFrame() |
| 770 | { |
| 771 | SBFrame result; |
| 772 | if (m_opaque_sp) |
| 773 | { |
| 774 | if (m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()) |
| 775 | { |
| 776 | result = SBFrame(lldb::StackFrameSP(m_opaque_sp->GetUpdatePoint().GetExecutionContextScope()->CalculateStackFrame())); |
| 777 | } |
| 778 | } |
| 779 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 780 | if (log) |
| 781 | { |
| 782 | if (result.get() == NULL) |
| 783 | log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get()); |
| 784 | else |
| 785 | log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get()); |
| 786 | } |
| 787 | return result; |
| 788 | } |
| 789 | |
| 790 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 791 | // Mimic shared pointer... |
| 792 | lldb_private::ValueObject * |
| 793 | SBValue::get() const |
| 794 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 795 | return m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | lldb_private::ValueObject * |
| 799 | SBValue::operator->() const |
| 800 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 801 | return m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | lldb::ValueObjectSP & |
| 805 | SBValue::operator*() |
| 806 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 807 | return m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 808 | } |
| 809 | |
| 810 | const lldb::ValueObjectSP & |
| 811 | SBValue::operator*() const |
| 812 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 813 | return m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 814 | } |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 815 | |
| 816 | bool |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 817 | SBValue::GetExpressionPath (SBStream &description) |
| 818 | { |
| 819 | if (m_opaque_sp) |
| 820 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 821 | m_opaque_sp->GetExpressionPath (description.ref(), false); |
| 822 | return true; |
| 823 | } |
| 824 | return false; |
| 825 | } |
| 826 | |
| 827 | bool |
| 828 | SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes) |
| 829 | { |
| 830 | if (m_opaque_sp) |
| 831 | { |
| 832 | m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 833 | return true; |
| 834 | } |
| 835 | return false; |
| 836 | } |
| 837 | |
| 838 | bool |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 839 | SBValue::GetDescription (SBStream &description) |
| 840 | { |
| 841 | if (m_opaque_sp) |
| 842 | { |
Greg Clayton | bafc86e | 2011-07-06 16:49:27 +0000 | [diff] [blame] | 843 | uint32_t ptr_depth = 0; |
| 844 | uint32_t curr_depth = 0; |
| 845 | uint32_t max_depth = UINT32_MAX; |
| 846 | bool show_types = false; |
| 847 | bool show_location = false; |
| 848 | bool use_objc = false; |
| 849 | lldb::DynamicValueType use_dynamic = eNoDynamicValues; |
| 850 | bool scope_already_checked = false; |
| 851 | bool flat_output = false; |
Enrico Granata | e4e3e2c | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 852 | bool use_synthetic = true; |
| 853 | uint32_t no_summary_depth = 0; |
Greg Clayton | bafc86e | 2011-07-06 16:49:27 +0000 | [diff] [blame] | 854 | ValueObject::DumpValueObject (description.ref(), |
| 855 | m_opaque_sp.get(), |
| 856 | m_opaque_sp->GetName().GetCString(), |
| 857 | ptr_depth, |
| 858 | curr_depth, |
| 859 | max_depth, |
| 860 | show_types, show_location, |
| 861 | use_objc, |
Enrico Granata | e4e3e2c | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 862 | use_dynamic, |
| 863 | use_synthetic, |
Greg Clayton | bafc86e | 2011-07-06 16:49:27 +0000 | [diff] [blame] | 864 | scope_already_checked, |
Enrico Granata | 7f163b3 | 2011-07-16 01:22:04 +0000 | [diff] [blame] | 865 | flat_output, |
Enrico Granata | e4e3e2c | 2011-07-22 00:16:08 +0000 | [diff] [blame] | 866 | no_summary_depth); |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 867 | } |
| 868 | else |
| 869 | description.Printf ("No value"); |
| 870 | |
| 871 | return true; |
| 872 | } |
Greg Clayton | e179a58 | 2011-01-05 18:43:15 +0000 | [diff] [blame] | 873 | |
| 874 | lldb::Format |
| 875 | SBValue::GetFormat () const |
| 876 | { |
| 877 | if (m_opaque_sp) |
| 878 | return m_opaque_sp->GetFormat(); |
| 879 | return eFormatDefault; |
| 880 | } |
| 881 | |
| 882 | void |
| 883 | SBValue::SetFormat (lldb::Format format) |
| 884 | { |
| 885 | if (m_opaque_sp) |
| 886 | m_opaque_sp->SetFormat(format); |
| 887 | } |
| 888 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame^] | 889 | lldb::SBValue |
| 890 | SBValue::AddressOf() |
| 891 | { |
| 892 | SBValue sb_value; |
| 893 | if (m_opaque_sp) |
| 894 | { |
| 895 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 896 | { |
| 897 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 898 | |
| 899 | Error error; |
| 900 | sb_value = m_opaque_sp->AddressOf (error); |
| 901 | } |
| 902 | } |
| 903 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 904 | if (log) |
| 905 | log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); |
| 906 | |
| 907 | return sb_value; |
| 908 | } |