blob: ceab3b72bdbf82a08d53bc9edfcb6b9d70ea6002 [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"
27#include "lldb/Symbol/SymbolContext.h"
28#include "lldb/Symbol/VariableList.h"
29#include "lldb/Symbol/Variable.h"
30#include "lldb/Target/ExecutionContext.h"
31#include "lldb/Target/Target.h"
32#include "lldb/Target/Process.h"
33#include "lldb/Target/RegisterContext.h"
34#include "lldb/Target/StackFrame.h"
Greg Clayton334d33a2012-01-30 07:41:31 +000035#include "lldb/Target/StackID.h"
Chris Lattner24943d22010-06-08 16:52:24 +000036#include "lldb/Target/Thread.h"
37
Eli Friedman7a62c8b2010-06-09 07:44:37 +000038#include "lldb/API/SBDebugger.h"
39#include "lldb/API/SBValue.h"
40#include "lldb/API/SBAddress.h"
Caroline Tice98f930f2010-09-20 05:20:02 +000041#include "lldb/API/SBStream.h"
Eli Friedman7a62c8b2010-06-09 07:44:37 +000042#include "lldb/API/SBSymbolContext.h"
43#include "lldb/API/SBThread.h"
Chris Lattner24943d22010-06-08 16:52:24 +000044
45using namespace lldb;
46using namespace lldb_private;
47
Greg Clayton334d33a2012-01-30 07:41:31 +000048
Chris Lattner24943d22010-06-08 16:52:24 +000049SBFrame::SBFrame () :
Greg Claytona894fe72012-04-05 16:12:35 +000050 m_opaque_sp (new ExecutionContextRef())
Chris Lattner24943d22010-06-08 16:52:24 +000051{
52}
53
Greg Clayton4e9267d2010-12-14 18:39:31 +000054SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) :
Greg Claytona894fe72012-04-05 16:12:35 +000055 m_opaque_sp (new ExecutionContextRef (lldb_object_sp))
Chris Lattner24943d22010-06-08 16:52:24 +000056{
Greg Clayton4e9267d2010-12-14 18:39:31 +000057 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +000058
59 if (log)
60 {
61 SBStream sstr;
62 GetDescription (sstr);
Greg Claytona66ba462010-10-30 04:51:46 +000063 log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
Greg Clayton334d33a2012-01-30 07:41:31 +000064 lldb_object_sp.get(), lldb_object_sp.get(), sstr.GetData());
Caroline Tice61ba7ec2010-10-26 23:49:36 +000065
Caroline Tice7826c882010-10-26 03:11:13 +000066 }
Chris Lattner24943d22010-06-08 16:52:24 +000067}
68
Greg Clayton538eb822010-11-05 23:17:00 +000069SBFrame::SBFrame(const SBFrame &rhs) :
Greg Claytona894fe72012-04-05 16:12:35 +000070 m_opaque_sp (new ExecutionContextRef (*rhs.m_opaque_sp))
Greg Clayton538eb822010-11-05 23:17:00 +000071{
72}
73
74const SBFrame &
75SBFrame::operator = (const SBFrame &rhs)
76{
77 if (this != &rhs)
Greg Claytona894fe72012-04-05 16:12:35 +000078 *m_opaque_sp = *rhs.m_opaque_sp;
Greg Clayton538eb822010-11-05 23:17:00 +000079 return *this;
80}
81
Chris Lattner24943d22010-06-08 16:52:24 +000082SBFrame::~SBFrame()
83{
84}
85
Greg Clayton334d33a2012-01-30 07:41:31 +000086StackFrameSP
87SBFrame::GetFrameSP() const
Chris Lattner24943d22010-06-08 16:52:24 +000088{
Greg Clayton26425852012-04-12 20:58:26 +000089 if (m_opaque_sp)
90 return m_opaque_sp->GetFrameSP();
91 return StackFrameSP();
Chris Lattner24943d22010-06-08 16:52:24 +000092}
93
Greg Clayton334d33a2012-01-30 07:41:31 +000094void
95SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
96{
Greg Claytona894fe72012-04-05 16:12:35 +000097 return m_opaque_sp->SetFrameSP(lldb_object_sp);
Greg Clayton334d33a2012-01-30 07:41:31 +000098}
Chris Lattner24943d22010-06-08 16:52:24 +000099
100bool
101SBFrame::IsValid() const
102{
Greg Claytona894fe72012-04-05 16:12:35 +0000103 return GetFrameSP().get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000104}
105
106SBSymbolContext
107SBFrame::GetSymbolContext (uint32_t resolve_scope) const
108{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000109 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner24943d22010-06-08 16:52:24 +0000110 SBSymbolContext sb_sym_ctx;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000111 Mutex::Locker api_locker;
112 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
113
Greg Clayton289afcb2012-02-18 05:35:26 +0000114 StackFrame *frame = exe_ctx.GetFramePtr();
115 Target *target = exe_ctx.GetTargetPtr();
116 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000117 {
Greg Claytona894fe72012-04-05 16:12:35 +0000118 Process::StopLocker stop_locker;
119 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
120 {
Greg Claytona894fe72012-04-05 16:12:35 +0000121 sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext (resolve_scope));
122 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000123 else
124 {
125 if (log)
126 log->Printf ("SBFrame(%p)::GetSymbolContext () => error: process is running", frame);
127 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000128 }
Caroline Tice7826c882010-10-26 03:11:13 +0000129
130 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000131 log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000132 frame, resolve_scope, sb_sym_ctx.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000133
Chris Lattner24943d22010-06-08 16:52:24 +0000134 return sb_sym_ctx;
135}
136
137SBModule
138SBFrame::GetModule () const
139{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000140 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000141 SBModule sb_module;
Greg Clayton0416bdf2012-01-30 09:04:36 +0000142 ModuleSP module_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000143 Mutex::Locker api_locker;
144 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
145
Greg Clayton289afcb2012-02-18 05:35:26 +0000146 StackFrame *frame = exe_ctx.GetFramePtr();
147 Target *target = exe_ctx.GetTargetPtr();
148 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000149 {
Greg Claytona894fe72012-04-05 16:12:35 +0000150 Process::StopLocker stop_locker;
151 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
152 {
Greg Claytona894fe72012-04-05 16:12:35 +0000153 module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp;
154 sb_module.SetSP (module_sp);
155 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000156 else
157 {
158 if (log)
159 log->Printf ("SBFrame(%p)::GetModule () => error: process is running", frame);
160 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000161 }
Greg Claytondd62d722010-12-14 04:58:53 +0000162
Greg Claytona66ba462010-10-30 04:51:46 +0000163 if (log)
164 log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000165 frame, module_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000166
Chris Lattner24943d22010-06-08 16:52:24 +0000167 return sb_module;
168}
169
170SBCompileUnit
171SBFrame::GetCompileUnit () const
172{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000173 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000174 SBCompileUnit sb_comp_unit;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000175 Mutex::Locker api_locker;
176 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
177
Greg Clayton289afcb2012-02-18 05:35:26 +0000178 StackFrame *frame = exe_ctx.GetFramePtr();
179 Target *target = exe_ctx.GetTargetPtr();
180 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000181 {
Greg Claytona894fe72012-04-05 16:12:35 +0000182 Process::StopLocker stop_locker;
183 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
184 {
Greg Claytona894fe72012-04-05 16:12:35 +0000185 sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
186 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000187 else
188 {
189 if (log)
190 log->Printf ("SBFrame(%p)::GetCompileUnit () => error: process is running", frame);
191 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000192 }
Caroline Tice7826c882010-10-26 03:11:13 +0000193 if (log)
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000194 log->Printf ("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000195 frame, sb_comp_unit.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000196
Chris Lattner24943d22010-06-08 16:52:24 +0000197 return sb_comp_unit;
198}
199
200SBFunction
201SBFrame::GetFunction () const
202{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000203 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000204 SBFunction sb_function;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000205 Mutex::Locker api_locker;
206 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
207
Greg Clayton289afcb2012-02-18 05:35:26 +0000208 StackFrame *frame = exe_ctx.GetFramePtr();
209 Target *target = exe_ctx.GetTargetPtr();
210 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000211 {
Greg Claytona894fe72012-04-05 16:12:35 +0000212 Process::StopLocker stop_locker;
213 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
214 {
Greg Claytona894fe72012-04-05 16:12:35 +0000215 sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function);
216 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000217 else
218 {
219 if (log)
220 log->Printf ("SBFrame(%p)::GetFunction () => error: process is running", frame);
221 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000222 }
Greg Claytona66ba462010-10-30 04:51:46 +0000223 if (log)
224 log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000225 frame, sb_function.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000226
Chris Lattner24943d22010-06-08 16:52:24 +0000227 return sb_function;
228}
229
Greg Clayton8f1e08b2010-10-04 18:37:52 +0000230SBSymbol
231SBFrame::GetSymbol () const
232{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000233 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000234 SBSymbol sb_symbol;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000235 Mutex::Locker api_locker;
236 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
237
Greg Clayton289afcb2012-02-18 05:35:26 +0000238 StackFrame *frame = exe_ctx.GetFramePtr();
239 Target *target = exe_ctx.GetTargetPtr();
240 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000241 {
Greg Claytona894fe72012-04-05 16:12:35 +0000242 Process::StopLocker stop_locker;
243 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
244 {
Greg Claytona894fe72012-04-05 16:12:35 +0000245 sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol);
246 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000247 else
248 {
249 if (log)
250 log->Printf ("SBFrame(%p)::GetSymbol () => error: process is running", frame);
251 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000252 }
Greg Claytona66ba462010-10-30 04:51:46 +0000253 if (log)
254 log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000255 frame, sb_symbol.get());
Greg Clayton8f1e08b2010-10-04 18:37:52 +0000256 return sb_symbol;
257}
258
Chris Lattner24943d22010-06-08 16:52:24 +0000259SBBlock
260SBFrame::GetBlock () const
261{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000262 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000263 SBBlock sb_block;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000264 Mutex::Locker api_locker;
265 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
266
Greg Clayton289afcb2012-02-18 05:35:26 +0000267 StackFrame *frame = exe_ctx.GetFramePtr();
268 Target *target = exe_ctx.GetTargetPtr();
269 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000270 {
Greg Claytona894fe72012-04-05 16:12:35 +0000271 Process::StopLocker stop_locker;
272 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
273 {
Greg Claytona894fe72012-04-05 16:12:35 +0000274 sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block);
275 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000276 else
277 {
278 if (log)
279 log->Printf ("SBFrame(%p)::GetBlock () => error: process is running", frame);
280 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000281 }
Greg Claytona66ba462010-10-30 04:51:46 +0000282 if (log)
283 log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000284 frame, sb_block.GetPtr());
Chris Lattner24943d22010-06-08 16:52:24 +0000285 return sb_block;
286}
287
Greg Clayton69aa5d92010-09-07 04:20:48 +0000288SBBlock
289SBFrame::GetFrameBlock () const
290{
Greg Claytondd62d722010-12-14 04:58:53 +0000291 SBBlock sb_block;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000292 Mutex::Locker api_locker;
293 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
294
Greg Clayton289afcb2012-02-18 05:35:26 +0000295 StackFrame *frame = exe_ctx.GetFramePtr();
296 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000297 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton289afcb2012-02-18 05:35:26 +0000298 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000299 {
Greg Claytona894fe72012-04-05 16:12:35 +0000300 Process::StopLocker stop_locker;
301 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
302 {
Greg Claytona894fe72012-04-05 16:12:35 +0000303 sb_block.SetPtr(frame->GetFrameBlock ());
304 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000305 else
306 {
307 if (log)
308 log->Printf ("SBFrame(%p)::GetFrameBlock () => error: process is running", frame);
309 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000310 }
Greg Claytona66ba462010-10-30 04:51:46 +0000311 if (log)
312 log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000313 frame, sb_block.GetPtr());
Greg Clayton69aa5d92010-09-07 04:20:48 +0000314 return sb_block;
315}
316
Chris Lattner24943d22010-06-08 16:52:24 +0000317SBLineEntry
318SBFrame::GetLineEntry () const
319{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000320 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000321 SBLineEntry sb_line_entry;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000322 Mutex::Locker api_locker;
323 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
324
Greg Clayton289afcb2012-02-18 05:35:26 +0000325 StackFrame *frame = exe_ctx.GetFramePtr();
326 Target *target = exe_ctx.GetTargetPtr();
327 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000328 {
Greg Claytona894fe72012-04-05 16:12:35 +0000329 Process::StopLocker stop_locker;
330 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
331 {
Greg Claytona894fe72012-04-05 16:12:35 +0000332 sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry);
333 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000334 else
335 {
336 if (log)
337 log->Printf ("SBFrame(%p)::GetLineEntry () => error: process is running", frame);
338 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000339 }
Greg Claytona66ba462010-10-30 04:51:46 +0000340 if (log)
341 log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000342 frame, sb_line_entry.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000343 return sb_line_entry;
344}
345
346uint32_t
347SBFrame::GetFrameID () const
348{
Greg Clayton334d33a2012-01-30 07:41:31 +0000349 uint32_t frame_idx = UINT32_MAX;
350
Greg Claytona894fe72012-04-05 16:12:35 +0000351 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000352 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytona894fe72012-04-05 16:12:35 +0000353 if (frame)
Greg Clayton289afcb2012-02-18 05:35:26 +0000354 frame_idx = frame->GetFrameIndex ();
Greg Claytona66ba462010-10-30 04:51:46 +0000355
Greg Clayton4e9267d2010-12-14 18:39:31 +0000356 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000357 if (log)
358 log->Printf ("SBFrame(%p)::GetFrameID () => %u",
Greg Clayton289afcb2012-02-18 05:35:26 +0000359 frame, frame_idx);
Greg Claytona66ba462010-10-30 04:51:46 +0000360 return frame_idx;
Chris Lattner24943d22010-06-08 16:52:24 +0000361}
362
Greg Clayton4e9267d2010-12-14 18:39:31 +0000363addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000364SBFrame::GetPC () const
365{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000366 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000367 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000368 Mutex::Locker api_locker;
369 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
370
Greg Clayton289afcb2012-02-18 05:35:26 +0000371 StackFrame *frame = exe_ctx.GetFramePtr();
372 Target *target = exe_ctx.GetTargetPtr();
373 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000374 {
Greg Claytona894fe72012-04-05 16:12:35 +0000375 Process::StopLocker stop_locker;
376 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
377 {
Greg Claytona894fe72012-04-05 16:12:35 +0000378 addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
379 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000380 else
381 {
382 if (log)
383 log->Printf ("SBFrame(%p)::GetPC () => error: process is running", frame);
384 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000385 }
Caroline Tice7826c882010-10-26 03:11:13 +0000386
387 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000388 log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", frame, addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000389
390 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000391}
392
393bool
Greg Clayton4e9267d2010-12-14 18:39:31 +0000394SBFrame::SetPC (addr_t new_pc)
Chris Lattner24943d22010-06-08 16:52:24 +0000395{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000396 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000397 bool ret_val = false;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000398 Mutex::Locker api_locker;
399 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
400
Greg Clayton289afcb2012-02-18 05:35:26 +0000401 StackFrame *frame = exe_ctx.GetFramePtr();
402 Target *target = exe_ctx.GetTargetPtr();
403 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000404 {
Greg Claytona894fe72012-04-05 16:12:35 +0000405 Process::StopLocker stop_locker;
406 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
407 {
Greg Claytona894fe72012-04-05 16:12:35 +0000408 ret_val = frame->GetRegisterContext()->SetPC (new_pc);
409 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000410 else
411 {
412 if (log)
413 log->Printf ("SBFrame(%p)::SetPC () => error: process is running", frame);
414 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000415 }
Caroline Tice7826c882010-10-26 03:11:13 +0000416
417 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000418 log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i",
Greg Clayton289afcb2012-02-18 05:35:26 +0000419 frame, new_pc, ret_val);
Caroline Tice7826c882010-10-26 03:11:13 +0000420
421 return ret_val;
Chris Lattner24943d22010-06-08 16:52:24 +0000422}
423
Greg Clayton4e9267d2010-12-14 18:39:31 +0000424addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000425SBFrame::GetSP () const
426{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000427 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000428 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000429 Mutex::Locker api_locker;
430 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
431
Greg Clayton289afcb2012-02-18 05:35:26 +0000432 StackFrame *frame = exe_ctx.GetFramePtr();
433 Target *target = exe_ctx.GetTargetPtr();
434 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000435 {
Greg Claytona894fe72012-04-05 16:12:35 +0000436 Process::StopLocker stop_locker;
437 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
438 {
Greg Claytona894fe72012-04-05 16:12:35 +0000439 addr = frame->GetRegisterContext()->GetSP();
440 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000441 else
442 {
443 if (log)
444 log->Printf ("SBFrame(%p)::GetSP () => error: process is running", frame);
445 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000446 }
Greg Claytona66ba462010-10-30 04:51:46 +0000447 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000448 log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", frame, addr);
Greg Claytona66ba462010-10-30 04:51:46 +0000449
450 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000451}
452
453
Greg Clayton4e9267d2010-12-14 18:39:31 +0000454addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000455SBFrame::GetFP () const
456{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000457 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000458 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000459 Mutex::Locker api_locker;
460 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
461
Greg Clayton289afcb2012-02-18 05:35:26 +0000462 StackFrame *frame = exe_ctx.GetFramePtr();
463 Target *target = exe_ctx.GetTargetPtr();
464 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000465 {
Greg Claytona894fe72012-04-05 16:12:35 +0000466 Process::StopLocker stop_locker;
467 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
468 {
Greg Claytona894fe72012-04-05 16:12:35 +0000469 addr = frame->GetRegisterContext()->GetFP();
470 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000471 else
472 {
473 if (log)
474 log->Printf ("SBFrame(%p)::GetFP () => error: process is running", frame);
475 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000476 }
Caroline Tice7826c882010-10-26 03:11:13 +0000477
478 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000479 log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", frame, addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000480 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000481}
482
483
484SBAddress
485SBFrame::GetPCAddress () const
486{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000487 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner24943d22010-06-08 16:52:24 +0000488 SBAddress sb_addr;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000489 Mutex::Locker api_locker;
490 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
491
Greg Clayton289afcb2012-02-18 05:35:26 +0000492 StackFrame *frame = exe_ctx.GetFramePtr();
493 Target *target = exe_ctx.GetTargetPtr();
494 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000495 {
Greg Claytona894fe72012-04-05 16:12:35 +0000496 Process::StopLocker stop_locker;
497 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
498 {
Greg Claytona894fe72012-04-05 16:12:35 +0000499 sb_addr.SetAddress (&frame->GetFrameCodeAddress());
500 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000501 else
502 {
503 if (log)
504 log->Printf ("SBFrame(%p)::GetPCAddress () => error: process is running", frame);
505 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000506 }
Greg Claytona66ba462010-10-30 04:51:46 +0000507 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000508 log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame, sb_addr.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000509 return sb_addr;
510}
511
512void
513SBFrame::Clear()
514{
Greg Clayton26425852012-04-12 20:58:26 +0000515 m_opaque_sp->Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000516}
517
Greg Claytond62b9c12012-02-03 07:02:37 +0000518lldb::SBValue
519SBFrame::GetValueForVariablePath (const char *var_path)
520{
521 SBValue sb_value;
Greg Claytona894fe72012-04-05 16:12:35 +0000522 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000523 StackFrame *frame = exe_ctx.GetFramePtr();
524 Target *target = exe_ctx.GetTargetPtr();
525 if (frame && target)
Greg Claytond62b9c12012-02-03 07:02:37 +0000526 {
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000527 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
528 sb_value = GetValueForVariablePath (var_path, use_dynamic);
Greg Claytond62b9c12012-02-03 07:02:37 +0000529 }
530 return sb_value;
531}
532
533lldb::SBValue
534SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
535{
536 SBValue sb_value;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000537 Mutex::Locker api_locker;
538 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
539
Greg Clayton289afcb2012-02-18 05:35:26 +0000540 StackFrame *frame = exe_ctx.GetFramePtr();
541 Target *target = exe_ctx.GetTargetPtr();
542 if (frame && target && var_path && var_path[0])
Greg Claytond62b9c12012-02-03 07:02:37 +0000543 {
Greg Claytona894fe72012-04-05 16:12:35 +0000544 Process::StopLocker stop_locker;
545 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
546 {
Greg Claytona894fe72012-04-05 16:12:35 +0000547 VariableSP var_sp;
548 Error error;
549 ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path,
550 use_dynamic,
Greg Claytonb3a1a2b2012-07-14 00:53:55 +0000551 StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
Greg Claytona894fe72012-04-05 16:12:35 +0000552 var_sp,
553 error));
554 sb_value.SetSP(value_sp);
555 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000556 else
557 {
558 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
559 if (log)
560 log->Printf ("SBFrame(%p)::GetValueForVariablePath () => error: process is running", frame);
561 }
Greg Claytond62b9c12012-02-03 07:02:37 +0000562 }
563 return sb_value;
564}
565
Chris Lattner24943d22010-06-08 16:52:24 +0000566SBValue
Greg Clayton4e9267d2010-12-14 18:39:31 +0000567SBFrame::FindVariable (const char *name)
Chris Lattner24943d22010-06-08 16:52:24 +0000568{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000569 SBValue value;
Greg Claytona894fe72012-04-05 16:12:35 +0000570 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000571 StackFrame *frame = exe_ctx.GetFramePtr();
572 Target *target = exe_ctx.GetTargetPtr();
573 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000574 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000575 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000576 value = FindVariable (name, use_dynamic);
577 }
578 return value;
Jim Inghame41494a2011-04-16 00:01:13 +0000579}
Greg Claytond62b9c12012-02-03 07:02:37 +0000580
Jim Inghame41494a2011-04-16 00:01:13 +0000581
582SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000583SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000584{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000585 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000586 VariableSP var_sp;
Jim Ingham47da8102011-04-22 23:53:53 +0000587 SBValue sb_value;
Greg Clayton0a19a1b2012-02-04 02:27:34 +0000588 ValueObjectSP value_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000589 Mutex::Locker api_locker;
590 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
591
Greg Clayton289afcb2012-02-18 05:35:26 +0000592 StackFrame *frame = exe_ctx.GetFramePtr();
593 Target *target = exe_ctx.GetTargetPtr();
594 if (frame && target && name && name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000595 {
Greg Claytona894fe72012-04-05 16:12:35 +0000596 Process::StopLocker stop_locker;
597 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000598 {
Greg Claytona894fe72012-04-05 16:12:35 +0000599 VariableList variable_list;
Greg Claytona894fe72012-04-05 16:12:35 +0000600 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
601
602 if (sc.block)
Greg Claytondd62d722010-12-14 04:58:53 +0000603 {
Greg Claytona894fe72012-04-05 16:12:35 +0000604 const bool can_create = true;
605 const bool get_parent_variables = true;
606 const bool stop_if_block_is_inlined_function = true;
607
608 if (sc.block->AppendVariables (can_create,
609 get_parent_variables,
610 stop_if_block_is_inlined_function,
611 &variable_list))
612 {
613 var_sp = variable_list.FindVariable (ConstString(name));
614 }
615 }
616
617 if (var_sp)
618 {
619 value_sp = frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
620 sb_value.SetSP(value_sp);
Greg Claytondd62d722010-12-14 04:58:53 +0000621 }
Chris Lattner24943d22010-06-08 16:52:24 +0000622 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000623 else
624 {
625 if (log)
626 log->Printf ("SBFrame(%p)::FindVariable () => error: process is running", frame);
627 }
Chris Lattner24943d22010-06-08 16:52:24 +0000628 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000629
Greg Claytona66ba462010-10-30 04:51:46 +0000630 if (log)
Greg Clayton4e9267d2010-12-14 18:39:31 +0000631 log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000632 frame, name, value_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000633
Chris Lattner24943d22010-06-08 16:52:24 +0000634 return sb_value;
635}
636
637SBValue
Greg Clayton4e9267d2010-12-14 18:39:31 +0000638SBFrame::FindValue (const char *name, ValueType value_type)
Chris Lattner24943d22010-06-08 16:52:24 +0000639{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000640 SBValue value;
Greg Claytona894fe72012-04-05 16:12:35 +0000641 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000642 StackFrame *frame = exe_ctx.GetFramePtr();
643 Target *target = exe_ctx.GetTargetPtr();
644 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000645 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000646 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000647 value = FindValue (name, value_type, use_dynamic);
648 }
649 return value;
Jim Inghame41494a2011-04-16 00:01:13 +0000650}
651
652SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000653SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000654{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000655 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000656 SBValue sb_value;
Greg Clayton0a19a1b2012-02-04 02:27:34 +0000657 ValueObjectSP value_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000658 Mutex::Locker api_locker;
659 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
660
Greg Clayton289afcb2012-02-18 05:35:26 +0000661 StackFrame *frame = exe_ctx.GetFramePtr();
662 Target *target = exe_ctx.GetTargetPtr();
663 if (frame && target && name && name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000664 {
Greg Claytona894fe72012-04-05 16:12:35 +0000665 Process::StopLocker stop_locker;
666 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000667 {
Greg Claytona894fe72012-04-05 16:12:35 +0000668 switch (value_type)
Chris Lattner24943d22010-06-08 16:52:24 +0000669 {
Greg Claytona894fe72012-04-05 16:12:35 +0000670 case eValueTypeVariableGlobal: // global variable
671 case eValueTypeVariableStatic: // static variable
672 case eValueTypeVariableArgument: // function argument variables
673 case eValueTypeVariableLocal: // function local variables
674 {
675 VariableList *variable_list = frame->GetVariableList(true);
Greg Clayton4e9267d2010-12-14 18:39:31 +0000676
Greg Claytona894fe72012-04-05 16:12:35 +0000677 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000678
Greg Claytona894fe72012-04-05 16:12:35 +0000679 const bool can_create = true;
680 const bool get_parent_variables = true;
681 const bool stop_if_block_is_inlined_function = true;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000682
Greg Claytona894fe72012-04-05 16:12:35 +0000683 if (sc.block && sc.block->AppendVariables (can_create,
684 get_parent_variables,
685 stop_if_block_is_inlined_function,
686 variable_list))
687 {
688 ConstString const_name(name);
689 const uint32_t num_variables = variable_list->GetSize();
690 for (uint32_t i = 0; i < num_variables; ++i)
691 {
692 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
693 if (variable_sp &&
694 variable_sp->GetScope() == value_type &&
695 variable_sp->GetName() == const_name)
696 {
697 value_sp = frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic);
698 sb_value.SetSP (value_sp);
699 break;
700 }
701 }
702 }
703 }
704 break;
705
706 case eValueTypeRegister: // stack frame register value
707 {
708 RegisterContextSP reg_ctx (frame->GetRegisterContext());
709 if (reg_ctx)
710 {
711 const uint32_t num_regs = reg_ctx->GetRegisterCount();
712 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
713 {
714 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
715 if (reg_info &&
716 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
717 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
718 {
719 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
720 sb_value.SetSP (value_sp);
721 break;
722 }
723 }
724 }
725 }
726 break;
727
728 case eValueTypeRegisterSet: // A collection of stack frame register values
729 {
730 RegisterContextSP reg_ctx (frame->GetRegisterContext());
731 if (reg_ctx)
732 {
733 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
734 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
735 {
736 const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx);
737 if (reg_set &&
738 ((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
739 (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
740 {
741 value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx);
742 sb_value.SetSP (value_sp);
743 break;
744 }
745 }
746 }
747 }
748 break;
749
750 case eValueTypeConstResult: // constant result variables
Johnny Chenc35750a2010-11-19 18:07:14 +0000751 {
Greg Clayton4e9267d2010-12-14 18:39:31 +0000752 ConstString const_name(name);
Greg Claytona894fe72012-04-05 16:12:35 +0000753 ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
754 if (expr_var_sp)
Johnny Chenc35750a2010-11-19 18:07:14 +0000755 {
Greg Claytona894fe72012-04-05 16:12:35 +0000756 value_sp = expr_var_sp->GetValueObject();
757 sb_value.SetSP (value_sp);
Johnny Chenc35750a2010-11-19 18:07:14 +0000758 }
759 }
Greg Claytona894fe72012-04-05 16:12:35 +0000760 break;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000761
Greg Claytona894fe72012-04-05 16:12:35 +0000762 default:
763 break;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000764 }
Chris Lattner24943d22010-06-08 16:52:24 +0000765 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000766 else
767 {
768 if (log)
769 log->Printf ("SBFrame(%p)::FindValue () => error: process is running", frame);
770 }
Chris Lattner24943d22010-06-08 16:52:24 +0000771 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000772
Greg Claytona66ba462010-10-30 04:51:46 +0000773 if (log)
Greg Clayton4e9267d2010-12-14 18:39:31 +0000774 log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000775 frame, name, value_type, value_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000776
777
Chris Lattner24943d22010-06-08 16:52:24 +0000778 return sb_value;
779}
780
781bool
Johnny Chen0164b752012-03-05 19:53:24 +0000782SBFrame::IsEqual (const SBFrame &that) const
783{
784 lldb::StackFrameSP this_sp = GetFrameSP();
785 lldb::StackFrameSP that_sp = that.GetFrameSP();
786 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
787}
788
789bool
Chris Lattner24943d22010-06-08 16:52:24 +0000790SBFrame::operator == (const SBFrame &rhs) const
791{
Johnny Chen0164b752012-03-05 19:53:24 +0000792 return IsEqual(rhs);
Chris Lattner24943d22010-06-08 16:52:24 +0000793}
794
795bool
796SBFrame::operator != (const SBFrame &rhs) const
797{
Johnny Chen0164b752012-03-05 19:53:24 +0000798 return !IsEqual(rhs);
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000799}
Chris Lattner24943d22010-06-08 16:52:24 +0000800
801SBThread
802SBFrame::GetThread () const
803{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000804 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000805
Greg Claytona894fe72012-04-05 16:12:35 +0000806 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000807 ThreadSP thread_sp (exe_ctx.GetThreadSP());
808 SBThread sb_thread (thread_sp);
Caroline Tice7826c882010-10-26 03:11:13 +0000809
810 if (log)
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000811 {
812 SBStream sstr;
813 sb_thread.GetDescription (sstr);
Greg Clayton289afcb2012-02-18 05:35:26 +0000814 log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s",
815 exe_ctx.GetFramePtr(),
816 thread_sp.get(),
817 sstr.GetData());
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000818 }
Caroline Tice7826c882010-10-26 03:11:13 +0000819
Chris Lattner24943d22010-06-08 16:52:24 +0000820 return sb_thread;
821}
822
823const char *
824SBFrame::Disassemble () const
825{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000826 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000827 const char *disassembly = NULL;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000828 Mutex::Locker api_locker;
829 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
830
Greg Clayton289afcb2012-02-18 05:35:26 +0000831 StackFrame *frame = exe_ctx.GetFramePtr();
832 Target *target = exe_ctx.GetTargetPtr();
833 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000834 {
Greg Claytona894fe72012-04-05 16:12:35 +0000835 Process::StopLocker stop_locker;
836 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
837 {
Greg Claytona894fe72012-04-05 16:12:35 +0000838 disassembly = frame->Disassemble();
839 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000840 else
841 {
842 if (log)
843 log->Printf ("SBFrame(%p)::Disassemble () => error: process is running", frame);
844 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000845 }
Greg Claytona66ba462010-10-30 04:51:46 +0000846
847 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000848 log->Printf ("SBFrame(%p)::Disassemble () => %s", frame, disassembly);
Greg Claytona66ba462010-10-30 04:51:46 +0000849
850 return disassembly;
Chris Lattner24943d22010-06-08 16:52:24 +0000851}
852
853
Chris Lattner24943d22010-06-08 16:52:24 +0000854SBValueList
855SBFrame::GetVariables (bool arguments,
856 bool locals,
857 bool statics,
858 bool in_scope_only)
859{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000860 SBValueList value_list;
Greg Claytona894fe72012-04-05 16:12:35 +0000861 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000862 StackFrame *frame = exe_ctx.GetFramePtr();
863 Target *target = exe_ctx.GetTargetPtr();
864 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000865 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000866 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000867 value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
868 }
869 return value_list;
Jim Inghame41494a2011-04-16 00:01:13 +0000870}
871
872SBValueList
873SBFrame::GetVariables (bool arguments,
874 bool locals,
875 bool statics,
876 bool in_scope_only,
Jim Ingham10de7d12011-05-04 03:43:18 +0000877 lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000878{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000879 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000880
Greg Clayton334d33a2012-01-30 07:41:31 +0000881 SBValueList value_list;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000882 Mutex::Locker api_locker;
883 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
884
Greg Clayton289afcb2012-02-18 05:35:26 +0000885 StackFrame *frame = exe_ctx.GetFramePtr();
886 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton334d33a2012-01-30 07:41:31 +0000887
Caroline Tice7826c882010-10-26 03:11:13 +0000888 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000889 log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000890 frame,
Greg Claytona66ba462010-10-30 04:51:46 +0000891 arguments,
892 locals,
893 statics,
894 in_scope_only);
Greg Clayton334d33a2012-01-30 07:41:31 +0000895
Greg Clayton289afcb2012-02-18 05:35:26 +0000896 if (frame && target)
Chris Lattner24943d22010-06-08 16:52:24 +0000897 {
Greg Claytona894fe72012-04-05 16:12:35 +0000898 Process::StopLocker stop_locker;
899 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
900 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000901
Greg Claytona894fe72012-04-05 16:12:35 +0000902 size_t i;
903 VariableList *variable_list = NULL;
Jim Ingham887f62d2012-04-13 23:29:44 +0000904 variable_list = frame->GetVariableList(true);
Greg Claytona894fe72012-04-05 16:12:35 +0000905 if (variable_list)
906 {
907 const size_t num_variables = variable_list->GetSize();
908 if (num_variables)
Chris Lattner24943d22010-06-08 16:52:24 +0000909 {
Greg Claytona894fe72012-04-05 16:12:35 +0000910 for (i = 0; i < num_variables; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000911 {
Greg Claytona894fe72012-04-05 16:12:35 +0000912 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
913 if (variable_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000914 {
Greg Claytona894fe72012-04-05 16:12:35 +0000915 bool add_variable = false;
916 switch (variable_sp->GetScope())
917 {
918 case eValueTypeVariableGlobal:
919 case eValueTypeVariableStatic:
920 add_variable = statics;
921 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000922
Greg Claytona894fe72012-04-05 16:12:35 +0000923 case eValueTypeVariableArgument:
924 add_variable = arguments;
925 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000926
Greg Claytona894fe72012-04-05 16:12:35 +0000927 case eValueTypeVariableLocal:
928 add_variable = locals;
929 break;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000930
Greg Claytona894fe72012-04-05 16:12:35 +0000931 default:
932 break;
933 }
934 if (add_variable)
935 {
936 if (in_scope_only && !variable_sp->IsInScope(frame))
937 continue;
Chris Lattner24943d22010-06-08 16:52:24 +0000938
Greg Claytona894fe72012-04-05 16:12:35 +0000939 value_list.Append(frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
940 }
Chris Lattner24943d22010-06-08 16:52:24 +0000941 }
942 }
943 }
944 }
Greg Claytona894fe72012-04-05 16:12:35 +0000945 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000946 else
947 {
948 if (log)
949 log->Printf ("SBFrame(%p)::GetVariables () => error: process is running", frame);
950 }
Chris Lattner24943d22010-06-08 16:52:24 +0000951 }
Caroline Tice7826c882010-10-26 03:11:13 +0000952
953 if (log)
954 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000955 log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame,
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000956 value_list.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000957 }
958
Chris Lattner24943d22010-06-08 16:52:24 +0000959 return value_list;
960}
961
Greg Clayton4e9267d2010-12-14 18:39:31 +0000962SBValueList
Chris Lattner24943d22010-06-08 16:52:24 +0000963SBFrame::GetRegisters ()
964{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000965 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000966
Chris Lattner24943d22010-06-08 16:52:24 +0000967 SBValueList value_list;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000968 Mutex::Locker api_locker;
969 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
970
Greg Clayton289afcb2012-02-18 05:35:26 +0000971 StackFrame *frame = exe_ctx.GetFramePtr();
972 Target *target = exe_ctx.GetTargetPtr();
973 if (frame && target)
Chris Lattner24943d22010-06-08 16:52:24 +0000974 {
Greg Claytona894fe72012-04-05 16:12:35 +0000975 Process::StopLocker stop_locker;
976 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000977 {
Greg Claytona894fe72012-04-05 16:12:35 +0000978 RegisterContextSP reg_ctx (frame->GetRegisterContext());
979 if (reg_ctx)
Chris Lattner24943d22010-06-08 16:52:24 +0000980 {
Greg Claytona894fe72012-04-05 16:12:35 +0000981 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
982 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
983 {
984 value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx));
985 }
Chris Lattner24943d22010-06-08 16:52:24 +0000986 }
987 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000988 else
989 {
990 if (log)
991 log->Printf ("SBFrame(%p)::GetRegisters () => error: process is running", frame);
992 }
Chris Lattner24943d22010-06-08 16:52:24 +0000993 }
Caroline Tice7826c882010-10-26 03:11:13 +0000994
995 if (log)
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000996 log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", frame, value_list.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000997
Chris Lattner24943d22010-06-08 16:52:24 +0000998 return value_list;
999}
1000
Caroline Tice98f930f2010-09-20 05:20:02 +00001001bool
1002SBFrame::GetDescription (SBStream &description)
1003{
Greg Clayton96154be2011-11-13 06:57:31 +00001004 Stream &strm = description.ref();
1005
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001006 Mutex::Locker api_locker;
1007 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1008
Greg Clayton289afcb2012-02-18 05:35:26 +00001009 StackFrame *frame = exe_ctx.GetFramePtr();
1010 Target *target = exe_ctx.GetTargetPtr();
1011 if (frame && target)
Caroline Tice98f930f2010-09-20 05:20:02 +00001012 {
Greg Claytona894fe72012-04-05 16:12:35 +00001013 Process::StopLocker stop_locker;
1014 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1015 {
Greg Claytona894fe72012-04-05 16:12:35 +00001016 frame->DumpUsingSettingsFormat (&strm);
1017 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001018 else
1019 {
1020 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1021 if (log)
1022 log->Printf ("SBFrame(%p)::GetDescription () => error: process is running", frame);
1023 }
1024
Caroline Tice98f930f2010-09-20 05:20:02 +00001025 }
1026 else
Greg Clayton96154be2011-11-13 06:57:31 +00001027 strm.PutCString ("No value");
Caroline Tice98f930f2010-09-20 05:20:02 +00001028
1029 return true;
1030}
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001031
Greg Clayton4e9267d2010-12-14 18:39:31 +00001032SBValue
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001033SBFrame::EvaluateExpression (const char *expr)
1034{
Greg Clayton582ed0e2011-06-18 20:06:08 +00001035 SBValue result;
Greg Claytona894fe72012-04-05 16:12:35 +00001036 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001037 StackFrame *frame = exe_ctx.GetFramePtr();
1038 Target *target = exe_ctx.GetTargetPtr();
1039 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001040 {
Greg Clayton289afcb2012-02-18 05:35:26 +00001041 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +00001042 result = EvaluateExpression (expr, use_dynamic);
1043 }
1044 return result;
Jim Inghame41494a2011-04-16 00:01:13 +00001045}
1046
1047SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +00001048SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
Jim Inghame41494a2011-04-16 00:01:13 +00001049{
Jim Inghamd82bc6d2012-05-11 23:47:32 +00001050 return EvaluateExpression (expr, fetch_dynamic_value, true);
1051}
1052
1053SBValue
1054SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
1055{
Greg Clayton4e9267d2010-12-14 18:39:31 +00001056 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Sean Callanan94d255f2010-12-07 22:55:01 +00001057
Greg Clayton4e9267d2010-12-14 18:39:31 +00001058 LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Greg Claytona66ba462010-10-30 04:51:46 +00001059
Greg Clayton4a379b12012-07-17 03:23:13 +00001060 ExecutionResults exe_results = eExecutionSetupError;
Greg Clayton4e9267d2010-12-14 18:39:31 +00001061 SBValue expr_result;
Greg Clayton0a19a1b2012-02-04 02:27:34 +00001062 ValueObjectSP expr_value_sp;
Greg Claytona66ba462010-10-30 04:51:46 +00001063
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001064 Mutex::Locker api_locker;
1065 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1066
Greg Clayton289afcb2012-02-18 05:35:26 +00001067 StackFrame *frame = exe_ctx.GetFramePtr();
1068 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton334d33a2012-01-30 07:41:31 +00001069 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +00001070 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", frame, expr);
Greg Clayton334d33a2012-01-30 07:41:31 +00001071
Greg Clayton289afcb2012-02-18 05:35:26 +00001072 if (frame && target)
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001073 {
Greg Claytona894fe72012-04-05 16:12:35 +00001074 Process::StopLocker stop_locker;
1075 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1076 {
Enrico Granata299aa702012-05-29 18:06:49 +00001077#ifdef LLDB_CONFIGURATION_DEBUG
Greg Claytona894fe72012-04-05 16:12:35 +00001078 StreamString frame_description;
1079 frame->DumpUsingSettingsFormat (&frame_description);
Greg Claytona894fe72012-04-05 16:12:35 +00001080 Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
1081 expr, fetch_dynamic_value, frame_description.GetString().c_str());
Enrico Granata299aa702012-05-29 18:06:49 +00001082#endif
Greg Claytona894fe72012-04-05 16:12:35 +00001083 const bool coerce_to_id = false;
Greg Claytona894fe72012-04-05 16:12:35 +00001084 const bool keep_in_memory = false;
1085
1086 exe_results = target->EvaluateExpression (expr,
1087 frame,
1088 eExecutionPolicyOnlyWhenNeeded,
1089 coerce_to_id,
1090 unwind_on_error,
1091 keep_in_memory,
1092 fetch_dynamic_value,
1093 expr_value_sp);
1094 expr_result.SetSP(expr_value_sp);
Enrico Granata299aa702012-05-29 18:06:49 +00001095#ifdef LLDB_CONFIGURATION_DEBUG
Greg Claytona894fe72012-04-05 16:12:35 +00001096 Host::SetCrashDescription (NULL);
Enrico Granata299aa702012-05-29 18:06:49 +00001097#endif
Greg Claytona894fe72012-04-05 16:12:35 +00001098 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001099 else
1100 {
1101 if (log)
1102 log->Printf ("SBFrame(%p)::EvaluateExpression () => error: process is running", frame);
1103 }
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001104 }
Jason Molendac48ca822012-02-21 05:33:55 +00001105
1106#ifndef LLDB_DISABLE_PYTHON
Sean Callanan94d255f2010-12-07 22:55:01 +00001107 if (expr_log)
Jim Inghame41494a2011-04-16 00:01:13 +00001108 expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **",
Greg Clayton0fb0bcc2011-08-03 22:57:10 +00001109 expr_result.GetValue(),
1110 expr_result.GetSummary());
Sean Callanan94d255f2010-12-07 22:55:01 +00001111
Greg Claytona66ba462010-10-30 04:51:46 +00001112 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +00001113 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
1114 frame,
Jim Inghame41494a2011-04-16 00:01:13 +00001115 expr,
Greg Clayton0a19a1b2012-02-04 02:27:34 +00001116 expr_value_sp.get(),
Johnny Chenee6e7902011-08-10 22:06:24 +00001117 exe_results);
Jason Molendac48ca822012-02-21 05:33:55 +00001118#endif
Greg Claytona66ba462010-10-30 04:51:46 +00001119
Greg Clayton49ce6822010-10-31 03:01:06 +00001120 return expr_result;
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001121}
Greg Clayton582ed0e2011-06-18 20:06:08 +00001122
1123bool
1124SBFrame::IsInlined()
1125{
Greg Claytona894fe72012-04-05 16:12:35 +00001126 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001127 StackFrame *frame = exe_ctx.GetFramePtr();
1128 Target *target = exe_ctx.GetTargetPtr();
1129 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001130 {
Greg Claytona894fe72012-04-05 16:12:35 +00001131 Process::StopLocker stop_locker;
1132 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1133 {
1134
1135 Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
1136 if (block)
1137 return block->GetContainingInlinedBlock () != NULL;
1138 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001139 else
1140 {
1141 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1142 if (log)
1143 log->Printf ("SBFrame(%p)::IsInlined () => error: process is running", frame);
1144 }
1145
Greg Clayton582ed0e2011-06-18 20:06:08 +00001146 }
1147 return false;
1148}
1149
1150const char *
1151SBFrame::GetFunctionName()
1152{
1153 const char *name = NULL;
Greg Claytona894fe72012-04-05 16:12:35 +00001154 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001155 StackFrame *frame = exe_ctx.GetFramePtr();
1156 Target *target = exe_ctx.GetTargetPtr();
1157 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001158 {
Greg Claytona894fe72012-04-05 16:12:35 +00001159 Process::StopLocker stop_locker;
1160 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Greg Clayton582ed0e2011-06-18 20:06:08 +00001161 {
Greg Claytona894fe72012-04-05 16:12:35 +00001162 SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
1163 if (sc.block)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001164 {
Greg Claytona894fe72012-04-05 16:12:35 +00001165 Block *inlined_block = sc.block->GetContainingInlinedBlock ();
1166 if (inlined_block)
1167 {
1168 const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo();
1169 name = inlined_info->GetName().AsCString();
1170 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001171 }
Greg Claytona894fe72012-04-05 16:12:35 +00001172
1173 if (name == NULL)
1174 {
1175 if (sc.function)
1176 name = sc.function->GetName().GetCString();
1177 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001178
Greg Claytona894fe72012-04-05 16:12:35 +00001179 if (name == NULL)
1180 {
1181 if (sc.symbol)
1182 name = sc.symbol->GetName().GetCString();
1183 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001184 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001185 else
1186 {
1187 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1188 if (log)
1189 log->Printf ("SBFrame(%p)::GetFunctionName() => error: process is running", frame);
1190
1191 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001192 }
1193 return name;
1194}
1195