blob: f89c25b27e1c58e359dd79084be49fd32b5a4449 [file] [log] [blame]
Chris Lattner24943d22010-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 Friedman7a62c8b2010-06-09 07:44:37 +000010#include "lldb/API/SBFrame.h"
Chris Lattner24943d22010-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 Tice7826c882010-10-26 03:11:13 +000019#include "lldb/Core/Log.h"
Chris Lattner24943d22010-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 Claytond1719722010-10-05 03:13:51 +000024#include "lldb/Expression/ClangUserExpression.h"
Greg Clayton87ac9022011-06-25 04:35:01 +000025#include "lldb/Host/Host.h"
Chris Lattner24943d22010-06-08 16:52:24 +000026#include "lldb/Symbol/Block.h"
Greg Clayton49ce8962012-08-29 21:13:06 +000027#include "lldb/Symbol/Function.h"
28#include "lldb/Symbol/Symbol.h"
Chris Lattner24943d22010-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"
36#include "lldb/Target/StackFrame.h"
Greg Clayton334d33a2012-01-30 07:41:31 +000037#include "lldb/Target/StackID.h"
Chris Lattner24943d22010-06-08 16:52:24 +000038#include "lldb/Target/Thread.h"
39
Eli Friedman7a62c8b2010-06-09 07:44:37 +000040#include "lldb/API/SBDebugger.h"
41#include "lldb/API/SBValue.h"
42#include "lldb/API/SBAddress.h"
Jim Ingham47beabb2012-10-16 21:41:58 +000043#include "lldb/API/SBExpressionOptions.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000044#include "lldb/API/SBStream.h"
Eli Friedman7a62c8b2010-06-09 07:44:37 +000045#include "lldb/API/SBSymbolContext.h"
46#include "lldb/API/SBThread.h"
Chris Lattner24943d22010-06-08 16:52:24 +000047
48using namespace lldb;
49using namespace lldb_private;
50
Greg Clayton334d33a2012-01-30 07:41:31 +000051
Chris Lattner24943d22010-06-08 16:52:24 +000052SBFrame::SBFrame () :
Greg Claytona894fe72012-04-05 16:12:35 +000053 m_opaque_sp (new ExecutionContextRef())
Chris Lattner24943d22010-06-08 16:52:24 +000054{
55}
56
Greg Clayton4e9267d2010-12-14 18:39:31 +000057SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) :
Greg Claytona894fe72012-04-05 16:12:35 +000058 m_opaque_sp (new ExecutionContextRef (lldb_object_sp))
Chris Lattner24943d22010-06-08 16:52:24 +000059{
Greg Clayton4e9267d2010-12-14 18:39:31 +000060 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +000061
62 if (log)
63 {
64 SBStream sstr;
65 GetDescription (sstr);
Greg Claytona66ba462010-10-30 04:51:46 +000066 log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
Greg Clayton334d33a2012-01-30 07:41:31 +000067 lldb_object_sp.get(), lldb_object_sp.get(), sstr.GetData());
Caroline Tice61ba7ec2010-10-26 23:49:36 +000068
Caroline Tice7826c882010-10-26 03:11:13 +000069 }
Chris Lattner24943d22010-06-08 16:52:24 +000070}
71
Greg Clayton538eb822010-11-05 23:17:00 +000072SBFrame::SBFrame(const SBFrame &rhs) :
Greg Claytona894fe72012-04-05 16:12:35 +000073 m_opaque_sp (new ExecutionContextRef (*rhs.m_opaque_sp))
Greg Clayton538eb822010-11-05 23:17:00 +000074{
75}
76
77const SBFrame &
78SBFrame::operator = (const SBFrame &rhs)
79{
80 if (this != &rhs)
Greg Claytona894fe72012-04-05 16:12:35 +000081 *m_opaque_sp = *rhs.m_opaque_sp;
Greg Clayton538eb822010-11-05 23:17:00 +000082 return *this;
83}
84
Chris Lattner24943d22010-06-08 16:52:24 +000085SBFrame::~SBFrame()
86{
87}
88
Greg Clayton334d33a2012-01-30 07:41:31 +000089StackFrameSP
90SBFrame::GetFrameSP() const
Chris Lattner24943d22010-06-08 16:52:24 +000091{
Greg Clayton26425852012-04-12 20:58:26 +000092 if (m_opaque_sp)
93 return m_opaque_sp->GetFrameSP();
94 return StackFrameSP();
Chris Lattner24943d22010-06-08 16:52:24 +000095}
96
Greg Clayton334d33a2012-01-30 07:41:31 +000097void
98SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
99{
Greg Claytona894fe72012-04-05 16:12:35 +0000100 return m_opaque_sp->SetFrameSP(lldb_object_sp);
Greg Clayton334d33a2012-01-30 07:41:31 +0000101}
Chris Lattner24943d22010-06-08 16:52:24 +0000102
103bool
104SBFrame::IsValid() const
105{
Greg Claytona894fe72012-04-05 16:12:35 +0000106 return GetFrameSP().get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000107}
108
109SBSymbolContext
110SBFrame::GetSymbolContext (uint32_t resolve_scope) const
111{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000112 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner24943d22010-06-08 16:52:24 +0000113 SBSymbolContext sb_sym_ctx;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000114 Mutex::Locker api_locker;
115 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
116
Greg Clayton289afcb2012-02-18 05:35:26 +0000117 StackFrame *frame = exe_ctx.GetFramePtr();
118 Target *target = exe_ctx.GetTargetPtr();
119 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000120 {
Greg Claytona894fe72012-04-05 16:12:35 +0000121 Process::StopLocker stop_locker;
122 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
123 {
Greg Claytona894fe72012-04-05 16:12:35 +0000124 sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext (resolve_scope));
125 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000126 else
127 {
128 if (log)
129 log->Printf ("SBFrame(%p)::GetSymbolContext () => error: process is running", frame);
130 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000131 }
Caroline Tice7826c882010-10-26 03:11:13 +0000132
133 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000134 log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000135 frame, resolve_scope, sb_sym_ctx.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000136
Chris Lattner24943d22010-06-08 16:52:24 +0000137 return sb_sym_ctx;
138}
139
140SBModule
141SBFrame::GetModule () const
142{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000143 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000144 SBModule sb_module;
Greg Clayton0416bdf2012-01-30 09:04:36 +0000145 ModuleSP module_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000146 Mutex::Locker api_locker;
147 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
148
Greg Clayton289afcb2012-02-18 05:35:26 +0000149 StackFrame *frame = exe_ctx.GetFramePtr();
150 Target *target = exe_ctx.GetTargetPtr();
151 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000152 {
Greg Claytona894fe72012-04-05 16:12:35 +0000153 Process::StopLocker stop_locker;
154 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
155 {
Greg Claytona894fe72012-04-05 16:12:35 +0000156 module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp;
157 sb_module.SetSP (module_sp);
158 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000159 else
160 {
161 if (log)
162 log->Printf ("SBFrame(%p)::GetModule () => error: process is running", frame);
163 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000164 }
Greg Claytondd62d722010-12-14 04:58:53 +0000165
Greg Claytona66ba462010-10-30 04:51:46 +0000166 if (log)
167 log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000168 frame, module_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000169
Chris Lattner24943d22010-06-08 16:52:24 +0000170 return sb_module;
171}
172
173SBCompileUnit
174SBFrame::GetCompileUnit () const
175{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000176 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000177 SBCompileUnit sb_comp_unit;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000178 Mutex::Locker api_locker;
179 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
180
Greg Clayton289afcb2012-02-18 05:35:26 +0000181 StackFrame *frame = exe_ctx.GetFramePtr();
182 Target *target = exe_ctx.GetTargetPtr();
183 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000184 {
Greg Claytona894fe72012-04-05 16:12:35 +0000185 Process::StopLocker stop_locker;
186 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
187 {
Greg Claytona894fe72012-04-05 16:12:35 +0000188 sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
189 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000190 else
191 {
192 if (log)
193 log->Printf ("SBFrame(%p)::GetCompileUnit () => error: process is running", frame);
194 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000195 }
Caroline Tice7826c882010-10-26 03:11:13 +0000196 if (log)
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000197 log->Printf ("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000198 frame, sb_comp_unit.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000199
Chris Lattner24943d22010-06-08 16:52:24 +0000200 return sb_comp_unit;
201}
202
203SBFunction
204SBFrame::GetFunction () const
205{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000206 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000207 SBFunction sb_function;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000208 Mutex::Locker api_locker;
209 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
210
Greg Clayton289afcb2012-02-18 05:35:26 +0000211 StackFrame *frame = exe_ctx.GetFramePtr();
212 Target *target = exe_ctx.GetTargetPtr();
213 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000214 {
Greg Claytona894fe72012-04-05 16:12:35 +0000215 Process::StopLocker stop_locker;
216 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
217 {
Greg Claytona894fe72012-04-05 16:12:35 +0000218 sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function);
219 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000220 else
221 {
222 if (log)
223 log->Printf ("SBFrame(%p)::GetFunction () => error: process is running", frame);
224 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000225 }
Greg Claytona66ba462010-10-30 04:51:46 +0000226 if (log)
227 log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000228 frame, sb_function.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000229
Chris Lattner24943d22010-06-08 16:52:24 +0000230 return sb_function;
231}
232
Greg Clayton8f1e08b2010-10-04 18:37:52 +0000233SBSymbol
234SBFrame::GetSymbol () const
235{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000236 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000237 SBSymbol sb_symbol;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000238 Mutex::Locker api_locker;
239 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
240
Greg Clayton289afcb2012-02-18 05:35:26 +0000241 StackFrame *frame = exe_ctx.GetFramePtr();
242 Target *target = exe_ctx.GetTargetPtr();
243 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000244 {
Greg Claytona894fe72012-04-05 16:12:35 +0000245 Process::StopLocker stop_locker;
246 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
247 {
Greg Claytona894fe72012-04-05 16:12:35 +0000248 sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol);
249 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000250 else
251 {
252 if (log)
253 log->Printf ("SBFrame(%p)::GetSymbol () => error: process is running", frame);
254 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000255 }
Greg Claytona66ba462010-10-30 04:51:46 +0000256 if (log)
257 log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000258 frame, sb_symbol.get());
Greg Clayton8f1e08b2010-10-04 18:37:52 +0000259 return sb_symbol;
260}
261
Chris Lattner24943d22010-06-08 16:52:24 +0000262SBBlock
263SBFrame::GetBlock () const
264{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000265 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000266 SBBlock sb_block;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000267 Mutex::Locker api_locker;
268 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
269
Greg Clayton289afcb2012-02-18 05:35:26 +0000270 StackFrame *frame = exe_ctx.GetFramePtr();
271 Target *target = exe_ctx.GetTargetPtr();
272 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000273 {
Greg Claytona894fe72012-04-05 16:12:35 +0000274 Process::StopLocker stop_locker;
275 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
276 {
Greg Claytona894fe72012-04-05 16:12:35 +0000277 sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block);
278 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000279 else
280 {
281 if (log)
282 log->Printf ("SBFrame(%p)::GetBlock () => error: process is running", frame);
283 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000284 }
Greg Claytona66ba462010-10-30 04:51:46 +0000285 if (log)
286 log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000287 frame, sb_block.GetPtr());
Chris Lattner24943d22010-06-08 16:52:24 +0000288 return sb_block;
289}
290
Greg Clayton69aa5d92010-09-07 04:20:48 +0000291SBBlock
292SBFrame::GetFrameBlock () const
293{
Greg Claytondd62d722010-12-14 04:58:53 +0000294 SBBlock sb_block;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000295 Mutex::Locker api_locker;
296 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
297
Greg Clayton289afcb2012-02-18 05:35:26 +0000298 StackFrame *frame = exe_ctx.GetFramePtr();
299 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000300 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton289afcb2012-02-18 05:35:26 +0000301 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000302 {
Greg Claytona894fe72012-04-05 16:12:35 +0000303 Process::StopLocker stop_locker;
304 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
305 {
Greg Claytona894fe72012-04-05 16:12:35 +0000306 sb_block.SetPtr(frame->GetFrameBlock ());
307 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000308 else
309 {
310 if (log)
311 log->Printf ("SBFrame(%p)::GetFrameBlock () => error: process is running", frame);
312 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000313 }
Greg Claytona66ba462010-10-30 04:51:46 +0000314 if (log)
315 log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000316 frame, sb_block.GetPtr());
Greg Clayton69aa5d92010-09-07 04:20:48 +0000317 return sb_block;
318}
319
Chris Lattner24943d22010-06-08 16:52:24 +0000320SBLineEntry
321SBFrame::GetLineEntry () const
322{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000323 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000324 SBLineEntry sb_line_entry;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000325 Mutex::Locker api_locker;
326 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
327
Greg Clayton289afcb2012-02-18 05:35:26 +0000328 StackFrame *frame = exe_ctx.GetFramePtr();
329 Target *target = exe_ctx.GetTargetPtr();
330 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000331 {
Greg Claytona894fe72012-04-05 16:12:35 +0000332 Process::StopLocker stop_locker;
333 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
334 {
Greg Claytona894fe72012-04-05 16:12:35 +0000335 sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry);
336 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000337 else
338 {
339 if (log)
340 log->Printf ("SBFrame(%p)::GetLineEntry () => error: process is running", frame);
341 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000342 }
Greg Claytona66ba462010-10-30 04:51:46 +0000343 if (log)
344 log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000345 frame, sb_line_entry.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000346 return sb_line_entry;
347}
348
349uint32_t
350SBFrame::GetFrameID () const
351{
Greg Clayton334d33a2012-01-30 07:41:31 +0000352 uint32_t frame_idx = UINT32_MAX;
353
Greg Claytona894fe72012-04-05 16:12:35 +0000354 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000355 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytona894fe72012-04-05 16:12:35 +0000356 if (frame)
Greg Clayton289afcb2012-02-18 05:35:26 +0000357 frame_idx = frame->GetFrameIndex ();
Greg Claytona66ba462010-10-30 04:51:46 +0000358
Greg Clayton4e9267d2010-12-14 18:39:31 +0000359 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000360 if (log)
361 log->Printf ("SBFrame(%p)::GetFrameID () => %u",
Greg Clayton289afcb2012-02-18 05:35:26 +0000362 frame, frame_idx);
Greg Claytona66ba462010-10-30 04:51:46 +0000363 return frame_idx;
Chris Lattner24943d22010-06-08 16:52:24 +0000364}
365
Greg Clayton4e9267d2010-12-14 18:39:31 +0000366addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000367SBFrame::GetPC () const
368{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000369 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000370 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000371 Mutex::Locker api_locker;
372 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
373
Greg Clayton289afcb2012-02-18 05:35:26 +0000374 StackFrame *frame = exe_ctx.GetFramePtr();
375 Target *target = exe_ctx.GetTargetPtr();
376 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000377 {
Greg Claytona894fe72012-04-05 16:12:35 +0000378 Process::StopLocker stop_locker;
379 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
380 {
Greg Claytona894fe72012-04-05 16:12:35 +0000381 addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
382 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000383 else
384 {
385 if (log)
386 log->Printf ("SBFrame(%p)::GetPC () => error: process is running", frame);
387 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000388 }
Caroline Tice7826c882010-10-26 03:11:13 +0000389
390 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000391 log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", frame, addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000392
393 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000394}
395
396bool
Greg Clayton4e9267d2010-12-14 18:39:31 +0000397SBFrame::SetPC (addr_t new_pc)
Chris Lattner24943d22010-06-08 16:52:24 +0000398{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000399 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000400 bool ret_val = false;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000401 Mutex::Locker api_locker;
402 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
403
Greg Clayton289afcb2012-02-18 05:35:26 +0000404 StackFrame *frame = exe_ctx.GetFramePtr();
405 Target *target = exe_ctx.GetTargetPtr();
406 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000407 {
Greg Claytona894fe72012-04-05 16:12:35 +0000408 Process::StopLocker stop_locker;
409 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
410 {
Greg Claytona894fe72012-04-05 16:12:35 +0000411 ret_val = frame->GetRegisterContext()->SetPC (new_pc);
412 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000413 else
414 {
415 if (log)
416 log->Printf ("SBFrame(%p)::SetPC () => error: process is running", frame);
417 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000418 }
Caroline Tice7826c882010-10-26 03:11:13 +0000419
420 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000421 log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i",
Greg Clayton289afcb2012-02-18 05:35:26 +0000422 frame, new_pc, ret_val);
Caroline Tice7826c882010-10-26 03:11:13 +0000423
424 return ret_val;
Chris Lattner24943d22010-06-08 16:52:24 +0000425}
426
Greg Clayton4e9267d2010-12-14 18:39:31 +0000427addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000428SBFrame::GetSP () const
429{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000430 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000431 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000432 Mutex::Locker api_locker;
433 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
434
Greg Clayton289afcb2012-02-18 05:35:26 +0000435 StackFrame *frame = exe_ctx.GetFramePtr();
436 Target *target = exe_ctx.GetTargetPtr();
437 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000438 {
Greg Claytona894fe72012-04-05 16:12:35 +0000439 Process::StopLocker stop_locker;
440 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
441 {
Greg Claytona894fe72012-04-05 16:12:35 +0000442 addr = frame->GetRegisterContext()->GetSP();
443 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000444 else
445 {
446 if (log)
447 log->Printf ("SBFrame(%p)::GetSP () => error: process is running", frame);
448 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000449 }
Greg Claytona66ba462010-10-30 04:51:46 +0000450 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000451 log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", frame, addr);
Greg Claytona66ba462010-10-30 04:51:46 +0000452
453 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000454}
455
456
Greg Clayton4e9267d2010-12-14 18:39:31 +0000457addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000458SBFrame::GetFP () const
459{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000460 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000461 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000462 Mutex::Locker api_locker;
463 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
464
Greg Clayton289afcb2012-02-18 05:35:26 +0000465 StackFrame *frame = exe_ctx.GetFramePtr();
466 Target *target = exe_ctx.GetTargetPtr();
467 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000468 {
Greg Claytona894fe72012-04-05 16:12:35 +0000469 Process::StopLocker stop_locker;
470 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
471 {
Greg Claytona894fe72012-04-05 16:12:35 +0000472 addr = frame->GetRegisterContext()->GetFP();
473 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000474 else
475 {
476 if (log)
477 log->Printf ("SBFrame(%p)::GetFP () => error: process is running", frame);
478 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000479 }
Caroline Tice7826c882010-10-26 03:11:13 +0000480
481 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000482 log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", frame, addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000483 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000484}
485
486
487SBAddress
488SBFrame::GetPCAddress () const
489{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000490 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner24943d22010-06-08 16:52:24 +0000491 SBAddress sb_addr;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000492 Mutex::Locker api_locker;
493 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
494
Greg Clayton289afcb2012-02-18 05:35:26 +0000495 StackFrame *frame = exe_ctx.GetFramePtr();
496 Target *target = exe_ctx.GetTargetPtr();
497 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000498 {
Greg Claytona894fe72012-04-05 16:12:35 +0000499 Process::StopLocker stop_locker;
500 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
501 {
Greg Claytona894fe72012-04-05 16:12:35 +0000502 sb_addr.SetAddress (&frame->GetFrameCodeAddress());
503 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000504 else
505 {
506 if (log)
507 log->Printf ("SBFrame(%p)::GetPCAddress () => error: process is running", frame);
508 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000509 }
Greg Claytona66ba462010-10-30 04:51:46 +0000510 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000511 log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame, sb_addr.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000512 return sb_addr;
513}
514
515void
516SBFrame::Clear()
517{
Greg Clayton26425852012-04-12 20:58:26 +0000518 m_opaque_sp->Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000519}
520
Greg Claytond62b9c12012-02-03 07:02:37 +0000521lldb::SBValue
522SBFrame::GetValueForVariablePath (const char *var_path)
523{
524 SBValue sb_value;
Greg Claytona894fe72012-04-05 16:12:35 +0000525 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000526 StackFrame *frame = exe_ctx.GetFramePtr();
527 Target *target = exe_ctx.GetTargetPtr();
528 if (frame && target)
Greg Claytond62b9c12012-02-03 07:02:37 +0000529 {
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000530 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
531 sb_value = GetValueForVariablePath (var_path, use_dynamic);
Greg Claytond62b9c12012-02-03 07:02:37 +0000532 }
533 return sb_value;
534}
535
536lldb::SBValue
537SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
538{
539 SBValue sb_value;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000540 Mutex::Locker api_locker;
541 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
542
Greg Clayton289afcb2012-02-18 05:35:26 +0000543 StackFrame *frame = exe_ctx.GetFramePtr();
544 Target *target = exe_ctx.GetTargetPtr();
545 if (frame && target && var_path && var_path[0])
Greg Claytond62b9c12012-02-03 07:02:37 +0000546 {
Greg Claytona894fe72012-04-05 16:12:35 +0000547 Process::StopLocker stop_locker;
548 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
549 {
Greg Claytona894fe72012-04-05 16:12:35 +0000550 VariableSP var_sp;
551 Error error;
552 ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path,
553 use_dynamic,
Greg Claytonb3a1a2b2012-07-14 00:53:55 +0000554 StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
Greg Claytona894fe72012-04-05 16:12:35 +0000555 var_sp,
556 error));
557 sb_value.SetSP(value_sp);
558 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000559 else
560 {
561 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
562 if (log)
563 log->Printf ("SBFrame(%p)::GetValueForVariablePath () => error: process is running", frame);
564 }
Greg Claytond62b9c12012-02-03 07:02:37 +0000565 }
566 return sb_value;
567}
568
Chris Lattner24943d22010-06-08 16:52:24 +0000569SBValue
Greg Clayton4e9267d2010-12-14 18:39:31 +0000570SBFrame::FindVariable (const char *name)
Chris Lattner24943d22010-06-08 16:52:24 +0000571{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000572 SBValue value;
Greg Claytona894fe72012-04-05 16:12:35 +0000573 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000574 StackFrame *frame = exe_ctx.GetFramePtr();
575 Target *target = exe_ctx.GetTargetPtr();
576 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000577 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000578 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000579 value = FindVariable (name, use_dynamic);
580 }
581 return value;
Jim Inghame41494a2011-04-16 00:01:13 +0000582}
Greg Claytond62b9c12012-02-03 07:02:37 +0000583
Jim Inghame41494a2011-04-16 00:01:13 +0000584
585SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000586SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000587{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000588 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000589 VariableSP var_sp;
Jim Ingham47da8102011-04-22 23:53:53 +0000590 SBValue sb_value;
Greg Clayton0a19a1b2012-02-04 02:27:34 +0000591 ValueObjectSP value_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000592 Mutex::Locker api_locker;
593 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
594
Greg Clayton289afcb2012-02-18 05:35:26 +0000595 StackFrame *frame = exe_ctx.GetFramePtr();
596 Target *target = exe_ctx.GetTargetPtr();
597 if (frame && target && name && name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000598 {
Greg Claytona894fe72012-04-05 16:12:35 +0000599 Process::StopLocker stop_locker;
600 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000601 {
Greg Claytona894fe72012-04-05 16:12:35 +0000602 VariableList variable_list;
Greg Claytona894fe72012-04-05 16:12:35 +0000603 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
604
605 if (sc.block)
Greg Claytondd62d722010-12-14 04:58:53 +0000606 {
Greg Claytona894fe72012-04-05 16:12:35 +0000607 const bool can_create = true;
608 const bool get_parent_variables = true;
609 const bool stop_if_block_is_inlined_function = true;
610
611 if (sc.block->AppendVariables (can_create,
612 get_parent_variables,
613 stop_if_block_is_inlined_function,
614 &variable_list))
615 {
616 var_sp = variable_list.FindVariable (ConstString(name));
617 }
618 }
619
620 if (var_sp)
621 {
622 value_sp = frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
623 sb_value.SetSP(value_sp);
Greg Claytondd62d722010-12-14 04:58:53 +0000624 }
Chris Lattner24943d22010-06-08 16:52:24 +0000625 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000626 else
627 {
628 if (log)
629 log->Printf ("SBFrame(%p)::FindVariable () => error: process is running", frame);
630 }
Chris Lattner24943d22010-06-08 16:52:24 +0000631 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000632
Greg Claytona66ba462010-10-30 04:51:46 +0000633 if (log)
Greg Clayton4e9267d2010-12-14 18:39:31 +0000634 log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000635 frame, name, value_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000636
Chris Lattner24943d22010-06-08 16:52:24 +0000637 return sb_value;
638}
639
640SBValue
Greg Clayton4e9267d2010-12-14 18:39:31 +0000641SBFrame::FindValue (const char *name, ValueType value_type)
Chris Lattner24943d22010-06-08 16:52:24 +0000642{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000643 SBValue value;
Greg Claytona894fe72012-04-05 16:12:35 +0000644 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000645 StackFrame *frame = exe_ctx.GetFramePtr();
646 Target *target = exe_ctx.GetTargetPtr();
647 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000648 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000649 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000650 value = FindValue (name, value_type, use_dynamic);
651 }
652 return value;
Jim Inghame41494a2011-04-16 00:01:13 +0000653}
654
655SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000656SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000657{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000658 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000659 SBValue sb_value;
Greg Clayton0a19a1b2012-02-04 02:27:34 +0000660 ValueObjectSP value_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000661 Mutex::Locker api_locker;
662 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
663
Greg Clayton289afcb2012-02-18 05:35:26 +0000664 StackFrame *frame = exe_ctx.GetFramePtr();
665 Target *target = exe_ctx.GetTargetPtr();
666 if (frame && target && name && name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000667 {
Greg Claytona894fe72012-04-05 16:12:35 +0000668 Process::StopLocker stop_locker;
669 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000670 {
Greg Claytona894fe72012-04-05 16:12:35 +0000671 switch (value_type)
Chris Lattner24943d22010-06-08 16:52:24 +0000672 {
Greg Claytona894fe72012-04-05 16:12:35 +0000673 case eValueTypeVariableGlobal: // global variable
674 case eValueTypeVariableStatic: // static variable
675 case eValueTypeVariableArgument: // function argument variables
676 case eValueTypeVariableLocal: // function local variables
677 {
678 VariableList *variable_list = frame->GetVariableList(true);
Greg Clayton4e9267d2010-12-14 18:39:31 +0000679
Greg Claytona894fe72012-04-05 16:12:35 +0000680 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000681
Greg Claytona894fe72012-04-05 16:12:35 +0000682 const bool can_create = true;
683 const bool get_parent_variables = true;
684 const bool stop_if_block_is_inlined_function = true;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000685
Greg Claytona894fe72012-04-05 16:12:35 +0000686 if (sc.block && sc.block->AppendVariables (can_create,
687 get_parent_variables,
688 stop_if_block_is_inlined_function,
689 variable_list))
690 {
691 ConstString const_name(name);
692 const uint32_t num_variables = variable_list->GetSize();
693 for (uint32_t i = 0; i < num_variables; ++i)
694 {
695 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
696 if (variable_sp &&
697 variable_sp->GetScope() == value_type &&
698 variable_sp->GetName() == const_name)
699 {
700 value_sp = frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic);
701 sb_value.SetSP (value_sp);
702 break;
703 }
704 }
705 }
706 }
707 break;
708
709 case eValueTypeRegister: // stack frame register value
710 {
711 RegisterContextSP reg_ctx (frame->GetRegisterContext());
712 if (reg_ctx)
713 {
714 const uint32_t num_regs = reg_ctx->GetRegisterCount();
715 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
716 {
717 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
718 if (reg_info &&
719 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
720 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
721 {
722 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
723 sb_value.SetSP (value_sp);
724 break;
725 }
726 }
727 }
728 }
729 break;
730
731 case eValueTypeRegisterSet: // A collection of stack frame register values
732 {
733 RegisterContextSP reg_ctx (frame->GetRegisterContext());
734 if (reg_ctx)
735 {
736 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
737 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
738 {
739 const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx);
740 if (reg_set &&
741 ((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
742 (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
743 {
744 value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx);
745 sb_value.SetSP (value_sp);
746 break;
747 }
748 }
749 }
750 }
751 break;
752
753 case eValueTypeConstResult: // constant result variables
Johnny Chenc35750a2010-11-19 18:07:14 +0000754 {
Greg Clayton4e9267d2010-12-14 18:39:31 +0000755 ConstString const_name(name);
Greg Claytona894fe72012-04-05 16:12:35 +0000756 ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
757 if (expr_var_sp)
Johnny Chenc35750a2010-11-19 18:07:14 +0000758 {
Greg Claytona894fe72012-04-05 16:12:35 +0000759 value_sp = expr_var_sp->GetValueObject();
760 sb_value.SetSP (value_sp);
Johnny Chenc35750a2010-11-19 18:07:14 +0000761 }
762 }
Greg Claytona894fe72012-04-05 16:12:35 +0000763 break;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000764
Greg Claytona894fe72012-04-05 16:12:35 +0000765 default:
766 break;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000767 }
Chris Lattner24943d22010-06-08 16:52:24 +0000768 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000769 else
770 {
771 if (log)
772 log->Printf ("SBFrame(%p)::FindValue () => error: process is running", frame);
773 }
Chris Lattner24943d22010-06-08 16:52:24 +0000774 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000775
Greg Claytona66ba462010-10-30 04:51:46 +0000776 if (log)
Greg Clayton4e9267d2010-12-14 18:39:31 +0000777 log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000778 frame, name, value_type, value_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000779
780
Chris Lattner24943d22010-06-08 16:52:24 +0000781 return sb_value;
782}
783
784bool
Johnny Chen0164b752012-03-05 19:53:24 +0000785SBFrame::IsEqual (const SBFrame &that) const
786{
787 lldb::StackFrameSP this_sp = GetFrameSP();
788 lldb::StackFrameSP that_sp = that.GetFrameSP();
789 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
790}
791
792bool
Chris Lattner24943d22010-06-08 16:52:24 +0000793SBFrame::operator == (const SBFrame &rhs) const
794{
Johnny Chen0164b752012-03-05 19:53:24 +0000795 return IsEqual(rhs);
Chris Lattner24943d22010-06-08 16:52:24 +0000796}
797
798bool
799SBFrame::operator != (const SBFrame &rhs) const
800{
Johnny Chen0164b752012-03-05 19:53:24 +0000801 return !IsEqual(rhs);
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000802}
Chris Lattner24943d22010-06-08 16:52:24 +0000803
804SBThread
805SBFrame::GetThread () const
806{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000807 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000808
Greg Claytona894fe72012-04-05 16:12:35 +0000809 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000810 ThreadSP thread_sp (exe_ctx.GetThreadSP());
811 SBThread sb_thread (thread_sp);
Caroline Tice7826c882010-10-26 03:11:13 +0000812
813 if (log)
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000814 {
815 SBStream sstr;
816 sb_thread.GetDescription (sstr);
Greg Clayton289afcb2012-02-18 05:35:26 +0000817 log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s",
818 exe_ctx.GetFramePtr(),
819 thread_sp.get(),
820 sstr.GetData());
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000821 }
Caroline Tice7826c882010-10-26 03:11:13 +0000822
Chris Lattner24943d22010-06-08 16:52:24 +0000823 return sb_thread;
824}
825
826const char *
827SBFrame::Disassemble () const
828{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000829 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000830 const char *disassembly = NULL;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000831 Mutex::Locker api_locker;
832 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
833
Greg Clayton289afcb2012-02-18 05:35:26 +0000834 StackFrame *frame = exe_ctx.GetFramePtr();
835 Target *target = exe_ctx.GetTargetPtr();
836 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000837 {
Greg Claytona894fe72012-04-05 16:12:35 +0000838 Process::StopLocker stop_locker;
839 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
840 {
Greg Claytona894fe72012-04-05 16:12:35 +0000841 disassembly = frame->Disassemble();
842 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000843 else
844 {
845 if (log)
846 log->Printf ("SBFrame(%p)::Disassemble () => error: process is running", frame);
847 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000848 }
Greg Claytona66ba462010-10-30 04:51:46 +0000849
850 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000851 log->Printf ("SBFrame(%p)::Disassemble () => %s", frame, disassembly);
Greg Claytona66ba462010-10-30 04:51:46 +0000852
853 return disassembly;
Chris Lattner24943d22010-06-08 16:52:24 +0000854}
855
856
Chris Lattner24943d22010-06-08 16:52:24 +0000857SBValueList
858SBFrame::GetVariables (bool arguments,
859 bool locals,
860 bool statics,
861 bool in_scope_only)
862{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000863 SBValueList value_list;
Greg Claytona894fe72012-04-05 16:12:35 +0000864 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000865 StackFrame *frame = exe_ctx.GetFramePtr();
866 Target *target = exe_ctx.GetTargetPtr();
867 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000868 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000869 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000870 value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
871 }
872 return value_list;
Jim Inghame41494a2011-04-16 00:01:13 +0000873}
874
875SBValueList
876SBFrame::GetVariables (bool arguments,
877 bool locals,
878 bool statics,
879 bool in_scope_only,
Jim Ingham10de7d12011-05-04 03:43:18 +0000880 lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000881{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000882 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000883
Greg Clayton334d33a2012-01-30 07:41:31 +0000884 SBValueList value_list;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000885 Mutex::Locker api_locker;
886 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
887
Greg Clayton289afcb2012-02-18 05:35:26 +0000888 StackFrame *frame = exe_ctx.GetFramePtr();
889 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton334d33a2012-01-30 07:41:31 +0000890
Caroline Tice7826c882010-10-26 03:11:13 +0000891 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000892 log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000893 frame,
Greg Claytona66ba462010-10-30 04:51:46 +0000894 arguments,
895 locals,
896 statics,
897 in_scope_only);
Greg Clayton334d33a2012-01-30 07:41:31 +0000898
Greg Clayton289afcb2012-02-18 05:35:26 +0000899 if (frame && target)
Chris Lattner24943d22010-06-08 16:52:24 +0000900 {
Greg Claytona894fe72012-04-05 16:12:35 +0000901 Process::StopLocker stop_locker;
902 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
903 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000904
Greg Claytona894fe72012-04-05 16:12:35 +0000905 size_t i;
906 VariableList *variable_list = NULL;
Jim Ingham887f62d2012-04-13 23:29:44 +0000907 variable_list = frame->GetVariableList(true);
Greg Claytona894fe72012-04-05 16:12:35 +0000908 if (variable_list)
909 {
910 const size_t num_variables = variable_list->GetSize();
911 if (num_variables)
Chris Lattner24943d22010-06-08 16:52:24 +0000912 {
Greg Claytona894fe72012-04-05 16:12:35 +0000913 for (i = 0; i < num_variables; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000914 {
Greg Claytona894fe72012-04-05 16:12:35 +0000915 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
916 if (variable_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000917 {
Greg Claytona894fe72012-04-05 16:12:35 +0000918 bool add_variable = false;
919 switch (variable_sp->GetScope())
920 {
921 case eValueTypeVariableGlobal:
922 case eValueTypeVariableStatic:
923 add_variable = statics;
924 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000925
Greg Claytona894fe72012-04-05 16:12:35 +0000926 case eValueTypeVariableArgument:
927 add_variable = arguments;
928 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000929
Greg Claytona894fe72012-04-05 16:12:35 +0000930 case eValueTypeVariableLocal:
931 add_variable = locals;
932 break;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000933
Greg Claytona894fe72012-04-05 16:12:35 +0000934 default:
935 break;
936 }
937 if (add_variable)
938 {
939 if (in_scope_only && !variable_sp->IsInScope(frame))
940 continue;
Chris Lattner24943d22010-06-08 16:52:24 +0000941
Greg Claytona894fe72012-04-05 16:12:35 +0000942 value_list.Append(frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
943 }
Chris Lattner24943d22010-06-08 16:52:24 +0000944 }
945 }
946 }
947 }
Greg Claytona894fe72012-04-05 16:12:35 +0000948 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000949 else
950 {
951 if (log)
952 log->Printf ("SBFrame(%p)::GetVariables () => error: process is running", frame);
953 }
Chris Lattner24943d22010-06-08 16:52:24 +0000954 }
Caroline Tice7826c882010-10-26 03:11:13 +0000955
956 if (log)
957 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000958 log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame,
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000959 value_list.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000960 }
961
Chris Lattner24943d22010-06-08 16:52:24 +0000962 return value_list;
963}
964
Greg Clayton4e9267d2010-12-14 18:39:31 +0000965SBValueList
Chris Lattner24943d22010-06-08 16:52:24 +0000966SBFrame::GetRegisters ()
967{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000968 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000969
Chris Lattner24943d22010-06-08 16:52:24 +0000970 SBValueList value_list;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000971 Mutex::Locker api_locker;
972 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
973
Greg Clayton289afcb2012-02-18 05:35:26 +0000974 StackFrame *frame = exe_ctx.GetFramePtr();
975 Target *target = exe_ctx.GetTargetPtr();
976 if (frame && target)
Chris Lattner24943d22010-06-08 16:52:24 +0000977 {
Greg Claytona894fe72012-04-05 16:12:35 +0000978 Process::StopLocker stop_locker;
979 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000980 {
Greg Claytona894fe72012-04-05 16:12:35 +0000981 RegisterContextSP reg_ctx (frame->GetRegisterContext());
982 if (reg_ctx)
Chris Lattner24943d22010-06-08 16:52:24 +0000983 {
Greg Claytona894fe72012-04-05 16:12:35 +0000984 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
985 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
986 {
987 value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx));
988 }
Chris Lattner24943d22010-06-08 16:52:24 +0000989 }
990 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000991 else
992 {
993 if (log)
994 log->Printf ("SBFrame(%p)::GetRegisters () => error: process is running", frame);
995 }
Chris Lattner24943d22010-06-08 16:52:24 +0000996 }
Caroline Tice7826c882010-10-26 03:11:13 +0000997
998 if (log)
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000999 log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", frame, value_list.get());
Caroline Tice7826c882010-10-26 03:11:13 +00001000
Chris Lattner24943d22010-06-08 16:52:24 +00001001 return value_list;
1002}
1003
Caroline Tice98f930f2010-09-20 05:20:02 +00001004bool
1005SBFrame::GetDescription (SBStream &description)
1006{
Greg Clayton96154be2011-11-13 06:57:31 +00001007 Stream &strm = description.ref();
1008
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001009 Mutex::Locker api_locker;
1010 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1011
Greg Clayton289afcb2012-02-18 05:35:26 +00001012 StackFrame *frame = exe_ctx.GetFramePtr();
1013 Target *target = exe_ctx.GetTargetPtr();
1014 if (frame && target)
Caroline Tice98f930f2010-09-20 05:20:02 +00001015 {
Greg Claytona894fe72012-04-05 16:12:35 +00001016 Process::StopLocker stop_locker;
1017 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1018 {
Greg Claytona894fe72012-04-05 16:12:35 +00001019 frame->DumpUsingSettingsFormat (&strm);
1020 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001021 else
1022 {
1023 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1024 if (log)
1025 log->Printf ("SBFrame(%p)::GetDescription () => error: process is running", frame);
1026 }
1027
Caroline Tice98f930f2010-09-20 05:20:02 +00001028 }
1029 else
Greg Clayton96154be2011-11-13 06:57:31 +00001030 strm.PutCString ("No value");
Caroline Tice98f930f2010-09-20 05:20:02 +00001031
1032 return true;
1033}
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001034
Greg Clayton4e9267d2010-12-14 18:39:31 +00001035SBValue
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001036SBFrame::EvaluateExpression (const char *expr)
1037{
Greg Clayton582ed0e2011-06-18 20:06:08 +00001038 SBValue result;
Greg Claytona894fe72012-04-05 16:12:35 +00001039 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001040 StackFrame *frame = exe_ctx.GetFramePtr();
1041 Target *target = exe_ctx.GetTargetPtr();
1042 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001043 {
Jim Ingham47beabb2012-10-16 21:41:58 +00001044 SBExpressionOptions options;
1045 lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue();
1046 options.SetUseDynamic (fetch_dynamic_value);
1047 options.SetUnwindOnError (true);
1048 return EvaluateExpression (expr, options);
Greg Clayton582ed0e2011-06-18 20:06:08 +00001049 }
1050 return result;
Jim Inghame41494a2011-04-16 00:01:13 +00001051}
1052
1053SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +00001054SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
Jim Inghame41494a2011-04-16 00:01:13 +00001055{
Jim Ingham47beabb2012-10-16 21:41:58 +00001056 SBExpressionOptions options;
1057 options.SetUseDynamic (fetch_dynamic_value);
1058 options.SetUnwindOnError (true);
1059 return EvaluateExpression (expr, options);
Jim Inghamd82bc6d2012-05-11 23:47:32 +00001060}
1061
1062SBValue
1063SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
1064{
Jim Ingham47beabb2012-10-16 21:41:58 +00001065 SBExpressionOptions options;
1066 options.SetUseDynamic (fetch_dynamic_value);
1067 options.SetUnwindOnError (unwind_on_error);
1068 return EvaluateExpression (expr, options);
1069}
1070
1071lldb::SBValue
1072SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &options)
1073{
Greg Clayton4e9267d2010-12-14 18:39:31 +00001074 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Sean Callanan94d255f2010-12-07 22:55:01 +00001075
Greg Clayton4e9267d2010-12-14 18:39:31 +00001076 LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Greg Claytona66ba462010-10-30 04:51:46 +00001077
Greg Clayton4a379b12012-07-17 03:23:13 +00001078 ExecutionResults exe_results = eExecutionSetupError;
Greg Clayton4e9267d2010-12-14 18:39:31 +00001079 SBValue expr_result;
Greg Clayton0a19a1b2012-02-04 02:27:34 +00001080 ValueObjectSP expr_value_sp;
Greg Claytona66ba462010-10-30 04:51:46 +00001081
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001082 Mutex::Locker api_locker;
1083 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1084
Greg Clayton289afcb2012-02-18 05:35:26 +00001085 StackFrame *frame = exe_ctx.GetFramePtr();
1086 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton334d33a2012-01-30 07:41:31 +00001087 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +00001088 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", frame, expr);
Greg Clayton334d33a2012-01-30 07:41:31 +00001089
Greg Clayton289afcb2012-02-18 05:35:26 +00001090 if (frame && target)
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001091 {
Greg Claytona894fe72012-04-05 16:12:35 +00001092 Process::StopLocker stop_locker;
1093 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1094 {
Enrico Granata299aa702012-05-29 18:06:49 +00001095#ifdef LLDB_CONFIGURATION_DEBUG
Greg Claytona894fe72012-04-05 16:12:35 +00001096 StreamString frame_description;
1097 frame->DumpUsingSettingsFormat (&frame_description);
Greg Claytona894fe72012-04-05 16:12:35 +00001098 Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
Jim Ingham47beabb2012-10-16 21:41:58 +00001099 expr, options.GetUseDynamic(), frame_description.GetString().c_str());
Enrico Granata299aa702012-05-29 18:06:49 +00001100#endif
Greg Claytona894fe72012-04-05 16:12:35 +00001101 exe_results = target->EvaluateExpression (expr,
1102 frame,
Enrico Granatad27026e2012-09-05 20:41:26 +00001103 expr_value_sp,
Jim Ingham47beabb2012-10-16 21:41:58 +00001104 options.ref());
Greg Claytona894fe72012-04-05 16:12:35 +00001105 expr_result.SetSP(expr_value_sp);
Enrico Granata299aa702012-05-29 18:06:49 +00001106#ifdef LLDB_CONFIGURATION_DEBUG
Greg Claytona894fe72012-04-05 16:12:35 +00001107 Host::SetCrashDescription (NULL);
Enrico Granata299aa702012-05-29 18:06:49 +00001108#endif
Greg Claytona894fe72012-04-05 16:12:35 +00001109 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001110 else
1111 {
1112 if (log)
1113 log->Printf ("SBFrame(%p)::EvaluateExpression () => error: process is running", frame);
1114 }
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001115 }
Jason Molendac48ca822012-02-21 05:33:55 +00001116
1117#ifndef LLDB_DISABLE_PYTHON
Sean Callanan94d255f2010-12-07 22:55:01 +00001118 if (expr_log)
Jim Inghame41494a2011-04-16 00:01:13 +00001119 expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **",
Greg Clayton0fb0bcc2011-08-03 22:57:10 +00001120 expr_result.GetValue(),
1121 expr_result.GetSummary());
Sean Callanan94d255f2010-12-07 22:55:01 +00001122
Greg Claytona66ba462010-10-30 04:51:46 +00001123 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +00001124 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
1125 frame,
Jim Inghame41494a2011-04-16 00:01:13 +00001126 expr,
Greg Clayton0a19a1b2012-02-04 02:27:34 +00001127 expr_value_sp.get(),
Johnny Chenee6e7902011-08-10 22:06:24 +00001128 exe_results);
Jason Molendac48ca822012-02-21 05:33:55 +00001129#endif
Greg Claytona66ba462010-10-30 04:51:46 +00001130
Greg Clayton49ce6822010-10-31 03:01:06 +00001131 return expr_result;
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001132}
Greg Clayton582ed0e2011-06-18 20:06:08 +00001133
1134bool
1135SBFrame::IsInlined()
1136{
Greg Claytona894fe72012-04-05 16:12:35 +00001137 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001138 StackFrame *frame = exe_ctx.GetFramePtr();
1139 Target *target = exe_ctx.GetTargetPtr();
1140 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001141 {
Greg Claytona894fe72012-04-05 16:12:35 +00001142 Process::StopLocker stop_locker;
1143 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1144 {
1145
1146 Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
1147 if (block)
1148 return block->GetContainingInlinedBlock () != NULL;
1149 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001150 else
1151 {
1152 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1153 if (log)
1154 log->Printf ("SBFrame(%p)::IsInlined () => error: process is running", frame);
1155 }
1156
Greg Clayton582ed0e2011-06-18 20:06:08 +00001157 }
1158 return false;
1159}
1160
1161const char *
1162SBFrame::GetFunctionName()
1163{
1164 const char *name = NULL;
Greg Claytona894fe72012-04-05 16:12:35 +00001165 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001166 StackFrame *frame = exe_ctx.GetFramePtr();
1167 Target *target = exe_ctx.GetTargetPtr();
1168 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001169 {
Greg Claytona894fe72012-04-05 16:12:35 +00001170 Process::StopLocker stop_locker;
1171 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Greg Clayton582ed0e2011-06-18 20:06:08 +00001172 {
Greg Claytona894fe72012-04-05 16:12:35 +00001173 SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
1174 if (sc.block)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001175 {
Greg Claytona894fe72012-04-05 16:12:35 +00001176 Block *inlined_block = sc.block->GetContainingInlinedBlock ();
1177 if (inlined_block)
1178 {
1179 const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo();
1180 name = inlined_info->GetName().AsCString();
1181 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001182 }
Greg Claytona894fe72012-04-05 16:12:35 +00001183
1184 if (name == NULL)
1185 {
1186 if (sc.function)
1187 name = sc.function->GetName().GetCString();
1188 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001189
Greg Claytona894fe72012-04-05 16:12:35 +00001190 if (name == NULL)
1191 {
1192 if (sc.symbol)
1193 name = sc.symbol->GetName().GetCString();
1194 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001195 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001196 else
1197 {
1198 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1199 if (log)
1200 log->Printf ("SBFrame(%p)::GetFunctionName() => error: process is running", frame);
1201
1202 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001203 }
1204 return name;
1205}
1206