LLDB  mainline
SBFrame.cpp
Go to the documentation of this file.
1 //===-- SBFrame.cpp -------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include <algorithm>
10 #include <set>
11 #include <string>
12 
13 #include "lldb/API/SBFrame.h"
14 
15 #include "lldb/lldb-types.h"
16 
17 #include "Utils.h"
18 #include "lldb/Core/Address.h"
19 #include "lldb/Core/StreamFile.h"
24 #include "lldb/Host/Host.h"
25 #include "lldb/Symbol/Block.h"
26 #include "lldb/Symbol/Function.h"
27 #include "lldb/Symbol/Symbol.h"
29 #include "lldb/Symbol/Variable.h"
32 #include "lldb/Target/Process.h"
34 #include "lldb/Target/StackFrame.h"
36 #include "lldb/Target/StackID.h"
37 #include "lldb/Target/Target.h"
38 #include "lldb/Target/Thread.h"
41 #include "lldb/Utility/LLDBLog.h"
42 #include "lldb/Utility/Stream.h"
43 
44 #include "lldb/API/SBAddress.h"
45 #include "lldb/API/SBDebugger.h"
47 #include "lldb/API/SBStream.h"
49 #include "lldb/API/SBThread.h"
50 #include "lldb/API/SBValue.h"
52 
53 #include "llvm/Support/PrettyStackTrace.h"
54 
55 using namespace lldb;
56 using namespace lldb_private;
57 
58 SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {
59  LLDB_INSTRUMENT_VA(this);
60 }
61 
62 SBFrame::SBFrame(const StackFrameSP &lldb_object_sp)
63  : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
64  LLDB_INSTRUMENT_VA(this, lldb_object_sp);
65 }
66 
68  LLDB_INSTRUMENT_VA(this, rhs);
69 
71 }
72 
73 SBFrame::~SBFrame() = default;
74 
75 const SBFrame &SBFrame::operator=(const SBFrame &rhs) {
76  LLDB_INSTRUMENT_VA(this, rhs);
77 
78  if (this != &rhs)
80  return *this;
81 }
82 
83 StackFrameSP SBFrame::GetFrameSP() const {
84  return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP());
85 }
86 
87 void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) {
88  return m_opaque_sp->SetFrameSP(lldb_object_sp);
89 }
90 
91 bool SBFrame::IsValid() const {
92  LLDB_INSTRUMENT_VA(this);
93  return this->operator bool();
94 }
95 SBFrame::operator bool() const {
96  LLDB_INSTRUMENT_VA(this);
97 
98  std::unique_lock<std::recursive_mutex> lock;
99  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
100 
101  Target *target = exe_ctx.GetTargetPtr();
102  Process *process = exe_ctx.GetProcessPtr();
103  if (target && process) {
104  Process::StopLocker stop_locker;
105  if (stop_locker.TryLock(&process->GetRunLock()))
106  return GetFrameSP().get() != nullptr;
107  }
108 
109  // Without a target & process we can't have a valid stack frame.
110  return false;
111 }
112 
114  LLDB_INSTRUMENT_VA(this, resolve_scope);
115 
116  SBSymbolContext sb_sym_ctx;
117  std::unique_lock<std::recursive_mutex> lock;
118  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
119  SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
120  Target *target = exe_ctx.GetTargetPtr();
121  Process *process = exe_ctx.GetProcessPtr();
122  if (target && process) {
123  Process::StopLocker stop_locker;
124  if (stop_locker.TryLock(&process->GetRunLock())) {
125  if (StackFrame *frame = exe_ctx.GetFramePtr())
126  sb_sym_ctx = frame->GetSymbolContext(scope);
127  }
128  }
129 
130  return sb_sym_ctx;
131 }
132 
134  LLDB_INSTRUMENT_VA(this);
135 
136  SBModule sb_module;
137  ModuleSP module_sp;
138  std::unique_lock<std::recursive_mutex> lock;
139  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
140 
141  StackFrame *frame = nullptr;
142  Target *target = exe_ctx.GetTargetPtr();
143  Process *process = exe_ctx.GetProcessPtr();
144  if (target && process) {
145  Process::StopLocker stop_locker;
146  if (stop_locker.TryLock(&process->GetRunLock())) {
147  frame = exe_ctx.GetFramePtr();
148  if (frame) {
149  module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp;
150  sb_module.SetSP(module_sp);
151  }
152  }
153  }
154 
155  return sb_module;
156 }
157 
159  LLDB_INSTRUMENT_VA(this);
160 
161  SBCompileUnit sb_comp_unit;
162  std::unique_lock<std::recursive_mutex> lock;
163  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
164 
165  StackFrame *frame = nullptr;
166  Target *target = exe_ctx.GetTargetPtr();
167  Process *process = exe_ctx.GetProcessPtr();
168  if (target && process) {
169  Process::StopLocker stop_locker;
170  if (stop_locker.TryLock(&process->GetRunLock())) {
171  frame = exe_ctx.GetFramePtr();
172  if (frame) {
173  sb_comp_unit.reset(
174  frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
175  }
176  }
177  }
178 
179  return sb_comp_unit;
180 }
181 
183  LLDB_INSTRUMENT_VA(this);
184 
185  SBFunction sb_function;
186  std::unique_lock<std::recursive_mutex> lock;
187  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
188 
189  StackFrame *frame = nullptr;
190  Target *target = exe_ctx.GetTargetPtr();
191  Process *process = exe_ctx.GetProcessPtr();
192  if (target && process) {
193  Process::StopLocker stop_locker;
194  if (stop_locker.TryLock(&process->GetRunLock())) {
195  frame = exe_ctx.GetFramePtr();
196  if (frame) {
197  sb_function.reset(
198  frame->GetSymbolContext(eSymbolContextFunction).function);
199  }
200  }
201  }
202 
203  return sb_function;
204 }
205 
207  LLDB_INSTRUMENT_VA(this);
208 
209  SBSymbol sb_symbol;
210  std::unique_lock<std::recursive_mutex> lock;
211  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
212 
213  StackFrame *frame = nullptr;
214  Target *target = exe_ctx.GetTargetPtr();
215  Process *process = exe_ctx.GetProcessPtr();
216  if (target && process) {
217  Process::StopLocker stop_locker;
218  if (stop_locker.TryLock(&process->GetRunLock())) {
219  frame = exe_ctx.GetFramePtr();
220  if (frame) {
221  sb_symbol.reset(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
222  }
223  }
224  }
225 
226  return sb_symbol;
227 }
228 
230  LLDB_INSTRUMENT_VA(this);
231 
232  SBBlock sb_block;
233  std::unique_lock<std::recursive_mutex> lock;
234  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
235 
236  StackFrame *frame = nullptr;
237  Target *target = exe_ctx.GetTargetPtr();
238  Process *process = exe_ctx.GetProcessPtr();
239  if (target && process) {
240  Process::StopLocker stop_locker;
241  if (stop_locker.TryLock(&process->GetRunLock())) {
242  frame = exe_ctx.GetFramePtr();
243  if (frame)
244  sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block);
245  }
246  }
247  return sb_block;
248 }
249 
251  LLDB_INSTRUMENT_VA(this);
252 
253  SBBlock sb_block;
254  std::unique_lock<std::recursive_mutex> lock;
255  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
256 
257  StackFrame *frame = nullptr;
258  Target *target = exe_ctx.GetTargetPtr();
259  Process *process = exe_ctx.GetProcessPtr();
260  if (target && process) {
261  Process::StopLocker stop_locker;
262  if (stop_locker.TryLock(&process->GetRunLock())) {
263  frame = exe_ctx.GetFramePtr();
264  if (frame)
265  sb_block.SetPtr(frame->GetFrameBlock());
266  }
267  }
268  return sb_block;
269 }
270 
272  LLDB_INSTRUMENT_VA(this);
273 
274  SBLineEntry sb_line_entry;
275  std::unique_lock<std::recursive_mutex> lock;
276  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
277 
278  StackFrame *frame = nullptr;
279  Target *target = exe_ctx.GetTargetPtr();
280  Process *process = exe_ctx.GetProcessPtr();
281  if (target && process) {
282  Process::StopLocker stop_locker;
283  if (stop_locker.TryLock(&process->GetRunLock())) {
284  frame = exe_ctx.GetFramePtr();
285  if (frame) {
286  sb_line_entry.SetLineEntry(
287  frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
288  }
289  }
290  }
291  return sb_line_entry;
292 }
293 
295  LLDB_INSTRUMENT_VA(this);
296 
297  uint32_t frame_idx = UINT32_MAX;
298 
299  std::unique_lock<std::recursive_mutex> lock;
300  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
301 
302  StackFrame *frame = exe_ctx.GetFramePtr();
303  if (frame)
304  frame_idx = frame->GetFrameIndex();
305 
306  return frame_idx;
307 }
308 
310  LLDB_INSTRUMENT_VA(this);
311 
312  std::unique_lock<std::recursive_mutex> lock;
313  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
314 
315  StackFrame *frame = exe_ctx.GetFramePtr();
316  if (frame)
317  return frame->GetStackID().GetCallFrameAddress();
318  return LLDB_INVALID_ADDRESS;
319 }
320 
322  LLDB_INSTRUMENT_VA(this);
323 
325  std::unique_lock<std::recursive_mutex> lock;
326  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
327 
328  StackFrame *frame = nullptr;
329  Target *target = exe_ctx.GetTargetPtr();
330  Process *process = exe_ctx.GetProcessPtr();
331  if (target && process) {
332  Process::StopLocker stop_locker;
333  if (stop_locker.TryLock(&process->GetRunLock())) {
334  frame = exe_ctx.GetFramePtr();
335  if (frame) {
337  target, AddressClass::eCode);
338  }
339  }
340  }
341 
342  return addr;
343 }
344 
345 bool SBFrame::SetPC(addr_t new_pc) {
346  LLDB_INSTRUMENT_VA(this, new_pc);
347 
348  bool ret_val = false;
349  std::unique_lock<std::recursive_mutex> lock;
350  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
351 
352  Target *target = exe_ctx.GetTargetPtr();
353  Process *process = exe_ctx.GetProcessPtr();
354  if (target && process) {
355  Process::StopLocker stop_locker;
356  if (stop_locker.TryLock(&process->GetRunLock())) {
357  if (StackFrame *frame = exe_ctx.GetFramePtr()) {
358  if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
359  ret_val = reg_ctx_sp->SetPC(new_pc);
360  }
361  }
362  }
363  }
364 
365  return ret_val;
366 }
367 
369  LLDB_INSTRUMENT_VA(this);
370 
372  std::unique_lock<std::recursive_mutex> lock;
373  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
374 
375  Target *target = exe_ctx.GetTargetPtr();
376  Process *process = exe_ctx.GetProcessPtr();
377  if (target && process) {
378  Process::StopLocker stop_locker;
379  if (stop_locker.TryLock(&process->GetRunLock())) {
380  if (StackFrame *frame = exe_ctx.GetFramePtr()) {
381  if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
382  addr = reg_ctx_sp->GetSP();
383  }
384  }
385  }
386  }
387 
388  return addr;
389 }
390 
392  LLDB_INSTRUMENT_VA(this);
393 
395  std::unique_lock<std::recursive_mutex> lock;
396  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
397 
398  Target *target = exe_ctx.GetTargetPtr();
399  Process *process = exe_ctx.GetProcessPtr();
400  if (target && process) {
401  Process::StopLocker stop_locker;
402  if (stop_locker.TryLock(&process->GetRunLock())) {
403  if (StackFrame *frame = exe_ctx.GetFramePtr()) {
404  if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
405  addr = reg_ctx_sp->GetFP();
406  }
407  }
408  }
409  }
410 
411  return addr;
412 }
413 
415  LLDB_INSTRUMENT_VA(this);
416 
417  SBAddress sb_addr;
418  std::unique_lock<std::recursive_mutex> lock;
419  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
420 
421  StackFrame *frame = exe_ctx.GetFramePtr();
422  Target *target = exe_ctx.GetTargetPtr();
423  Process *process = exe_ctx.GetProcessPtr();
424  if (target && process) {
425  Process::StopLocker stop_locker;
426  if (stop_locker.TryLock(&process->GetRunLock())) {
427  frame = exe_ctx.GetFramePtr();
428  if (frame)
429  sb_addr.SetAddress(frame->GetFrameCodeAddress());
430  }
431  }
432  return sb_addr;
433 }
434 
436  LLDB_INSTRUMENT_VA(this);
437 
438  m_opaque_sp->Clear();
439 }
440 
442  LLDB_INSTRUMENT_VA(this, var_path);
443 
444  SBValue sb_value;
445  std::unique_lock<std::recursive_mutex> lock;
446  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
447 
448  StackFrame *frame = exe_ctx.GetFramePtr();
449  Target *target = exe_ctx.GetTargetPtr();
450  if (frame && target) {
451  lldb::DynamicValueType use_dynamic =
452  frame->CalculateTarget()->GetPreferDynamicValue();
453  sb_value = GetValueForVariablePath(var_path, use_dynamic);
454  }
455  return sb_value;
456 }
457 
459  DynamicValueType use_dynamic) {
460  LLDB_INSTRUMENT_VA(this, var_path, use_dynamic);
461 
462  SBValue sb_value;
463  if (var_path == nullptr || var_path[0] == '\0') {
464  return sb_value;
465  }
466 
467  std::unique_lock<std::recursive_mutex> lock;
468  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
469 
470  StackFrame *frame = nullptr;
471  Target *target = exe_ctx.GetTargetPtr();
472  Process *process = exe_ctx.GetProcessPtr();
473  if (target && process) {
474  Process::StopLocker stop_locker;
475  if (stop_locker.TryLock(&process->GetRunLock())) {
476  frame = exe_ctx.GetFramePtr();
477  if (frame) {
478  VariableSP var_sp;
479  Status error;
480  ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
481  var_path, eNoDynamicValues,
482  StackFrame::eExpressionPathOptionCheckPtrVsMember |
483  StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
484  var_sp, error));
485  sb_value.SetSP(value_sp, use_dynamic);
486  }
487  }
488  }
489  return sb_value;
490 }
491 
492 SBValue SBFrame::FindVariable(const char *name) {
493  LLDB_INSTRUMENT_VA(this, name);
494 
495  SBValue value;
496  std::unique_lock<std::recursive_mutex> lock;
497  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
498 
499  StackFrame *frame = exe_ctx.GetFramePtr();
500  Target *target = exe_ctx.GetTargetPtr();
501  if (frame && target) {
502  lldb::DynamicValueType use_dynamic =
503  frame->CalculateTarget()->GetPreferDynamicValue();
504  value = FindVariable(name, use_dynamic);
505  }
506  return value;
507 }
508 
510  lldb::DynamicValueType use_dynamic) {
511  LLDB_INSTRUMENT_VA(this, name, use_dynamic);
512 
513  VariableSP var_sp;
514  SBValue sb_value;
515 
516  if (name == nullptr || name[0] == '\0') {
517  return sb_value;
518  }
519 
520  ValueObjectSP value_sp;
521  std::unique_lock<std::recursive_mutex> lock;
522  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
523 
524  StackFrame *frame = nullptr;
525  Target *target = exe_ctx.GetTargetPtr();
526  Process *process = exe_ctx.GetProcessPtr();
527  if (target && process) {
528  Process::StopLocker stop_locker;
529  if (stop_locker.TryLock(&process->GetRunLock())) {
530  frame = exe_ctx.GetFramePtr();
531  if (frame) {
532  value_sp = frame->FindVariable(ConstString(name));
533 
534  if (value_sp)
535  sb_value.SetSP(value_sp, use_dynamic);
536  }
537  }
538  }
539 
540  return sb_value;
541 }
542 
543 SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
544  LLDB_INSTRUMENT_VA(this, name, value_type);
545 
546  SBValue value;
547  std::unique_lock<std::recursive_mutex> lock;
548  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
549 
550  StackFrame *frame = exe_ctx.GetFramePtr();
551  Target *target = exe_ctx.GetTargetPtr();
552  if (frame && target) {
553  lldb::DynamicValueType use_dynamic =
554  frame->CalculateTarget()->GetPreferDynamicValue();
555  value = FindValue(name, value_type, use_dynamic);
556  }
557  return value;
558 }
559 
560 SBValue SBFrame::FindValue(const char *name, ValueType value_type,
561  lldb::DynamicValueType use_dynamic) {
562  LLDB_INSTRUMENT_VA(this, name, value_type, use_dynamic);
563 
564  SBValue sb_value;
565 
566  if (name == nullptr || name[0] == '\0') {
567  return sb_value;
568  }
569 
570  ValueObjectSP value_sp;
571  std::unique_lock<std::recursive_mutex> lock;
572  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
573 
574  StackFrame *frame = nullptr;
575  Target *target = exe_ctx.GetTargetPtr();
576  Process *process = exe_ctx.GetProcessPtr();
577  if (target && process) {
578  Process::StopLocker stop_locker;
579  if (stop_locker.TryLock(&process->GetRunLock())) {
580  frame = exe_ctx.GetFramePtr();
581  if (frame) {
582  VariableList variable_list;
583 
584  switch (value_type) {
585  case eValueTypeVariableGlobal: // global variable
586  case eValueTypeVariableStatic: // static variable
587  case eValueTypeVariableArgument: // function argument variables
588  case eValueTypeVariableLocal: // function local variables
589  case eValueTypeVariableThreadLocal: // thread local variables
590  {
591  SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
592 
593  const bool can_create = true;
594  const bool get_parent_variables = true;
595  const bool stop_if_block_is_inlined_function = true;
596 
597  if (sc.block)
599  can_create, get_parent_variables,
600  stop_if_block_is_inlined_function,
601  [frame](Variable *v) { return v->IsInScope(frame); },
602  &variable_list);
603  if (value_type == eValueTypeVariableGlobal) {
604  const bool get_file_globals = true;
605  VariableList *frame_vars = frame->GetVariableList(get_file_globals,
606  nullptr);
607  if (frame_vars)
608  frame_vars->AppendVariablesIfUnique(variable_list);
609  }
610  ConstString const_name(name);
611  VariableSP variable_sp(
612  variable_list.FindVariable(const_name, value_type));
613  if (variable_sp) {
614  value_sp = frame->GetValueObjectForFrameVariable(variable_sp,
616  sb_value.SetSP(value_sp, use_dynamic);
617  }
618  } break;
619 
620  case eValueTypeRegister: // stack frame register value
621  {
622  RegisterContextSP reg_ctx(frame->GetRegisterContext());
623  if (reg_ctx) {
624  if (const RegisterInfo *reg_info =
625  reg_ctx->GetRegisterInfoByName(name)) {
626  value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
627  sb_value.SetSP(value_sp);
628  }
629  }
630  } break;
631 
632  case eValueTypeRegisterSet: // A collection of stack frame register
633  // values
634  {
635  RegisterContextSP reg_ctx(frame->GetRegisterContext());
636  if (reg_ctx) {
637  const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
638  for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
639  const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
640  if (reg_set &&
641  (llvm::StringRef(reg_set->name).equals_insensitive(name) ||
642  llvm::StringRef(reg_set->short_name)
643  .equals_insensitive(name))) {
644  value_sp =
645  ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
646  sb_value.SetSP(value_sp);
647  break;
648  }
649  }
650  }
651  } break;
652 
653  case eValueTypeConstResult: // constant result variables
654  {
655  ConstString const_name(name);
656  ExpressionVariableSP expr_var_sp(
657  target->GetPersistentVariable(const_name));
658  if (expr_var_sp) {
659  value_sp = expr_var_sp->GetValueObject();
660  sb_value.SetSP(value_sp, use_dynamic);
661  }
662  } break;
663 
664  default:
665  break;
666  }
667  }
668  }
669  }
670 
671  return sb_value;
672 }
673 
674 bool SBFrame::IsEqual(const SBFrame &that) const {
675  LLDB_INSTRUMENT_VA(this, that);
676 
677  lldb::StackFrameSP this_sp = GetFrameSP();
678  lldb::StackFrameSP that_sp = that.GetFrameSP();
679  return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
680 }
681 
682 bool SBFrame::operator==(const SBFrame &rhs) const {
683  LLDB_INSTRUMENT_VA(this, rhs);
684 
685  return IsEqual(rhs);
686 }
687 
688 bool SBFrame::operator!=(const SBFrame &rhs) const {
689  LLDB_INSTRUMENT_VA(this, rhs);
690 
691  return !IsEqual(rhs);
692 }
693 
695  LLDB_INSTRUMENT_VA(this);
696 
697  std::unique_lock<std::recursive_mutex> lock;
698  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
699 
700  ThreadSP thread_sp(exe_ctx.GetThreadSP());
701  SBThread sb_thread(thread_sp);
702 
703  return sb_thread;
704 }
705 
706 const char *SBFrame::Disassemble() const {
707  LLDB_INSTRUMENT_VA(this);
708 
709  const char *disassembly = nullptr;
710  std::unique_lock<std::recursive_mutex> lock;
711  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
712 
713  StackFrame *frame = nullptr;
714  Target *target = exe_ctx.GetTargetPtr();
715  Process *process = exe_ctx.GetProcessPtr();
716  if (target && process) {
717  Process::StopLocker stop_locker;
718  if (stop_locker.TryLock(&process->GetRunLock())) {
719  frame = exe_ctx.GetFramePtr();
720  if (frame) {
721  disassembly = frame->Disassemble();
722  }
723  }
724  }
725 
726  return disassembly;
727 }
728 
729 SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
730  bool in_scope_only) {
731  LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only);
732 
733  SBValueList value_list;
734  std::unique_lock<std::recursive_mutex> lock;
735  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
736 
737  StackFrame *frame = exe_ctx.GetFramePtr();
738  Target *target = exe_ctx.GetTargetPtr();
739  if (frame && target) {
740  lldb::DynamicValueType use_dynamic =
741  frame->CalculateTarget()->GetPreferDynamicValue();
742  const bool include_runtime_support_values =
744 
745  SBVariablesOptions options;
746  options.SetIncludeArguments(arguments);
747  options.SetIncludeLocals(locals);
748  options.SetIncludeStatics(statics);
749  options.SetInScopeOnly(in_scope_only);
750  options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
751  options.SetUseDynamic(use_dynamic);
752 
753  value_list = GetVariables(options);
754  }
755  return value_list;
756 }
757 
758 lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
759  bool statics, bool in_scope_only,
760  lldb::DynamicValueType use_dynamic) {
761  LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only,
762  use_dynamic);
763 
764  std::unique_lock<std::recursive_mutex> lock;
765  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
766 
767  Target *target = exe_ctx.GetTargetPtr();
768  const bool include_runtime_support_values =
769  target ? target->GetDisplayRuntimeSupportValues() : false;
770  SBVariablesOptions options;
771  options.SetIncludeArguments(arguments);
772  options.SetIncludeLocals(locals);
773  options.SetIncludeStatics(statics);
774  options.SetInScopeOnly(in_scope_only);
775  options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
776  options.SetUseDynamic(use_dynamic);
777  return GetVariables(options);
778 }
779 
781  LLDB_INSTRUMENT_VA(this, options);
782 
783  SBValueList value_list;
784  std::unique_lock<std::recursive_mutex> lock;
785  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
786 
787  StackFrame *frame = nullptr;
788  Target *target = exe_ctx.GetTargetPtr();
789 
790  const bool statics = options.GetIncludeStatics();
791  const bool arguments = options.GetIncludeArguments();
792  const bool recognized_arguments =
794  const bool locals = options.GetIncludeLocals();
795  const bool in_scope_only = options.GetInScopeOnly();
796  const bool include_runtime_support_values =
798  const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
799 
800 
801  std::set<VariableSP> variable_set;
802  Process *process = exe_ctx.GetProcessPtr();
803  if (target && process) {
804  Process::StopLocker stop_locker;
805  if (stop_locker.TryLock(&process->GetRunLock())) {
806  frame = exe_ctx.GetFramePtr();
807  if (frame) {
808  VariableList *variable_list = nullptr;
809  Status var_error;
810  variable_list = frame->GetVariableList(true, &var_error);
811  if (var_error.Fail())
812  value_list.SetError(var_error);
813  if (variable_list) {
814  const size_t num_variables = variable_list->GetSize();
815  if (num_variables) {
816  for (const VariableSP &variable_sp : *variable_list) {
817  if (variable_sp) {
818  bool add_variable = false;
819  switch (variable_sp->GetScope()) {
823  add_variable = statics;
824  break;
825 
827  add_variable = arguments;
828  break;
829 
831  add_variable = locals;
832  break;
833 
834  default:
835  break;
836  }
837  if (add_variable) {
838  // Only add variables once so we don't end up with duplicates
839  if (variable_set.find(variable_sp) == variable_set.end())
840  variable_set.insert(variable_sp);
841  else
842  continue;
843 
844  if (in_scope_only && !variable_sp->IsInScope(frame))
845  continue;
846 
847  ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable(
848  variable_sp, eNoDynamicValues));
849 
850  if (!include_runtime_support_values && valobj_sp != nullptr &&
851  valobj_sp->IsRuntimeSupportValue())
852  continue;
853 
854  SBValue value_sb;
855  value_sb.SetSP(valobj_sp, use_dynamic);
856  value_list.Append(value_sb);
857  }
858  }
859  }
860  }
861  }
862  if (recognized_arguments) {
863  auto recognized_frame = frame->GetRecognizedFrame();
864  if (recognized_frame) {
865  ValueObjectListSP recognized_arg_list =
866  recognized_frame->GetRecognizedArguments();
867  if (recognized_arg_list) {
868  for (auto &rec_value_sp : recognized_arg_list->GetObjects()) {
869  SBValue value_sb;
870  value_sb.SetSP(rec_value_sp, use_dynamic);
871  value_list.Append(value_sb);
872  }
873  }
874  }
875  }
876  }
877  }
878  }
879 
880  return value_list;
881 }
882 
884  LLDB_INSTRUMENT_VA(this);
885 
886  SBValueList value_list;
887  std::unique_lock<std::recursive_mutex> lock;
888  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
889 
890  StackFrame *frame = nullptr;
891  Target *target = exe_ctx.GetTargetPtr();
892  Process *process = exe_ctx.GetProcessPtr();
893  if (target && process) {
894  Process::StopLocker stop_locker;
895  if (stop_locker.TryLock(&process->GetRunLock())) {
896  frame = exe_ctx.GetFramePtr();
897  if (frame) {
898  RegisterContextSP reg_ctx(frame->GetRegisterContext());
899  if (reg_ctx) {
900  const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
901  for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
902  value_list.Append(
903  ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
904  }
905  }
906  }
907  }
908  }
909 
910  return value_list;
911 }
912 
913 SBValue SBFrame::FindRegister(const char *name) {
914  LLDB_INSTRUMENT_VA(this, name);
915 
916  SBValue result;
917  ValueObjectSP value_sp;
918  std::unique_lock<std::recursive_mutex> lock;
919  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
920 
921  StackFrame *frame = nullptr;
922  Target *target = exe_ctx.GetTargetPtr();
923  Process *process = exe_ctx.GetProcessPtr();
924  if (target && process) {
925  Process::StopLocker stop_locker;
926  if (stop_locker.TryLock(&process->GetRunLock())) {
927  frame = exe_ctx.GetFramePtr();
928  if (frame) {
929  RegisterContextSP reg_ctx(frame->GetRegisterContext());
930  if (reg_ctx) {
931  if (const RegisterInfo *reg_info =
932  reg_ctx->GetRegisterInfoByName(name)) {
933  value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
934  result.SetSP(value_sp);
935  }
936  }
937  }
938  }
939  }
940 
941  return result;
942 }
943 
944 bool SBFrame::GetDescription(SBStream &description) {
945  LLDB_INSTRUMENT_VA(this, description);
946 
947  Stream &strm = description.ref();
948 
949  std::unique_lock<std::recursive_mutex> lock;
950  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
951 
952  StackFrame *frame;
953  Target *target = exe_ctx.GetTargetPtr();
954  Process *process = exe_ctx.GetProcessPtr();
955  if (target && process) {
956  Process::StopLocker stop_locker;
957  if (stop_locker.TryLock(&process->GetRunLock())) {
958  frame = exe_ctx.GetFramePtr();
959  if (frame) {
960  frame->DumpUsingSettingsFormat(&strm);
961  }
962  }
963 
964  } else
965  strm.PutCString("No value");
966 
967  return true;
968 }
969 
971  LLDB_INSTRUMENT_VA(this, expr);
972 
973  SBValue result;
974  std::unique_lock<std::recursive_mutex> lock;
975  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
976 
977  StackFrame *frame = exe_ctx.GetFramePtr();
978  Target *target = exe_ctx.GetTargetPtr();
979  if (frame && target) {
980  SBExpressionOptions options;
981  lldb::DynamicValueType fetch_dynamic_value =
982  frame->CalculateTarget()->GetPreferDynamicValue();
983  options.SetFetchDynamicValue(fetch_dynamic_value);
984  options.SetUnwindOnError(true);
985  options.SetIgnoreBreakpoints(true);
986  if (target->GetLanguage() != eLanguageTypeUnknown)
987  options.SetLanguage(target->GetLanguage());
988  else
989  options.SetLanguage(frame->GetLanguage());
990  return EvaluateExpression(expr, options);
991  }
992  return result;
993 }
994 
995 SBValue
997  lldb::DynamicValueType fetch_dynamic_value) {
998  LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value);
999 
1000  SBExpressionOptions options;
1001  options.SetFetchDynamicValue(fetch_dynamic_value);
1002  options.SetUnwindOnError(true);
1003  options.SetIgnoreBreakpoints(true);
1004  std::unique_lock<std::recursive_mutex> lock;
1005  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1006 
1007  StackFrame *frame = exe_ctx.GetFramePtr();
1008  Target *target = exe_ctx.GetTargetPtr();
1009  if (target && target->GetLanguage() != eLanguageTypeUnknown)
1010  options.SetLanguage(target->GetLanguage());
1011  else if (frame)
1012  options.SetLanguage(frame->GetLanguage());
1013  return EvaluateExpression(expr, options);
1014 }
1015 
1017  lldb::DynamicValueType fetch_dynamic_value,
1018  bool unwind_on_error) {
1019  LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value, unwind_on_error);
1020 
1021  SBExpressionOptions options;
1022  std::unique_lock<std::recursive_mutex> lock;
1023  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1024 
1025  options.SetFetchDynamicValue(fetch_dynamic_value);
1026  options.SetUnwindOnError(unwind_on_error);
1027  options.SetIgnoreBreakpoints(true);
1028  StackFrame *frame = exe_ctx.GetFramePtr();
1029  Target *target = exe_ctx.GetTargetPtr();
1030  if (target && target->GetLanguage() != eLanguageTypeUnknown)
1031  options.SetLanguage(target->GetLanguage());
1032  else if (frame)
1033  options.SetLanguage(frame->GetLanguage());
1034  return EvaluateExpression(expr, options);
1035 }
1036 
1038  const SBExpressionOptions &options) {
1039  LLDB_INSTRUMENT_VA(this, expr, options);
1040 
1041  Log *expr_log = GetLog(LLDBLog::Expressions);
1042 
1043  SBValue expr_result;
1044 
1045  if (expr == nullptr || expr[0] == '\0') {
1046  return expr_result;
1047  }
1048 
1049  ValueObjectSP expr_value_sp;
1050 
1051  std::unique_lock<std::recursive_mutex> lock;
1052  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1053 
1054 
1055  StackFrame *frame = nullptr;
1056  Target *target = exe_ctx.GetTargetPtr();
1057  Process *process = exe_ctx.GetProcessPtr();
1058 
1059  if (target && process) {
1060  Process::StopLocker stop_locker;
1061  if (stop_locker.TryLock(&process->GetRunLock())) {
1062  frame = exe_ctx.GetFramePtr();
1063  if (frame) {
1064  std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1065  if (target->GetDisplayExpressionsInCrashlogs()) {
1066  StreamString frame_description;
1067  frame->DumpUsingSettingsFormat(&frame_description);
1068  stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1069  "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1070  "= %u) %s",
1071  expr, options.GetFetchDynamicValue(),
1072  frame_description.GetData());
1073  }
1074 
1075  target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
1076  expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
1077  }
1078  }
1079  }
1080 
1081  LLDB_LOGF(expr_log,
1082  "** [SBFrame::EvaluateExpression] Expression result is "
1083  "%s, summary %s **",
1084  expr_result.GetValue(), expr_result.GetSummary());
1085 
1086  return expr_result;
1087 }
1088 
1090  LLDB_INSTRUMENT_VA(this);
1091 
1092  return static_cast<const SBFrame *>(this)->IsInlined();
1093 }
1094 
1095 bool SBFrame::IsInlined() const {
1096  LLDB_INSTRUMENT_VA(this);
1097 
1098  std::unique_lock<std::recursive_mutex> lock;
1099  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1100 
1101  StackFrame *frame = nullptr;
1102  Target *target = exe_ctx.GetTargetPtr();
1103  Process *process = exe_ctx.GetProcessPtr();
1104  if (target && process) {
1105  Process::StopLocker stop_locker;
1106  if (stop_locker.TryLock(&process->GetRunLock())) {
1107  frame = exe_ctx.GetFramePtr();
1108  if (frame) {
1109 
1110  Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
1111  if (block)
1112  return block->GetContainingInlinedBlock() != nullptr;
1113  }
1114  }
1115  }
1116  return false;
1117 }
1118 
1120  LLDB_INSTRUMENT_VA(this);
1121 
1122  return static_cast<const SBFrame *>(this)->IsArtificial();
1123 }
1124 
1125 bool SBFrame::IsArtificial() const {
1126  LLDB_INSTRUMENT_VA(this);
1127 
1128  std::unique_lock<std::recursive_mutex> lock;
1129  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1130 
1131  StackFrame *frame = exe_ctx.GetFramePtr();
1132  if (frame)
1133  return frame->IsArtificial();
1134 
1135  return false;
1136 }
1137 
1139  LLDB_INSTRUMENT_VA(this);
1140 
1141  return static_cast<const SBFrame *>(this)->GetFunctionName();
1142 }
1143 
1145  LLDB_INSTRUMENT_VA(this);
1146 
1147  std::unique_lock<std::recursive_mutex> lock;
1148  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1149 
1150  StackFrame *frame = nullptr;
1151  Target *target = exe_ctx.GetTargetPtr();
1152  Process *process = exe_ctx.GetProcessPtr();
1153  if (target && process) {
1154  Process::StopLocker stop_locker;
1155  if (stop_locker.TryLock(&process->GetRunLock())) {
1156  frame = exe_ctx.GetFramePtr();
1157  if (frame) {
1158  return frame->GuessLanguage();
1159  }
1160  }
1161  }
1162  return eLanguageTypeUnknown;
1163 }
1164 
1165 const char *SBFrame::GetFunctionName() const {
1166  LLDB_INSTRUMENT_VA(this);
1167 
1168  const char *name = nullptr;
1169  std::unique_lock<std::recursive_mutex> lock;
1170  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1171 
1172  StackFrame *frame = nullptr;
1173  Target *target = exe_ctx.GetTargetPtr();
1174  Process *process = exe_ctx.GetProcessPtr();
1175  if (target && process) {
1176  Process::StopLocker stop_locker;
1177  if (stop_locker.TryLock(&process->GetRunLock())) {
1178  frame = exe_ctx.GetFramePtr();
1179  if (frame) {
1180  SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
1181  eSymbolContextBlock |
1182  eSymbolContextSymbol));
1183  if (sc.block) {
1184  Block *inlined_block = sc.block->GetContainingInlinedBlock();
1185  if (inlined_block) {
1186  const InlineFunctionInfo *inlined_info =
1187  inlined_block->GetInlinedFunctionInfo();
1188  name = inlined_info->GetName().AsCString();
1189  }
1190  }
1191 
1192  if (name == nullptr) {
1193  if (sc.function)
1194  name = sc.function->GetName().GetCString();
1195  }
1196 
1197  if (name == nullptr) {
1198  if (sc.symbol)
1199  name = sc.symbol->GetName().GetCString();
1200  }
1201  }
1202  }
1203  }
1204  return name;
1205 }
1206 
1208  LLDB_INSTRUMENT_VA(this);
1209 
1210  const char *name = nullptr;
1211 
1212  std::unique_lock<std::recursive_mutex> lock;
1213  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1214 
1215  StackFrame *frame = nullptr;
1216  Target *target = exe_ctx.GetTargetPtr();
1217  Process *process = exe_ctx.GetProcessPtr();
1218  if (target && process) {
1219  Process::StopLocker stop_locker;
1220  if (stop_locker.TryLock(&process->GetRunLock())) {
1221  frame = exe_ctx.GetFramePtr();
1222  if (frame) {
1223  SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
1224  eSymbolContextBlock |
1225  eSymbolContextSymbol));
1226  if (sc.block) {
1227  Block *inlined_block = sc.block->GetContainingInlinedBlock();
1228  if (inlined_block) {
1229  const InlineFunctionInfo *inlined_info =
1230  inlined_block->GetInlinedFunctionInfo();
1231  name = inlined_info->GetDisplayName().AsCString();
1232  }
1233  }
1234 
1235  if (name == nullptr) {
1236  if (sc.function)
1237  name = sc.function->GetDisplayName().GetCString();
1238  }
1239 
1240  if (name == nullptr) {
1241  if (sc.symbol)
1242  name = sc.symbol->GetDisplayName().GetCString();
1243  }
1244  }
1245  }
1246  }
1247  return name;
1248 }
lldb::SBFrame::GetThread
lldb::SBThread GetThread() const
Definition: SBFrame.cpp:694
lldb::SBValueList
Definition: SBValueList.h:18
lldb_private::StackFrame::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: StackFrame.cpp:1759
Instrumentation.h
Block.h
lldb::SBFrame::GetSP
lldb::addr_t GetSP() const
Definition: SBFrame.cpp:368
lldb::SBFrame::GuessLanguage
lldb::LanguageType GuessLanguage() const
Definition: SBFrame.cpp:1144
lldb_private::SymbolContext::block
Block * block
The Block for a given query.
Definition: SymbolContext.h:321
lldb::SBVariablesOptions
Definition: SBVariablesOptions.h:19
lldb_private::ExecutionContext
Definition: ExecutionContext.h:292
lldb_private::SymbolContext::comp_unit
CompileUnit * comp_unit
The CompileUnit for a given query.
Definition: SymbolContext.h:319
lldb::SBStream::ref
lldb_private::Stream & ref()
Definition: SBStream.cpp:176
ExpressionVariable.h
lldb::SBThread
Definition: SBThread.h:20
lldb_private::ExecutionContext::GetThreadSP
const lldb::ThreadSP & GetThreadSP() const
Get accessor to get the thread shared pointer.
Definition: ExecutionContext.h:464
lldb::SBFrame::GetFunction
lldb::SBFunction GetFunction() const
Definition: SBFrame.cpp:182
lldb_private::TargetProperties::GetDisplayExpressionsInCrashlogs
bool GetDisplayExpressionsInCrashlogs() const
Definition: Target.cpp:4513
lldb::SBFrame::FindRegister
lldb::SBValue FindRegister(const char *name)
Definition: SBFrame.cpp:913
lldb_private::StackFrame::GetVariableList
VariableList * GetVariableList(bool get_file_globals, Status *error_ptr)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:424
lldb::eValueTypeVariableGlobal
@ eValueTypeVariableGlobal
globals variable
Definition: lldb-enumerations.h:317
lldb::SBFrame::GetFrameSP
lldb::StackFrameSP GetFrameSP() const
Definition: SBFrame.cpp:83
lldb::SBFrame::m_opaque_sp
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBFrame.h:200
lldb_private::InlineFunctionInfo
Definition: Function.h:125
lldb::SBValue::GetValue
const char * GetValue()
Definition: SBValue.cpp:353
lldb::SBCompileUnit
Definition: SBCompileUnit.h:17
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb::SBFrame::IsValid
bool IsValid() const
Definition: SBFrame.cpp:91
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:206
Host.h
lldb::SBExpressionOptions::GetFetchDynamicValue
lldb::DynamicValueType GetFetchDynamicValue() const
Definition: SBExpressionOptions.cpp:76
lldb_private::StackFrame::DumpUsingSettingsFormat
void DumpUsingSettingsFormat(Stream *strm, bool show_unique=false, const char *frame_marker=nullptr)
Print a description for this frame using the frame-format formatter settings.
Definition: StackFrame.cpp:1786
lldb::SBVariablesOptions::GetIncludeLocals
bool GetIncludeLocals() const
Definition: SBVariablesOptions.cpp:136
lldb::SBFrame::operator==
bool operator==(const lldb::SBFrame &rhs) const
Definition: SBFrame.cpp:682
lldb_private::StackFrame::GetFrameCodeAddress
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:190
SBSymbolContext.h
lldb_private::Function::GetDisplayName
ConstString GetDisplayName() const
Definition: Function.cpp:486
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:344
lldb_private::Process
Definition: Process.h:338
lldb::SBValue
Definition: SBValue.h:21
lldb::SBFrame::FindValue
lldb::SBValue FindValue(const char *name, ValueType value_type)
Find variables, register sets, registers, or persistent variables using the frame as the scope.
Definition: SBFrame.cpp:543
lldb::SBSymbol
Definition: SBSymbol.h:19
lldb_private::StackFrame::GetFrameBlock
Block * GetFrameBlock()
Get the current lexical scope block for this StackFrame, if possible.
Definition: StackFrame.cpp:275
lldb_private::ProcessRunLock::ProcessRunLocker
Definition: ProcessRunLock.h:36
lldb_private::VariableList::GetSize
size_t GetSize() const
Definition: VariableList.cpp:165
lldb::LanguageType
LanguageType
Programming language type.
Definition: lldb-enumerations.h:436
lldb_private::VariableList::FindVariable
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
Definition: VariableList.cpp:72
lldb::SBFrame::GetRegisters
lldb::SBValueList GetRegisters()
Definition: SBFrame.cpp:883
lldb::SBFrame::GetPCAddress
lldb::SBAddress GetPCAddress() const
Definition: SBFrame.cpp:414
lldb::SBExpressionOptions::SetUnwindOnError
void SetUnwindOnError(bool unwind=true)
Definition: SBExpressionOptions.cpp:58
lldb_private::ExecutionContext::GetFramePtr
StackFrame * GetFramePtr() const
Returns a pointer to the frame object.
Definition: ExecutionContext.h:408
lldb_private::ConstString::AsCString
const char * AsCString(const char *value_if_empty=nullptr) const
Get the string value as a C string.
Definition: ConstString.h:192
UserExpression.h
lldb::SBVariablesOptions::GetUseDynamic
lldb::DynamicValueType GetUseDynamic() const
Definition: SBVariablesOptions.cpp:185
StackFrame.h
lldb::eValueTypeRegisterSet
@ eValueTypeRegisterSet
A collection of stack frame register values.
Definition: lldb-enumerations.h:322
lldb_private::Stream
Definition: Stream.h:28
lldb_private::StackFrame::FindVariable
lldb::ValueObjectSP FindVariable(ConstString name)
Attempt to reconstruct the ValueObject for a variable with a given name from within the current Stack...
Definition: StackFrame.cpp:1724
lldb::SBBlock::SetPtr
void SetPtr(lldb_private::Block *lldb_object_ptr)
Definition: SBBlock.cpp:161
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb::SBFrame::GetCompileUnit
lldb::SBCompileUnit GetCompileUnit() const
Definition: SBFrame.cpp:158
lldb::SBAddress::SetAddress
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition: SBAddress.cpp:88
lldb_private::Process::GetRunLock
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5604
lldb::SBExpressionOptions::ref
lldb_private::EvaluateExpressionOptions & ref() const
Definition: SBExpressionOptions.cpp:256
lldb::SBFrame::GetSymbolContext
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const
Definition: SBFrame.cpp:113
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:469
lldb_private::Address::GetOpcodeLoadAddress
lldb::addr_t GetOpcodeLoadAddress(Target *target, AddressClass addr_class=AddressClass::eInvalid) const
Get the load address as an opcode load address.
Definition: Address.cpp:368
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::Target::GetPersistentVariable
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition: Target.cpp:2539
lldb::SBFrame::IsInlined
bool IsInlined()
Return true if this frame represents an inlined function.
Definition: SBFrame.cpp:1089
lldb::SBFrame::GetFrameBlock
lldb::SBBlock GetFrameBlock() const
Gets the lexical block that defines the stack frame.
Definition: SBFrame.cpp:250
Process.h
SBExpressionOptions.h
lldb::SBVariablesOptions::GetIncludeRecognizedArguments
bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const
Definition: SBVariablesOptions.cpp:123
Target.h
lldb_private::StackID::GetCallFrameAddress
lldb::addr_t GetCallFrameAddress() const
Definition: StackID.h:33
lldb::SBFrame::EvaluateExpression
lldb::SBValue EvaluateExpression(const char *expr)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
Definition: SBFrame.cpp:970
error
static llvm::raw_ostream & error(Stream &strm)
Definition: CommandReturnObject.cpp:17
lldb_private::SymbolContext::symbol
Symbol * symbol
The Symbol for a given query.
Definition: SymbolContext.h:323
SBStream.h
lldb_private::Variable::IsInScope
bool IsInScope(StackFrame *frame)
Definition: Variable.cpp:272
lldb::SBFrame::GetSymbol
lldb::SBSymbol GetSymbol() const
Definition: SBFrame.cpp:206
lldb::SBFrame
Definition: SBFrame.h:17
bool
lldb::SBSymbol::reset
void reset(lldb_private::Symbol *)
Definition: SBSymbol.cpp:139
SBThread.h
lldb::SBVariablesOptions::GetIncludeStatics
bool GetIncludeStatics() const
Definition: SBVariablesOptions.cpp:148
lldb_private::clone
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition: Utils.h:17
Utils.h
lldb_private::ProcessRunLock::ProcessRunLocker::TryLock
bool TryLock(ProcessRunLock *lock)
Definition: ProcessRunLock.h:43
lldb::SBFrame::GetVariables
lldb::SBValueList GetVariables(bool arguments, bool locals, bool statics, bool in_scope_only)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
Definition: SBFrame.cpp:729
lldb::SBFrame::GetCFA
lldb::addr_t GetCFA() const
Definition: SBFrame.cpp:309
lldb::SBModule::SetSP
void SetSP(const ModuleSP &module_sp)
Definition: SBModule.cpp:211
lldb_private::Status::Fail
bool Fail() const
Test for error condition.
Definition: Status.cpp:181
lldb::SBFrame::GetDisplayFunctionName
const char * GetDisplayFunctionName()
Definition: SBFrame.cpp:1207
SBFrame.h
lldb_private::StreamString::GetData
const char * GetData() const
Definition: StreamString.h:43
lldb_private::SymbolContext::function
Function * function
The Function for a given query.
Definition: SymbolContext.h:320
lldb::SBFrame::GetLineEntry
lldb::SBLineEntry GetLineEntry() const
Definition: SBFrame.cpp:271
lldb::SBBlock
Definition: SBBlock.h:19
ValueObjectRegister.h
lldb_private::StackFrame::GetValueForVariableExpressionPath
lldb::ValueObjectSP GetValueForVariableExpressionPath(llvm::StringRef var_expr, lldb::DynamicValueType use_dynamic, uint32_t options, lldb::VariableSP &var_sp, Status &error)
Create a ValueObject for a variable name / pathname, possibly including simple dereference/child sele...
Definition: StackFrame.cpp:508
lldb_private::ConstString
Definition: ConstString.h:39
lldb::SBFrame::GetBlock
lldb::SBBlock GetBlock() const
Gets the deepest block that contains the frame PC.
Definition: SBFrame.cpp:229
lldb::SBVariablesOptions::SetInScopeOnly
void SetInScopeOnly(bool)
Definition: SBVariablesOptions.cpp:166
lldb_private::StreamString
Definition: StreamString.h:23
lldb::SBFrame::GetModule
lldb::SBModule GetModule() const
Definition: SBFrame.cpp:133
lldb::SBFrame::IsArtificial
bool IsArtificial()
Definition: SBFrame.cpp:1119
StackID.h
lldb::SBValueList::Append
void Append(const lldb::SBValue &val_obj)
Definition: SBValueList.cpp:131
lldb::SBFrame::operator!=
bool operator!=(const lldb::SBFrame &rhs) const
Definition: SBFrame.cpp:688
lldb_private::InlineFunctionInfo::GetName
ConstString GetName() const
Definition: Function.cpp:96
lldb::SBFunction
Definition: SBFunction.h:18
lldb::SBFrame::GetDescription
bool GetDescription(lldb::SBStream &description)
Definition: SBFrame.cpp:944
lldb::SBFunction::reset
void reset(lldb_private::Function *lldb_object_ptr)
Definition: SBFunction.cpp:139
lldb::SBValueList::SetError
void SetError(const lldb_private::Status &status)
Definition: SBValueList.cpp:212
SBDebugger.h
lldb::SBFrame::FindVariable
lldb::SBValue FindVariable(const char *var_name)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
Definition: SBFrame.cpp:492
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb::SBFrame::Disassemble
const char * Disassemble() const
Definition: SBFrame.cpp:706
lldb::SBFrame::GetPC
lldb::addr_t GetPC() const
Definition: SBFrame.cpp:321
lldb::eValueTypeVariableArgument
@ eValueTypeVariableArgument
function argument variables
Definition: lldb-enumerations.h:319
lldb::SBFrame::GetFP
lldb::addr_t GetFP() const
Definition: SBFrame.cpp:391
lldb::SBFrame::GetFrameID
uint32_t GetFrameID() const
Definition: SBFrame.cpp:294
lldb::SBFrame::operator=
const lldb::SBFrame & operator=(const lldb::SBFrame &rhs)
Definition: SBFrame.cpp:75
lldb::SBVariablesOptions::GetIncludeRuntimeSupportValues
bool GetIncludeRuntimeSupportValues() const
Definition: SBVariablesOptions.cpp:172
lldb::SBVariablesOptions::GetIncludeArguments
bool GetIncludeArguments() const
Definition: SBVariablesOptions.cpp:111
lldb::SBVariablesOptions::SetIncludeRuntimeSupportValues
void SetIncludeRuntimeSupportValues(bool)
Definition: SBVariablesOptions.cpp:178
Thread.h
lldb_private::TargetProperties::GetDisplayRuntimeSupportValues
bool GetDisplayRuntimeSupportValues() const
Definition: Target.cpp:4556
lldb::SBFrame::GetValueForVariablePath
lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr, DynamicValueType use_dynamic)
Definition: SBFrame.cpp:458
Address.h
lldb::SBFrame::SetPC
bool SetPC(lldb::addr_t new_pc)
Definition: SBFrame.cpp:345
VariableList.h
lldb::SBExpressionOptions::SetLanguage
void SetLanguage(lldb::LanguageType language)
Definition: SBExpressionOptions.cpp:153
lldb::SBVariablesOptions::SetIncludeLocals
void SetIncludeLocals(bool)
Definition: SBVariablesOptions.cpp:142
SBAddress.h
lldb_private::StackFrame::GetStackID
StackID & GetStackID()
Definition: StackFrame.cpp:145
lldb-types.h
lldb::SBExpressionOptions::SetFetchDynamicValue
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: SBExpressionOptions.cpp:82
lldb_private::Block::AppendVariables
uint32_t AppendVariables(bool can_create, bool get_parent_variables, bool stop_if_block_is_inlined_function, const std::function< bool(Variable *)> &filter, VariableList *variable_list)
Appends the variables from this block, and optionally from all parent blocks, to variable_list.
Definition: Block.cpp:443
Symbol.h
StreamFile.h
lldb::SBFrame::~SBFrame
~SBFrame()
lldb::SBExpressionOptions
Definition: SBExpressionOptions.h:18
lldb_private::InlineFunctionInfo::GetDisplayName
ConstString GetDisplayName() const
Definition: Function.cpp:102
lldb::eValueTypeVariableLocal
@ eValueTypeVariableLocal
function local variables
Definition: lldb-enumerations.h:320
lldb_private::Status
Definition: Status.h:44
lldb::SBSymbolContext
Definition: SBSymbolContext.h:22
lldb::ValueType
ValueType
Definition: lldb-enumerations.h:315
lldb_private::Block
Definition: Block.h:41
lldb::eLanguageTypeUnknown
@ eLanguageTypeUnknown
Unknown or invalid language value.
Definition: lldb-enumerations.h:437
SBVariablesOptions.h
uint32_t
lldb::SBVariablesOptions::GetInScopeOnly
bool GetInScopeOnly() const
Definition: SBVariablesOptions.cpp:160
lldb_private::Target::EvaluateExpression
lldb::ExpressionResults EvaluateExpression(llvm::StringRef expression, ExecutionContextScope *exe_scope, lldb::ValueObjectSP &result_valobj_sp, const EvaluateExpressionOptions &options=EvaluateExpressionOptions(), std::string *fixed_expression=nullptr, ValueObject *ctx_obj=nullptr)
Definition: Target.cpp:2475
lldb::SBValue::GetSummary
const char * GetSummary()
Definition: SBValue.cpp:420
lldb_private::StackFrame::GuessLanguage
lldb::LanguageType GuessLanguage()
Definition: StackFrame.cpp:1220
lldb::SBTarget
class LLDB_API SBTarget
Definition: SBDefines.h:86
lldb_private::StackFrame::GetLanguage
lldb::LanguageType GetLanguage()
Query this frame to determine what the default language should be when parsing expressions given the ...
Definition: StackFrame.cpp:1213
lldb::SBModule
Definition: SBModule.h:20
lldb_private::StackFrame::IsArtificial
bool IsArtificial() const
Query whether this frame is artificial (e.g a synthesized result of inferring missing tail call frame...
Definition: StackFrame.cpp:1209
lldb_private::StackFrame::Disassemble
const char * Disassemble()
Return the disassembly for the instructions of this StackFrame's function as a single C string.
Definition: StackFrame.cpp:261
lldb::SBValue::SetSP
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1066
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:19
lldb::SBVariablesOptions::SetIncludeStatics
void SetIncludeStatics(bool)
Definition: SBVariablesOptions.cpp:154
lldb::SBFrame::IsEqual
bool IsEqual(const lldb::SBFrame &that) const
Definition: SBFrame.cpp:674
lldb::SBCompileUnit::reset
void reset(lldb_private::CompileUnit *lldb_object_ptr)
Definition: SBCompileUnit.cpp:220
lldb_private::SymbolContext::module_sp
lldb::ModuleSP module_sp
The Module for a given query.
Definition: SymbolContext.h:318
SBValue.h
LLDB_INVALID_ADDRESS
#define LLDB_INVALID_ADDRESS
Definition: lldb-defines.h:74
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:215
lldb_private::ExecutionContext::GetTargetSP
const lldb::TargetSP & GetTargetSP() const
Get accessor to get the target shared pointer.
Definition: ExecutionContext.h:454
lldb::SBVariablesOptions::SetUseDynamic
void SetUseDynamic(lldb::DynamicValueType)
Definition: SBVariablesOptions.cpp:191
lldb::SBLineEntry
Definition: SBLineEntry.h:18
Function.h
lldb::SBAddress
Definition: SBAddress.h:17
lldb_private::VariableList::AppendVariablesIfUnique
size_t AppendVariablesIfUnique(VariableList &var_list)
Definition: VariableList.cpp:103
SymbolContext.h
lldb::eValueTypeVariableThreadLocal
@ eValueTypeVariableThreadLocal
thread local storage variable
Definition: lldb-enumerations.h:324
lldb_private
A class that represents a running process on the host machine.
Definition: SBCommandInterpreterRunOptions.h:16
lldb_private::TargetProperties::GetLanguage
lldb::LanguageType GetLanguage() const
Definition: Target.cpp:4465
lldb::eValueTypeConstResult
@ eValueTypeConstResult
constant result variables
Definition: lldb-enumerations.h:323
lldb::SBFrame::Clear
void Clear()
Definition: SBFrame.cpp:435
lldb_private::StackFrame::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
Definition: StackFrame.cpp:1143
LLDB_INSTRUMENT_VA
#define LLDB_INSTRUMENT_VA(...)
Definition: Instrumentation.h:98
lldb::SBLineEntry::SetLineEntry
void SetLineEntry(const lldb_private::LineEntry &lldb_object_ref)
Definition: SBLineEntry.cpp:43
ConstString.h
lldb::SBFrame::GetFunctionName
const char * GetFunctionName()
Get the appropriate function name for this frame.
Definition: SBFrame.cpp:1138
lldb_private::StackFrame::GetRecognizedFrame
lldb::RecognizedStackFrameSP GetRecognizedFrame()
Definition: StackFrame.cpp:1978
ValueObjectVariable.h
Stream.h
lldb::eValueTypeRegister
@ eValueTypeRegister
stack frame register value
Definition: lldb-enumerations.h:321
lldb_private::Log
Definition: Log.h:115
lldb_private::StackFrame::GetFrameIndex
uint32_t GetFrameIndex() const
Query this frame to find what frame it is in this Thread's StackFrameList.
Definition: StackFrame.cpp:175
lldb::eValueTypeVariableStatic
@ eValueTypeVariableStatic
static variable
Definition: lldb-enumerations.h:318
lldb_private::Variable
Definition: Variable.h:25
lldb_private::Block::GetInlinedFunctionInfo
const InlineFunctionInfo * GetInlinedFunctionInfo() const
Get const accessor for any inlined function information.
Definition: Block.h:276
lldb_private::Stream::PutCString
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition: Stream.cpp:63
lldb::SBFrame::SetFrameSP
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition: SBFrame.cpp:87
lldb::SBStream
Definition: SBStream.h:18
lldb::SBFrame::SBFrame
SBFrame()
Definition: SBFrame.cpp:58
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
Variable.h
lldb_private::GetLog
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition: Log.h:309
lldb_private::Symbol::GetDisplayName
ConstString GetDisplayName() const
Definition: Symbol.cpp:121
lldb::SBVariablesOptions::SetIncludeArguments
void SetIncludeArguments(bool)
Definition: SBVariablesOptions.cpp:117
lldb_private::StackFrame
Definition: StackFrame.h:40
lldb
Definition: SBAddress.h:15
StackFrameRecognizer.h
RegisterContext.h
lldb_private::ExecutionContextRef
Execution context objects refer to objects in the execution of the program that is being debugged.
Definition: ExecutionContext.h:72
lldb_private::StackFrame::GetSymbolContext
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
Definition: StackFrame.cpp:300
LLDBLog.h
lldb_private::Block::GetContainingInlinedBlock
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition: Block.cpp:208
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:198
ExecutionContext.h
lldb::SBExpressionOptions::SetIgnoreBreakpoints
void SetIgnoreBreakpoints(bool ignore=true)
Definition: SBExpressionOptions.cpp:70
lldb_private::StackFrame::GetValueObjectForFrameVariable
lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
Create a ValueObject for a given Variable in this StackFrame.
Definition: StackFrame.cpp:1159