blob: 8448bd2f975c3d2f47cc5a0a71e4d51ad8d26ca9 [file] [log] [blame]
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001//===-- 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 Friedman4c5de692010-06-09 07:44:37 +000010#include "lldb/API/SBFrame.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000011
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 Ticeceb6b132010-10-26 03:11:13 +000019#include "lldb/Core/Log.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000020#include "lldb/Core/Stream.h"
21#include "lldb/Core/StreamFile.h"
22#include "lldb/Core/ValueObjectRegister.h"
23#include "lldb/Core/ValueObjectVariable.h"
Greg Claytonb71f3842010-10-05 03:13:51 +000024#include "lldb/Expression/ClangUserExpression.h"
Greg Clayton1ba7c4d2011-06-25 04:35:01 +000025#include "lldb/Host/Host.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000026#include "lldb/Symbol/Block.h"
Greg Clayton1f746072012-08-29 21:13:06 +000027#include "lldb/Symbol/Function.h"
28#include "lldb/Symbol/Symbol.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000029#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"
Jason Molendab57e4a12013-11-04 09:33:30 +000036#include "lldb/Target/StackFrame.h"
Greg Claytonb9556ac2012-01-30 07:41:31 +000037#include "lldb/Target/StackID.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000038#include "lldb/Target/Thread.h"
39
Eli Friedman4c5de692010-06-09 07:44:37 +000040#include "lldb/API/SBDebugger.h"
41#include "lldb/API/SBValue.h"
42#include "lldb/API/SBAddress.h"
Jim Ingham35e1bda2012-10-16 21:41:58 +000043#include "lldb/API/SBExpressionOptions.h"
Caroline Ticedde9cff2010-09-20 05:20:02 +000044#include "lldb/API/SBStream.h"
Eli Friedman4c5de692010-06-09 07:44:37 +000045#include "lldb/API/SBSymbolContext.h"
46#include "lldb/API/SBThread.h"
Chris Lattner30fdc8d2010-06-08 16:52:24 +000047
48using namespace lldb;
49using namespace lldb_private;
50
Greg Claytonb9556ac2012-01-30 07:41:31 +000051
Chris Lattner30fdc8d2010-06-08 16:52:24 +000052SBFrame::SBFrame () :
Greg Clayton7fdf9ef2012-04-05 16:12:35 +000053 m_opaque_sp (new ExecutionContextRef())
Chris Lattner30fdc8d2010-06-08 16:52:24 +000054{
55}
56
Jason Molendab57e4a12013-11-04 09:33:30 +000057SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) :
Greg Clayton7fdf9ef2012-04-05 16:12:35 +000058 m_opaque_sp (new ExecutionContextRef (lldb_object_sp))
Chris Lattner30fdc8d2010-06-08 16:52:24 +000059{
Greg Clayton5160ce52013-03-27 23:08:40 +000060 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +000061
62 if (log)
63 {
64 SBStream sstr;
65 GetDescription (sstr);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +000066 log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
67 static_cast<void*>(lldb_object_sp.get()),
68 static_cast<void*>(lldb_object_sp.get()), sstr.GetData());
Caroline Ticeceb6b132010-10-26 03:11:13 +000069 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +000070}
71
Greg Claytonefabb122010-11-05 23:17:00 +000072SBFrame::SBFrame(const SBFrame &rhs) :
Greg Clayton7fdf9ef2012-04-05 16:12:35 +000073 m_opaque_sp (new ExecutionContextRef (*rhs.m_opaque_sp))
Greg Claytonefabb122010-11-05 23:17:00 +000074{
75}
76
77const SBFrame &
78SBFrame::operator = (const SBFrame &rhs)
79{
80 if (this != &rhs)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +000081 *m_opaque_sp = *rhs.m_opaque_sp;
Greg Claytonefabb122010-11-05 23:17:00 +000082 return *this;
83}
84
Chris Lattner30fdc8d2010-06-08 16:52:24 +000085SBFrame::~SBFrame()
86{
87}
88
Jason Molendab57e4a12013-11-04 09:33:30 +000089StackFrameSP
Greg Claytonb9556ac2012-01-30 07:41:31 +000090SBFrame::GetFrameSP() const
Chris Lattner30fdc8d2010-06-08 16:52:24 +000091{
Greg Claytonaf2589e2012-04-12 20:58:26 +000092 if (m_opaque_sp)
93 return m_opaque_sp->GetFrameSP();
Jason Molendab57e4a12013-11-04 09:33:30 +000094 return StackFrameSP();
Chris Lattner30fdc8d2010-06-08 16:52:24 +000095}
96
Greg Claytonb9556ac2012-01-30 07:41:31 +000097void
Jason Molendab57e4a12013-11-04 09:33:30 +000098SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
Greg Claytonb9556ac2012-01-30 07:41:31 +000099{
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000100 return m_opaque_sp->SetFrameSP(lldb_object_sp);
Greg Claytonb9556ac2012-01-30 07:41:31 +0000101}
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000102
103bool
104SBFrame::IsValid() const
105{
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000106 return GetFrameSP().get() != NULL;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000107}
108
109SBSymbolContext
110SBFrame::GetSymbolContext (uint32_t resolve_scope) const
111{
Greg Clayton5160ce52013-03-27 23:08:40 +0000112 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000113 SBSymbolContext sb_sym_ctx;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000114 Mutex::Locker api_locker;
115 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
116
Jason Molendab57e4a12013-11-04 09:33:30 +0000117 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000118 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000119 Process *process = exe_ctx.GetProcessPtr();
120 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000121 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000122 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000123 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000124 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000125 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 Clayton7fdf9ef2012-04-05 16:12:35 +0000135 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000136 else
137 {
138 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000139 log->Printf ("SBFrame::GetSymbolContext () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000140 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000141 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000142
143 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000144 log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)",
145 static_cast<void*>(frame), resolve_scope,
146 static_cast<void*>(sb_sym_ctx.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000147
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000148 return sb_sym_ctx;
149}
150
151SBModule
152SBFrame::GetModule () const
153{
Greg Clayton5160ce52013-03-27 23:08:40 +0000154 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton72eff182010-12-14 04:58:53 +0000155 SBModule sb_module;
Greg Claytonacdbe812012-01-30 09:04:36 +0000156 ModuleSP module_sp;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000157 Mutex::Locker api_locker;
158 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
159
Jason Molendab57e4a12013-11-04 09:33:30 +0000160 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000161 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000162 Process *process = exe_ctx.GetProcessPtr();
163 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000164 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000165 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000166 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000167 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000168 frame = exe_ctx.GetFramePtr();
169 if (frame)
170 {
171 module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp;
172 sb_module.SetSP (module_sp);
173 }
174 else
175 {
176 if (log)
177 log->Printf ("SBFrame::GetModule () => error: could not reconstruct frame object for this SBFrame.");
178 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000179 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000180 else
181 {
182 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000183 log->Printf ("SBFrame::GetModule () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000184 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000185 }
Greg Clayton72eff182010-12-14 04:58:53 +0000186
Greg Clayton48381312010-10-30 04:51:46 +0000187 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000188 log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)",
189 static_cast<void*>(frame),
190 static_cast<void*>(module_sp.get()));
Greg Clayton48381312010-10-30 04:51:46 +0000191
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000192 return sb_module;
193}
194
195SBCompileUnit
196SBFrame::GetCompileUnit () const
197{
Greg Clayton5160ce52013-03-27 23:08:40 +0000198 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton72eff182010-12-14 04:58:53 +0000199 SBCompileUnit sb_comp_unit;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000200 Mutex::Locker api_locker;
201 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
202
Jason Molendab57e4a12013-11-04 09:33:30 +0000203 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000204 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000205 Process *process = exe_ctx.GetProcessPtr();
206 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000207 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000208 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000209 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000210 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000211 frame = exe_ctx.GetFramePtr();
212 if (frame)
213 {
214 sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
215 }
216 else
217 {
218 if (log)
219 log->Printf ("SBFrame::GetCompileUnit () => error: could not reconstruct frame object for this SBFrame.");
220 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000221 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000222 else
223 {
224 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000225 log->Printf ("SBFrame::GetCompileUnit () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000226 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000227 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000228 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000229 log->Printf ("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)",
230 static_cast<void*>(frame),
231 static_cast<void*>(sb_comp_unit.get()));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000232
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000233 return sb_comp_unit;
234}
235
236SBFunction
237SBFrame::GetFunction () const
238{
Greg Clayton5160ce52013-03-27 23:08:40 +0000239 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton72eff182010-12-14 04:58:53 +0000240 SBFunction sb_function;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000241 Mutex::Locker api_locker;
242 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
243
Jason Molendab57e4a12013-11-04 09:33:30 +0000244 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000245 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000246 Process *process = exe_ctx.GetProcessPtr();
247 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000248 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000249 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000250 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000251 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000252 frame = exe_ctx.GetFramePtr();
253 if (frame)
254 {
255 sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function);
256 }
257 else
258 {
259 if (log)
260 log->Printf ("SBFrame::GetFunction () => error: could not reconstruct frame object for this SBFrame.");
261 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000262 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000263 else
264 {
265 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000266 log->Printf ("SBFrame::GetFunction () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000267 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000268 }
Greg Clayton48381312010-10-30 04:51:46 +0000269 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000270 log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)",
271 static_cast<void*>(frame),
272 static_cast<void*>(sb_function.get()));
Greg Clayton48381312010-10-30 04:51:46 +0000273
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000274 return sb_function;
275}
276
Greg Clayton3b065572010-10-04 18:37:52 +0000277SBSymbol
278SBFrame::GetSymbol () const
279{
Greg Clayton5160ce52013-03-27 23:08:40 +0000280 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton72eff182010-12-14 04:58:53 +0000281 SBSymbol sb_symbol;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000282 Mutex::Locker api_locker;
283 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
284
Jason Molendab57e4a12013-11-04 09:33:30 +0000285 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000286 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000287 Process *process = exe_ctx.GetProcessPtr();
288 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000289 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000290 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000291 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000292 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000293 frame = exe_ctx.GetFramePtr();
294 if (frame)
295 {
296 sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol);
297 }
298 else
299 {
300 if (log)
301 log->Printf ("SBFrame::GetSymbol () => error: could not reconstruct frame object for this SBFrame.");
302 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000303 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000304 else
305 {
306 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000307 log->Printf ("SBFrame::GetSymbol () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000308 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000309 }
Greg Clayton48381312010-10-30 04:51:46 +0000310 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000311 log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
312 static_cast<void*>(frame),
313 static_cast<void*>(sb_symbol.get()));
Greg Clayton3b065572010-10-04 18:37:52 +0000314 return sb_symbol;
315}
316
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000317SBBlock
318SBFrame::GetBlock () const
319{
Greg Clayton5160ce52013-03-27 23:08:40 +0000320 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton72eff182010-12-14 04:58:53 +0000321 SBBlock sb_block;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000322 Mutex::Locker api_locker;
323 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
324
Jason Molendab57e4a12013-11-04 09:33:30 +0000325 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000326 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000327 Process *process = exe_ctx.GetProcessPtr();
328 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000329 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000330 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000331 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000332 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000333 frame = exe_ctx.GetFramePtr();
334 if (frame)
335 {
336 sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block);
337 }
338 else
339 {
340 if (log)
341 log->Printf ("SBFrame::GetBlock () => error: could not reconstruct frame object for this SBFrame.");
342 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000343 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000344 else
345 {
346 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000347 log->Printf ("SBFrame(%p)::GetBlock () => error: process is running",
348 static_cast<void*>(frame));
Greg Claytonc9858e42012-04-06 02:17:47 +0000349 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000350 }
Greg Clayton48381312010-10-30 04:51:46 +0000351 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000352 log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
353 static_cast<void*>(frame),
354 static_cast<void*>(sb_block.GetPtr()));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000355 return sb_block;
356}
357
Greg Clayton95897c62010-09-07 04:20:48 +0000358SBBlock
359SBFrame::GetFrameBlock () const
360{
Greg Clayton72eff182010-12-14 04:58:53 +0000361 SBBlock sb_block;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000362 Mutex::Locker api_locker;
363 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
364
Jason Molendab57e4a12013-11-04 09:33:30 +0000365 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000366 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton5160ce52013-03-27 23:08:40 +0000367 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham7730b9a2012-11-29 00:26:19 +0000368 Process *process = exe_ctx.GetProcessPtr();
369 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000370 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000371 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000372 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000373 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000374 frame = exe_ctx.GetFramePtr();
375 if (frame)
376 {
377 sb_block.SetPtr(frame->GetFrameBlock ());
378 }
379 else
380 {
381 if (log)
382 log->Printf ("SBFrame::GetFrameBlock () => error: could not reconstruct frame object for this SBFrame.");
383 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000384 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000385 else
386 {
387 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000388 log->Printf ("SBFrame::GetFrameBlock () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000389 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000390 }
Greg Clayton48381312010-10-30 04:51:46 +0000391 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000392 log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
393 static_cast<void*>(frame),
394 static_cast<void*>(sb_block.GetPtr()));
Greg Clayton95897c62010-09-07 04:20:48 +0000395 return sb_block;
396}
397
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000398SBLineEntry
399SBFrame::GetLineEntry () const
400{
Greg Clayton5160ce52013-03-27 23:08:40 +0000401 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton72eff182010-12-14 04:58:53 +0000402 SBLineEntry sb_line_entry;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000403 Mutex::Locker api_locker;
404 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
405
Jason Molendab57e4a12013-11-04 09:33:30 +0000406 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000407 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000408 Process *process = exe_ctx.GetProcessPtr();
409 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000410 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000411 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000412 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000413 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000414 frame = exe_ctx.GetFramePtr();
415 if (frame)
416 {
417 sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry);
418 }
419 else
420 {
421 if (log)
422 log->Printf ("SBFrame::GetLineEntry () => error: could not reconstruct frame object for this SBFrame.");
423 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000424 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000425 else
426 {
427 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000428 log->Printf ("SBFrame::GetLineEntry () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000429 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000430 }
Greg Clayton48381312010-10-30 04:51:46 +0000431 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000432 log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
433 static_cast<void*>(frame),
434 static_cast<void*>(sb_line_entry.get()));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000435 return sb_line_entry;
436}
437
438uint32_t
439SBFrame::GetFrameID () const
440{
Greg Claytonb9556ac2012-01-30 07:41:31 +0000441 uint32_t frame_idx = UINT32_MAX;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000442
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000443 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +0000444 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000445 if (frame)
Greg Claytond9e416c2012-02-18 05:35:26 +0000446 frame_idx = frame->GetFrameIndex ();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000447
Greg Clayton5160ce52013-03-27 23:08:40 +0000448 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000449 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000450 log->Printf ("SBFrame(%p)::GetFrameID () => %u",
451 static_cast<void*>(frame), frame_idx);
Greg Clayton48381312010-10-30 04:51:46 +0000452 return frame_idx;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000453}
454
Greg Clayton69b582f2010-12-14 18:39:31 +0000455addr_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000456SBFrame::GetPC () const
457{
Greg Clayton5160ce52013-03-27 23:08:40 +0000458 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton69b582f2010-12-14 18:39:31 +0000459 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000460 Mutex::Locker api_locker;
461 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
462
Jason Molendab57e4a12013-11-04 09:33:30 +0000463 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000464 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000465 Process *process = exe_ctx.GetProcessPtr();
466 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000467 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000468 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000469 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000470 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000471 frame = exe_ctx.GetFramePtr();
472 if (frame)
473 {
474 addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
475 }
476 else
477 {
478 if (log)
479 log->Printf ("SBFrame::GetPC () => error: could not reconstruct frame object for this SBFrame.");
480 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000481 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000482 else
483 {
484 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000485 log->Printf ("SBFrame::GetPC () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000486 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000487 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000488
489 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000490 log->Printf ("SBFrame(%p)::GetPC () => 0x%" PRIx64,
491 static_cast<void*>(frame), addr);
Caroline Ticeceb6b132010-10-26 03:11:13 +0000492
493 return addr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000494}
495
496bool
Greg Clayton69b582f2010-12-14 18:39:31 +0000497SBFrame::SetPC (addr_t new_pc)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000498{
Greg Clayton5160ce52013-03-27 23:08:40 +0000499 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +0000500 bool ret_val = false;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000501 Mutex::Locker api_locker;
502 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
503
Jason Molendab57e4a12013-11-04 09:33:30 +0000504 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000505 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000506 Process *process = exe_ctx.GetProcessPtr();
507 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000508 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000509 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000510 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000511 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000512 frame = exe_ctx.GetFramePtr();
513 if (frame)
514 {
515 ret_val = frame->GetRegisterContext()->SetPC (new_pc);
516 }
517 else
518 {
519 if (log)
520 log->Printf ("SBFrame::SetPC () => error: could not reconstruct frame object for this SBFrame.");
521 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000522 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000523 else
524 {
525 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000526 log->Printf ("SBFrame::SetPC () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000527 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000528 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000529
530 if (log)
Daniel Malead01b2952012-11-29 21:49:15 +0000531 log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%" PRIx64 ") => %i",
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000532 static_cast<void*>(frame), new_pc, ret_val);
Caroline Ticeceb6b132010-10-26 03:11:13 +0000533
534 return ret_val;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000535}
536
Greg Clayton69b582f2010-12-14 18:39:31 +0000537addr_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000538SBFrame::GetSP () const
539{
Greg Clayton5160ce52013-03-27 23:08:40 +0000540 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +0000541 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000542 Mutex::Locker api_locker;
543 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
544
Jason Molendab57e4a12013-11-04 09:33:30 +0000545 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000546 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000547 Process *process = exe_ctx.GetProcessPtr();
548 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000549 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000550 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000551 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000552 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000553 frame = exe_ctx.GetFramePtr();
554 if (frame)
555 {
556 addr = frame->GetRegisterContext()->GetSP();
557 }
558 else
559 {
560 if (log)
561 log->Printf ("SBFrame::GetSP () => error: could not reconstruct frame object for this SBFrame.");
562 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000563 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000564 else
565 {
566 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000567 log->Printf ("SBFrame::GetSP () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000568 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000569 }
Greg Clayton48381312010-10-30 04:51:46 +0000570 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000571 log->Printf ("SBFrame(%p)::GetSP () => 0x%" PRIx64,
572 static_cast<void*>(frame), addr);
Greg Clayton48381312010-10-30 04:51:46 +0000573
574 return addr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000575}
576
577
Greg Clayton69b582f2010-12-14 18:39:31 +0000578addr_t
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000579SBFrame::GetFP () const
580{
Greg Clayton5160ce52013-03-27 23:08:40 +0000581 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton69b582f2010-12-14 18:39:31 +0000582 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000583 Mutex::Locker api_locker;
584 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
585
Jason Molendab57e4a12013-11-04 09:33:30 +0000586 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000587 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000588 Process *process = exe_ctx.GetProcessPtr();
589 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000590 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000591 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000592 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000593 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000594 frame = exe_ctx.GetFramePtr();
595 if (frame)
596 {
597 addr = frame->GetRegisterContext()->GetFP();
598 }
599 else
600 {
601 if (log)
602 log->Printf ("SBFrame::GetFP () => error: could not reconstruct frame object for this SBFrame.");
603 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000604 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000605 else
606 {
607 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000608 log->Printf ("SBFrame::GetFP () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000609 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000610 }
Caroline Ticeceb6b132010-10-26 03:11:13 +0000611
612 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000613 log->Printf ("SBFrame(%p)::GetFP () => 0x%" PRIx64,
614 static_cast<void*>(frame), addr);
Caroline Ticeceb6b132010-10-26 03:11:13 +0000615 return addr;
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000616}
617
618
619SBAddress
620SBFrame::GetPCAddress () const
621{
Greg Clayton5160ce52013-03-27 23:08:40 +0000622 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000623 SBAddress sb_addr;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000624 Mutex::Locker api_locker;
625 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
626
Jason Molendab57e4a12013-11-04 09:33:30 +0000627 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytond9e416c2012-02-18 05:35:26 +0000628 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000629 Process *process = exe_ctx.GetProcessPtr();
630 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +0000631 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000632 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000633 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000634 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000635 frame = exe_ctx.GetFramePtr();
636 if (frame)
637 {
638 sb_addr.SetAddress (&frame->GetFrameCodeAddress());
639 }
640 else
641 {
642 if (log)
643 log->Printf ("SBFrame::GetPCAddress () => error: could not reconstruct frame object for this SBFrame.");
644 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000645 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000646 else
647 {
648 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000649 log->Printf ("SBFrame::GetPCAddress () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000650 }
Greg Claytonaf67cec2010-12-20 20:49:23 +0000651 }
Greg Clayton48381312010-10-30 04:51:46 +0000652 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000653 log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)",
654 static_cast<void*>(frame),
655 static_cast<void*>(sb_addr.get()));
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000656 return sb_addr;
657}
658
659void
660SBFrame::Clear()
661{
Greg Claytonaf2589e2012-04-12 20:58:26 +0000662 m_opaque_sp->Clear();
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000663}
664
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000665lldb::SBValue
666SBFrame::GetValueForVariablePath (const char *var_path)
667{
668 SBValue sb_value;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000669 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +0000670 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytond9e416c2012-02-18 05:35:26 +0000671 Target *target = exe_ctx.GetTargetPtr();
672 if (frame && target)
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000673 {
Greg Claytonc9858e42012-04-06 02:17:47 +0000674 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
675 sb_value = GetValueForVariablePath (var_path, use_dynamic);
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000676 }
677 return sb_value;
678}
679
680lldb::SBValue
681SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
682{
683 SBValue sb_value;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000684 Mutex::Locker api_locker;
Greg Clayton5160ce52013-03-27 23:08:40 +0000685 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Jim Ingham7730b9a2012-11-29 00:26:19 +0000686 if (var_path == NULL || var_path[0] == '\0')
687 {
688 if (log)
689 log->Printf ("SBFrame::GetValueForVariablePath called with empty variable path.");
690 return sb_value;
691 }
692
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000693 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
694
Jason Molendab57e4a12013-11-04 09:33:30 +0000695 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000696 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000697 Process *process = exe_ctx.GetProcessPtr();
698 if (target && process)
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000699 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000700 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000701 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000702 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000703 frame = exe_ctx.GetFramePtr();
704 if (frame)
705 {
706 VariableSP var_sp;
707 Error error;
708 ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path,
709 eNoDynamicValues,
Jason Molendab57e4a12013-11-04 09:33:30 +0000710 StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
Jim Ingham7730b9a2012-11-29 00:26:19 +0000711 var_sp,
712 error));
713 sb_value.SetSP(value_sp, use_dynamic);
714 }
715 else
716 {
717 if (log)
718 log->Printf ("SBFrame::GetValueForVariablePath () => error: could not reconstruct frame object for this SBFrame.");
719 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000720 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000721 else
722 {
Greg Claytonc9858e42012-04-06 02:17:47 +0000723 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000724 log->Printf ("SBFrame::GetValueForVariablePath () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000725 }
Greg Clayton7edbdfc2012-02-03 07:02:37 +0000726 }
727 return sb_value;
728}
729
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000730SBValue
Greg Clayton69b582f2010-12-14 18:39:31 +0000731SBFrame::FindVariable (const char *name)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000732{
Greg Clayton316d4982011-06-18 20:06:08 +0000733 SBValue value;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000734 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +0000735 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytond9e416c2012-02-18 05:35:26 +0000736 Target *target = exe_ctx.GetTargetPtr();
737 if (frame && target)
Greg Clayton316d4982011-06-18 20:06:08 +0000738 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000739 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton316d4982011-06-18 20:06:08 +0000740 value = FindVariable (name, use_dynamic);
741 }
742 return value;
Jim Ingham78a685a2011-04-16 00:01:13 +0000743}
744
745SBValue
Jim Ingham2837b762011-05-04 03:43:18 +0000746SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
Jim Ingham78a685a2011-04-16 00:01:13 +0000747{
Greg Clayton5160ce52013-03-27 23:08:40 +0000748 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton69b582f2010-12-14 18:39:31 +0000749 VariableSP var_sp;
Jim Ingham58b59f92011-04-22 23:53:53 +0000750 SBValue sb_value;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000751
752 if (name == NULL || name[0] == '\0')
753 {
754 if (log)
755 log->Printf ("SBFrame::FindVariable called with empty name");
756 return sb_value;
757 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000758
Greg Clayton81e871e2012-02-04 02:27:34 +0000759 ValueObjectSP value_sp;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000760 Mutex::Locker api_locker;
761 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
762
Jason Molendab57e4a12013-11-04 09:33:30 +0000763 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000764 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000765 Process *process = exe_ctx.GetProcessPtr();
766 if (target && process)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000767 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000768 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000769 if (stop_locker.TryLock(&process->GetRunLock()))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000770 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000771 frame = exe_ctx.GetFramePtr();
772 if (frame)
Greg Clayton72eff182010-12-14 04:58:53 +0000773 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000774 VariableList variable_list;
775 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
776
777 if (sc.block)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000778 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000779 const bool can_create = true;
780 const bool get_parent_variables = true;
781 const bool stop_if_block_is_inlined_function = true;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000782
Jim Ingham7730b9a2012-11-29 00:26:19 +0000783 if (sc.block->AppendVariables (can_create,
784 get_parent_variables,
785 stop_if_block_is_inlined_function,
786 &variable_list))
787 {
788 var_sp = variable_list.FindVariable (ConstString(name));
789 }
790 }
791
792 if (var_sp)
793 {
794 value_sp = frame->GetValueObjectForFrameVariable(var_sp, eNoDynamicValues);
795 sb_value.SetSP(value_sp, use_dynamic);
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000796 }
797 }
Jim Ingham7730b9a2012-11-29 00:26:19 +0000798 else
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000799 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000800 if (log)
801 log->Printf ("SBFrame::FindVariable () => error: could not reconstruct frame object for this SBFrame.");
Greg Clayton72eff182010-12-14 04:58:53 +0000802 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000803 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000804 else
805 {
806 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000807 log->Printf ("SBFrame::FindVariable () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000808 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000809 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000810
Greg Clayton48381312010-10-30 04:51:46 +0000811 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000812 log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
813 static_cast<void*>(frame), name,
814 static_cast<void*>(value_sp.get()));
Greg Clayton48381312010-10-30 04:51:46 +0000815
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000816 return sb_value;
817}
818
819SBValue
Greg Clayton69b582f2010-12-14 18:39:31 +0000820SBFrame::FindValue (const char *name, ValueType value_type)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000821{
Greg Clayton316d4982011-06-18 20:06:08 +0000822 SBValue value;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000823 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +0000824 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytond9e416c2012-02-18 05:35:26 +0000825 Target *target = exe_ctx.GetTargetPtr();
826 if (frame && target)
Greg Clayton316d4982011-06-18 20:06:08 +0000827 {
Greg Claytond9e416c2012-02-18 05:35:26 +0000828 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton316d4982011-06-18 20:06:08 +0000829 value = FindValue (name, value_type, use_dynamic);
830 }
831 return value;
Jim Ingham78a685a2011-04-16 00:01:13 +0000832}
833
834SBValue
Jim Ingham2837b762011-05-04 03:43:18 +0000835SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic)
Jim Ingham78a685a2011-04-16 00:01:13 +0000836{
Greg Clayton5160ce52013-03-27 23:08:40 +0000837 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton69b582f2010-12-14 18:39:31 +0000838 SBValue sb_value;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000839
Jim Ingham7730b9a2012-11-29 00:26:19 +0000840 if (name == NULL || name[0] == '\0')
841 {
842 if (log)
843 log->Printf ("SBFrame::FindValue called with empty name.");
844 return sb_value;
845 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000846
Greg Clayton81e871e2012-02-04 02:27:34 +0000847 ValueObjectSP value_sp;
Jim Ingham4fc6cb92012-08-22 21:34:33 +0000848 Mutex::Locker api_locker;
849 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
850
Jason Molendab57e4a12013-11-04 09:33:30 +0000851 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +0000852 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +0000853 Process *process = exe_ctx.GetProcessPtr();
854 if (target && process)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000855 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000856 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000857 if (stop_locker.TryLock(&process->GetRunLock()))
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000858 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000859 frame = exe_ctx.GetFramePtr();
860 if (frame)
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000861 {
Enrico Granata8a2a0df2014-02-19 19:35:13 +0000862 VariableList variable_list;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000863
Jim Ingham7730b9a2012-11-29 00:26:19 +0000864 switch (value_type)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000865 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000866 case eValueTypeVariableGlobal: // global variable
867 case eValueTypeVariableStatic: // static variable
868 case eValueTypeVariableArgument: // function argument variables
869 case eValueTypeVariableLocal: // function local variables
870 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000871 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
Greg Clayton69b582f2010-12-14 18:39:31 +0000872
Jim Ingham7730b9a2012-11-29 00:26:19 +0000873 const bool can_create = true;
874 const bool get_parent_variables = true;
875 const bool stop_if_block_is_inlined_function = true;
Greg Clayton69b582f2010-12-14 18:39:31 +0000876
Jim Ingham7730b9a2012-11-29 00:26:19 +0000877 if (sc.block && sc.block->AppendVariables (can_create,
878 get_parent_variables,
879 stop_if_block_is_inlined_function,
Enrico Granata08a04322014-02-18 23:48:11 +0000880 &variable_list))
Jim Ingham7730b9a2012-11-29 00:26:19 +0000881 {
Enrico Granata8a2a0df2014-02-19 19:35:13 +0000882 if (value_type == eValueTypeVariableGlobal)
883 {
884 const bool get_file_globals = true;
885 VariableList* frame_vars = frame->GetVariableList(get_file_globals);
886 if (frame_vars)
887 frame_vars->AppendVariablesIfUnique(variable_list);
888 }
Jim Ingham7730b9a2012-11-29 00:26:19 +0000889 ConstString const_name(name);
Enrico Granata08a04322014-02-18 23:48:11 +0000890 VariableSP variable_sp(variable_list.FindVariable(const_name,value_type));
891 if (variable_sp)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000892 {
Enrico Granata08a04322014-02-18 23:48:11 +0000893 value_sp = frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues);
894 sb_value.SetSP (value_sp, use_dynamic);
895 break;
Jim Ingham7730b9a2012-11-29 00:26:19 +0000896 }
897 }
898 }
899 break;
900
901 case eValueTypeRegister: // stack frame register value
902 {
903 RegisterContextSP reg_ctx (frame->GetRegisterContext());
904 if (reg_ctx)
905 {
906 const uint32_t num_regs = reg_ctx->GetRegisterCount();
907 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
908 {
909 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
910 if (reg_info &&
911 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
912 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
913 {
914 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
915 sb_value.SetSP (value_sp);
916 break;
917 }
918 }
919 }
920 }
921 break;
922
923 case eValueTypeRegisterSet: // A collection of stack frame register values
924 {
925 RegisterContextSP reg_ctx (frame->GetRegisterContext());
926 if (reg_ctx)
927 {
928 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
929 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
930 {
931 const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx);
932 if (reg_set &&
933 ((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
934 (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
935 {
936 value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx);
937 sb_value.SetSP (value_sp);
938 break;
939 }
940 }
941 }
942 }
943 break;
944
945 case eValueTypeConstResult: // constant result variables
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000946 {
947 ConstString const_name(name);
Jim Ingham7730b9a2012-11-29 00:26:19 +0000948 ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
949 if (expr_var_sp)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000950 {
Jim Ingham7730b9a2012-11-29 00:26:19 +0000951 value_sp = expr_var_sp->GetValueObject();
952 sb_value.SetSP (value_sp, use_dynamic);
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000953 }
954 }
Jim Ingham7730b9a2012-11-29 00:26:19 +0000955 break;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000956
Jim Ingham7730b9a2012-11-29 00:26:19 +0000957 default:
958 break;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +0000959 }
Jim Ingham7730b9a2012-11-29 00:26:19 +0000960 }
961 else
962 {
963 if (log)
964 log->Printf ("SBFrame::FindValue () => error: could not reconstruct frame object for this SBFrame.");
Greg Clayton69b582f2010-12-14 18:39:31 +0000965 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000966 }
Greg Claytonc9858e42012-04-06 02:17:47 +0000967 else
968 {
969 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +0000970 log->Printf ("SBFrame::FindValue () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +0000971 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000972 }
Greg Clayton48381312010-10-30 04:51:46 +0000973
Saleem Abdulrasool324a1032014-04-04 04:06:10 +0000974 if (log)
975 log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)",
976 static_cast<void*>(frame), name, value_type,
977 static_cast<void*>(value_sp.get()));
978
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000979 return sb_value;
980}
981
982bool
Johnny Chen35e2ab62012-03-05 19:53:24 +0000983SBFrame::IsEqual (const SBFrame &that) const
984{
Jason Molendab57e4a12013-11-04 09:33:30 +0000985 lldb::StackFrameSP this_sp = GetFrameSP();
986 lldb::StackFrameSP that_sp = that.GetFrameSP();
Johnny Chen35e2ab62012-03-05 19:53:24 +0000987 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
988}
989
990bool
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000991SBFrame::operator == (const SBFrame &rhs) const
992{
Johnny Chen35e2ab62012-03-05 19:53:24 +0000993 return IsEqual(rhs);
Chris Lattner30fdc8d2010-06-08 16:52:24 +0000994}
995
996bool
997SBFrame::operator != (const SBFrame &rhs) const
998{
Johnny Chen35e2ab62012-03-05 19:53:24 +0000999 return !IsEqual(rhs);
Greg Clayton481cef22011-01-21 06:11:58 +00001000}
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001001
1002SBThread
1003SBFrame::GetThread () const
1004{
Greg Clayton5160ce52013-03-27 23:08:40 +00001005 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001006
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001007 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Claytond9e416c2012-02-18 05:35:26 +00001008 ThreadSP thread_sp (exe_ctx.GetThreadSP());
1009 SBThread sb_thread (thread_sp);
Caroline Ticeceb6b132010-10-26 03:11:13 +00001010
1011 if (log)
Caroline Tice750cd172010-10-26 23:49:36 +00001012 {
1013 SBStream sstr;
1014 sb_thread.GetDescription (sstr);
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001015 log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s",
1016 static_cast<void*>(exe_ctx.GetFramePtr()),
1017 static_cast<void*>(thread_sp.get()), sstr.GetData());
Caroline Tice750cd172010-10-26 23:49:36 +00001018 }
Caroline Ticeceb6b132010-10-26 03:11:13 +00001019
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001020 return sb_thread;
1021}
1022
1023const char *
1024SBFrame::Disassemble () const
1025{
Greg Clayton5160ce52013-03-27 23:08:40 +00001026 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton48381312010-10-30 04:51:46 +00001027 const char *disassembly = NULL;
Jim Ingham4fc6cb92012-08-22 21:34:33 +00001028 Mutex::Locker api_locker;
1029 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1030
Jason Molendab57e4a12013-11-04 09:33:30 +00001031 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +00001032 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +00001033 Process *process = exe_ctx.GetProcessPtr();
1034 if (target && process)
Greg Claytonaf67cec2010-12-20 20:49:23 +00001035 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001036 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001037 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001038 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001039 frame = exe_ctx.GetFramePtr();
1040 if (frame)
1041 {
1042 disassembly = frame->Disassemble();
1043 }
1044 else
1045 {
1046 if (log)
1047 log->Printf ("SBFrame::Disassemble () => error: could not reconstruct frame object for this SBFrame.");
1048 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001049 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001050 else
1051 {
1052 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001053 log->Printf ("SBFrame::Disassemble () => error: process is running");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001054 }
Greg Claytonaf67cec2010-12-20 20:49:23 +00001055 }
Greg Clayton48381312010-10-30 04:51:46 +00001056
1057 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001058 log->Printf ("SBFrame(%p)::Disassemble () => %s",
1059 static_cast<void*>(frame), disassembly);
Greg Clayton48381312010-10-30 04:51:46 +00001060
1061 return disassembly;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001062}
1063
1064
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001065SBValueList
1066SBFrame::GetVariables (bool arguments,
1067 bool locals,
1068 bool statics,
1069 bool in_scope_only)
1070{
Greg Clayton316d4982011-06-18 20:06:08 +00001071 SBValueList value_list;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001072 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +00001073 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytond9e416c2012-02-18 05:35:26 +00001074 Target *target = exe_ctx.GetTargetPtr();
1075 if (frame && target)
Greg Clayton316d4982011-06-18 20:06:08 +00001076 {
Greg Claytond9e416c2012-02-18 05:35:26 +00001077 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton316d4982011-06-18 20:06:08 +00001078 value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
1079 }
1080 return value_list;
Jim Ingham78a685a2011-04-16 00:01:13 +00001081}
1082
1083SBValueList
1084SBFrame::GetVariables (bool arguments,
1085 bool locals,
1086 bool statics,
1087 bool in_scope_only,
Jim Ingham2837b762011-05-04 03:43:18 +00001088 lldb::DynamicValueType use_dynamic)
Jim Ingham78a685a2011-04-16 00:01:13 +00001089{
Greg Clayton5160ce52013-03-27 23:08:40 +00001090 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001091
Greg Claytonb9556ac2012-01-30 07:41:31 +00001092 SBValueList value_list;
Jim Ingham4fc6cb92012-08-22 21:34:33 +00001093 Mutex::Locker api_locker;
1094 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1095
Jason Molendab57e4a12013-11-04 09:33:30 +00001096 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +00001097 Target *target = exe_ctx.GetTargetPtr();
Greg Claytonb9556ac2012-01-30 07:41:31 +00001098
Caroline Ticeceb6b132010-10-26 03:11:13 +00001099 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001100 log->Printf ("SBFrame::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)",
1101 arguments, locals, statics, in_scope_only);
1102
Jim Ingham7730b9a2012-11-29 00:26:19 +00001103 Process *process = exe_ctx.GetProcessPtr();
1104 if (target && process)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001105 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001106 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001107 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001108 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001109 frame = exe_ctx.GetFramePtr();
1110 if (frame)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001111 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001112 size_t i;
1113 VariableList *variable_list = NULL;
1114 variable_list = frame->GetVariableList(true);
1115 if (variable_list)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001116 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001117 const size_t num_variables = variable_list->GetSize();
1118 if (num_variables)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001119 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001120 for (i = 0; i < num_variables; ++i)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001121 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001122 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
1123 if (variable_sp)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001124 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001125 bool add_variable = false;
1126 switch (variable_sp->GetScope())
1127 {
1128 case eValueTypeVariableGlobal:
1129 case eValueTypeVariableStatic:
1130 add_variable = statics;
1131 break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001132
Jim Ingham7730b9a2012-11-29 00:26:19 +00001133 case eValueTypeVariableArgument:
1134 add_variable = arguments;
1135 break;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001136
Jim Ingham7730b9a2012-11-29 00:26:19 +00001137 case eValueTypeVariableLocal:
1138 add_variable = locals;
1139 break;
Greg Claytonc982c762010-07-09 20:39:50 +00001140
Jim Ingham7730b9a2012-11-29 00:26:19 +00001141 default:
1142 break;
1143 }
1144 if (add_variable)
1145 {
1146 if (in_scope_only && !variable_sp->IsInScope(frame))
1147 continue;
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001148
Jim Ingham7730b9a2012-11-29 00:26:19 +00001149 ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable (variable_sp, eNoDynamicValues));
1150 SBValue value_sb;
1151 value_sb.SetSP(valobj_sp,use_dynamic);
1152 value_list.Append(value_sb);
1153 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001154 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001155 }
1156 }
1157 }
1158 }
Jim Ingham7730b9a2012-11-29 00:26:19 +00001159 else
1160 {
1161 if (log)
1162 log->Printf ("SBFrame::GetVariables () => error: could not reconstruct frame object for this SBFrame.");
1163 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001164 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001165 else
1166 {
1167 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001168 log->Printf ("SBFrame::GetVariables () => error: process is running");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001169 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001170 }
Caroline Ticeceb6b132010-10-26 03:11:13 +00001171
1172 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001173 log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)",
1174 static_cast<void*>(frame),
1175 static_cast<void*>(value_list.opaque_ptr()));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001176
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001177 return value_list;
1178}
1179
Greg Clayton69b582f2010-12-14 18:39:31 +00001180SBValueList
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001181SBFrame::GetRegisters ()
1182{
Greg Clayton5160ce52013-03-27 23:08:40 +00001183 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001184
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001185 SBValueList value_list;
Jim Ingham4fc6cb92012-08-22 21:34:33 +00001186 Mutex::Locker api_locker;
1187 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1188
Jason Molendab57e4a12013-11-04 09:33:30 +00001189 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +00001190 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +00001191 Process *process = exe_ctx.GetProcessPtr();
1192 if (target && process)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001193 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001194 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001195 if (stop_locker.TryLock(&process->GetRunLock()))
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001196 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001197 frame = exe_ctx.GetFramePtr();
1198 if (frame)
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001199 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001200 RegisterContextSP reg_ctx (frame->GetRegisterContext());
1201 if (reg_ctx)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001202 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001203 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
1204 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
1205 {
1206 value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx));
1207 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001208 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001209 }
Jim Ingham7730b9a2012-11-29 00:26:19 +00001210 else
1211 {
1212 if (log)
1213 log->Printf ("SBFrame::GetRegisters () => error: could not reconstruct frame object for this SBFrame.");
1214 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001215 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001216 else
1217 {
1218 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001219 log->Printf ("SBFrame::GetRegisters () => error: process is running");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001220 }
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001221 }
Caroline Ticeceb6b132010-10-26 03:11:13 +00001222
1223 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001224 log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)",
1225 static_cast<void*>(frame),
1226 static_cast<void*>(value_list.opaque_ptr()));
Caroline Ticeceb6b132010-10-26 03:11:13 +00001227
Chris Lattner30fdc8d2010-06-08 16:52:24 +00001228 return value_list;
1229}
1230
Jason Molendaad9a53c2013-07-26 02:08:48 +00001231SBValue
1232SBFrame::FindRegister (const char *name)
1233{
1234 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1235
1236 SBValue result;
1237 ValueObjectSP value_sp;
1238 Mutex::Locker api_locker;
1239 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1240
Jason Molendab57e4a12013-11-04 09:33:30 +00001241 StackFrame *frame = NULL;
Jason Molendaad9a53c2013-07-26 02:08:48 +00001242 Target *target = exe_ctx.GetTargetPtr();
1243 Process *process = exe_ctx.GetProcessPtr();
1244 if (target && process)
1245 {
1246 Process::StopLocker stop_locker;
1247 if (stop_locker.TryLock(&process->GetRunLock()))
1248 {
1249 frame = exe_ctx.GetFramePtr();
1250 if (frame)
1251 {
1252 RegisterContextSP reg_ctx (frame->GetRegisterContext());
1253 if (reg_ctx)
1254 {
1255 const uint32_t num_regs = reg_ctx->GetRegisterCount();
1256 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
1257 {
1258 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
1259 if (reg_info &&
1260 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
1261 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
1262 {
1263 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
1264 result.SetSP (value_sp);
1265 break;
1266 }
1267 }
1268 }
1269 }
1270 else
1271 {
1272 if (log)
Jason Molenda5d353842013-07-26 22:52:30 +00001273 log->Printf ("SBFrame::FindRegister () => error: could not reconstruct frame object for this SBFrame.");
Jason Molendaad9a53c2013-07-26 02:08:48 +00001274 }
1275 }
1276 else
1277 {
1278 if (log)
Jason Molenda5d353842013-07-26 22:52:30 +00001279 log->Printf ("SBFrame::FindRegister () => error: process is running");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001280 }
Jason Molendaad9a53c2013-07-26 02:08:48 +00001281 }
1282
1283 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001284 log->Printf ("SBFrame(%p)::FindRegister () => SBValue(%p)",
1285 static_cast<void*>(frame),
1286 static_cast<void*>(value_sp.get()));
Jason Molendaad9a53c2013-07-26 02:08:48 +00001287
1288 return result;
1289}
1290
Caroline Ticedde9cff2010-09-20 05:20:02 +00001291bool
1292SBFrame::GetDescription (SBStream &description)
1293{
Greg Clayton5160ce52013-03-27 23:08:40 +00001294 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001295 Stream &strm = description.ref();
1296
Jim Ingham4fc6cb92012-08-22 21:34:33 +00001297 Mutex::Locker api_locker;
1298 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1299
Jason Molendab57e4a12013-11-04 09:33:30 +00001300 StackFrame *frame;
Greg Claytond9e416c2012-02-18 05:35:26 +00001301 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +00001302 Process *process = exe_ctx.GetProcessPtr();
1303 if (target && process)
Caroline Ticedde9cff2010-09-20 05:20:02 +00001304 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001305 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001306 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001307 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001308 frame = exe_ctx.GetFramePtr();
1309 if (frame)
1310 {
1311 frame->DumpUsingSettingsFormat (&strm);
1312 }
1313 else
1314 {
1315 if (log)
1316 log->Printf ("SBFrame::GetDescription () => error: could not reconstruct frame object for this SBFrame.");
1317 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001318 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001319 else
1320 {
Greg Claytonc9858e42012-04-06 02:17:47 +00001321 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001322 log->Printf ("SBFrame::GetDescription () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +00001323 }
1324
Caroline Ticedde9cff2010-09-20 05:20:02 +00001325 }
1326 else
Greg Claytonda7bc7d2011-11-13 06:57:31 +00001327 strm.PutCString ("No value");
Caroline Ticedde9cff2010-09-20 05:20:02 +00001328
1329 return true;
1330}
Greg Clayton1d3afba2010-10-05 00:00:42 +00001331
Greg Clayton69b582f2010-12-14 18:39:31 +00001332SBValue
Greg Clayton1d3afba2010-10-05 00:00:42 +00001333SBFrame::EvaluateExpression (const char *expr)
1334{
Greg Clayton316d4982011-06-18 20:06:08 +00001335 SBValue result;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001336 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +00001337 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytond9e416c2012-02-18 05:35:26 +00001338 Target *target = exe_ctx.GetTargetPtr();
1339 if (frame && target)
Greg Clayton316d4982011-06-18 20:06:08 +00001340 {
Jim Ingham35e1bda2012-10-16 21:41:58 +00001341 SBExpressionOptions options;
1342 lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Claytoncced1562012-10-16 22:58:25 +00001343 options.SetFetchDynamicValue (fetch_dynamic_value);
Jim Ingham35e1bda2012-10-16 21:41:58 +00001344 options.SetUnwindOnError (true);
1345 return EvaluateExpression (expr, options);
Greg Clayton316d4982011-06-18 20:06:08 +00001346 }
1347 return result;
Jim Ingham78a685a2011-04-16 00:01:13 +00001348}
1349
1350SBValue
Jim Ingham2837b762011-05-04 03:43:18 +00001351SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
Jim Ingham78a685a2011-04-16 00:01:13 +00001352{
Jim Ingham35e1bda2012-10-16 21:41:58 +00001353 SBExpressionOptions options;
Greg Claytoncced1562012-10-16 22:58:25 +00001354 options.SetFetchDynamicValue (fetch_dynamic_value);
Jim Ingham35e1bda2012-10-16 21:41:58 +00001355 options.SetUnwindOnError (true);
1356 return EvaluateExpression (expr, options);
Jim Ingham7ba6e992012-05-11 23:47:32 +00001357}
1358
1359SBValue
1360SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
1361{
Jim Ingham35e1bda2012-10-16 21:41:58 +00001362 SBExpressionOptions options;
Greg Claytoncced1562012-10-16 22:58:25 +00001363 options.SetFetchDynamicValue (fetch_dynamic_value);
Jim Ingham35e1bda2012-10-16 21:41:58 +00001364 options.SetUnwindOnError (unwind_on_error);
1365 return EvaluateExpression (expr, options);
1366}
1367
1368lldb::SBValue
1369SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
1370{
Greg Clayton5160ce52013-03-27 23:08:40 +00001371 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001372
Greg Clayton5160ce52013-03-27 23:08:40 +00001373 Log *expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Greg Clayton48381312010-10-30 04:51:46 +00001374
Greg Clayton23f59502012-07-17 03:23:13 +00001375 ExecutionResults exe_results = eExecutionSetupError;
Greg Clayton69b582f2010-12-14 18:39:31 +00001376 SBValue expr_result;
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001377
Jim Ingham7730b9a2012-11-29 00:26:19 +00001378 if (expr == NULL || expr[0] == '\0')
1379 {
1380 if (log)
1381 log->Printf ("SBFrame::EvaluateExpression called with an empty expression");
1382 return expr_result;
1383 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001384
Greg Clayton81e871e2012-02-04 02:27:34 +00001385 ValueObjectSP expr_value_sp;
Greg Clayton48381312010-10-30 04:51:46 +00001386
Jim Ingham4fc6cb92012-08-22 21:34:33 +00001387 Mutex::Locker api_locker;
1388 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1389
Greg Claytonb9556ac2012-01-30 07:41:31 +00001390 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001391 log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr);
Greg Claytonb9556ac2012-01-30 07:41:31 +00001392
Jason Molendab57e4a12013-11-04 09:33:30 +00001393 StackFrame *frame = NULL;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001394 Target *target = exe_ctx.GetTargetPtr();
1395 Process *process = exe_ctx.GetProcessPtr();
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001396
Jim Ingham7730b9a2012-11-29 00:26:19 +00001397 if (target && process)
1398 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001399 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001400 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001401 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001402 frame = exe_ctx.GetFramePtr();
1403 if (frame)
1404 {
Greg Claytonfb6621e2013-12-06 21:59:52 +00001405 if (target->GetDisplayExpressionsInCrashlogs())
1406 {
1407 StreamString frame_description;
1408 frame->DumpUsingSettingsFormat (&frame_description);
1409 Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
1410 expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str());
1411 }
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001412
Greg Claytonfb6621e2013-12-06 21:59:52 +00001413 exe_results = target->EvaluateExpression (expr,
Jim Ingham7730b9a2012-11-29 00:26:19 +00001414 frame,
1415 expr_value_sp,
1416 options.ref());
1417 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
Greg Claytonfb6621e2013-12-06 21:59:52 +00001418
1419 if (target->GetDisplayExpressionsInCrashlogs())
1420 Host::SetCrashDescription (NULL);
Jim Ingham7730b9a2012-11-29 00:26:19 +00001421 }
1422 else
1423 {
1424 if (log)
1425 log->Printf ("SBFrame::EvaluateExpression () => error: could not reconstruct frame object for this SBFrame.");
1426 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001427 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001428 else
1429 {
1430 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001431 log->Printf ("SBFrame::EvaluateExpression () => error: process is running");
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001432 }
Greg Clayton1d3afba2010-10-05 00:00:42 +00001433 }
Jason Molendacf7e2dc2012-02-21 05:33:55 +00001434
1435#ifndef LLDB_DISABLE_PYTHON
Sean Callanana162eba2010-12-07 22:55:01 +00001436 if (expr_log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001437 expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **",
1438 expr_result.GetValue(), expr_result.GetSummary());
1439
Greg Clayton48381312010-10-30 04:51:46 +00001440 if (log)
Saleem Abdulrasool324a1032014-04-04 04:06:10 +00001441 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
1442 static_cast<void*>(frame), expr,
1443 static_cast<void*>(expr_value_sp.get()), exe_results);
Jason Molendacf7e2dc2012-02-21 05:33:55 +00001444#endif
Greg Clayton48381312010-10-30 04:51:46 +00001445
Greg Claytoncfd1ace2010-10-31 03:01:06 +00001446 return expr_result;
Greg Clayton1d3afba2010-10-05 00:00:42 +00001447}
Greg Clayton316d4982011-06-18 20:06:08 +00001448
1449bool
1450SBFrame::IsInlined()
1451{
Greg Clayton5160ce52013-03-27 23:08:40 +00001452 Log *log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001453 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +00001454 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +00001455 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +00001456 Process *process = exe_ctx.GetProcessPtr();
1457 if (target && process)
Greg Clayton316d4982011-06-18 20:06:08 +00001458 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001459 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001460 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001461 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001462 frame = exe_ctx.GetFramePtr();
1463 if (frame)
1464 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001465
Jim Ingham7730b9a2012-11-29 00:26:19 +00001466 Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
1467 if (block)
1468 return block->GetContainingInlinedBlock () != NULL;
1469 }
1470 else
1471 {
1472 if (log)
1473 log->Printf ("SBFrame::IsInlined () => error: could not reconstruct frame object for this SBFrame.");
1474 }
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001475 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001476 else
1477 {
Greg Claytonc9858e42012-04-06 02:17:47 +00001478 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001479 log->Printf ("SBFrame::IsInlined () => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +00001480 }
1481
Greg Clayton316d4982011-06-18 20:06:08 +00001482 }
1483 return false;
1484}
1485
1486const char *
1487SBFrame::GetFunctionName()
1488{
Greg Clayton5160ce52013-03-27 23:08:40 +00001489 Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton316d4982011-06-18 20:06:08 +00001490 const char *name = NULL;
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001491 ExecutionContext exe_ctx(m_opaque_sp.get());
Jason Molendab57e4a12013-11-04 09:33:30 +00001492 StackFrame *frame = NULL;
Greg Claytond9e416c2012-02-18 05:35:26 +00001493 Target *target = exe_ctx.GetTargetPtr();
Jim Ingham7730b9a2012-11-29 00:26:19 +00001494 Process *process = exe_ctx.GetProcessPtr();
1495 if (target && process)
Greg Clayton316d4982011-06-18 20:06:08 +00001496 {
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001497 Process::StopLocker stop_locker;
Jim Ingham7730b9a2012-11-29 00:26:19 +00001498 if (stop_locker.TryLock(&process->GetRunLock()))
Greg Clayton316d4982011-06-18 20:06:08 +00001499 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001500 frame = exe_ctx.GetFramePtr();
1501 if (frame)
Greg Clayton316d4982011-06-18 20:06:08 +00001502 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001503 SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
1504 if (sc.block)
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001505 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001506 Block *inlined_block = sc.block->GetContainingInlinedBlock ();
1507 if (inlined_block)
1508 {
1509 const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo();
1510 name = inlined_info->GetName().AsCString();
1511 }
1512 }
1513
1514 if (name == NULL)
1515 {
1516 if (sc.function)
1517 name = sc.function->GetName().GetCString();
1518 }
1519
1520 if (name == NULL)
1521 {
1522 if (sc.symbol)
1523 name = sc.symbol->GetName().GetCString();
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001524 }
Greg Clayton316d4982011-06-18 20:06:08 +00001525 }
Jim Ingham7730b9a2012-11-29 00:26:19 +00001526 else
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001527 {
Jim Ingham7730b9a2012-11-29 00:26:19 +00001528 if (log)
1529 log->Printf ("SBFrame::GetFunctionName () => error: could not reconstruct frame object for this SBFrame.");
Greg Clayton7fdf9ef2012-04-05 16:12:35 +00001530 }
Greg Clayton316d4982011-06-18 20:06:08 +00001531 }
Greg Claytonc9858e42012-04-06 02:17:47 +00001532 else
1533 {
Greg Claytonc9858e42012-04-06 02:17:47 +00001534 if (log)
Jim Ingham7730b9a2012-11-29 00:26:19 +00001535 log->Printf ("SBFrame::GetFunctionName() => error: process is running");
Greg Claytonc9858e42012-04-06 02:17:47 +00001536
1537 }
Greg Clayton316d4982011-06-18 20:06:08 +00001538 }
1539 return name;
1540}
1541