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 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 13 | #include "lldb/Breakpoint/Watchpoint.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 14 | #include "lldb/Core/DataExtractor.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 15 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 16 | #include "lldb/Core/Module.h" |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 17 | #include "lldb/Core/Scalar.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 18 | #include "lldb/Core/Stream.h" |
| 19 | #include "lldb/Core/StreamFile.h" |
| 20 | #include "lldb/Core/Value.h" |
| 21 | #include "lldb/Core/ValueObject.h" |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 22 | #include "lldb/Core/ValueObjectConstResult.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 23 | #include "lldb/Symbol/Block.h" |
| 24 | #include "lldb/Symbol/ObjectFile.h" |
| 25 | #include "lldb/Symbol/Variable.h" |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 26 | #include "lldb/Symbol/VariableList.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 27 | #include "lldb/Target/ExecutionContext.h" |
| 28 | #include "lldb/Target/Process.h" |
| 29 | #include "lldb/Target/StackFrame.h" |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 30 | #include "lldb/Target/Target.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 31 | #include "lldb/Target/Thread.h" |
| 32 | |
Eli Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 33 | #include "lldb/API/SBProcess.h" |
| 34 | #include "lldb/API/SBTarget.h" |
| 35 | #include "lldb/API/SBThread.h" |
| 36 | #include "lldb/API/SBFrame.h" |
| 37 | #include "lldb/API/SBDebugger.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | |
| 39 | using namespace lldb; |
| 40 | using namespace lldb_private; |
| 41 | |
| 42 | SBValue::SBValue () : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 43 | m_opaque_sp () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 44 | { |
| 45 | } |
| 46 | |
| 47 | SBValue::SBValue (const lldb::ValueObjectSP &value_sp) : |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 48 | m_opaque_sp (value_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 49 | { |
| 50 | } |
| 51 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 52 | SBValue::SBValue(const SBValue &rhs) : |
| 53 | m_opaque_sp (rhs.m_opaque_sp) |
| 54 | { |
| 55 | } |
| 56 | |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 57 | SBValue & |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 58 | SBValue::operator = (const SBValue &rhs) |
| 59 | { |
| 60 | if (this != &rhs) |
| 61 | m_opaque_sp = rhs.m_opaque_sp; |
| 62 | return *this; |
| 63 | } |
| 64 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 65 | SBValue::~SBValue() |
| 66 | { |
| 67 | } |
| 68 | |
| 69 | bool |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 70 | SBValue::IsValid () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 71 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 72 | // If this function ever changes to anything that does more than just |
| 73 | // check if the opaque shared pointer is non NULL, then we need to update |
| 74 | // all "if (m_opaque_sp)" code in this file. |
| 75 | return m_opaque_sp.get() != NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 76 | } |
| 77 | |
Jim Ingham | e0bd571 | 2011-12-19 20:39:44 +0000 | [diff] [blame] | 78 | void |
| 79 | SBValue::Clear() |
| 80 | { |
| 81 | m_opaque_sp.reset(); |
| 82 | } |
| 83 | |
Greg Clayton | c5f728c | 2010-10-06 22:10:17 +0000 | [diff] [blame] | 84 | SBError |
| 85 | SBValue::GetError() |
| 86 | { |
| 87 | SBError sb_error; |
| 88 | |
| 89 | if (m_opaque_sp.get()) |
| 90 | sb_error.SetError(m_opaque_sp->GetError()); |
| 91 | |
| 92 | return sb_error; |
| 93 | } |
| 94 | |
Johnny Chen | 968958c | 2011-07-07 20:46:23 +0000 | [diff] [blame] | 95 | user_id_t |
| 96 | SBValue::GetID() |
| 97 | { |
| 98 | if (m_opaque_sp) |
| 99 | return m_opaque_sp->GetID(); |
| 100 | return LLDB_INVALID_UID; |
| 101 | } |
| 102 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 103 | const char * |
| 104 | SBValue::GetName() |
| 105 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 106 | |
| 107 | const char *name = NULL; |
| 108 | if (m_opaque_sp) |
| 109 | name = m_opaque_sp->GetName().GetCString(); |
| 110 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 111 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 3f5ee7f | 2010-10-29 04:59:35 +0000 | [diff] [blame] | 112 | if (log) |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 113 | { |
| 114 | if (name) |
| 115 | log->Printf ("SBValue(%p)::GetName () => \"%s\"", m_opaque_sp.get(), name); |
| 116 | else |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 117 | log->Printf ("SBValue(%p)::GetName () => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 118 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 119 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 120 | return name; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 121 | } |
| 122 | |
| 123 | const char * |
| 124 | SBValue::GetTypeName () |
| 125 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 126 | const char *name = NULL; |
| 127 | if (m_opaque_sp) |
| 128 | name = m_opaque_sp->GetTypeName().GetCString(); |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 129 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 130 | if (log) |
| 131 | { |
| 132 | if (name) |
| 133 | log->Printf ("SBValue(%p)::GetTypeName () => \"%s\"", m_opaque_sp.get(), name); |
| 134 | else |
| 135 | log->Printf ("SBValue(%p)::GetTypeName () => NULL", m_opaque_sp.get()); |
| 136 | } |
| 137 | |
| 138 | return name; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 139 | } |
| 140 | |
| 141 | size_t |
| 142 | SBValue::GetByteSize () |
| 143 | { |
| 144 | size_t result = 0; |
| 145 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 146 | if (m_opaque_sp) |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 147 | result = m_opaque_sp->GetByteSize(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 148 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 149 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 150 | if (log) |
| 151 | log->Printf ("SBValue(%p)::GetByteSize () => %zu", m_opaque_sp.get(), result); |
| 152 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 153 | return result; |
| 154 | } |
| 155 | |
| 156 | bool |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 157 | SBValue::IsInScope () |
| 158 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 159 | bool result = false; |
| 160 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 161 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 162 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 163 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 164 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 165 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 166 | result = m_opaque_sp->IsInScope (); |
| 167 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 168 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 169 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 170 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 171 | if (log) |
| 172 | log->Printf ("SBValue(%p)::IsInScope () => %i", m_opaque_sp.get(), result); |
| 173 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 174 | return result; |
| 175 | } |
| 176 | |
| 177 | const char * |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 178 | SBValue::GetValue () |
| 179 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 180 | const char *cstr = NULL; |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 181 | if (m_opaque_sp) |
| 182 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 183 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 184 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 185 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 186 | cstr = m_opaque_sp->GetValueAsCString (); |
| 187 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 188 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 189 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 190 | if (log) |
| 191 | { |
| 192 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 193 | log->Printf ("SBValue(%p)::GetValue => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 194 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 195 | log->Printf ("SBValue(%p)::GetValue => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 196 | } |
| 197 | |
| 198 | return cstr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 199 | } |
| 200 | |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 201 | ValueType |
| 202 | SBValue::GetValueType () |
| 203 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 204 | ValueType result = eValueTypeInvalid; |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 205 | if (m_opaque_sp) |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 206 | result = m_opaque_sp->GetValueType(); |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 207 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 208 | if (log) |
| 209 | { |
| 210 | switch (result) |
| 211 | { |
| 212 | case eValueTypeInvalid: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeInvalid", m_opaque_sp.get()); break; |
| 213 | case eValueTypeVariableGlobal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableGlobal", m_opaque_sp.get()); break; |
| 214 | case eValueTypeVariableStatic: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableStatic", m_opaque_sp.get()); break; |
| 215 | case eValueTypeVariableArgument:log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableArgument", m_opaque_sp.get()); break; |
| 216 | case eValueTypeVariableLocal: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeVariableLocal", m_opaque_sp.get()); break; |
| 217 | case eValueTypeRegister: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegister", m_opaque_sp.get()); break; |
| 218 | case eValueTypeRegisterSet: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeRegisterSet", m_opaque_sp.get()); break; |
| 219 | case eValueTypeConstResult: log->Printf ("SBValue(%p)::GetValueType () => eValueTypeConstResult", m_opaque_sp.get()); break; |
| 220 | default: log->Printf ("SBValue(%p)::GetValueType () => %i ???", m_opaque_sp.get(), result); break; |
| 221 | } |
| 222 | } |
| 223 | return result; |
Greg Clayton | f3d0b0c | 2010-10-27 03:32:59 +0000 | [diff] [blame] | 224 | } |
| 225 | |
Jim Ingham | 4ae5196 | 2010-09-10 23:12:17 +0000 | [diff] [blame] | 226 | const char * |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 227 | SBValue::GetObjectDescription () |
| 228 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 229 | const char *cstr = NULL; |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 230 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 231 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 232 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 233 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 234 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 235 | cstr = m_opaque_sp->GetObjectDescription (); |
| 236 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 237 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 238 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 239 | if (log) |
| 240 | { |
| 241 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 242 | log->Printf ("SBValue(%p)::GetObjectDescription => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 243 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 244 | log->Printf ("SBValue(%p)::GetObjectDescription => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 245 | } |
| 246 | return cstr; |
Jim Ingham | 4ae5196 | 2010-09-10 23:12:17 +0000 | [diff] [blame] | 247 | } |
| 248 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 249 | SBType |
| 250 | SBValue::GetType() |
| 251 | { |
| 252 | SBType result; |
| 253 | if (m_opaque_sp) |
| 254 | { |
| 255 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 256 | { |
| 257 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 258 | result = SBType(ClangASTType (m_opaque_sp->GetClangAST(), m_opaque_sp->GetClangType())); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 259 | } |
| 260 | } |
| 261 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 262 | if (log) |
| 263 | { |
| 264 | if (result.IsValid()) |
| 265 | log->Printf ("SBValue(%p)::GetType => %p", m_opaque_sp.get(), &result); |
| 266 | else |
| 267 | log->Printf ("SBValue(%p)::GetType => NULL", m_opaque_sp.get()); |
| 268 | } |
| 269 | return result; |
| 270 | } |
| 271 | |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 272 | bool |
| 273 | SBValue::GetValueDidChange () |
| 274 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 275 | bool result = false; |
| 276 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 277 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 278 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 279 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 280 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 281 | result = m_opaque_sp->GetValueDidChange (); |
| 282 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 283 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 284 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 285 | if (log) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 286 | log->Printf ("SBValue(%p)::GetValueDidChange => %i", m_opaque_sp.get(), result); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 287 | |
| 288 | return result; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 289 | } |
| 290 | |
| 291 | const char * |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 292 | SBValue::GetSummary () |
| 293 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 294 | const char *cstr = NULL; |
| 295 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 296 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 297 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 298 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 299 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 300 | cstr = m_opaque_sp->GetSummaryAsCString(); |
| 301 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 302 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 303 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 304 | if (log) |
| 305 | { |
| 306 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 307 | log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 308 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 309 | log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 310 | } |
| 311 | return cstr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | } |
| 313 | |
| 314 | const char * |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 315 | SBValue::GetLocation () |
| 316 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 317 | const char *cstr = NULL; |
| 318 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 319 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 320 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 321 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 322 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 323 | cstr = m_opaque_sp->GetLocationAsCString(); |
| 324 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 325 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 326 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 327 | if (log) |
| 328 | { |
| 329 | if (cstr) |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 330 | log->Printf ("SBValue(%p)::GetSummary => \"%s\"", m_opaque_sp.get(), cstr); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 331 | else |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 332 | log->Printf ("SBValue(%p)::GetSummary => NULL", m_opaque_sp.get()); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 333 | } |
| 334 | return cstr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | bool |
Jim Ingham | fa3a16a | 2011-03-31 00:19:25 +0000 | [diff] [blame] | 338 | SBValue::SetValueFromCString (const char *value_str) |
| 339 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 340 | bool success = false; |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 341 | if (m_opaque_sp) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 342 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 343 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 344 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 345 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 346 | success = m_opaque_sp->SetValueFromCString (value_str); |
| 347 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 348 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 349 | return success; |
| 350 | } |
| 351 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 352 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 353 | SBValue::CreateChildAtOffset (const char *name, uint32_t offset, SBType type) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 354 | { |
| 355 | lldb::SBValue result; |
| 356 | if (m_opaque_sp) |
| 357 | { |
| 358 | if (type.IsValid()) |
| 359 | { |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 360 | result = SBValue(m_opaque_sp->GetSyntheticChildAtOffset(offset, type.m_opaque_sp->GetClangASTType(), true)); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 361 | result.m_opaque_sp->SetName(ConstString(name)); |
| 362 | } |
| 363 | } |
| 364 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 365 | if (log) |
| 366 | { |
| 367 | if (result.IsValid()) |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 368 | log->Printf ("SBValue(%p)::GetChildAtOffset => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 369 | else |
| 370 | log->Printf ("SBValue(%p)::GetChildAtOffset => NULL", m_opaque_sp.get()); |
| 371 | } |
| 372 | return result; |
| 373 | } |
| 374 | |
| 375 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 376 | SBValue::Cast (SBType type) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 377 | { |
| 378 | return CreateChildAtOffset(m_opaque_sp->GetName().GetCString(), 0, type); |
| 379 | } |
| 380 | |
| 381 | lldb::SBValue |
| 382 | SBValue::CreateValueFromExpression (const char *name, const char* expression) |
| 383 | { |
| 384 | lldb::SBValue result; |
| 385 | if (m_opaque_sp) |
| 386 | { |
| 387 | ValueObjectSP result_valobj_sp; |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 388 | m_opaque_sp->GetUpdatePoint().GetTargetSP()->EvaluateExpression (expression, |
Jim Ingham | 1586d97 | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 389 | m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame(), |
Sean Callanan | a8428a4 | 2011-09-22 00:41:11 +0000 | [diff] [blame] | 390 | eExecutionPolicyOnlyWhenNeeded, |
Sean Callanan | daa6efe | 2011-12-21 22:22:58 +0000 | [diff] [blame] | 391 | false, // coerce to id |
Sean Callanan | 47dc457 | 2011-09-15 02:13:07 +0000 | [diff] [blame] | 392 | true, // unwind on error |
| 393 | true, // keep in memory |
| 394 | eNoDynamicValues, |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 395 | result_valobj_sp); |
Johnny Chen | 9fd2e38 | 2011-12-20 01:52:44 +0000 | [diff] [blame] | 396 | if (result_valobj_sp) |
| 397 | { |
| 398 | result_valobj_sp->SetName(ConstString(name)); |
| 399 | result = SBValue(result_valobj_sp); |
| 400 | } |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 401 | } |
| 402 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 403 | if (log) |
| 404 | { |
| 405 | if (result.IsValid()) |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 406 | log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 407 | else |
| 408 | log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get()); |
| 409 | } |
| 410 | return result; |
| 411 | } |
| 412 | |
| 413 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 414 | SBValue::CreateValueFromAddress(const char* name, lldb::addr_t address, SBType type) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 415 | { |
| 416 | lldb::SBValue result; |
Johnny Chen | 943485c | 2011-12-15 01:55:36 +0000 | [diff] [blame] | 417 | if (m_opaque_sp && type.IsValid() && type.GetPointerType().IsValid()) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 418 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 419 | SBType real_type(type.GetPointerType()); |
| 420 | |
| 421 | lldb::DataBufferSP buffer(new lldb_private::DataBufferHeap(&address,sizeof(lldb::addr_t))); |
| 422 | |
Jim Ingham | 1586d97 | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 423 | ValueObjectSP ptr_result_valobj_sp(ValueObjectConstResult::Create (m_opaque_sp->GetExecutionContextScope(), |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 424 | real_type.m_opaque_sp->GetASTContext(), |
| 425 | real_type.m_opaque_sp->GetOpaqueQualType(), |
| 426 | ConstString(name), |
| 427 | buffer, |
| 428 | lldb::endian::InlHostByteOrder(), |
| 429 | GetTarget().GetProcess().GetAddressByteSize())); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 430 | |
Enrico Granata | c931030 | 2011-08-04 17:07:02 +0000 | [diff] [blame] | 431 | ValueObjectSP result_valobj_sp; |
| 432 | |
| 433 | ptr_result_valobj_sp->GetValue().SetValueType(Value::eValueTypeLoadAddress); |
| 434 | if (ptr_result_valobj_sp) |
| 435 | { |
| 436 | Error err; |
| 437 | result_valobj_sp = ptr_result_valobj_sp->Dereference(err); |
| 438 | if (result_valobj_sp) |
| 439 | result_valobj_sp->SetName(ConstString(name)); |
| 440 | } |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 441 | result = SBValue(result_valobj_sp); |
| 442 | } |
| 443 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 444 | if (log) |
| 445 | { |
| 446 | if (result.IsValid()) |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 447 | log->Printf ("SBValue(%p)::GetChildFromAddress => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); |
Johnny Chen | a713b86 | 2011-08-09 22:38:07 +0000 | [diff] [blame] | 448 | else |
| 449 | log->Printf ("SBValue(%p)::GetChildFromAddress => NULL", m_opaque_sp.get()); |
| 450 | } |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 451 | return result; |
| 452 | } |
| 453 | |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 454 | lldb::SBValue |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 455 | SBValue::CreateValueFromData (const char* name, SBData data, SBType type) |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 456 | { |
| 457 | SBValue result; |
| 458 | |
| 459 | AddressType addr_of_children_priv = eAddressTypeLoad; |
| 460 | |
| 461 | if (m_opaque_sp) |
| 462 | { |
| 463 | ValueObjectSP valobj_sp; |
| 464 | valobj_sp = ValueObjectConstResult::Create (m_opaque_sp->GetExecutionContextScope(), |
| 465 | type.m_opaque_sp->GetASTContext() , |
| 466 | type.m_opaque_sp->GetOpaqueQualType(), |
| 467 | ConstString(name), |
| 468 | *data.m_opaque_sp, |
| 469 | LLDB_INVALID_ADDRESS); |
| 470 | valobj_sp->SetAddressTypeOfChildren(addr_of_children_priv); |
| 471 | result = SBValue(valobj_sp); |
| 472 | } |
| 473 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 474 | if (log) |
| 475 | { |
| 476 | if (result.IsValid()) |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 477 | log->Printf ("SBValue(%p)::GetChildFromExpression => \"%s\"", m_opaque_sp.get(), result.m_opaque_sp->GetName().AsCString()); |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 478 | else |
| 479 | log->Printf ("SBValue(%p)::GetChildFromExpression => NULL", m_opaque_sp.get()); |
| 480 | } |
| 481 | return result; |
| 482 | } |
| 483 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | SBValue |
| 485 | SBValue::GetChildAtIndex (uint32_t idx) |
| 486 | { |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 487 | const bool can_create_synthetic = false; |
| 488 | lldb::DynamicValueType use_dynamic = eNoDynamicValues; |
Johnny Chen | 446ccaa | 2011-06-29 21:19:39 +0000 | [diff] [blame] | 489 | if (m_opaque_sp) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 490 | use_dynamic = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue(); |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 491 | return GetChildAtIndex (idx, use_dynamic, can_create_synthetic); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | SBValue |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 495 | 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] | 496 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 497 | lldb::ValueObjectSP child_sp; |
| 498 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 499 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 500 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 501 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 502 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 503 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 504 | const bool can_create = true; |
| 505 | child_sp = m_opaque_sp->GetChildAtIndex (idx, can_create); |
| 506 | if (can_create_synthetic && !child_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 507 | { |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 508 | if (m_opaque_sp->IsPointerType()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 509 | { |
Greg Clayton | 8f64c47 | 2011-07-15 19:31:49 +0000 | [diff] [blame] | 510 | child_sp = m_opaque_sp->GetSyntheticArrayMemberFromPointer(idx, can_create); |
| 511 | } |
| 512 | else if (m_opaque_sp->IsArrayType()) |
| 513 | { |
| 514 | child_sp = m_opaque_sp->GetSyntheticArrayMemberFromArray(idx, can_create); |
| 515 | } |
| 516 | } |
| 517 | |
| 518 | if (child_sp) |
| 519 | { |
| 520 | if (use_dynamic != lldb::eNoDynamicValues) |
| 521 | { |
| 522 | lldb::ValueObjectSP dynamic_sp(child_sp->GetDynamicValue (use_dynamic)); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 523 | if (dynamic_sp) |
| 524 | child_sp = dynamic_sp; |
| 525 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 526 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 527 | } |
| 528 | } |
| 529 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 530 | SBValue sb_value (child_sp); |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 531 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 532 | if (log) |
| 533 | log->Printf ("SBValue(%p)::GetChildAtIndex (%u) => SBValue(%p)", m_opaque_sp.get(), idx, sb_value.get()); |
| 534 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 535 | return sb_value; |
| 536 | } |
| 537 | |
| 538 | uint32_t |
| 539 | SBValue::GetIndexOfChildWithName (const char *name) |
| 540 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 541 | uint32_t idx = UINT32_MAX; |
| 542 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 543 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 544 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 545 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 546 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 547 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 548 | idx = m_opaque_sp->GetIndexOfChildWithName (ConstString(name)); |
| 549 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 550 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 551 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 552 | if (log) |
| 553 | { |
| 554 | if (idx == UINT32_MAX) |
Jason Molenda | 7e5fa7f | 2011-09-20 21:44:10 +0000 | [diff] [blame] | 555 | log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => NOT FOUND", m_opaque_sp.get(), name); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 556 | else |
| 557 | log->Printf ("SBValue(%p)::GetIndexOfChildWithName (name=\"%s\") => %u", m_opaque_sp.get(), name, idx); |
| 558 | } |
| 559 | return idx; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 560 | } |
| 561 | |
| 562 | SBValue |
| 563 | SBValue::GetChildMemberWithName (const char *name) |
| 564 | { |
Johnny Chen | 446ccaa | 2011-06-29 21:19:39 +0000 | [diff] [blame] | 565 | if (m_opaque_sp) |
| 566 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 567 | lldb::DynamicValueType use_dynamic_value = m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetPreferDynamicValue(); |
Johnny Chen | 446ccaa | 2011-06-29 21:19:39 +0000 | [diff] [blame] | 568 | return GetChildMemberWithName (name, use_dynamic_value); |
| 569 | } |
| 570 | else |
| 571 | return GetChildMemberWithName (name, eNoDynamicValues); |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 572 | } |
| 573 | |
| 574 | SBValue |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 575 | SBValue::GetChildMemberWithName (const char *name, lldb::DynamicValueType use_dynamic_value) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 576 | { |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 577 | lldb::ValueObjectSP child_sp; |
| 578 | const ConstString str_name (name); |
| 579 | |
Greg Clayton | 905acaf | 2011-05-20 22:07:17 +0000 | [diff] [blame] | 580 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 581 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 582 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 583 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 584 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 585 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 586 | child_sp = m_opaque_sp->GetChildMemberWithName (str_name, true); |
| 587 | if (use_dynamic_value != lldb::eNoDynamicValues) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 588 | { |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 589 | if (child_sp) |
| 590 | { |
| 591 | lldb::ValueObjectSP dynamic_sp = child_sp->GetDynamicValue (use_dynamic_value); |
| 592 | if (dynamic_sp) |
| 593 | child_sp = dynamic_sp; |
| 594 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 595 | } |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 596 | } |
| 597 | } |
| 598 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 599 | SBValue sb_value (child_sp); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 600 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 601 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 602 | if (log) |
| 603 | log->Printf ("SBValue(%p)::GetChildMemberWithName (name=\"%s\") => SBValue(%p)", m_opaque_sp.get(), name, sb_value.get()); |
| 604 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 605 | return sb_value; |
| 606 | } |
| 607 | |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 608 | lldb::SBValue |
Jim Ingham | 1b42575 | 2011-12-08 19:44:08 +0000 | [diff] [blame] | 609 | SBValue::GetDynamicValue (lldb::DynamicValueType use_dynamic) |
| 610 | { |
| 611 | if (m_opaque_sp) |
| 612 | { |
| 613 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 614 | { |
| 615 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 616 | return SBValue (m_opaque_sp->GetDynamicValue(use_dynamic)); |
| 617 | } |
| 618 | } |
| 619 | |
| 620 | return SBValue(); |
| 621 | } |
| 622 | |
| 623 | lldb::SBValue |
| 624 | SBValue::GetStaticValue () |
| 625 | { |
| 626 | if (m_opaque_sp) |
| 627 | { |
| 628 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 629 | { |
| 630 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 631 | return SBValue(m_opaque_sp->GetStaticValue()); |
| 632 | } |
| 633 | } |
| 634 | |
| 635 | return SBValue(); |
| 636 | } |
| 637 | |
| 638 | bool |
| 639 | SBValue::IsDynamic() |
| 640 | { |
| 641 | if (m_opaque_sp) |
| 642 | { |
| 643 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 644 | { |
| 645 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 646 | return m_opaque_sp->IsDynamic(); |
| 647 | } |
| 648 | } |
| 649 | return false; |
| 650 | } |
| 651 | |
| 652 | lldb::SBValue |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 653 | SBValue::GetValueForExpressionPath(const char* expr_path) |
| 654 | { |
| 655 | lldb::ValueObjectSP child_sp; |
| 656 | if (m_opaque_sp) |
| 657 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 658 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 659 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 660 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Enrico Granata | f7a9b14 | 2011-07-15 02:26:42 +0000 | [diff] [blame] | 661 | // using default values for all the fancy options, just do it if you can |
| 662 | child_sp = m_opaque_sp->GetValueForExpressionPath(expr_path); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | SBValue sb_value (child_sp); |
| 667 | |
| 668 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 669 | if (log) |
| 670 | log->Printf ("SBValue(%p)::GetValueForExpressionPath (expr_path=\"%s\") => SBValue(%p)", m_opaque_sp.get(), expr_path, sb_value.get()); |
| 671 | |
| 672 | return sb_value; |
| 673 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 674 | |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 675 | int64_t |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 676 | SBValue::GetValueAsSigned(SBError& error, int64_t fail_value) |
| 677 | { |
Jim Ingham | 574c3d6 | 2011-08-12 23:34:31 +0000 | [diff] [blame] | 678 | error.Clear(); |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 679 | if (m_opaque_sp) |
| 680 | { |
| 681 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 682 | { |
| 683 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 684 | Scalar scalar; |
| 685 | if (m_opaque_sp->ResolveValue (scalar)) |
| 686 | return scalar.GetRawBits64(fail_value); |
| 687 | else |
| 688 | error.SetErrorString("could not get value"); |
| 689 | } |
| 690 | else |
| 691 | error.SetErrorString("could not get target"); |
| 692 | } |
| 693 | error.SetErrorString("invalid SBValue"); |
| 694 | return fail_value; |
| 695 | } |
| 696 | |
| 697 | uint64_t |
| 698 | SBValue::GetValueAsUnsigned(SBError& error, uint64_t fail_value) |
| 699 | { |
Jim Ingham | 574c3d6 | 2011-08-12 23:34:31 +0000 | [diff] [blame] | 700 | error.Clear(); |
Enrico Granata | c92eb40 | 2011-08-04 01:41:02 +0000 | [diff] [blame] | 701 | if (m_opaque_sp) |
| 702 | { |
| 703 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 704 | { |
| 705 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 706 | Scalar scalar; |
| 707 | if (m_opaque_sp->ResolveValue (scalar)) |
| 708 | return scalar.GetRawBits64(fail_value); |
| 709 | else |
| 710 | error.SetErrorString("could not get value"); |
| 711 | } |
| 712 | else |
| 713 | error.SetErrorString("could not get target"); |
| 714 | } |
| 715 | error.SetErrorString("invalid SBValue"); |
| 716 | return fail_value; |
| 717 | } |
| 718 | |
| 719 | int64_t |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 720 | SBValue::GetValueAsSigned(int64_t fail_value) |
| 721 | { |
| 722 | if (m_opaque_sp) |
| 723 | { |
| 724 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 725 | { |
| 726 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 727 | Scalar scalar; |
| 728 | if (m_opaque_sp->ResolveValue (scalar)) |
| 729 | return scalar.GetRawBits64(fail_value); |
| 730 | } |
| 731 | } |
| 732 | return fail_value; |
| 733 | } |
| 734 | |
| 735 | uint64_t |
| 736 | SBValue::GetValueAsUnsigned(uint64_t fail_value) |
| 737 | { |
| 738 | if (m_opaque_sp) |
| 739 | { |
| 740 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 741 | { |
| 742 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
| 743 | Scalar scalar; |
| 744 | if (m_opaque_sp->ResolveValue (scalar)) |
| 745 | return scalar.GetRawBits64(fail_value); |
| 746 | } |
| 747 | } |
| 748 | return fail_value; |
| 749 | } |
| 750 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 751 | uint32_t |
| 752 | SBValue::GetNumChildren () |
| 753 | { |
| 754 | uint32_t num_children = 0; |
| 755 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 756 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 757 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 758 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 759 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 760 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 761 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 762 | num_children = m_opaque_sp->GetNumChildren(); |
| 763 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 764 | } |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 765 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 766 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 767 | if (log) |
| 768 | log->Printf ("SBValue(%p)::GetNumChildren () => %u", m_opaque_sp.get(), num_children); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 769 | |
| 770 | return num_children; |
| 771 | } |
| 772 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 773 | |
| 774 | SBValue |
| 775 | SBValue::Dereference () |
| 776 | { |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 777 | SBValue sb_value; |
| 778 | if (m_opaque_sp) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 779 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 780 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 781 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 782 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 783 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 784 | Error error; |
| 785 | sb_value = m_opaque_sp->Dereference (error); |
| 786 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 787 | } |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 788 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 789 | if (log) |
| 790 | log->Printf ("SBValue(%p)::Dereference () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); |
| 791 | |
| 792 | return sb_value; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 793 | } |
| 794 | |
| 795 | bool |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 796 | SBValue::TypeIsPointerType () |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 797 | { |
| 798 | bool is_ptr_type = false; |
| 799 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 800 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 801 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 802 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 803 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 804 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 805 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 806 | is_ptr_type = m_opaque_sp->IsPointerType(); |
| 807 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 808 | } |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 809 | |
Greg Clayton | e005f2c | 2010-11-06 01:53:30 +0000 | [diff] [blame] | 810 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 811 | if (log) |
| 812 | log->Printf ("SBValue(%p)::TypeIsPointerType () => %i", m_opaque_sp.get(), is_ptr_type); |
| 813 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 814 | |
| 815 | return is_ptr_type; |
| 816 | } |
| 817 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 818 | void * |
| 819 | SBValue::GetOpaqueType() |
| 820 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 821 | if (m_opaque_sp) |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 822 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 823 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 824 | { |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 825 | Mutex::Locker api_locker (m_opaque_sp->GetUpdatePoint().GetTargetSP()->GetAPIMutex()); |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 826 | |
Greg Clayton | b9dcc51 | 2011-06-29 18:28:50 +0000 | [diff] [blame] | 827 | return m_opaque_sp->GetClangType(); |
| 828 | } |
Greg Clayton | fab305b | 2011-05-20 23:51:26 +0000 | [diff] [blame] | 829 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 830 | return NULL; |
| 831 | } |
| 832 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 833 | lldb::SBTarget |
| 834 | SBValue::GetTarget() |
| 835 | { |
| 836 | SBTarget result; |
| 837 | if (m_opaque_sp) |
| 838 | { |
| 839 | if (m_opaque_sp->GetUpdatePoint().GetTargetSP()) |
| 840 | { |
| 841 | result = SBTarget(lldb::TargetSP(m_opaque_sp->GetUpdatePoint().GetTargetSP())); |
| 842 | } |
| 843 | } |
| 844 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 845 | if (log) |
| 846 | { |
| 847 | if (result.get() == NULL) |
| 848 | log->Printf ("SBValue(%p)::GetTarget () => NULL", m_opaque_sp.get()); |
| 849 | else |
| 850 | log->Printf ("SBValue(%p)::GetTarget () => %p", m_opaque_sp.get(), result.get()); |
| 851 | } |
| 852 | return result; |
| 853 | } |
| 854 | |
| 855 | lldb::SBProcess |
| 856 | SBValue::GetProcess() |
| 857 | { |
| 858 | SBProcess result; |
| 859 | if (m_opaque_sp) |
| 860 | { |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 861 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 862 | if (target) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 863 | { |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 864 | result = SBProcess(lldb::ProcessSP(target->GetProcessSP())); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 865 | } |
| 866 | } |
| 867 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 868 | if (log) |
| 869 | { |
| 870 | if (result.get() == NULL) |
| 871 | log->Printf ("SBValue(%p)::GetProcess () => NULL", m_opaque_sp.get()); |
| 872 | else |
| 873 | log->Printf ("SBValue(%p)::GetProcess () => %p", m_opaque_sp.get(), result.get()); |
| 874 | } |
| 875 | return result; |
| 876 | } |
| 877 | |
| 878 | lldb::SBThread |
| 879 | SBValue::GetThread() |
| 880 | { |
Greg Clayton | 90c5214 | 2012-01-30 02:53:15 +0000 | [diff] [blame^] | 881 | SBThread sb_thread; |
| 882 | ThreadSP thread_sp; |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 883 | if (m_opaque_sp) |
| 884 | { |
Jim Ingham | 1586d97 | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 885 | if (m_opaque_sp->GetExecutionContextScope()) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 886 | { |
Greg Clayton | 90c5214 | 2012-01-30 02:53:15 +0000 | [diff] [blame^] | 887 | thread_sp = m_opaque_sp->GetExecutionContextScope()->CalculateThread()->shared_from_this(); |
| 888 | sb_thread.SetThread(thread_sp); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 889 | } |
| 890 | } |
| 891 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 892 | if (log) |
| 893 | { |
Greg Clayton | 90c5214 | 2012-01-30 02:53:15 +0000 | [diff] [blame^] | 894 | if (thread_sp.get() == NULL) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 895 | log->Printf ("SBValue(%p)::GetThread () => NULL", m_opaque_sp.get()); |
| 896 | else |
Greg Clayton | 90c5214 | 2012-01-30 02:53:15 +0000 | [diff] [blame^] | 897 | log->Printf ("SBValue(%p)::GetThread () => %p", m_opaque_sp.get(), thread_sp.get()); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 898 | } |
Greg Clayton | 90c5214 | 2012-01-30 02:53:15 +0000 | [diff] [blame^] | 899 | return sb_thread; |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 900 | } |
| 901 | |
| 902 | lldb::SBFrame |
| 903 | SBValue::GetFrame() |
| 904 | { |
| 905 | SBFrame result; |
| 906 | if (m_opaque_sp) |
| 907 | { |
Jim Ingham | 1586d97 | 2011-12-17 01:35:57 +0000 | [diff] [blame] | 908 | if (m_opaque_sp->GetExecutionContextScope()) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 909 | { |
Greg Clayton | 13d24fb | 2012-01-29 20:56:30 +0000 | [diff] [blame] | 910 | result.SetFrame (m_opaque_sp->GetExecutionContextScope()->CalculateStackFrame()->shared_from_this()); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 911 | } |
| 912 | } |
| 913 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 914 | if (log) |
| 915 | { |
| 916 | if (result.get() == NULL) |
| 917 | log->Printf ("SBValue(%p)::GetFrame () => NULL", m_opaque_sp.get()); |
| 918 | else |
| 919 | log->Printf ("SBValue(%p)::GetFrame () => %p", m_opaque_sp.get(), result.get()); |
| 920 | } |
| 921 | return result; |
| 922 | } |
| 923 | |
| 924 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 925 | // Mimic shared pointer... |
| 926 | lldb_private::ValueObject * |
| 927 | SBValue::get() const |
| 928 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 929 | return m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 930 | } |
| 931 | |
| 932 | lldb_private::ValueObject * |
| 933 | SBValue::operator->() const |
| 934 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 935 | return m_opaque_sp.get(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 936 | } |
| 937 | |
| 938 | lldb::ValueObjectSP & |
| 939 | SBValue::operator*() |
| 940 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 941 | return m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 942 | } |
| 943 | |
| 944 | const lldb::ValueObjectSP & |
| 945 | SBValue::operator*() const |
| 946 | { |
Greg Clayton | 63094e0 | 2010-06-23 01:19:29 +0000 | [diff] [blame] | 947 | return m_opaque_sp; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 948 | } |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 949 | |
| 950 | bool |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 951 | SBValue::GetExpressionPath (SBStream &description) |
| 952 | { |
| 953 | if (m_opaque_sp) |
| 954 | { |
Greg Clayton | b01000f | 2011-01-17 03:46:26 +0000 | [diff] [blame] | 955 | m_opaque_sp->GetExpressionPath (description.ref(), false); |
| 956 | return true; |
| 957 | } |
| 958 | return false; |
| 959 | } |
| 960 | |
| 961 | bool |
| 962 | SBValue::GetExpressionPath (SBStream &description, bool qualify_cxx_base_classes) |
| 963 | { |
| 964 | if (m_opaque_sp) |
| 965 | { |
| 966 | m_opaque_sp->GetExpressionPath (description.ref(), qualify_cxx_base_classes); |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 967 | return true; |
| 968 | } |
| 969 | return false; |
| 970 | } |
| 971 | |
| 972 | bool |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 973 | SBValue::GetDescription (SBStream &description) |
| 974 | { |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 975 | Stream &strm = description.ref(); |
| 976 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 977 | if (m_opaque_sp) |
| 978 | { |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 979 | ValueObject::DumpValueObject (strm, m_opaque_sp.get()); |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 980 | } |
| 981 | else |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 982 | strm.PutCString ("No value"); |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 983 | |
| 984 | return true; |
| 985 | } |
Greg Clayton | e179a58 | 2011-01-05 18:43:15 +0000 | [diff] [blame] | 986 | |
| 987 | lldb::Format |
Greg Clayton | d68e089 | 2011-09-09 23:04:00 +0000 | [diff] [blame] | 988 | SBValue::GetFormat () |
Greg Clayton | e179a58 | 2011-01-05 18:43:15 +0000 | [diff] [blame] | 989 | { |
| 990 | if (m_opaque_sp) |
| 991 | return m_opaque_sp->GetFormat(); |
| 992 | return eFormatDefault; |
| 993 | } |
| 994 | |
| 995 | void |
| 996 | SBValue::SetFormat (lldb::Format format) |
| 997 | { |
| 998 | if (m_opaque_sp) |
| 999 | m_opaque_sp->SetFormat(format); |
| 1000 | } |
| 1001 | |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1002 | lldb::SBValue |
| 1003 | SBValue::AddressOf() |
| 1004 | { |
| 1005 | SBValue sb_value; |
| 1006 | if (m_opaque_sp) |
| 1007 | { |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1008 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1009 | if (target) |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1010 | { |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1011 | Mutex::Locker api_locker (target->GetAPIMutex()); |
Enrico Granata | 979e20d | 2011-07-29 19:53:35 +0000 | [diff] [blame] | 1012 | Error error; |
| 1013 | sb_value = m_opaque_sp->AddressOf (error); |
| 1014 | } |
| 1015 | } |
| 1016 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1017 | if (log) |
| 1018 | log->Printf ("SBValue(%p)::GetPointerToObject () => SBValue(%p)", m_opaque_sp.get(), sb_value.get()); |
| 1019 | |
| 1020 | return sb_value; |
Johnny Chen | a713b86 | 2011-08-09 22:38:07 +0000 | [diff] [blame] | 1021 | } |
Enrico Granata | 9154480 | 2011-09-06 19:20:51 +0000 | [diff] [blame] | 1022 | |
| 1023 | lldb::addr_t |
| 1024 | SBValue::GetLoadAddress() |
| 1025 | { |
| 1026 | lldb::addr_t value = LLDB_INVALID_ADDRESS; |
| 1027 | if (m_opaque_sp) |
| 1028 | { |
| 1029 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1030 | if (target) |
| 1031 | { |
| 1032 | Mutex::Locker api_locker (target->GetAPIMutex()); |
| 1033 | const bool scalar_is_load_address = true; |
| 1034 | AddressType addr_type; |
| 1035 | value = m_opaque_sp->GetAddressOf(scalar_is_load_address, &addr_type); |
| 1036 | if (addr_type == eAddressTypeFile) |
| 1037 | { |
| 1038 | Module* module = m_opaque_sp->GetModule(); |
| 1039 | if (!module) |
| 1040 | value = LLDB_INVALID_ADDRESS; |
| 1041 | else |
| 1042 | { |
| 1043 | Address addr; |
| 1044 | module->ResolveFileAddress(value, addr); |
| 1045 | value = addr.GetLoadAddress(m_opaque_sp->GetUpdatePoint().GetTargetSP().get()); |
| 1046 | } |
| 1047 | } |
| 1048 | else if (addr_type == eAddressTypeHost || addr_type == eAddressTypeInvalid) |
| 1049 | value = LLDB_INVALID_ADDRESS; |
| 1050 | } |
| 1051 | } |
| 1052 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1053 | if (log) |
| 1054 | log->Printf ("SBValue(%p)::GetLoadAddress () => (%llu)", m_opaque_sp.get(), value); |
| 1055 | |
| 1056 | return value; |
| 1057 | } |
| 1058 | |
| 1059 | lldb::SBAddress |
| 1060 | SBValue::GetAddress() |
| 1061 | { |
| 1062 | Address addr; |
| 1063 | if (m_opaque_sp) |
| 1064 | { |
| 1065 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1066 | if (target) |
| 1067 | { |
| 1068 | lldb::addr_t value = LLDB_INVALID_ADDRESS; |
| 1069 | Mutex::Locker api_locker (target->GetAPIMutex()); |
| 1070 | const bool scalar_is_load_address = true; |
| 1071 | AddressType addr_type; |
| 1072 | value = m_opaque_sp->GetAddressOf(scalar_is_load_address, &addr_type); |
| 1073 | if (addr_type == eAddressTypeFile) |
| 1074 | { |
| 1075 | Module* module = m_opaque_sp->GetModule(); |
| 1076 | if (module) |
| 1077 | module->ResolveFileAddress(value, addr); |
| 1078 | } |
| 1079 | else if (addr_type == eAddressTypeLoad) |
| 1080 | { |
| 1081 | // no need to check the return value on this.. if it can actually do the resolve |
| 1082 | // addr will be in the form (section,offset), otherwise it will simply be returned |
| 1083 | // as (NULL, value) |
| 1084 | addr.SetLoadAddress(value, target); |
| 1085 | } |
| 1086 | } |
| 1087 | } |
| 1088 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1089 | if (log) |
| 1090 | log->Printf ("SBValue(%p)::GetAddress () => (%s,%llu)", m_opaque_sp.get(), (addr.GetSection() ? addr.GetSection()->GetName().GetCString() : "NULL"), addr.GetOffset()); |
| 1091 | return SBAddress(new Address(addr)); |
| 1092 | } |
| 1093 | |
| 1094 | lldb::SBData |
| 1095 | SBValue::GetPointeeData (uint32_t item_idx, |
| 1096 | uint32_t item_count) |
| 1097 | { |
| 1098 | lldb::SBData sb_data; |
| 1099 | if (m_opaque_sp) |
| 1100 | { |
| 1101 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1102 | if (target) |
| 1103 | { |
| 1104 | DataExtractorSP data_sp(new DataExtractor()); |
| 1105 | Mutex::Locker api_locker (target->GetAPIMutex()); |
| 1106 | m_opaque_sp->GetPointeeData(*data_sp, item_idx, item_count); |
| 1107 | if (data_sp->GetByteSize() > 0) |
| 1108 | *sb_data = data_sp; |
| 1109 | } |
| 1110 | } |
| 1111 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1112 | if (log) |
| 1113 | log->Printf ("SBValue(%p)::GetPointeeData (%d, %d) => SBData(%p)", |
| 1114 | m_opaque_sp.get(), |
| 1115 | item_idx, |
| 1116 | item_count, |
| 1117 | sb_data.get()); |
| 1118 | |
| 1119 | return sb_data; |
| 1120 | } |
| 1121 | |
| 1122 | lldb::SBData |
| 1123 | SBValue::GetData () |
| 1124 | { |
| 1125 | lldb::SBData sb_data; |
| 1126 | if (m_opaque_sp) |
| 1127 | { |
| 1128 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1129 | if (target) |
| 1130 | { |
| 1131 | DataExtractorSP data_sp(new DataExtractor()); |
| 1132 | Mutex::Locker api_locker (target->GetAPIMutex()); |
| 1133 | m_opaque_sp->GetData(*data_sp); |
| 1134 | if (data_sp->GetByteSize() > 0) |
| 1135 | *sb_data = data_sp; |
| 1136 | } |
| 1137 | } |
| 1138 | LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1139 | if (log) |
| 1140 | log->Printf ("SBValue(%p)::GetData () => SBData(%p)", |
| 1141 | m_opaque_sp.get(), |
| 1142 | sb_data.get()); |
| 1143 | |
| 1144 | return sb_data; |
| 1145 | } |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1146 | |
| 1147 | lldb::SBWatchpoint |
| 1148 | SBValue::Watch (bool resolve_location, bool read, bool write) |
| 1149 | { |
| 1150 | lldb::SBWatchpoint sb_watchpoint; |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1151 | if (!m_opaque_sp) |
| 1152 | return sb_watchpoint; |
| 1153 | |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1154 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1155 | if (target) |
| 1156 | { |
| 1157 | Mutex::Locker api_locker (target->GetAPIMutex()); |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1158 | sb_watchpoint = WatchValue(read, write, false); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1159 | } |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1160 | LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1161 | if (log) |
| 1162 | log->Printf ("SBValue(%p)::Watch (resolve_location=%i, read=%i, write=%i) => wp(%p)", |
| 1163 | m_opaque_sp.get(), resolve_location, read, write, sb_watchpoint.get()); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1164 | return sb_watchpoint; |
| 1165 | } |
| 1166 | |
| 1167 | lldb::SBWatchpoint |
| 1168 | SBValue::WatchPointee (bool resolve_location, bool read, bool write) |
| 1169 | { |
| 1170 | lldb::SBWatchpoint sb_watchpoint; |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1171 | if (!m_opaque_sp) |
| 1172 | return sb_watchpoint; |
| 1173 | |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1174 | Target* target = m_opaque_sp->GetUpdatePoint().GetTargetSP().get(); |
| 1175 | if (target) |
| 1176 | { |
| 1177 | Mutex::Locker api_locker (target->GetAPIMutex()); |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1178 | sb_watchpoint = WatchValue(read, write, true); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1179 | } |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1180 | LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
| 1181 | if (log) |
| 1182 | log->Printf ("SBValue(%p)::WatchPointee (resolve_location=%i, read=%i, write=%i) => wp(%p)", |
| 1183 | m_opaque_sp.get(), resolve_location, read, write, sb_watchpoint.get()); |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1184 | return sb_watchpoint; |
| 1185 | } |
| 1186 | |
Johnny Chen | ecd4feb | 2011-10-14 00:42:25 +0000 | [diff] [blame] | 1187 | // Helper function for SBValue::Watch() and SBValue::WatchPointee(). |
| 1188 | SBWatchpoint |
| 1189 | SBValue::WatchValue(bool read, bool write, bool watch_pointee) |
| 1190 | { |
| 1191 | SBWatchpoint sb_wp_empty; |
| 1192 | |
| 1193 | // If the SBValue is not valid, there's no point in even trying to watch it. |
| 1194 | if (!IsValid() || !GetFrame().IsValid()) |
| 1195 | return sb_wp_empty; |
| 1196 | |
| 1197 | // Read and Write cannot both be false. |
| 1198 | if (!read && !write) |
| 1199 | return sb_wp_empty; |
| 1200 | |
| 1201 | // If we are watching the pointee, check that the SBValue is a pointer type. |
| 1202 | if (watch_pointee && !GetType().IsPointerType()) |
| 1203 | return sb_wp_empty; |
| 1204 | |
| 1205 | addr_t addr; |
| 1206 | size_t size; |
| 1207 | if (watch_pointee) { |
| 1208 | addr = GetValueAsUnsigned(LLDB_INVALID_ADDRESS); |
| 1209 | size = GetType().GetPointeeType().GetByteSize(); |
| 1210 | } else { |
| 1211 | addr = GetLoadAddress(); |
| 1212 | size = GetByteSize(); |
| 1213 | } |
| 1214 | |
| 1215 | // Sanity check the address and the size before calling Target::CreateWatchpoint(). |
| 1216 | if (addr == LLDB_INVALID_ADDRESS || size == 0) |
| 1217 | return sb_wp_empty; |
| 1218 | |
| 1219 | uint32_t watch_type = (read ? LLDB_WATCH_TYPE_READ : 0) | |
| 1220 | (write ? LLDB_WATCH_TYPE_WRITE : 0); |
| 1221 | WatchpointSP wp_sp = GetFrame().m_opaque_sp->GetThread().GetProcess().GetTarget(). |
| 1222 | CreateWatchpoint(addr, size, watch_type); |
| 1223 | |
| 1224 | if (wp_sp) { |
| 1225 | // StackFrame::GetInScopeVariableList(true) to get file globals as well. |
| 1226 | VariableListSP var_list_sp(GetFrame().m_opaque_sp->GetInScopeVariableList(true)); |
| 1227 | VariableSP var_sp = var_list_sp->FindVariable(ConstString(GetName())); |
| 1228 | if (var_sp && var_sp->GetDeclaration().GetFile()) { |
| 1229 | StreamString ss; |
| 1230 | // True to show fullpath for declaration file. |
| 1231 | var_sp->GetDeclaration().DumpStopContext(&ss, true); |
| 1232 | wp_sp->SetDeclInfo(ss.GetString()); |
| 1233 | } |
| 1234 | } |
| 1235 | return wp_sp; |
| 1236 | } |
Greg Clayton | 1fa6b3d | 2011-10-13 18:08:26 +0000 | [diff] [blame] | 1237 | |