Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1 | //===-- SBFrame.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/SBFrame.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 11 | |
| 12 | #include <string> |
| 13 | #include <algorithm> |
| 14 | |
| 15 | #include "lldb/lldb-types.h" |
| 16 | |
| 17 | #include "lldb/Core/Address.h" |
| 18 | #include "lldb/Core/ConstString.h" |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 19 | #include "lldb/Core/Log.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 20 | #include "lldb/Core/Stream.h" |
| 21 | #include "lldb/Core/StreamFile.h" |
| 22 | #include "lldb/Core/ValueObjectRegister.h" |
| 23 | #include "lldb/Core/ValueObjectVariable.h" |
Greg Clayton | d171972 | 2010-10-05 03:13:51 +0000 | [diff] [blame] | 24 | #include "lldb/Expression/ClangUserExpression.h" |
Greg Clayton | 87ac902 | 2011-06-25 04:35:01 +0000 | [diff] [blame] | 25 | #include "lldb/Host/Host.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 26 | #include "lldb/Symbol/Block.h" |
Greg Clayton | 49ce896 | 2012-08-29 21:13:06 +0000 | [diff] [blame] | 27 | #include "lldb/Symbol/Function.h" |
| 28 | #include "lldb/Symbol/Symbol.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 29 | #include "lldb/Symbol/SymbolContext.h" |
| 30 | #include "lldb/Symbol/VariableList.h" |
| 31 | #include "lldb/Symbol/Variable.h" |
| 32 | #include "lldb/Target/ExecutionContext.h" |
| 33 | #include "lldb/Target/Target.h" |
| 34 | #include "lldb/Target/Process.h" |
| 35 | #include "lldb/Target/RegisterContext.h" |
| 36 | #include "lldb/Target/StackFrame.h" |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 37 | #include "lldb/Target/StackID.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 38 | #include "lldb/Target/Thread.h" |
| 39 | |
Eli Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 40 | #include "lldb/API/SBDebugger.h" |
| 41 | #include "lldb/API/SBValue.h" |
| 42 | #include "lldb/API/SBAddress.h" |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 43 | #include "lldb/API/SBExpressionOptions.h" |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 44 | #include "lldb/API/SBStream.h" |
Eli Friedman | 7a62c8b | 2010-06-09 07:44:37 +0000 | [diff] [blame] | 45 | #include "lldb/API/SBSymbolContext.h" |
| 46 | #include "lldb/API/SBThread.h" |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 47 | |
| 48 | using namespace lldb; |
| 49 | using namespace lldb_private; |
| 50 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 51 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 52 | SBFrame::SBFrame () : |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 53 | m_opaque_sp (new ExecutionContextRef()) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 54 | { |
| 55 | } |
| 56 | |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 57 | SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) : |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 58 | m_opaque_sp (new ExecutionContextRef (lldb_object_sp)) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 59 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 60 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 61 | |
| 62 | if (log) |
| 63 | { |
| 64 | SBStream sstr; |
| 65 | GetDescription (sstr); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 66 | log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s", |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 67 | lldb_object_sp.get(), lldb_object_sp.get(), sstr.GetData()); |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 68 | |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 69 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 70 | } |
| 71 | |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 72 | SBFrame::SBFrame(const SBFrame &rhs) : |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 73 | m_opaque_sp (new ExecutionContextRef (*rhs.m_opaque_sp)) |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 74 | { |
| 75 | } |
| 76 | |
| 77 | const SBFrame & |
| 78 | SBFrame::operator = (const SBFrame &rhs) |
| 79 | { |
| 80 | if (this != &rhs) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 81 | *m_opaque_sp = *rhs.m_opaque_sp; |
Greg Clayton | 538eb82 | 2010-11-05 23:17:00 +0000 | [diff] [blame] | 82 | return *this; |
| 83 | } |
| 84 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 85 | SBFrame::~SBFrame() |
| 86 | { |
| 87 | } |
| 88 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 89 | StackFrameSP |
| 90 | SBFrame::GetFrameSP() const |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 91 | { |
Greg Clayton | 2642585 | 2012-04-12 20:58:26 +0000 | [diff] [blame] | 92 | if (m_opaque_sp) |
| 93 | return m_opaque_sp->GetFrameSP(); |
| 94 | return StackFrameSP(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 95 | } |
| 96 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 97 | void |
| 98 | SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp) |
| 99 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 100 | return m_opaque_sp->SetFrameSP(lldb_object_sp); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 101 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 102 | |
| 103 | bool |
| 104 | SBFrame::IsValid() const |
| 105 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 106 | return GetFrameSP().get() != NULL; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 107 | } |
| 108 | |
| 109 | SBSymbolContext |
| 110 | SBFrame::GetSymbolContext (uint32_t resolve_scope) const |
| 111 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 112 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 113 | SBSymbolContext sb_sym_ctx; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 114 | Mutex::Locker api_locker; |
| 115 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 116 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 117 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 118 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 119 | Process *process = exe_ctx.GetProcessPtr(); |
| 120 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 121 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 122 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 123 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 124 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 125 | frame = exe_ctx.GetFramePtr(); |
| 126 | if (frame) |
| 127 | { |
| 128 | sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext (resolve_scope)); |
| 129 | } |
| 130 | else |
| 131 | { |
| 132 | if (log) |
| 133 | log->Printf ("SBFrame::GetVariables () => error: could not reconstruct frame object for this SBFrame."); |
| 134 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 135 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 136 | else |
| 137 | { |
| 138 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 139 | log->Printf ("SBFrame::GetSymbolContext () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 140 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 141 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 142 | |
| 143 | if (log) |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 144 | log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 145 | frame, resolve_scope, sb_sym_ctx.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 146 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 147 | return sb_sym_ctx; |
| 148 | } |
| 149 | |
| 150 | SBModule |
| 151 | SBFrame::GetModule () const |
| 152 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 153 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 154 | SBModule sb_module; |
Greg Clayton | 0416bdf | 2012-01-30 09:04:36 +0000 | [diff] [blame] | 155 | ModuleSP module_sp; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 156 | Mutex::Locker api_locker; |
| 157 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 158 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 159 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 160 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 161 | Process *process = exe_ctx.GetProcessPtr(); |
| 162 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 163 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 164 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 165 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 166 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 167 | frame = exe_ctx.GetFramePtr(); |
| 168 | if (frame) |
| 169 | { |
| 170 | module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp; |
| 171 | sb_module.SetSP (module_sp); |
| 172 | } |
| 173 | else |
| 174 | { |
| 175 | if (log) |
| 176 | log->Printf ("SBFrame::GetModule () => error: could not reconstruct frame object for this SBFrame."); |
| 177 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 178 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 179 | else |
| 180 | { |
| 181 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 182 | log->Printf ("SBFrame::GetModule () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 183 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 184 | } |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 185 | |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 186 | if (log) |
| 187 | log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 188 | frame, module_sp.get()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 189 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 190 | return sb_module; |
| 191 | } |
| 192 | |
| 193 | SBCompileUnit |
| 194 | SBFrame::GetCompileUnit () const |
| 195 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 196 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 197 | SBCompileUnit sb_comp_unit; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 198 | Mutex::Locker api_locker; |
| 199 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 200 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 201 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 202 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 203 | Process *process = exe_ctx.GetProcessPtr(); |
| 204 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 205 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 206 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 207 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 208 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 209 | frame = exe_ctx.GetFramePtr(); |
| 210 | if (frame) |
| 211 | { |
| 212 | sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit); |
| 213 | } |
| 214 | else |
| 215 | { |
| 216 | if (log) |
| 217 | log->Printf ("SBFrame::GetCompileUnit () => error: could not reconstruct frame object for this SBFrame."); |
| 218 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 219 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 220 | else |
| 221 | { |
| 222 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 223 | log->Printf ("SBFrame::GetCompileUnit () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 224 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 225 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 226 | if (log) |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 227 | log->Printf ("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 228 | frame, sb_comp_unit.get()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 229 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 230 | return sb_comp_unit; |
| 231 | } |
| 232 | |
| 233 | SBFunction |
| 234 | SBFrame::GetFunction () const |
| 235 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 236 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 237 | SBFunction sb_function; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 238 | Mutex::Locker api_locker; |
| 239 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 240 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 241 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 242 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 243 | Process *process = exe_ctx.GetProcessPtr(); |
| 244 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 245 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 246 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 247 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 248 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 249 | frame = exe_ctx.GetFramePtr(); |
| 250 | if (frame) |
| 251 | { |
| 252 | sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | if (log) |
| 257 | log->Printf ("SBFrame::GetFunction () => error: could not reconstruct frame object for this SBFrame."); |
| 258 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 259 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 260 | else |
| 261 | { |
| 262 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 263 | log->Printf ("SBFrame::GetFunction () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 264 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 265 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 266 | if (log) |
| 267 | log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 268 | frame, sb_function.get()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 269 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 270 | return sb_function; |
| 271 | } |
| 272 | |
Greg Clayton | 8f1e08b | 2010-10-04 18:37:52 +0000 | [diff] [blame] | 273 | SBSymbol |
| 274 | SBFrame::GetSymbol () const |
| 275 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 276 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 277 | SBSymbol sb_symbol; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 278 | Mutex::Locker api_locker; |
| 279 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 280 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 281 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 282 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 283 | Process *process = exe_ctx.GetProcessPtr(); |
| 284 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 285 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 286 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 287 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 288 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 289 | frame = exe_ctx.GetFramePtr(); |
| 290 | if (frame) |
| 291 | { |
| 292 | sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol); |
| 293 | } |
| 294 | else |
| 295 | { |
| 296 | if (log) |
| 297 | log->Printf ("SBFrame::GetSymbol () => error: could not reconstruct frame object for this SBFrame."); |
| 298 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 299 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 300 | else |
| 301 | { |
| 302 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 303 | log->Printf ("SBFrame::GetSymbol () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 304 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 305 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 306 | if (log) |
| 307 | log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 308 | frame, sb_symbol.get()); |
Greg Clayton | 8f1e08b | 2010-10-04 18:37:52 +0000 | [diff] [blame] | 309 | return sb_symbol; |
| 310 | } |
| 311 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 312 | SBBlock |
| 313 | SBFrame::GetBlock () const |
| 314 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 315 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 316 | SBBlock sb_block; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 317 | Mutex::Locker api_locker; |
| 318 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 319 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 320 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 321 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 322 | Process *process = exe_ctx.GetProcessPtr(); |
| 323 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 324 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 325 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 326 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 327 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 328 | frame = exe_ctx.GetFramePtr(); |
| 329 | if (frame) |
| 330 | { |
| 331 | sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block); |
| 332 | } |
| 333 | else |
| 334 | { |
| 335 | if (log) |
| 336 | log->Printf ("SBFrame::GetBlock () => error: could not reconstruct frame object for this SBFrame."); |
| 337 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 338 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 339 | else |
| 340 | { |
| 341 | if (log) |
| 342 | log->Printf ("SBFrame(%p)::GetBlock () => error: process is running", frame); |
| 343 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 344 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 345 | if (log) |
| 346 | log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 347 | frame, sb_block.GetPtr()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 348 | return sb_block; |
| 349 | } |
| 350 | |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 351 | SBBlock |
| 352 | SBFrame::GetFrameBlock () const |
| 353 | { |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 354 | SBBlock sb_block; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 355 | Mutex::Locker api_locker; |
| 356 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 357 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 358 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 359 | Target *target = exe_ctx.GetTargetPtr(); |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 360 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 361 | Process *process = exe_ctx.GetProcessPtr(); |
| 362 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 363 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 364 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 365 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 366 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 367 | frame = exe_ctx.GetFramePtr(); |
| 368 | if (frame) |
| 369 | { |
| 370 | sb_block.SetPtr(frame->GetFrameBlock ()); |
| 371 | } |
| 372 | else |
| 373 | { |
| 374 | if (log) |
| 375 | log->Printf ("SBFrame::GetFrameBlock () => error: could not reconstruct frame object for this SBFrame."); |
| 376 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 377 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 378 | else |
| 379 | { |
| 380 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 381 | log->Printf ("SBFrame::GetFrameBlock () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 382 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 383 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 384 | if (log) |
| 385 | log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 386 | frame, sb_block.GetPtr()); |
Greg Clayton | 69aa5d9 | 2010-09-07 04:20:48 +0000 | [diff] [blame] | 387 | return sb_block; |
| 388 | } |
| 389 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 390 | SBLineEntry |
| 391 | SBFrame::GetLineEntry () const |
| 392 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 393 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 394 | SBLineEntry sb_line_entry; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 395 | Mutex::Locker api_locker; |
| 396 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 397 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 398 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 399 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 400 | Process *process = exe_ctx.GetProcessPtr(); |
| 401 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 402 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 403 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 404 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 405 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 406 | frame = exe_ctx.GetFramePtr(); |
| 407 | if (frame) |
| 408 | { |
| 409 | sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry); |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | if (log) |
| 414 | log->Printf ("SBFrame::GetLineEntry () => error: could not reconstruct frame object for this SBFrame."); |
| 415 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 416 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 417 | else |
| 418 | { |
| 419 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 420 | log->Printf ("SBFrame::GetLineEntry () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 421 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 422 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 423 | if (log) |
| 424 | log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 425 | frame, sb_line_entry.get()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 426 | return sb_line_entry; |
| 427 | } |
| 428 | |
| 429 | uint32_t |
| 430 | SBFrame::GetFrameID () const |
| 431 | { |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 432 | uint32_t frame_idx = UINT32_MAX; |
| 433 | |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 434 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 435 | StackFrame *frame = exe_ctx.GetFramePtr(); |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 436 | if (frame) |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 437 | frame_idx = frame->GetFrameIndex (); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 438 | |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 439 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 440 | if (log) |
| 441 | log->Printf ("SBFrame(%p)::GetFrameID () => %u", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 442 | frame, frame_idx); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 443 | return frame_idx; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 444 | } |
| 445 | |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 446 | addr_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 447 | SBFrame::GetPC () const |
| 448 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 449 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 450 | addr_t addr = LLDB_INVALID_ADDRESS; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 451 | Mutex::Locker api_locker; |
| 452 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 453 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 454 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 455 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 456 | Process *process = exe_ctx.GetProcessPtr(); |
| 457 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 458 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 459 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 460 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 461 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 462 | frame = exe_ctx.GetFramePtr(); |
| 463 | if (frame) |
| 464 | { |
| 465 | addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target); |
| 466 | } |
| 467 | else |
| 468 | { |
| 469 | if (log) |
| 470 | log->Printf ("SBFrame::GetPC () => error: could not reconstruct frame object for this SBFrame."); |
| 471 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 472 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 473 | else |
| 474 | { |
| 475 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 476 | log->Printf ("SBFrame::GetPC () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 477 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 478 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 479 | |
| 480 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 481 | log->Printf ("SBFrame(%p)::GetPC () => 0x%" PRIx64, frame, addr); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 482 | |
| 483 | return addr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 484 | } |
| 485 | |
| 486 | bool |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 487 | SBFrame::SetPC (addr_t new_pc) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 488 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 489 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 490 | bool ret_val = false; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 491 | Mutex::Locker api_locker; |
| 492 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 493 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 494 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 495 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 496 | Process *process = exe_ctx.GetProcessPtr(); |
| 497 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 498 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 499 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 500 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 501 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 502 | frame = exe_ctx.GetFramePtr(); |
| 503 | if (frame) |
| 504 | { |
| 505 | ret_val = frame->GetRegisterContext()->SetPC (new_pc); |
| 506 | } |
| 507 | else |
| 508 | { |
| 509 | if (log) |
| 510 | log->Printf ("SBFrame::SetPC () => error: could not reconstruct frame object for this SBFrame."); |
| 511 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 512 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 513 | else |
| 514 | { |
| 515 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 516 | log->Printf ("SBFrame::SetPC () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 517 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 518 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 519 | |
| 520 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 521 | log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%" PRIx64 ") => %i", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 522 | frame, new_pc, ret_val); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 523 | |
| 524 | return ret_val; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 525 | } |
| 526 | |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 527 | addr_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 528 | SBFrame::GetSP () const |
| 529 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 530 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 531 | addr_t addr = LLDB_INVALID_ADDRESS; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 532 | Mutex::Locker api_locker; |
| 533 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 534 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 535 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 536 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 537 | Process *process = exe_ctx.GetProcessPtr(); |
| 538 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 539 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 540 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 541 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 542 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 543 | frame = exe_ctx.GetFramePtr(); |
| 544 | if (frame) |
| 545 | { |
| 546 | addr = frame->GetRegisterContext()->GetSP(); |
| 547 | } |
| 548 | else |
| 549 | { |
| 550 | if (log) |
| 551 | log->Printf ("SBFrame::GetSP () => error: could not reconstruct frame object for this SBFrame."); |
| 552 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 553 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 554 | else |
| 555 | { |
| 556 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 557 | log->Printf ("SBFrame::GetSP () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 558 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 559 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 560 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 561 | log->Printf ("SBFrame(%p)::GetSP () => 0x%" PRIx64, frame, addr); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 562 | |
| 563 | return addr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 564 | } |
| 565 | |
| 566 | |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 567 | addr_t |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 568 | SBFrame::GetFP () const |
| 569 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 570 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 571 | addr_t addr = LLDB_INVALID_ADDRESS; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 572 | Mutex::Locker api_locker; |
| 573 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 574 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 575 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 576 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 577 | Process *process = exe_ctx.GetProcessPtr(); |
| 578 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 579 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 580 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 581 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 582 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 583 | frame = exe_ctx.GetFramePtr(); |
| 584 | if (frame) |
| 585 | { |
| 586 | addr = frame->GetRegisterContext()->GetFP(); |
| 587 | } |
| 588 | else |
| 589 | { |
| 590 | if (log) |
| 591 | log->Printf ("SBFrame::GetFP () => error: could not reconstruct frame object for this SBFrame."); |
| 592 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 593 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 594 | else |
| 595 | { |
| 596 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 597 | log->Printf ("SBFrame::GetFP () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 598 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 599 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 600 | |
| 601 | if (log) |
Daniel Malea | 5f35a4b | 2012-11-29 21:49:15 +0000 | [diff] [blame] | 602 | log->Printf ("SBFrame(%p)::GetFP () => 0x%" PRIx64, frame, addr); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 603 | return addr; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 604 | } |
| 605 | |
| 606 | |
| 607 | SBAddress |
| 608 | SBFrame::GetPCAddress () const |
| 609 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 610 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 611 | SBAddress sb_addr; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 612 | Mutex::Locker api_locker; |
| 613 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 614 | |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 615 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 616 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 617 | Process *process = exe_ctx.GetProcessPtr(); |
| 618 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 619 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 620 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 621 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 622 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 623 | frame = exe_ctx.GetFramePtr(); |
| 624 | if (frame) |
| 625 | { |
| 626 | sb_addr.SetAddress (&frame->GetFrameCodeAddress()); |
| 627 | } |
| 628 | else |
| 629 | { |
| 630 | if (log) |
| 631 | log->Printf ("SBFrame::GetPCAddress () => error: could not reconstruct frame object for this SBFrame."); |
| 632 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 633 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 634 | else |
| 635 | { |
| 636 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 637 | log->Printf ("SBFrame::GetPCAddress () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 638 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 639 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 640 | if (log) |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 641 | log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame, sb_addr.get()); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 642 | return sb_addr; |
| 643 | } |
| 644 | |
| 645 | void |
| 646 | SBFrame::Clear() |
| 647 | { |
Greg Clayton | 2642585 | 2012-04-12 20:58:26 +0000 | [diff] [blame] | 648 | m_opaque_sp->Clear(); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 649 | } |
| 650 | |
Greg Clayton | d62b9c1 | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 651 | lldb::SBValue |
| 652 | SBFrame::GetValueForVariablePath (const char *var_path) |
| 653 | { |
| 654 | SBValue sb_value; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 655 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 656 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 657 | Target *target = exe_ctx.GetTargetPtr(); |
| 658 | if (frame && target) |
Greg Clayton | d62b9c1 | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 659 | { |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 660 | lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); |
| 661 | sb_value = GetValueForVariablePath (var_path, use_dynamic); |
Greg Clayton | d62b9c1 | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 662 | } |
| 663 | return sb_value; |
| 664 | } |
| 665 | |
| 666 | lldb::SBValue |
| 667 | SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic) |
| 668 | { |
| 669 | SBValue sb_value; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 670 | Mutex::Locker api_locker; |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 671 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 672 | if (var_path == NULL || var_path[0] == '\0') |
| 673 | { |
| 674 | if (log) |
| 675 | log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path."); |
| 676 | return sb_value; |
| 677 | } |
| 678 | |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 679 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 680 | |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 681 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 682 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 683 | Process *process = exe_ctx.GetProcessPtr(); |
| 684 | if (target && process) |
Greg Clayton | d62b9c1 | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 685 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 686 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 687 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 688 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 689 | frame = exe_ctx.GetFramePtr(); |
| 690 | if (frame) |
| 691 | { |
| 692 | VariableSP var_sp; |
| 693 | Error error; |
| 694 | ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path, |
| 695 | eNoDynamicValues, |
| 696 | StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess, |
| 697 | var_sp, |
| 698 | error)); |
| 699 | sb_value.SetSP(value_sp, use_dynamic); |
| 700 | } |
| 701 | else |
| 702 | { |
| 703 | if (log) |
| 704 | log->Printf ("SBFrame::GetValueForVariablePath () => error: could not reconstruct frame object for this SBFrame."); |
| 705 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 706 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 707 | else |
| 708 | { |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 709 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 710 | log->Printf ("SBFrame::GetValueForVariablePath () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 711 | } |
Greg Clayton | d62b9c1 | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 712 | } |
| 713 | return sb_value; |
| 714 | } |
| 715 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 716 | SBValue |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 717 | SBFrame::FindVariable (const char *name) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 718 | { |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 719 | SBValue value; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 720 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 721 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 722 | Target *target = exe_ctx.GetTargetPtr(); |
| 723 | if (frame && target) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 724 | { |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 725 | lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 726 | value = FindVariable (name, use_dynamic); |
| 727 | } |
| 728 | return value; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 729 | } |
Greg Clayton | d62b9c1 | 2012-02-03 07:02:37 +0000 | [diff] [blame] | 730 | |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 731 | |
| 732 | SBValue |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 733 | SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 734 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 735 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 736 | VariableSP var_sp; |
Jim Ingham | 47da810 | 2011-04-22 23:53:53 +0000 | [diff] [blame] | 737 | SBValue sb_value; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 738 | |
| 739 | if (name == NULL || name[0] == '\0') |
| 740 | { |
| 741 | if (log) |
| 742 | log->Printf ("SBFrame::FindVariable called with empty name"); |
| 743 | return sb_value; |
| 744 | } |
| 745 | |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 746 | ValueObjectSP value_sp; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 747 | Mutex::Locker api_locker; |
| 748 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 749 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 750 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 751 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 752 | Process *process = exe_ctx.GetProcessPtr(); |
| 753 | if (target && process) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 754 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 755 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 756 | if (stop_locker.TryLock(&process->GetRunLock())) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 757 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 758 | frame = exe_ctx.GetFramePtr(); |
| 759 | if (frame) |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 760 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 761 | VariableList variable_list; |
| 762 | SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock)); |
| 763 | |
| 764 | if (sc.block) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 765 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 766 | const bool can_create = true; |
| 767 | const bool get_parent_variables = true; |
| 768 | const bool stop_if_block_is_inlined_function = true; |
| 769 | |
| 770 | if (sc.block->AppendVariables (can_create, |
| 771 | get_parent_variables, |
| 772 | stop_if_block_is_inlined_function, |
| 773 | &variable_list)) |
| 774 | { |
| 775 | var_sp = variable_list.FindVariable (ConstString(name)); |
| 776 | } |
| 777 | } |
| 778 | |
| 779 | if (var_sp) |
| 780 | { |
| 781 | value_sp = frame->GetValueObjectForFrameVariable(var_sp, eNoDynamicValues); |
| 782 | sb_value.SetSP(value_sp, use_dynamic); |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 783 | } |
| 784 | } |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 785 | else |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 786 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 787 | if (log) |
| 788 | log->Printf ("SBFrame::FindVariable () => error: could not reconstruct frame object for this SBFrame."); |
Greg Clayton | dd62d72 | 2010-12-14 04:58:53 +0000 | [diff] [blame] | 789 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 790 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 791 | else |
| 792 | { |
| 793 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 794 | log->Printf ("SBFrame::FindVariable () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 795 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 796 | } |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 797 | |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 798 | if (log) |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 799 | log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 800 | frame, name, value_sp.get()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 801 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 802 | return sb_value; |
| 803 | } |
| 804 | |
| 805 | SBValue |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 806 | SBFrame::FindValue (const char *name, ValueType value_type) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 807 | { |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 808 | SBValue value; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 809 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 810 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 811 | Target *target = exe_ctx.GetTargetPtr(); |
| 812 | if (frame && target) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 813 | { |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 814 | lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 815 | value = FindValue (name, value_type, use_dynamic); |
| 816 | } |
| 817 | return value; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 818 | } |
| 819 | |
| 820 | SBValue |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 821 | SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 822 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 823 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 824 | SBValue sb_value; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 825 | |
| 826 | if (name == NULL || name[0] == '\0') |
| 827 | { |
| 828 | if (log) |
| 829 | log->Printf ("SBFrame::FindValue called with empty name."); |
| 830 | return sb_value; |
| 831 | } |
| 832 | |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 833 | ValueObjectSP value_sp; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 834 | Mutex::Locker api_locker; |
| 835 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 836 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 837 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 838 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 839 | Process *process = exe_ctx.GetProcessPtr(); |
| 840 | if (target && process) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 841 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 842 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 843 | if (stop_locker.TryLock(&process->GetRunLock())) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 844 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 845 | frame = exe_ctx.GetFramePtr(); |
| 846 | if (frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 847 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 848 | switch (value_type) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 849 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 850 | case eValueTypeVariableGlobal: // global variable |
| 851 | case eValueTypeVariableStatic: // static variable |
| 852 | case eValueTypeVariableArgument: // function argument variables |
| 853 | case eValueTypeVariableLocal: // function local variables |
| 854 | { |
| 855 | VariableList *variable_list = frame->GetVariableList(true); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 856 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 857 | SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock)); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 858 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 859 | const bool can_create = true; |
| 860 | const bool get_parent_variables = true; |
| 861 | const bool stop_if_block_is_inlined_function = true; |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 862 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 863 | if (sc.block && sc.block->AppendVariables (can_create, |
| 864 | get_parent_variables, |
| 865 | stop_if_block_is_inlined_function, |
| 866 | variable_list)) |
| 867 | { |
| 868 | ConstString const_name(name); |
| 869 | const uint32_t num_variables = variable_list->GetSize(); |
| 870 | for (uint32_t i = 0; i < num_variables; ++i) |
| 871 | { |
| 872 | VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); |
| 873 | if (variable_sp && |
| 874 | variable_sp->GetScope() == value_type && |
| 875 | variable_sp->GetName() == const_name) |
| 876 | { |
| 877 | value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues); |
| 878 | sb_value.SetSP (value_sp, use_dynamic); |
| 879 | break; |
| 880 | } |
| 881 | } |
| 882 | } |
| 883 | } |
| 884 | break; |
| 885 | |
| 886 | case eValueTypeRegister: // stack frame register value |
| 887 | { |
| 888 | RegisterContextSP reg_ctx (frame->GetRegisterContext()); |
| 889 | if (reg_ctx) |
| 890 | { |
| 891 | const uint32_t num_regs = reg_ctx->GetRegisterCount(); |
| 892 | for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx) |
| 893 | { |
| 894 | const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx); |
| 895 | if (reg_info && |
| 896 | ((reg_info->name && strcasecmp (reg_info->name, name) == 0) || |
| 897 | (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0))) |
| 898 | { |
| 899 | value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx); |
| 900 | sb_value.SetSP (value_sp); |
| 901 | break; |
| 902 | } |
| 903 | } |
| 904 | } |
| 905 | } |
| 906 | break; |
| 907 | |
| 908 | case eValueTypeRegisterSet: // A collection of stack frame register values |
| 909 | { |
| 910 | RegisterContextSP reg_ctx (frame->GetRegisterContext()); |
| 911 | if (reg_ctx) |
| 912 | { |
| 913 | const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); |
| 914 | for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) |
| 915 | { |
| 916 | const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx); |
| 917 | if (reg_set && |
| 918 | ((reg_set->name && strcasecmp (reg_set->name, name) == 0) || |
| 919 | (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0))) |
| 920 | { |
| 921 | value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx); |
| 922 | sb_value.SetSP (value_sp); |
| 923 | break; |
| 924 | } |
| 925 | } |
| 926 | } |
| 927 | } |
| 928 | break; |
| 929 | |
| 930 | case eValueTypeConstResult: // constant result variables |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 931 | { |
| 932 | ConstString const_name(name); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 933 | ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name)); |
| 934 | if (expr_var_sp) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 935 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 936 | value_sp = expr_var_sp->GetValueObject(); |
| 937 | sb_value.SetSP (value_sp, use_dynamic); |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 938 | } |
| 939 | } |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 940 | break; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 941 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 942 | default: |
| 943 | break; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 944 | } |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 945 | } |
| 946 | else |
| 947 | { |
| 948 | if (log) |
| 949 | log->Printf ("SBFrame::FindValue () => error: could not reconstruct frame object for this SBFrame."); |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 950 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 951 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 952 | else |
| 953 | { |
| 954 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 955 | log->Printf ("SBFrame::FindValue () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 956 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 957 | } |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 958 | |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 959 | if (log) |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 960 | log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)", |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 961 | frame, name, value_type, value_sp.get()); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 962 | |
| 963 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 964 | return sb_value; |
| 965 | } |
| 966 | |
| 967 | bool |
Johnny Chen | 0164b75 | 2012-03-05 19:53:24 +0000 | [diff] [blame] | 968 | SBFrame::IsEqual (const SBFrame &that) const |
| 969 | { |
| 970 | lldb::StackFrameSP this_sp = GetFrameSP(); |
| 971 | lldb::StackFrameSP that_sp = that.GetFrameSP(); |
| 972 | return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID()); |
| 973 | } |
| 974 | |
| 975 | bool |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 976 | SBFrame::operator == (const SBFrame &rhs) const |
| 977 | { |
Johnny Chen | 0164b75 | 2012-03-05 19:53:24 +0000 | [diff] [blame] | 978 | return IsEqual(rhs); |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 979 | } |
| 980 | |
| 981 | bool |
| 982 | SBFrame::operator != (const SBFrame &rhs) const |
| 983 | { |
Johnny Chen | 0164b75 | 2012-03-05 19:53:24 +0000 | [diff] [blame] | 984 | return !IsEqual(rhs); |
Greg Clayton | 1ebdcc7 | 2011-01-21 06:11:58 +0000 | [diff] [blame] | 985 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 986 | |
| 987 | SBThread |
| 988 | SBFrame::GetThread () const |
| 989 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 990 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 991 | |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 992 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 993 | ThreadSP thread_sp (exe_ctx.GetThreadSP()); |
| 994 | SBThread sb_thread (thread_sp); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 995 | |
| 996 | if (log) |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 997 | { |
| 998 | SBStream sstr; |
| 999 | sb_thread.GetDescription (sstr); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1000 | log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s", |
| 1001 | exe_ctx.GetFramePtr(), |
| 1002 | thread_sp.get(), |
| 1003 | sstr.GetData()); |
Caroline Tice | 61ba7ec | 2010-10-26 23:49:36 +0000 | [diff] [blame] | 1004 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1005 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1006 | return sb_thread; |
| 1007 | } |
| 1008 | |
| 1009 | const char * |
| 1010 | SBFrame::Disassemble () const |
| 1011 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1012 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1013 | const char *disassembly = NULL; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 1014 | Mutex::Locker api_locker; |
| 1015 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 1016 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1017 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1018 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1019 | Process *process = exe_ctx.GetProcessPtr(); |
| 1020 | if (target && process) |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1021 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1022 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1023 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1024 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1025 | frame = exe_ctx.GetFramePtr(); |
| 1026 | if (frame) |
| 1027 | { |
| 1028 | disassembly = frame->Disassemble(); |
| 1029 | } |
| 1030 | else |
| 1031 | { |
| 1032 | if (log) |
| 1033 | log->Printf ("SBFrame::Disassemble () => error: could not reconstruct frame object for this SBFrame."); |
| 1034 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1035 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1036 | else |
| 1037 | { |
| 1038 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1039 | log->Printf ("SBFrame::Disassemble () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1040 | } |
Greg Clayton | bdcda46 | 2010-12-20 20:49:23 +0000 | [diff] [blame] | 1041 | } |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1042 | |
| 1043 | if (log) |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1044 | log->Printf ("SBFrame(%p)::Disassemble () => %s", frame, disassembly); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1045 | |
| 1046 | return disassembly; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1047 | } |
| 1048 | |
| 1049 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1050 | SBValueList |
| 1051 | SBFrame::GetVariables (bool arguments, |
| 1052 | bool locals, |
| 1053 | bool statics, |
| 1054 | bool in_scope_only) |
| 1055 | { |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1056 | SBValueList value_list; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1057 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1058 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 1059 | Target *target = exe_ctx.GetTargetPtr(); |
| 1060 | if (frame && target) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1061 | { |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1062 | lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue(); |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1063 | value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic); |
| 1064 | } |
| 1065 | return value_list; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1066 | } |
| 1067 | |
| 1068 | SBValueList |
| 1069 | SBFrame::GetVariables (bool arguments, |
| 1070 | bool locals, |
| 1071 | bool statics, |
| 1072 | bool in_scope_only, |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 1073 | lldb::DynamicValueType use_dynamic) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1074 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1075 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1076 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1077 | SBValueList value_list; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 1078 | Mutex::Locker api_locker; |
| 1079 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 1080 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1081 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1082 | Target *target = exe_ctx.GetTargetPtr(); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1083 | |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1084 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1085 | log->Printf ("SBFrame::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)", |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1086 | arguments, |
| 1087 | locals, |
| 1088 | statics, |
| 1089 | in_scope_only); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1090 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1091 | Process *process = exe_ctx.GetProcessPtr(); |
| 1092 | if (target && process) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1093 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1094 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1095 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1096 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1097 | frame = exe_ctx.GetFramePtr(); |
| 1098 | if (frame) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1099 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1100 | size_t i; |
| 1101 | VariableList *variable_list = NULL; |
| 1102 | variable_list = frame->GetVariableList(true); |
| 1103 | if (variable_list) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1104 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1105 | const size_t num_variables = variable_list->GetSize(); |
| 1106 | if (num_variables) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1107 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1108 | for (i = 0; i < num_variables; ++i) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1109 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1110 | VariableSP variable_sp (variable_list->GetVariableAtIndex(i)); |
| 1111 | if (variable_sp) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1112 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1113 | bool add_variable = false; |
| 1114 | switch (variable_sp->GetScope()) |
| 1115 | { |
| 1116 | case eValueTypeVariableGlobal: |
| 1117 | case eValueTypeVariableStatic: |
| 1118 | add_variable = statics; |
| 1119 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1120 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1121 | case eValueTypeVariableArgument: |
| 1122 | add_variable = arguments; |
| 1123 | break; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1124 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1125 | case eValueTypeVariableLocal: |
| 1126 | add_variable = locals; |
| 1127 | break; |
Greg Clayton | 54e7afa | 2010-07-09 20:39:50 +0000 | [diff] [blame] | 1128 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1129 | default: |
| 1130 | break; |
| 1131 | } |
| 1132 | if (add_variable) |
| 1133 | { |
| 1134 | if (in_scope_only && !variable_sp->IsInScope(frame)) |
| 1135 | continue; |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1136 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1137 | ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues)); |
| 1138 | SBValue value_sb; |
| 1139 | value_sb.SetSP(valobj_sp,use_dynamic); |
| 1140 | value_list.Append(value_sb); |
| 1141 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1142 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1143 | } |
| 1144 | } |
| 1145 | } |
| 1146 | } |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1147 | else |
| 1148 | { |
| 1149 | if (log) |
| 1150 | log->Printf ("SBFrame::GetVariables () => error: could not reconstruct frame object for this SBFrame."); |
| 1151 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1152 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1153 | else |
| 1154 | { |
| 1155 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1156 | log->Printf ("SBFrame::GetVariables () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1157 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1158 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1159 | |
| 1160 | if (log) |
| 1161 | { |
Enrico Granata | 9c7108f | 2013-02-07 22:57:46 +0000 | [diff] [blame] | 1162 | log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame, value_list.opaque_ptr()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1163 | } |
| 1164 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1165 | return value_list; |
| 1166 | } |
| 1167 | |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 1168 | SBValueList |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1169 | SBFrame::GetRegisters () |
| 1170 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1171 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1172 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1173 | SBValueList value_list; |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 1174 | Mutex::Locker api_locker; |
| 1175 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 1176 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1177 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1178 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1179 | Process *process = exe_ctx.GetProcessPtr(); |
| 1180 | if (target && process) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1181 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1182 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1183 | if (stop_locker.TryLock(&process->GetRunLock())) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1184 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1185 | frame = exe_ctx.GetFramePtr(); |
| 1186 | if (frame) |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1187 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1188 | RegisterContextSP reg_ctx (frame->GetRegisterContext()); |
| 1189 | if (reg_ctx) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1190 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1191 | const uint32_t num_sets = reg_ctx->GetRegisterSetCount(); |
| 1192 | for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) |
| 1193 | { |
| 1194 | value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx)); |
| 1195 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1196 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1197 | } |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1198 | else |
| 1199 | { |
| 1200 | if (log) |
| 1201 | log->Printf ("SBFrame::GetRegisters () => error: could not reconstruct frame object for this SBFrame."); |
| 1202 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1203 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1204 | else |
| 1205 | { |
| 1206 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1207 | log->Printf ("SBFrame::GetRegisters () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1208 | } |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1209 | } |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1210 | |
| 1211 | if (log) |
Enrico Granata | 9c7108f | 2013-02-07 22:57:46 +0000 | [diff] [blame] | 1212 | log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", frame, value_list.opaque_ptr()); |
Caroline Tice | 7826c88 | 2010-10-26 03:11:13 +0000 | [diff] [blame] | 1213 | |
Chris Lattner | 24943d2 | 2010-06-08 16:52:24 +0000 | [diff] [blame] | 1214 | return value_list; |
| 1215 | } |
| 1216 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1217 | bool |
| 1218 | SBFrame::GetDescription (SBStream &description) |
| 1219 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1220 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1221 | Stream &strm = description.ref(); |
| 1222 | |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 1223 | Mutex::Locker api_locker; |
| 1224 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 1225 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1226 | StackFrame *frame; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1227 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1228 | Process *process = exe_ctx.GetProcessPtr(); |
| 1229 | if (target && process) |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1230 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1231 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1232 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1233 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1234 | frame = exe_ctx.GetFramePtr(); |
| 1235 | if (frame) |
| 1236 | { |
| 1237 | frame->DumpUsingSettingsFormat (&strm); |
| 1238 | } |
| 1239 | else |
| 1240 | { |
| 1241 | if (log) |
| 1242 | log->Printf ("SBFrame::GetDescription () => error: could not reconstruct frame object for this SBFrame."); |
| 1243 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1244 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1245 | else |
| 1246 | { |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1247 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1248 | log->Printf ("SBFrame::GetDescription () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1249 | } |
| 1250 | |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1251 | } |
| 1252 | else |
Greg Clayton | 96154be | 2011-11-13 06:57:31 +0000 | [diff] [blame] | 1253 | strm.PutCString ("No value"); |
Caroline Tice | 98f930f | 2010-09-20 05:20:02 +0000 | [diff] [blame] | 1254 | |
| 1255 | return true; |
| 1256 | } |
Greg Clayton | 66ed2fb | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 1257 | |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 1258 | SBValue |
Greg Clayton | 66ed2fb | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 1259 | SBFrame::EvaluateExpression (const char *expr) |
| 1260 | { |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1261 | SBValue result; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1262 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1263 | StackFrame *frame = exe_ctx.GetFramePtr(); |
| 1264 | Target *target = exe_ctx.GetTargetPtr(); |
| 1265 | if (frame && target) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1266 | { |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1267 | SBExpressionOptions options; |
| 1268 | lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); |
Greg Clayton | 75a443b | 2012-10-16 22:58:25 +0000 | [diff] [blame] | 1269 | options.SetFetchDynamicValue (fetch_dynamic_value); |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1270 | options.SetUnwindOnError (true); |
| 1271 | return EvaluateExpression (expr, options); |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1272 | } |
| 1273 | return result; |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1274 | } |
| 1275 | |
| 1276 | SBValue |
Jim Ingham | 10de7d1 | 2011-05-04 03:43:18 +0000 | [diff] [blame] | 1277 | SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1278 | { |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1279 | SBExpressionOptions options; |
Greg Clayton | 75a443b | 2012-10-16 22:58:25 +0000 | [diff] [blame] | 1280 | options.SetFetchDynamicValue (fetch_dynamic_value); |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1281 | options.SetUnwindOnError (true); |
| 1282 | return EvaluateExpression (expr, options); |
Jim Ingham | d82bc6d | 2012-05-11 23:47:32 +0000 | [diff] [blame] | 1283 | } |
| 1284 | |
| 1285 | SBValue |
| 1286 | SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) |
| 1287 | { |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1288 | SBExpressionOptions options; |
Greg Clayton | 75a443b | 2012-10-16 22:58:25 +0000 | [diff] [blame] | 1289 | options.SetFetchDynamicValue (fetch_dynamic_value); |
Jim Ingham | 47beabb | 2012-10-16 21:41:58 +0000 | [diff] [blame] | 1290 | options.SetUnwindOnError (unwind_on_error); |
| 1291 | return EvaluateExpression (expr, options); |
| 1292 | } |
| 1293 | |
| 1294 | lldb::SBValue |
| 1295 | SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &options) |
| 1296 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1297 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Sean Callanan | 94d255f | 2010-12-07 22:55:01 +0000 | [diff] [blame] | 1298 | |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1299 | Log *expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1300 | |
Greg Clayton | 4a379b1 | 2012-07-17 03:23:13 +0000 | [diff] [blame] | 1301 | ExecutionResults exe_results = eExecutionSetupError; |
Greg Clayton | 4e9267d | 2010-12-14 18:39:31 +0000 | [diff] [blame] | 1302 | SBValue expr_result; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1303 | |
| 1304 | if (expr == NULL || expr[0] == '\0') |
| 1305 | { |
| 1306 | if (log) |
| 1307 | log->Printf ("SBFrame::EvaluateExpression called with an empty expression"); |
| 1308 | return expr_result; |
| 1309 | } |
| 1310 | |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1311 | ValueObjectSP expr_value_sp; |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1312 | |
Jim Ingham | d0bdddf | 2012-08-22 21:34:33 +0000 | [diff] [blame] | 1313 | Mutex::Locker api_locker; |
| 1314 | ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); |
| 1315 | |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1316 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1317 | log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); |
Greg Clayton | 334d33a | 2012-01-30 07:41:31 +0000 | [diff] [blame] | 1318 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1319 | StackFrame *frame = NULL; |
| 1320 | Target *target = exe_ctx.GetTargetPtr(); |
| 1321 | Process *process = exe_ctx.GetProcessPtr(); |
| 1322 | |
| 1323 | if (target && process) |
| 1324 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1325 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1326 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1327 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1328 | frame = exe_ctx.GetFramePtr(); |
| 1329 | if (frame) |
| 1330 | { |
Enrico Granata | 299aa70 | 2012-05-29 18:06:49 +0000 | [diff] [blame] | 1331 | #ifdef LLDB_CONFIGURATION_DEBUG |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1332 | StreamString frame_description; |
| 1333 | frame->DumpUsingSettingsFormat (&frame_description); |
| 1334 | Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", |
| 1335 | expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); |
Enrico Granata | 299aa70 | 2012-05-29 18:06:49 +0000 | [diff] [blame] | 1336 | #endif |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1337 | exe_results = target->EvaluateExpression (expr, |
| 1338 | frame, |
| 1339 | expr_value_sp, |
| 1340 | options.ref()); |
| 1341 | expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); |
Enrico Granata | 299aa70 | 2012-05-29 18:06:49 +0000 | [diff] [blame] | 1342 | #ifdef LLDB_CONFIGURATION_DEBUG |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1343 | Host::SetCrashDescription (NULL); |
Enrico Granata | 299aa70 | 2012-05-29 18:06:49 +0000 | [diff] [blame] | 1344 | #endif |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1345 | } |
| 1346 | else |
| 1347 | { |
| 1348 | if (log) |
| 1349 | log->Printf ("SBFrame::EvaluateExpression () => error: could not reconstruct frame object for this SBFrame."); |
| 1350 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1351 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1352 | else |
| 1353 | { |
| 1354 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1355 | log->Printf ("SBFrame::EvaluateExpression () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1356 | } |
Greg Clayton | 66ed2fb | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 1357 | } |
Jason Molenda | c48ca82 | 2012-02-21 05:33:55 +0000 | [diff] [blame] | 1358 | |
| 1359 | #ifndef LLDB_DISABLE_PYTHON |
Sean Callanan | 94d255f | 2010-12-07 22:55:01 +0000 | [diff] [blame] | 1360 | if (expr_log) |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1361 | expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", |
Greg Clayton | 0fb0bcc | 2011-08-03 22:57:10 +0000 | [diff] [blame] | 1362 | expr_result.GetValue(), |
| 1363 | expr_result.GetSummary()); |
Sean Callanan | 94d255f | 2010-12-07 22:55:01 +0000 | [diff] [blame] | 1364 | |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1365 | if (log) |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1366 | log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", |
| 1367 | frame, |
Jim Ingham | e41494a | 2011-04-16 00:01:13 +0000 | [diff] [blame] | 1368 | expr, |
Greg Clayton | 0a19a1b | 2012-02-04 02:27:34 +0000 | [diff] [blame] | 1369 | expr_value_sp.get(), |
Johnny Chen | ee6e790 | 2011-08-10 22:06:24 +0000 | [diff] [blame] | 1370 | exe_results); |
Jason Molenda | c48ca82 | 2012-02-21 05:33:55 +0000 | [diff] [blame] | 1371 | #endif |
Greg Clayton | a66ba46 | 2010-10-30 04:51:46 +0000 | [diff] [blame] | 1372 | |
Greg Clayton | 49ce682 | 2010-10-31 03:01:06 +0000 | [diff] [blame] | 1373 | return expr_result; |
Greg Clayton | 66ed2fb | 2010-10-05 00:00:42 +0000 | [diff] [blame] | 1374 | } |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1375 | |
| 1376 | bool |
| 1377 | SBFrame::IsInlined() |
| 1378 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1379 | Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1380 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1381 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1382 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1383 | Process *process = exe_ctx.GetProcessPtr(); |
| 1384 | if (target && process) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1385 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1386 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1387 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1388 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1389 | frame = exe_ctx.GetFramePtr(); |
| 1390 | if (frame) |
| 1391 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1392 | |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1393 | Block *block = frame->GetSymbolContext(eSymbolContextBlock).block; |
| 1394 | if (block) |
| 1395 | return block->GetContainingInlinedBlock () != NULL; |
| 1396 | } |
| 1397 | else |
| 1398 | { |
| 1399 | if (log) |
| 1400 | log->Printf ("SBFrame::IsInlined () => error: could not reconstruct frame object for this SBFrame."); |
| 1401 | } |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1402 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1403 | else |
| 1404 | { |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1405 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1406 | log->Printf ("SBFrame::IsInlined () => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1407 | } |
| 1408 | |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1409 | } |
| 1410 | return false; |
| 1411 | } |
| 1412 | |
| 1413 | const char * |
| 1414 | SBFrame::GetFunctionName() |
| 1415 | { |
Greg Clayton | 952e9dc | 2013-03-27 23:08:40 +0000 | [diff] [blame] | 1416 | Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1417 | const char *name = NULL; |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1418 | ExecutionContext exe_ctx(m_opaque_sp.get()); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1419 | StackFrame *frame = NULL; |
Greg Clayton | 289afcb | 2012-02-18 05:35:26 +0000 | [diff] [blame] | 1420 | Target *target = exe_ctx.GetTargetPtr(); |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1421 | Process *process = exe_ctx.GetProcessPtr(); |
| 1422 | if (target && process) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1423 | { |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1424 | Process::StopLocker stop_locker; |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1425 | if (stop_locker.TryLock(&process->GetRunLock())) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1426 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1427 | frame = exe_ctx.GetFramePtr(); |
| 1428 | if (frame) |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1429 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1430 | SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol)); |
| 1431 | if (sc.block) |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1432 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1433 | Block *inlined_block = sc.block->GetContainingInlinedBlock (); |
| 1434 | if (inlined_block) |
| 1435 | { |
| 1436 | const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo(); |
| 1437 | name = inlined_info->GetName().AsCString(); |
| 1438 | } |
| 1439 | } |
| 1440 | |
| 1441 | if (name == NULL) |
| 1442 | { |
| 1443 | if (sc.function) |
| 1444 | name = sc.function->GetName().GetCString(); |
| 1445 | } |
| 1446 | |
| 1447 | if (name == NULL) |
| 1448 | { |
| 1449 | if (sc.symbol) |
| 1450 | name = sc.symbol->GetName().GetCString(); |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1451 | } |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1452 | } |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1453 | else |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1454 | { |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1455 | if (log) |
| 1456 | log->Printf ("SBFrame::GetFunctionName () => error: could not reconstruct frame object for this SBFrame."); |
Greg Clayton | a894fe7 | 2012-04-05 16:12:35 +0000 | [diff] [blame] | 1457 | } |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1458 | } |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1459 | else |
| 1460 | { |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1461 | if (log) |
Jim Ingham | 15fd97d | 2012-11-29 00:26:19 +0000 | [diff] [blame] | 1462 | log->Printf ("SBFrame::GetFunctionName() => error: process is running"); |
Greg Clayton | 9f3c98e | 2012-04-06 02:17:47 +0000 | [diff] [blame] | 1463 | |
| 1464 | } |
Greg Clayton | 582ed0e | 2011-06-18 20:06:08 +0000 | [diff] [blame] | 1465 | } |
| 1466 | return name; |
| 1467 | } |
| 1468 | |