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