blob: ca451918c397498972ca128ceb06e6d62dcfc16b [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"
Caroline Tice98f930f2010-09-20 05:20:02 +000043#include "lldb/API/SBStream.h"
Eli Friedman7a62c8b2010-06-09 07:44:37 +000044#include "lldb/API/SBSymbolContext.h"
45#include "lldb/API/SBThread.h"
Chris Lattner24943d22010-06-08 16:52:24 +000046
47using namespace lldb;
48using namespace lldb_private;
49
Greg Clayton334d33a2012-01-30 07:41:31 +000050
Chris Lattner24943d22010-06-08 16:52:24 +000051SBFrame::SBFrame () :
Greg Claytona894fe72012-04-05 16:12:35 +000052 m_opaque_sp (new ExecutionContextRef())
Chris Lattner24943d22010-06-08 16:52:24 +000053{
54}
55
Greg Clayton4e9267d2010-12-14 18:39:31 +000056SBFrame::SBFrame (const StackFrameSP &lldb_object_sp) :
Greg Claytona894fe72012-04-05 16:12:35 +000057 m_opaque_sp (new ExecutionContextRef (lldb_object_sp))
Chris Lattner24943d22010-06-08 16:52:24 +000058{
Greg Clayton4e9267d2010-12-14 18:39:31 +000059 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +000060
61 if (log)
62 {
63 SBStream sstr;
64 GetDescription (sstr);
Greg Claytona66ba462010-10-30 04:51:46 +000065 log->Printf ("SBFrame::SBFrame (sp=%p) => SBFrame(%p): %s",
Greg Clayton334d33a2012-01-30 07:41:31 +000066 lldb_object_sp.get(), lldb_object_sp.get(), sstr.GetData());
Caroline Tice61ba7ec2010-10-26 23:49:36 +000067
Caroline Tice7826c882010-10-26 03:11:13 +000068 }
Chris Lattner24943d22010-06-08 16:52:24 +000069}
70
Greg Clayton538eb822010-11-05 23:17:00 +000071SBFrame::SBFrame(const SBFrame &rhs) :
Greg Claytona894fe72012-04-05 16:12:35 +000072 m_opaque_sp (new ExecutionContextRef (*rhs.m_opaque_sp))
Greg Clayton538eb822010-11-05 23:17:00 +000073{
74}
75
76const SBFrame &
77SBFrame::operator = (const SBFrame &rhs)
78{
79 if (this != &rhs)
Greg Claytona894fe72012-04-05 16:12:35 +000080 *m_opaque_sp = *rhs.m_opaque_sp;
Greg Clayton538eb822010-11-05 23:17:00 +000081 return *this;
82}
83
Chris Lattner24943d22010-06-08 16:52:24 +000084SBFrame::~SBFrame()
85{
86}
87
Greg Clayton334d33a2012-01-30 07:41:31 +000088StackFrameSP
89SBFrame::GetFrameSP() const
Chris Lattner24943d22010-06-08 16:52:24 +000090{
Greg Clayton26425852012-04-12 20:58:26 +000091 if (m_opaque_sp)
92 return m_opaque_sp->GetFrameSP();
93 return StackFrameSP();
Chris Lattner24943d22010-06-08 16:52:24 +000094}
95
Greg Clayton334d33a2012-01-30 07:41:31 +000096void
97SBFrame::SetFrameSP (const StackFrameSP &lldb_object_sp)
98{
Greg Claytona894fe72012-04-05 16:12:35 +000099 return m_opaque_sp->SetFrameSP(lldb_object_sp);
Greg Clayton334d33a2012-01-30 07:41:31 +0000100}
Chris Lattner24943d22010-06-08 16:52:24 +0000101
102bool
103SBFrame::IsValid() const
104{
Greg Claytona894fe72012-04-05 16:12:35 +0000105 return GetFrameSP().get() != NULL;
Chris Lattner24943d22010-06-08 16:52:24 +0000106}
107
108SBSymbolContext
109SBFrame::GetSymbolContext (uint32_t resolve_scope) const
110{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000111 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner24943d22010-06-08 16:52:24 +0000112 SBSymbolContext sb_sym_ctx;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000113 Mutex::Locker api_locker;
114 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
115
Greg Clayton289afcb2012-02-18 05:35:26 +0000116 StackFrame *frame = exe_ctx.GetFramePtr();
117 Target *target = exe_ctx.GetTargetPtr();
118 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000119 {
Greg Claytona894fe72012-04-05 16:12:35 +0000120 Process::StopLocker stop_locker;
121 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
122 {
Greg Claytona894fe72012-04-05 16:12:35 +0000123 sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext (resolve_scope));
124 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000125 else
126 {
127 if (log)
128 log->Printf ("SBFrame(%p)::GetSymbolContext () => error: process is running", frame);
129 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000130 }
Caroline Tice7826c882010-10-26 03:11:13 +0000131
132 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000133 log->Printf ("SBFrame(%p)::GetSymbolContext (resolve_scope=0x%8.8x) => SBSymbolContext(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000134 frame, resolve_scope, sb_sym_ctx.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000135
Chris Lattner24943d22010-06-08 16:52:24 +0000136 return sb_sym_ctx;
137}
138
139SBModule
140SBFrame::GetModule () const
141{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000142 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000143 SBModule sb_module;
Greg Clayton0416bdf2012-01-30 09:04:36 +0000144 ModuleSP module_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000145 Mutex::Locker api_locker;
146 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
147
Greg Clayton289afcb2012-02-18 05:35:26 +0000148 StackFrame *frame = exe_ctx.GetFramePtr();
149 Target *target = exe_ctx.GetTargetPtr();
150 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000151 {
Greg Claytona894fe72012-04-05 16:12:35 +0000152 Process::StopLocker stop_locker;
153 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
154 {
Greg Claytona894fe72012-04-05 16:12:35 +0000155 module_sp = frame->GetSymbolContext (eSymbolContextModule).module_sp;
156 sb_module.SetSP (module_sp);
157 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000158 else
159 {
160 if (log)
161 log->Printf ("SBFrame(%p)::GetModule () => error: process is running", frame);
162 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000163 }
Greg Claytondd62d722010-12-14 04:58:53 +0000164
Greg Claytona66ba462010-10-30 04:51:46 +0000165 if (log)
166 log->Printf ("SBFrame(%p)::GetModule () => SBModule(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000167 frame, module_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000168
Chris Lattner24943d22010-06-08 16:52:24 +0000169 return sb_module;
170}
171
172SBCompileUnit
173SBFrame::GetCompileUnit () const
174{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000175 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000176 SBCompileUnit sb_comp_unit;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000177 Mutex::Locker api_locker;
178 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
179
Greg Clayton289afcb2012-02-18 05:35:26 +0000180 StackFrame *frame = exe_ctx.GetFramePtr();
181 Target *target = exe_ctx.GetTargetPtr();
182 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000183 {
Greg Claytona894fe72012-04-05 16:12:35 +0000184 Process::StopLocker stop_locker;
185 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
186 {
Greg Claytona894fe72012-04-05 16:12:35 +0000187 sb_comp_unit.reset (frame->GetSymbolContext (eSymbolContextCompUnit).comp_unit);
188 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000189 else
190 {
191 if (log)
192 log->Printf ("SBFrame(%p)::GetCompileUnit () => error: process is running", frame);
193 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000194 }
Caroline Tice7826c882010-10-26 03:11:13 +0000195 if (log)
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000196 log->Printf ("SBFrame(%p)::GetCompileUnit () => SBCompileUnit(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000197 frame, sb_comp_unit.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000198
Chris Lattner24943d22010-06-08 16:52:24 +0000199 return sb_comp_unit;
200}
201
202SBFunction
203SBFrame::GetFunction () const
204{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000205 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000206 SBFunction sb_function;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000207 Mutex::Locker api_locker;
208 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
209
Greg Clayton289afcb2012-02-18 05:35:26 +0000210 StackFrame *frame = exe_ctx.GetFramePtr();
211 Target *target = exe_ctx.GetTargetPtr();
212 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000213 {
Greg Claytona894fe72012-04-05 16:12:35 +0000214 Process::StopLocker stop_locker;
215 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
216 {
Greg Claytona894fe72012-04-05 16:12:35 +0000217 sb_function.reset(frame->GetSymbolContext (eSymbolContextFunction).function);
218 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000219 else
220 {
221 if (log)
222 log->Printf ("SBFrame(%p)::GetFunction () => error: process is running", frame);
223 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000224 }
Greg Claytona66ba462010-10-30 04:51:46 +0000225 if (log)
226 log->Printf ("SBFrame(%p)::GetFunction () => SBFunction(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000227 frame, sb_function.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000228
Chris Lattner24943d22010-06-08 16:52:24 +0000229 return sb_function;
230}
231
Greg Clayton8f1e08b2010-10-04 18:37:52 +0000232SBSymbol
233SBFrame::GetSymbol () const
234{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000235 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000236 SBSymbol sb_symbol;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000237 Mutex::Locker api_locker;
238 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
239
Greg Clayton289afcb2012-02-18 05:35:26 +0000240 StackFrame *frame = exe_ctx.GetFramePtr();
241 Target *target = exe_ctx.GetTargetPtr();
242 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000243 {
Greg Claytona894fe72012-04-05 16:12:35 +0000244 Process::StopLocker stop_locker;
245 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
246 {
Greg Claytona894fe72012-04-05 16:12:35 +0000247 sb_symbol.reset(frame->GetSymbolContext (eSymbolContextSymbol).symbol);
248 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000249 else
250 {
251 if (log)
252 log->Printf ("SBFrame(%p)::GetSymbol () => error: process is running", frame);
253 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000254 }
Greg Claytona66ba462010-10-30 04:51:46 +0000255 if (log)
256 log->Printf ("SBFrame(%p)::GetSymbol () => SBSymbol(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000257 frame, sb_symbol.get());
Greg Clayton8f1e08b2010-10-04 18:37:52 +0000258 return sb_symbol;
259}
260
Chris Lattner24943d22010-06-08 16:52:24 +0000261SBBlock
262SBFrame::GetBlock () const
263{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000264 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000265 SBBlock sb_block;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000266 Mutex::Locker api_locker;
267 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
268
Greg Clayton289afcb2012-02-18 05:35:26 +0000269 StackFrame *frame = exe_ctx.GetFramePtr();
270 Target *target = exe_ctx.GetTargetPtr();
271 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000272 {
Greg Claytona894fe72012-04-05 16:12:35 +0000273 Process::StopLocker stop_locker;
274 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
275 {
Greg Claytona894fe72012-04-05 16:12:35 +0000276 sb_block.SetPtr (frame->GetSymbolContext (eSymbolContextBlock).block);
277 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000278 else
279 {
280 if (log)
281 log->Printf ("SBFrame(%p)::GetBlock () => error: process is running", frame);
282 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000283 }
Greg Claytona66ba462010-10-30 04:51:46 +0000284 if (log)
285 log->Printf ("SBFrame(%p)::GetBlock () => SBBlock(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000286 frame, sb_block.GetPtr());
Chris Lattner24943d22010-06-08 16:52:24 +0000287 return sb_block;
288}
289
Greg Clayton69aa5d92010-09-07 04:20:48 +0000290SBBlock
291SBFrame::GetFrameBlock () const
292{
Greg Claytondd62d722010-12-14 04:58:53 +0000293 SBBlock sb_block;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000294 Mutex::Locker api_locker;
295 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
296
Greg Clayton289afcb2012-02-18 05:35:26 +0000297 StackFrame *frame = exe_ctx.GetFramePtr();
298 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000299 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton289afcb2012-02-18 05:35:26 +0000300 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000301 {
Greg Claytona894fe72012-04-05 16:12:35 +0000302 Process::StopLocker stop_locker;
303 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
304 {
Greg Claytona894fe72012-04-05 16:12:35 +0000305 sb_block.SetPtr(frame->GetFrameBlock ());
306 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000307 else
308 {
309 if (log)
310 log->Printf ("SBFrame(%p)::GetFrameBlock () => error: process is running", frame);
311 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000312 }
Greg Claytona66ba462010-10-30 04:51:46 +0000313 if (log)
314 log->Printf ("SBFrame(%p)::GetFrameBlock () => SBBlock(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000315 frame, sb_block.GetPtr());
Greg Clayton69aa5d92010-09-07 04:20:48 +0000316 return sb_block;
317}
318
Chris Lattner24943d22010-06-08 16:52:24 +0000319SBLineEntry
320SBFrame::GetLineEntry () const
321{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000322 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytondd62d722010-12-14 04:58:53 +0000323 SBLineEntry sb_line_entry;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000324 Mutex::Locker api_locker;
325 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
326
Greg Clayton289afcb2012-02-18 05:35:26 +0000327 StackFrame *frame = exe_ctx.GetFramePtr();
328 Target *target = exe_ctx.GetTargetPtr();
329 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000330 {
Greg Claytona894fe72012-04-05 16:12:35 +0000331 Process::StopLocker stop_locker;
332 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
333 {
Greg Claytona894fe72012-04-05 16:12:35 +0000334 sb_line_entry.SetLineEntry (frame->GetSymbolContext (eSymbolContextLineEntry).line_entry);
335 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000336 else
337 {
338 if (log)
339 log->Printf ("SBFrame(%p)::GetLineEntry () => error: process is running", frame);
340 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000341 }
Greg Claytona66ba462010-10-30 04:51:46 +0000342 if (log)
343 log->Printf ("SBFrame(%p)::GetLineEntry () => SBLineEntry(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000344 frame, sb_line_entry.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000345 return sb_line_entry;
346}
347
348uint32_t
349SBFrame::GetFrameID () const
350{
Greg Clayton334d33a2012-01-30 07:41:31 +0000351 uint32_t frame_idx = UINT32_MAX;
352
Greg Claytona894fe72012-04-05 16:12:35 +0000353 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000354 StackFrame *frame = exe_ctx.GetFramePtr();
Greg Claytona894fe72012-04-05 16:12:35 +0000355 if (frame)
Greg Clayton289afcb2012-02-18 05:35:26 +0000356 frame_idx = frame->GetFrameIndex ();
Greg Claytona66ba462010-10-30 04:51:46 +0000357
Greg Clayton4e9267d2010-12-14 18:39:31 +0000358 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000359 if (log)
360 log->Printf ("SBFrame(%p)::GetFrameID () => %u",
Greg Clayton289afcb2012-02-18 05:35:26 +0000361 frame, frame_idx);
Greg Claytona66ba462010-10-30 04:51:46 +0000362 return frame_idx;
Chris Lattner24943d22010-06-08 16:52:24 +0000363}
364
Greg Clayton4e9267d2010-12-14 18:39:31 +0000365addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000366SBFrame::GetPC () const
367{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000368 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000369 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000370 Mutex::Locker api_locker;
371 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
372
Greg Clayton289afcb2012-02-18 05:35:26 +0000373 StackFrame *frame = exe_ctx.GetFramePtr();
374 Target *target = exe_ctx.GetTargetPtr();
375 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000376 {
Greg Claytona894fe72012-04-05 16:12:35 +0000377 Process::StopLocker stop_locker;
378 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
379 {
Greg Claytona894fe72012-04-05 16:12:35 +0000380 addr = frame->GetFrameCodeAddress().GetOpcodeLoadAddress (target);
381 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000382 else
383 {
384 if (log)
385 log->Printf ("SBFrame(%p)::GetPC () => error: process is running", frame);
386 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000387 }
Caroline Tice7826c882010-10-26 03:11:13 +0000388
389 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000390 log->Printf ("SBFrame(%p)::GetPC () => 0x%llx", frame, addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000391
392 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000393}
394
395bool
Greg Clayton4e9267d2010-12-14 18:39:31 +0000396SBFrame::SetPC (addr_t new_pc)
Chris Lattner24943d22010-06-08 16:52:24 +0000397{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000398 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000399 bool ret_val = false;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000400 Mutex::Locker api_locker;
401 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
402
Greg Clayton289afcb2012-02-18 05:35:26 +0000403 StackFrame *frame = exe_ctx.GetFramePtr();
404 Target *target = exe_ctx.GetTargetPtr();
405 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000406 {
Greg Claytona894fe72012-04-05 16:12:35 +0000407 Process::StopLocker stop_locker;
408 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
409 {
Greg Claytona894fe72012-04-05 16:12:35 +0000410 ret_val = frame->GetRegisterContext()->SetPC (new_pc);
411 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000412 else
413 {
414 if (log)
415 log->Printf ("SBFrame(%p)::SetPC () => error: process is running", frame);
416 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000417 }
Caroline Tice7826c882010-10-26 03:11:13 +0000418
419 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000420 log->Printf ("SBFrame(%p)::SetPC (new_pc=0x%llx) => %i",
Greg Clayton289afcb2012-02-18 05:35:26 +0000421 frame, new_pc, ret_val);
Caroline Tice7826c882010-10-26 03:11:13 +0000422
423 return ret_val;
Chris Lattner24943d22010-06-08 16:52:24 +0000424}
425
Greg Clayton4e9267d2010-12-14 18:39:31 +0000426addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000427SBFrame::GetSP () const
428{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000429 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000430 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000431 Mutex::Locker api_locker;
432 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
433
Greg Clayton289afcb2012-02-18 05:35:26 +0000434 StackFrame *frame = exe_ctx.GetFramePtr();
435 Target *target = exe_ctx.GetTargetPtr();
436 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000437 {
Greg Claytona894fe72012-04-05 16:12:35 +0000438 Process::StopLocker stop_locker;
439 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
440 {
Greg Claytona894fe72012-04-05 16:12:35 +0000441 addr = frame->GetRegisterContext()->GetSP();
442 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000443 else
444 {
445 if (log)
446 log->Printf ("SBFrame(%p)::GetSP () => error: process is running", frame);
447 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000448 }
Greg Claytona66ba462010-10-30 04:51:46 +0000449 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000450 log->Printf ("SBFrame(%p)::GetSP () => 0x%llx", frame, addr);
Greg Claytona66ba462010-10-30 04:51:46 +0000451
452 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000453}
454
455
Greg Clayton4e9267d2010-12-14 18:39:31 +0000456addr_t
Chris Lattner24943d22010-06-08 16:52:24 +0000457SBFrame::GetFP () const
458{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000459 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000460 addr_t addr = LLDB_INVALID_ADDRESS;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000461 Mutex::Locker api_locker;
462 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
463
Greg Clayton289afcb2012-02-18 05:35:26 +0000464 StackFrame *frame = exe_ctx.GetFramePtr();
465 Target *target = exe_ctx.GetTargetPtr();
466 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000467 {
Greg Claytona894fe72012-04-05 16:12:35 +0000468 Process::StopLocker stop_locker;
469 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
470 {
Greg Claytona894fe72012-04-05 16:12:35 +0000471 addr = frame->GetRegisterContext()->GetFP();
472 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000473 else
474 {
475 if (log)
476 log->Printf ("SBFrame(%p)::GetFP () => error: process is running", frame);
477 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000478 }
Caroline Tice7826c882010-10-26 03:11:13 +0000479
480 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000481 log->Printf ("SBFrame(%p)::GetFP () => 0x%llx", frame, addr);
Caroline Tice7826c882010-10-26 03:11:13 +0000482 return addr;
Chris Lattner24943d22010-06-08 16:52:24 +0000483}
484
485
486SBAddress
487SBFrame::GetPCAddress () const
488{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000489 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Chris Lattner24943d22010-06-08 16:52:24 +0000490 SBAddress sb_addr;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000491 Mutex::Locker api_locker;
492 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
493
Greg Clayton289afcb2012-02-18 05:35:26 +0000494 StackFrame *frame = exe_ctx.GetFramePtr();
495 Target *target = exe_ctx.GetTargetPtr();
496 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000497 {
Greg Claytona894fe72012-04-05 16:12:35 +0000498 Process::StopLocker stop_locker;
499 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
500 {
Greg Claytona894fe72012-04-05 16:12:35 +0000501 sb_addr.SetAddress (&frame->GetFrameCodeAddress());
502 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000503 else
504 {
505 if (log)
506 log->Printf ("SBFrame(%p)::GetPCAddress () => error: process is running", frame);
507 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000508 }
Greg Claytona66ba462010-10-30 04:51:46 +0000509 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000510 log->Printf ("SBFrame(%p)::GetPCAddress () => SBAddress(%p)", frame, sb_addr.get());
Chris Lattner24943d22010-06-08 16:52:24 +0000511 return sb_addr;
512}
513
514void
515SBFrame::Clear()
516{
Greg Clayton26425852012-04-12 20:58:26 +0000517 m_opaque_sp->Clear();
Chris Lattner24943d22010-06-08 16:52:24 +0000518}
519
Greg Claytond62b9c12012-02-03 07:02:37 +0000520lldb::SBValue
521SBFrame::GetValueForVariablePath (const char *var_path)
522{
523 SBValue sb_value;
Greg Claytona894fe72012-04-05 16:12:35 +0000524 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000525 StackFrame *frame = exe_ctx.GetFramePtr();
526 Target *target = exe_ctx.GetTargetPtr();
527 if (frame && target)
Greg Claytond62b9c12012-02-03 07:02:37 +0000528 {
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000529 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
530 sb_value = GetValueForVariablePath (var_path, use_dynamic);
Greg Claytond62b9c12012-02-03 07:02:37 +0000531 }
532 return sb_value;
533}
534
535lldb::SBValue
536SBFrame::GetValueForVariablePath (const char *var_path, DynamicValueType use_dynamic)
537{
538 SBValue sb_value;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000539 Mutex::Locker api_locker;
540 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
541
Greg Clayton289afcb2012-02-18 05:35:26 +0000542 StackFrame *frame = exe_ctx.GetFramePtr();
543 Target *target = exe_ctx.GetTargetPtr();
544 if (frame && target && var_path && var_path[0])
Greg Claytond62b9c12012-02-03 07:02:37 +0000545 {
Greg Claytona894fe72012-04-05 16:12:35 +0000546 Process::StopLocker stop_locker;
547 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
548 {
Greg Claytona894fe72012-04-05 16:12:35 +0000549 VariableSP var_sp;
550 Error error;
551 ValueObjectSP value_sp (frame->GetValueForVariableExpressionPath (var_path,
552 use_dynamic,
Greg Claytonb3a1a2b2012-07-14 00:53:55 +0000553 StackFrame::eExpressionPathOptionCheckPtrVsMember | StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
Greg Claytona894fe72012-04-05 16:12:35 +0000554 var_sp,
555 error));
556 sb_value.SetSP(value_sp);
557 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000558 else
559 {
560 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
561 if (log)
562 log->Printf ("SBFrame(%p)::GetValueForVariablePath () => error: process is running", frame);
563 }
Greg Claytond62b9c12012-02-03 07:02:37 +0000564 }
565 return sb_value;
566}
567
Chris Lattner24943d22010-06-08 16:52:24 +0000568SBValue
Greg Clayton4e9267d2010-12-14 18:39:31 +0000569SBFrame::FindVariable (const char *name)
Chris Lattner24943d22010-06-08 16:52:24 +0000570{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000571 SBValue value;
Greg Claytona894fe72012-04-05 16:12:35 +0000572 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000573 StackFrame *frame = exe_ctx.GetFramePtr();
574 Target *target = exe_ctx.GetTargetPtr();
575 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000576 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000577 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000578 value = FindVariable (name, use_dynamic);
579 }
580 return value;
Jim Inghame41494a2011-04-16 00:01:13 +0000581}
Greg Claytond62b9c12012-02-03 07:02:37 +0000582
Jim Inghame41494a2011-04-16 00:01:13 +0000583
584SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000585SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000586{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000587 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000588 VariableSP var_sp;
Jim Ingham47da8102011-04-22 23:53:53 +0000589 SBValue sb_value;
Greg Clayton0a19a1b2012-02-04 02:27:34 +0000590 ValueObjectSP value_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000591 Mutex::Locker api_locker;
592 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
593
Greg Clayton289afcb2012-02-18 05:35:26 +0000594 StackFrame *frame = exe_ctx.GetFramePtr();
595 Target *target = exe_ctx.GetTargetPtr();
596 if (frame && target && name && name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000597 {
Greg Claytona894fe72012-04-05 16:12:35 +0000598 Process::StopLocker stop_locker;
599 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000600 {
Greg Claytona894fe72012-04-05 16:12:35 +0000601 VariableList variable_list;
Greg Claytona894fe72012-04-05 16:12:35 +0000602 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
603
604 if (sc.block)
Greg Claytondd62d722010-12-14 04:58:53 +0000605 {
Greg Claytona894fe72012-04-05 16:12:35 +0000606 const bool can_create = true;
607 const bool get_parent_variables = true;
608 const bool stop_if_block_is_inlined_function = true;
609
610 if (sc.block->AppendVariables (can_create,
611 get_parent_variables,
612 stop_if_block_is_inlined_function,
613 &variable_list))
614 {
615 var_sp = variable_list.FindVariable (ConstString(name));
616 }
617 }
618
619 if (var_sp)
620 {
621 value_sp = frame->GetValueObjectForFrameVariable(var_sp, use_dynamic);
622 sb_value.SetSP(value_sp);
Greg Claytondd62d722010-12-14 04:58:53 +0000623 }
Chris Lattner24943d22010-06-08 16:52:24 +0000624 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000625 else
626 {
627 if (log)
628 log->Printf ("SBFrame(%p)::FindVariable () => error: process is running", frame);
629 }
Chris Lattner24943d22010-06-08 16:52:24 +0000630 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000631
Greg Claytona66ba462010-10-30 04:51:46 +0000632 if (log)
Greg Clayton4e9267d2010-12-14 18:39:31 +0000633 log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000634 frame, name, value_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000635
Chris Lattner24943d22010-06-08 16:52:24 +0000636 return sb_value;
637}
638
639SBValue
Greg Clayton4e9267d2010-12-14 18:39:31 +0000640SBFrame::FindValue (const char *name, ValueType value_type)
Chris Lattner24943d22010-06-08 16:52:24 +0000641{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000642 SBValue value;
Greg Claytona894fe72012-04-05 16:12:35 +0000643 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000644 StackFrame *frame = exe_ctx.GetFramePtr();
645 Target *target = exe_ctx.GetTargetPtr();
646 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000647 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000648 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000649 value = FindValue (name, value_type, use_dynamic);
650 }
651 return value;
Jim Inghame41494a2011-04-16 00:01:13 +0000652}
653
654SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +0000655SBFrame::FindValue (const char *name, ValueType value_type, lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000656{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000657 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000658 SBValue sb_value;
Greg Clayton0a19a1b2012-02-04 02:27:34 +0000659 ValueObjectSP value_sp;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000660 Mutex::Locker api_locker;
661 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
662
Greg Clayton289afcb2012-02-18 05:35:26 +0000663 StackFrame *frame = exe_ctx.GetFramePtr();
664 Target *target = exe_ctx.GetTargetPtr();
665 if (frame && target && name && name[0])
Chris Lattner24943d22010-06-08 16:52:24 +0000666 {
Greg Claytona894fe72012-04-05 16:12:35 +0000667 Process::StopLocker stop_locker;
668 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000669 {
Greg Claytona894fe72012-04-05 16:12:35 +0000670 switch (value_type)
Chris Lattner24943d22010-06-08 16:52:24 +0000671 {
Greg Claytona894fe72012-04-05 16:12:35 +0000672 case eValueTypeVariableGlobal: // global variable
673 case eValueTypeVariableStatic: // static variable
674 case eValueTypeVariableArgument: // function argument variables
675 case eValueTypeVariableLocal: // function local variables
676 {
677 VariableList *variable_list = frame->GetVariableList(true);
Greg Clayton4e9267d2010-12-14 18:39:31 +0000678
Greg Claytona894fe72012-04-05 16:12:35 +0000679 SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
Greg Clayton4e9267d2010-12-14 18:39:31 +0000680
Greg Claytona894fe72012-04-05 16:12:35 +0000681 const bool can_create = true;
682 const bool get_parent_variables = true;
683 const bool stop_if_block_is_inlined_function = true;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000684
Greg Claytona894fe72012-04-05 16:12:35 +0000685 if (sc.block && sc.block->AppendVariables (can_create,
686 get_parent_variables,
687 stop_if_block_is_inlined_function,
688 variable_list))
689 {
690 ConstString const_name(name);
691 const uint32_t num_variables = variable_list->GetSize();
692 for (uint32_t i = 0; i < num_variables; ++i)
693 {
694 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
695 if (variable_sp &&
696 variable_sp->GetScope() == value_type &&
697 variable_sp->GetName() == const_name)
698 {
699 value_sp = frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic);
700 sb_value.SetSP (value_sp);
701 break;
702 }
703 }
704 }
705 }
706 break;
707
708 case eValueTypeRegister: // stack frame register value
709 {
710 RegisterContextSP reg_ctx (frame->GetRegisterContext());
711 if (reg_ctx)
712 {
713 const uint32_t num_regs = reg_ctx->GetRegisterCount();
714 for (uint32_t reg_idx = 0; reg_idx < num_regs; ++reg_idx)
715 {
716 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoAtIndex (reg_idx);
717 if (reg_info &&
718 ((reg_info->name && strcasecmp (reg_info->name, name) == 0) ||
719 (reg_info->alt_name && strcasecmp (reg_info->alt_name, name) == 0)))
720 {
721 value_sp = ValueObjectRegister::Create (frame, reg_ctx, reg_idx);
722 sb_value.SetSP (value_sp);
723 break;
724 }
725 }
726 }
727 }
728 break;
729
730 case eValueTypeRegisterSet: // A collection of stack frame register values
731 {
732 RegisterContextSP reg_ctx (frame->GetRegisterContext());
733 if (reg_ctx)
734 {
735 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
736 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
737 {
738 const RegisterSet *reg_set = reg_ctx->GetRegisterSet (set_idx);
739 if (reg_set &&
740 ((reg_set->name && strcasecmp (reg_set->name, name) == 0) ||
741 (reg_set->short_name && strcasecmp (reg_set->short_name, name) == 0)))
742 {
743 value_sp = ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx);
744 sb_value.SetSP (value_sp);
745 break;
746 }
747 }
748 }
749 }
750 break;
751
752 case eValueTypeConstResult: // constant result variables
Johnny Chenc35750a2010-11-19 18:07:14 +0000753 {
Greg Clayton4e9267d2010-12-14 18:39:31 +0000754 ConstString const_name(name);
Greg Claytona894fe72012-04-05 16:12:35 +0000755 ClangExpressionVariableSP expr_var_sp (target->GetPersistentVariables().GetVariable (const_name));
756 if (expr_var_sp)
Johnny Chenc35750a2010-11-19 18:07:14 +0000757 {
Greg Claytona894fe72012-04-05 16:12:35 +0000758 value_sp = expr_var_sp->GetValueObject();
759 sb_value.SetSP (value_sp);
Johnny Chenc35750a2010-11-19 18:07:14 +0000760 }
761 }
Greg Claytona894fe72012-04-05 16:12:35 +0000762 break;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000763
Greg Claytona894fe72012-04-05 16:12:35 +0000764 default:
765 break;
Greg Clayton4e9267d2010-12-14 18:39:31 +0000766 }
Chris Lattner24943d22010-06-08 16:52:24 +0000767 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000768 else
769 {
770 if (log)
771 log->Printf ("SBFrame(%p)::FindValue () => error: process is running", frame);
772 }
Chris Lattner24943d22010-06-08 16:52:24 +0000773 }
Caroline Tice98f930f2010-09-20 05:20:02 +0000774
Greg Claytona66ba462010-10-30 04:51:46 +0000775 if (log)
Greg Clayton4e9267d2010-12-14 18:39:31 +0000776 log->Printf ("SBFrame(%p)::FindVariableInScope (name=\"%s\", value_type=%i) => SBValue(%p)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000777 frame, name, value_type, value_sp.get());
Greg Claytona66ba462010-10-30 04:51:46 +0000778
779
Chris Lattner24943d22010-06-08 16:52:24 +0000780 return sb_value;
781}
782
783bool
Johnny Chen0164b752012-03-05 19:53:24 +0000784SBFrame::IsEqual (const SBFrame &that) const
785{
786 lldb::StackFrameSP this_sp = GetFrameSP();
787 lldb::StackFrameSP that_sp = that.GetFrameSP();
788 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
789}
790
791bool
Chris Lattner24943d22010-06-08 16:52:24 +0000792SBFrame::operator == (const SBFrame &rhs) const
793{
Johnny Chen0164b752012-03-05 19:53:24 +0000794 return IsEqual(rhs);
Chris Lattner24943d22010-06-08 16:52:24 +0000795}
796
797bool
798SBFrame::operator != (const SBFrame &rhs) const
799{
Johnny Chen0164b752012-03-05 19:53:24 +0000800 return !IsEqual(rhs);
Greg Clayton1ebdcc72011-01-21 06:11:58 +0000801}
Chris Lattner24943d22010-06-08 16:52:24 +0000802
803SBThread
804SBFrame::GetThread () const
805{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000806 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000807
Greg Claytona894fe72012-04-05 16:12:35 +0000808 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000809 ThreadSP thread_sp (exe_ctx.GetThreadSP());
810 SBThread sb_thread (thread_sp);
Caroline Tice7826c882010-10-26 03:11:13 +0000811
812 if (log)
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000813 {
814 SBStream sstr;
815 sb_thread.GetDescription (sstr);
Greg Clayton289afcb2012-02-18 05:35:26 +0000816 log->Printf ("SBFrame(%p)::GetThread () => SBThread(%p): %s",
817 exe_ctx.GetFramePtr(),
818 thread_sp.get(),
819 sstr.GetData());
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000820 }
Caroline Tice7826c882010-10-26 03:11:13 +0000821
Chris Lattner24943d22010-06-08 16:52:24 +0000822 return sb_thread;
823}
824
825const char *
826SBFrame::Disassemble () const
827{
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000828 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Greg Claytona66ba462010-10-30 04:51:46 +0000829 const char *disassembly = NULL;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000830 Mutex::Locker api_locker;
831 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
832
Greg Clayton289afcb2012-02-18 05:35:26 +0000833 StackFrame *frame = exe_ctx.GetFramePtr();
834 Target *target = exe_ctx.GetTargetPtr();
835 if (frame && target)
Greg Claytonbdcda462010-12-20 20:49:23 +0000836 {
Greg Claytona894fe72012-04-05 16:12:35 +0000837 Process::StopLocker stop_locker;
838 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
839 {
Greg Claytona894fe72012-04-05 16:12:35 +0000840 disassembly = frame->Disassemble();
841 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000842 else
843 {
844 if (log)
845 log->Printf ("SBFrame(%p)::Disassemble () => error: process is running", frame);
846 }
Greg Claytonbdcda462010-12-20 20:49:23 +0000847 }
Greg Claytona66ba462010-10-30 04:51:46 +0000848
849 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +0000850 log->Printf ("SBFrame(%p)::Disassemble () => %s", frame, disassembly);
Greg Claytona66ba462010-10-30 04:51:46 +0000851
852 return disassembly;
Chris Lattner24943d22010-06-08 16:52:24 +0000853}
854
855
Chris Lattner24943d22010-06-08 16:52:24 +0000856SBValueList
857SBFrame::GetVariables (bool arguments,
858 bool locals,
859 bool statics,
860 bool in_scope_only)
861{
Greg Clayton582ed0e2011-06-18 20:06:08 +0000862 SBValueList value_list;
Greg Claytona894fe72012-04-05 16:12:35 +0000863 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +0000864 StackFrame *frame = exe_ctx.GetFramePtr();
865 Target *target = exe_ctx.GetTargetPtr();
866 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +0000867 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000868 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +0000869 value_list = GetVariables (arguments, locals, statics, in_scope_only, use_dynamic);
870 }
871 return value_list;
Jim Inghame41494a2011-04-16 00:01:13 +0000872}
873
874SBValueList
875SBFrame::GetVariables (bool arguments,
876 bool locals,
877 bool statics,
878 bool in_scope_only,
Jim Ingham10de7d12011-05-04 03:43:18 +0000879 lldb::DynamicValueType use_dynamic)
Jim Inghame41494a2011-04-16 00:01:13 +0000880{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000881 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000882
Greg Clayton334d33a2012-01-30 07:41:31 +0000883 SBValueList value_list;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000884 Mutex::Locker api_locker;
885 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
886
Greg Clayton289afcb2012-02-18 05:35:26 +0000887 StackFrame *frame = exe_ctx.GetFramePtr();
888 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton334d33a2012-01-30 07:41:31 +0000889
Caroline Tice7826c882010-10-26 03:11:13 +0000890 if (log)
Greg Claytona66ba462010-10-30 04:51:46 +0000891 log->Printf ("SBFrame(%p)::GetVariables (arguments=%i, locals=%i, statics=%i, in_scope_only=%i)",
Greg Clayton289afcb2012-02-18 05:35:26 +0000892 frame,
Greg Claytona66ba462010-10-30 04:51:46 +0000893 arguments,
894 locals,
895 statics,
896 in_scope_only);
Greg Clayton334d33a2012-01-30 07:41:31 +0000897
Greg Clayton289afcb2012-02-18 05:35:26 +0000898 if (frame && target)
Chris Lattner24943d22010-06-08 16:52:24 +0000899 {
Greg Claytona894fe72012-04-05 16:12:35 +0000900 Process::StopLocker stop_locker;
901 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
902 {
Greg Claytonbdcda462010-12-20 20:49:23 +0000903
Greg Claytona894fe72012-04-05 16:12:35 +0000904 size_t i;
905 VariableList *variable_list = NULL;
Jim Ingham887f62d2012-04-13 23:29:44 +0000906 variable_list = frame->GetVariableList(true);
Greg Claytona894fe72012-04-05 16:12:35 +0000907 if (variable_list)
908 {
909 const size_t num_variables = variable_list->GetSize();
910 if (num_variables)
Chris Lattner24943d22010-06-08 16:52:24 +0000911 {
Greg Claytona894fe72012-04-05 16:12:35 +0000912 for (i = 0; i < num_variables; ++i)
Chris Lattner24943d22010-06-08 16:52:24 +0000913 {
Greg Claytona894fe72012-04-05 16:12:35 +0000914 VariableSP variable_sp (variable_list->GetVariableAtIndex(i));
915 if (variable_sp)
Chris Lattner24943d22010-06-08 16:52:24 +0000916 {
Greg Claytona894fe72012-04-05 16:12:35 +0000917 bool add_variable = false;
918 switch (variable_sp->GetScope())
919 {
920 case eValueTypeVariableGlobal:
921 case eValueTypeVariableStatic:
922 add_variable = statics;
923 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000924
Greg Claytona894fe72012-04-05 16:12:35 +0000925 case eValueTypeVariableArgument:
926 add_variable = arguments;
927 break;
Chris Lattner24943d22010-06-08 16:52:24 +0000928
Greg Claytona894fe72012-04-05 16:12:35 +0000929 case eValueTypeVariableLocal:
930 add_variable = locals;
931 break;
Greg Clayton54e7afa2010-07-09 20:39:50 +0000932
Greg Claytona894fe72012-04-05 16:12:35 +0000933 default:
934 break;
935 }
936 if (add_variable)
937 {
938 if (in_scope_only && !variable_sp->IsInScope(frame))
939 continue;
Chris Lattner24943d22010-06-08 16:52:24 +0000940
Greg Claytona894fe72012-04-05 16:12:35 +0000941 value_list.Append(frame->GetValueObjectForFrameVariable (variable_sp, use_dynamic));
942 }
Chris Lattner24943d22010-06-08 16:52:24 +0000943 }
944 }
945 }
946 }
Greg Claytona894fe72012-04-05 16:12:35 +0000947 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000948 else
949 {
950 if (log)
951 log->Printf ("SBFrame(%p)::GetVariables () => error: process is running", frame);
952 }
Chris Lattner24943d22010-06-08 16:52:24 +0000953 }
Caroline Tice7826c882010-10-26 03:11:13 +0000954
955 if (log)
956 {
Greg Clayton289afcb2012-02-18 05:35:26 +0000957 log->Printf ("SBFrame(%p)::GetVariables (...) => SBValueList(%p)", frame,
Caroline Tice61ba7ec2010-10-26 23:49:36 +0000958 value_list.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000959 }
960
Chris Lattner24943d22010-06-08 16:52:24 +0000961 return value_list;
962}
963
Greg Clayton4e9267d2010-12-14 18:39:31 +0000964SBValueList
Chris Lattner24943d22010-06-08 16:52:24 +0000965SBFrame::GetRegisters ()
966{
Greg Clayton4e9267d2010-12-14 18:39:31 +0000967 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Caroline Tice7826c882010-10-26 03:11:13 +0000968
Chris Lattner24943d22010-06-08 16:52:24 +0000969 SBValueList value_list;
Jim Inghamd0bdddf2012-08-22 21:34:33 +0000970 Mutex::Locker api_locker;
971 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
972
Greg Clayton289afcb2012-02-18 05:35:26 +0000973 StackFrame *frame = exe_ctx.GetFramePtr();
974 Target *target = exe_ctx.GetTargetPtr();
975 if (frame && target)
Chris Lattner24943d22010-06-08 16:52:24 +0000976 {
Greg Claytona894fe72012-04-05 16:12:35 +0000977 Process::StopLocker stop_locker;
978 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Chris Lattner24943d22010-06-08 16:52:24 +0000979 {
Greg Claytona894fe72012-04-05 16:12:35 +0000980 RegisterContextSP reg_ctx (frame->GetRegisterContext());
981 if (reg_ctx)
Chris Lattner24943d22010-06-08 16:52:24 +0000982 {
Greg Claytona894fe72012-04-05 16:12:35 +0000983 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
984 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
985 {
986 value_list.Append(ValueObjectRegisterSet::Create (frame, reg_ctx, set_idx));
987 }
Chris Lattner24943d22010-06-08 16:52:24 +0000988 }
989 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000990 else
991 {
992 if (log)
993 log->Printf ("SBFrame(%p)::GetRegisters () => error: process is running", frame);
994 }
Chris Lattner24943d22010-06-08 16:52:24 +0000995 }
Caroline Tice7826c882010-10-26 03:11:13 +0000996
997 if (log)
Greg Clayton9f3c98e2012-04-06 02:17:47 +0000998 log->Printf ("SBFrame(%p)::GetRegisters () => SBValueList(%p)", frame, value_list.get());
Caroline Tice7826c882010-10-26 03:11:13 +0000999
Chris Lattner24943d22010-06-08 16:52:24 +00001000 return value_list;
1001}
1002
Caroline Tice98f930f2010-09-20 05:20:02 +00001003bool
1004SBFrame::GetDescription (SBStream &description)
1005{
Greg Clayton96154be2011-11-13 06:57:31 +00001006 Stream &strm = description.ref();
1007
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001008 Mutex::Locker api_locker;
1009 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1010
Greg Clayton289afcb2012-02-18 05:35:26 +00001011 StackFrame *frame = exe_ctx.GetFramePtr();
1012 Target *target = exe_ctx.GetTargetPtr();
1013 if (frame && target)
Caroline Tice98f930f2010-09-20 05:20:02 +00001014 {
Greg Claytona894fe72012-04-05 16:12:35 +00001015 Process::StopLocker stop_locker;
1016 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1017 {
Greg Claytona894fe72012-04-05 16:12:35 +00001018 frame->DumpUsingSettingsFormat (&strm);
1019 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001020 else
1021 {
1022 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1023 if (log)
1024 log->Printf ("SBFrame(%p)::GetDescription () => error: process is running", frame);
1025 }
1026
Caroline Tice98f930f2010-09-20 05:20:02 +00001027 }
1028 else
Greg Clayton96154be2011-11-13 06:57:31 +00001029 strm.PutCString ("No value");
Caroline Tice98f930f2010-09-20 05:20:02 +00001030
1031 return true;
1032}
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001033
Greg Clayton4e9267d2010-12-14 18:39:31 +00001034SBValue
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001035SBFrame::EvaluateExpression (const char *expr)
1036{
Greg Clayton582ed0e2011-06-18 20:06:08 +00001037 SBValue result;
Greg Claytona894fe72012-04-05 16:12:35 +00001038 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001039 StackFrame *frame = exe_ctx.GetFramePtr();
1040 Target *target = exe_ctx.GetTargetPtr();
1041 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001042 {
Greg Clayton289afcb2012-02-18 05:35:26 +00001043 lldb::DynamicValueType use_dynamic = frame->CalculateTarget()->GetPreferDynamicValue();
Greg Clayton582ed0e2011-06-18 20:06:08 +00001044 result = EvaluateExpression (expr, use_dynamic);
1045 }
1046 return result;
Jim Inghame41494a2011-04-16 00:01:13 +00001047}
1048
1049SBValue
Jim Ingham10de7d12011-05-04 03:43:18 +00001050SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value)
Jim Inghame41494a2011-04-16 00:01:13 +00001051{
Jim Inghamd82bc6d2012-05-11 23:47:32 +00001052 return EvaluateExpression (expr, fetch_dynamic_value, true);
1053}
1054
1055SBValue
1056SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error)
1057{
Greg Clayton4e9267d2010-12-14 18:39:31 +00001058 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
Sean Callanan94d255f2010-12-07 22:55:01 +00001059
Greg Clayton4e9267d2010-12-14 18:39:31 +00001060 LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS));
Greg Claytona66ba462010-10-30 04:51:46 +00001061
Greg Clayton4a379b12012-07-17 03:23:13 +00001062 ExecutionResults exe_results = eExecutionSetupError;
Greg Clayton4e9267d2010-12-14 18:39:31 +00001063 SBValue expr_result;
Greg Clayton0a19a1b2012-02-04 02:27:34 +00001064 ValueObjectSP expr_value_sp;
Greg Claytona66ba462010-10-30 04:51:46 +00001065
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001066 Mutex::Locker api_locker;
1067 ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
1068
Greg Clayton289afcb2012-02-18 05:35:26 +00001069 StackFrame *frame = exe_ctx.GetFramePtr();
1070 Target *target = exe_ctx.GetTargetPtr();
Greg Clayton334d33a2012-01-30 07:41:31 +00001071 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +00001072 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\")...", frame, expr);
Greg Clayton334d33a2012-01-30 07:41:31 +00001073
Greg Clayton289afcb2012-02-18 05:35:26 +00001074 if (frame && target)
Jim Inghamd0bdddf2012-08-22 21:34:33 +00001075 {
Greg Claytona894fe72012-04-05 16:12:35 +00001076 Process::StopLocker stop_locker;
1077 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1078 {
Enrico Granata299aa702012-05-29 18:06:49 +00001079#ifdef LLDB_CONFIGURATION_DEBUG
Greg Claytona894fe72012-04-05 16:12:35 +00001080 StreamString frame_description;
1081 frame->DumpUsingSettingsFormat (&frame_description);
Greg Claytona894fe72012-04-05 16:12:35 +00001082 Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s",
1083 expr, fetch_dynamic_value, frame_description.GetString().c_str());
Enrico Granata299aa702012-05-29 18:06:49 +00001084#endif
Greg Claytona894fe72012-04-05 16:12:35 +00001085 const bool coerce_to_id = false;
Greg Claytona894fe72012-04-05 16:12:35 +00001086 const bool keep_in_memory = false;
1087
1088 exe_results = target->EvaluateExpression (expr,
1089 frame,
1090 eExecutionPolicyOnlyWhenNeeded,
1091 coerce_to_id,
1092 unwind_on_error,
1093 keep_in_memory,
1094 fetch_dynamic_value,
1095 expr_value_sp);
1096 expr_result.SetSP(expr_value_sp);
Enrico Granata299aa702012-05-29 18:06:49 +00001097#ifdef LLDB_CONFIGURATION_DEBUG
Greg Claytona894fe72012-04-05 16:12:35 +00001098 Host::SetCrashDescription (NULL);
Enrico Granata299aa702012-05-29 18:06:49 +00001099#endif
Greg Claytona894fe72012-04-05 16:12:35 +00001100 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001101 else
1102 {
1103 if (log)
1104 log->Printf ("SBFrame(%p)::EvaluateExpression () => error: process is running", frame);
1105 }
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001106 }
Jason Molendac48ca822012-02-21 05:33:55 +00001107
1108#ifndef LLDB_DISABLE_PYTHON
Sean Callanan94d255f2010-12-07 22:55:01 +00001109 if (expr_log)
Jim Inghame41494a2011-04-16 00:01:13 +00001110 expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **",
Greg Clayton0fb0bcc2011-08-03 22:57:10 +00001111 expr_result.GetValue(),
1112 expr_result.GetSummary());
Sean Callanan94d255f2010-12-07 22:55:01 +00001113
Greg Claytona66ba462010-10-30 04:51:46 +00001114 if (log)
Greg Clayton289afcb2012-02-18 05:35:26 +00001115 log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)",
1116 frame,
Jim Inghame41494a2011-04-16 00:01:13 +00001117 expr,
Greg Clayton0a19a1b2012-02-04 02:27:34 +00001118 expr_value_sp.get(),
Johnny Chenee6e7902011-08-10 22:06:24 +00001119 exe_results);
Jason Molendac48ca822012-02-21 05:33:55 +00001120#endif
Greg Claytona66ba462010-10-30 04:51:46 +00001121
Greg Clayton49ce6822010-10-31 03:01:06 +00001122 return expr_result;
Greg Clayton66ed2fb2010-10-05 00:00:42 +00001123}
Greg Clayton582ed0e2011-06-18 20:06:08 +00001124
1125bool
1126SBFrame::IsInlined()
1127{
Greg Claytona894fe72012-04-05 16:12:35 +00001128 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001129 StackFrame *frame = exe_ctx.GetFramePtr();
1130 Target *target = exe_ctx.GetTargetPtr();
1131 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001132 {
Greg Claytona894fe72012-04-05 16:12:35 +00001133 Process::StopLocker stop_locker;
1134 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
1135 {
1136
1137 Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
1138 if (block)
1139 return block->GetContainingInlinedBlock () != NULL;
1140 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001141 else
1142 {
1143 LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1144 if (log)
1145 log->Printf ("SBFrame(%p)::IsInlined () => error: process is running", frame);
1146 }
1147
Greg Clayton582ed0e2011-06-18 20:06:08 +00001148 }
1149 return false;
1150}
1151
1152const char *
1153SBFrame::GetFunctionName()
1154{
1155 const char *name = NULL;
Greg Claytona894fe72012-04-05 16:12:35 +00001156 ExecutionContext exe_ctx(m_opaque_sp.get());
Greg Clayton289afcb2012-02-18 05:35:26 +00001157 StackFrame *frame = exe_ctx.GetFramePtr();
1158 Target *target = exe_ctx.GetTargetPtr();
1159 if (frame && target)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001160 {
Greg Claytona894fe72012-04-05 16:12:35 +00001161 Process::StopLocker stop_locker;
1162 if (stop_locker.TryLock(&exe_ctx.GetProcessPtr()->GetRunLock()))
Greg Clayton582ed0e2011-06-18 20:06:08 +00001163 {
Greg Claytona894fe72012-04-05 16:12:35 +00001164 SymbolContext sc (frame->GetSymbolContext(eSymbolContextFunction | eSymbolContextBlock | eSymbolContextSymbol));
1165 if (sc.block)
Greg Clayton582ed0e2011-06-18 20:06:08 +00001166 {
Greg Claytona894fe72012-04-05 16:12:35 +00001167 Block *inlined_block = sc.block->GetContainingInlinedBlock ();
1168 if (inlined_block)
1169 {
1170 const InlineFunctionInfo* inlined_info = inlined_block->GetInlinedFunctionInfo();
1171 name = inlined_info->GetName().AsCString();
1172 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001173 }
Greg Claytona894fe72012-04-05 16:12:35 +00001174
1175 if (name == NULL)
1176 {
1177 if (sc.function)
1178 name = sc.function->GetName().GetCString();
1179 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001180
Greg Claytona894fe72012-04-05 16:12:35 +00001181 if (name == NULL)
1182 {
1183 if (sc.symbol)
1184 name = sc.symbol->GetName().GetCString();
1185 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001186 }
Greg Clayton9f3c98e2012-04-06 02:17:47 +00001187 else
1188 {
1189 LogSP log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
1190 if (log)
1191 log->Printf ("SBFrame(%p)::GetFunctionName() => error: process is running", frame);
1192
1193 }
Greg Clayton582ed0e2011-06-18 20:06:08 +00001194 }
1195 return name;
1196}
1197