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 "SBReproducerPrivate.h"
18 #include "Utils.h"
19 #include "lldb/Core/Address.h"
20 #include "lldb/Core/StreamFile.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"
30 #include "lldb/Symbol/Variable.h"
33 #include "lldb/Target/Process.h"
35 #include "lldb/Target/StackFrame.h"
37 #include "lldb/Target/StackID.h"
38 #include "lldb/Target/Target.h"
39 #include "lldb/Target/Thread.h"
41 #include "lldb/Utility/Stream.h"
42 
43 #include "lldb/API/SBAddress.h"
44 #include "lldb/API/SBDebugger.h"
46 #include "lldb/API/SBStream.h"
48 #include "lldb/API/SBThread.h"
49 #include "lldb/API/SBValue.h"
51 
52 #include "llvm/Support/PrettyStackTrace.h"
53 
54 using namespace lldb;
55 using namespace lldb_private;
56 
57 SBFrame::SBFrame() : m_opaque_sp(new ExecutionContextRef()) {
59 }
60 
61 SBFrame::SBFrame(const StackFrameSP &lldb_object_sp)
62  : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
63  LLDB_RECORD_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &),
64  lldb_object_sp);
65 }
66 
67 SBFrame::SBFrame(const SBFrame &rhs) : m_opaque_sp() {
69 
71 }
72 
73 SBFrame::~SBFrame() = default;
74 
75 const SBFrame &SBFrame::operator=(const SBFrame &rhs) {
77  SBFrame, operator=,(const lldb::SBFrame &), rhs);
78 
79  if (this != &rhs)
81  return LLDB_RECORD_RESULT(*this);
82 }
83 
84 StackFrameSP SBFrame::GetFrameSP() const {
85  return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP());
86 }
87 
88 void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) {
89  return m_opaque_sp->SetFrameSP(lldb_object_sp);
90 }
91 
92 bool SBFrame::IsValid() const {
94  return this->operator bool();
95 }
96 SBFrame::operator bool() const {
97  LLDB_RECORD_METHOD_CONST_NO_ARGS(bool, SBFrame, operator bool);
98 
99  std::unique_lock<std::recursive_mutex> lock;
100  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
101 
102  Target *target = exe_ctx.GetTargetPtr();
103  Process *process = exe_ctx.GetProcessPtr();
104  if (target && process) {
105  Process::StopLocker stop_locker;
106  if (stop_locker.TryLock(&process->GetRunLock()))
107  return GetFrameSP().get() != nullptr;
108  }
109 
110  // Without a target & process we can't have a valid stack frame.
111  return false;
112 }
113 
116  (uint32_t), resolve_scope);
117 
118  SBSymbolContext sb_sym_ctx;
119  std::unique_lock<std::recursive_mutex> lock;
120  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
121  SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
122  StackFrame *frame = nullptr;
123  Target *target = exe_ctx.GetTargetPtr();
124  Process *process = exe_ctx.GetProcessPtr();
125  if (target && process) {
126  Process::StopLocker stop_locker;
127  if (stop_locker.TryLock(&process->GetRunLock())) {
128  frame = exe_ctx.GetFramePtr();
129  if (frame)
130  sb_sym_ctx.SetSymbolContext(&frame->GetSymbolContext(scope));
131  }
132  }
133 
134  return LLDB_RECORD_RESULT(sb_sym_ctx);
135 }
136 
139 
140  SBModule sb_module;
141  ModuleSP module_sp;
142  std::unique_lock<std::recursive_mutex> lock;
143  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
144 
145  StackFrame *frame = nullptr;
146  Target *target = exe_ctx.GetTargetPtr();
147  Process *process = exe_ctx.GetProcessPtr();
148  if (target && process) {
149  Process::StopLocker stop_locker;
150  if (stop_locker.TryLock(&process->GetRunLock())) {
151  frame = exe_ctx.GetFramePtr();
152  if (frame) {
153  module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp;
154  sb_module.SetSP(module_sp);
155  }
156  }
157  }
158 
159  return LLDB_RECORD_RESULT(sb_module);
160 }
161 
165 
166  SBCompileUnit sb_comp_unit;
167  std::unique_lock<std::recursive_mutex> lock;
168  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
169 
170  StackFrame *frame = nullptr;
171  Target *target = exe_ctx.GetTargetPtr();
172  Process *process = exe_ctx.GetProcessPtr();
173  if (target && process) {
174  Process::StopLocker stop_locker;
175  if (stop_locker.TryLock(&process->GetRunLock())) {
176  frame = exe_ctx.GetFramePtr();
177  if (frame) {
178  sb_comp_unit.reset(
179  frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
180  }
181  }
182  }
183 
184  return LLDB_RECORD_RESULT(sb_comp_unit);
185 }
186 
189 
190  SBFunction sb_function;
191  std::unique_lock<std::recursive_mutex> lock;
192  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
193 
194  StackFrame *frame = nullptr;
195  Target *target = exe_ctx.GetTargetPtr();
196  Process *process = exe_ctx.GetProcessPtr();
197  if (target && process) {
198  Process::StopLocker stop_locker;
199  if (stop_locker.TryLock(&process->GetRunLock())) {
200  frame = exe_ctx.GetFramePtr();
201  if (frame) {
202  sb_function.reset(
203  frame->GetSymbolContext(eSymbolContextFunction).function);
204  }
205  }
206  }
207 
208  return LLDB_RECORD_RESULT(sb_function);
209 }
210 
213 
214  SBSymbol sb_symbol;
215  std::unique_lock<std::recursive_mutex> lock;
216  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
217 
218  StackFrame *frame = nullptr;
219  Target *target = exe_ctx.GetTargetPtr();
220  Process *process = exe_ctx.GetProcessPtr();
221  if (target && process) {
222  Process::StopLocker stop_locker;
223  if (stop_locker.TryLock(&process->GetRunLock())) {
224  frame = exe_ctx.GetFramePtr();
225  if (frame) {
226  sb_symbol.reset(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
227  }
228  }
229  }
230 
231  return LLDB_RECORD_RESULT(sb_symbol);
232 }
233 
236 
237  SBBlock sb_block;
238  std::unique_lock<std::recursive_mutex> lock;
239  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
240 
241  StackFrame *frame = nullptr;
242  Target *target = exe_ctx.GetTargetPtr();
243  Process *process = exe_ctx.GetProcessPtr();
244  if (target && process) {
245  Process::StopLocker stop_locker;
246  if (stop_locker.TryLock(&process->GetRunLock())) {
247  frame = exe_ctx.GetFramePtr();
248  if (frame)
249  sb_block.SetPtr(frame->GetSymbolContext(eSymbolContextBlock).block);
250  }
251  }
252  return LLDB_RECORD_RESULT(sb_block);
253 }
254 
257 
258  SBBlock sb_block;
259  std::unique_lock<std::recursive_mutex> lock;
260  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
261 
262  StackFrame *frame = nullptr;
263  Target *target = exe_ctx.GetTargetPtr();
264  Process *process = exe_ctx.GetProcessPtr();
265  if (target && process) {
266  Process::StopLocker stop_locker;
267  if (stop_locker.TryLock(&process->GetRunLock())) {
268  frame = exe_ctx.GetFramePtr();
269  if (frame)
270  sb_block.SetPtr(frame->GetFrameBlock());
271  }
272  }
273  return LLDB_RECORD_RESULT(sb_block);
274 }
275 
278 
279  SBLineEntry sb_line_entry;
280  std::unique_lock<std::recursive_mutex> lock;
281  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
282 
283  StackFrame *frame = nullptr;
284  Target *target = exe_ctx.GetTargetPtr();
285  Process *process = exe_ctx.GetProcessPtr();
286  if (target && process) {
287  Process::StopLocker stop_locker;
288  if (stop_locker.TryLock(&process->GetRunLock())) {
289  frame = exe_ctx.GetFramePtr();
290  if (frame) {
291  sb_line_entry.SetLineEntry(
292  frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
293  }
294  }
295  }
296  return LLDB_RECORD_RESULT(sb_line_entry);
297 }
298 
301 
302  uint32_t frame_idx = UINT32_MAX;
303 
304  std::unique_lock<std::recursive_mutex> lock;
305  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
306 
307  StackFrame *frame = exe_ctx.GetFramePtr();
308  if (frame)
309  frame_idx = frame->GetFrameIndex();
310 
311  return frame_idx;
312 }
313 
316 
317  std::unique_lock<std::recursive_mutex> lock;
318  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
319 
320  StackFrame *frame = exe_ctx.GetFramePtr();
321  if (frame)
322  return frame->GetStackID().GetCallFrameAddress();
323  return LLDB_INVALID_ADDRESS;
324 }
325 
328 
330  std::unique_lock<std::recursive_mutex> lock;
331  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
332 
333  StackFrame *frame = nullptr;
334  Target *target = exe_ctx.GetTargetPtr();
335  Process *process = exe_ctx.GetProcessPtr();
336  if (target && process) {
337  Process::StopLocker stop_locker;
338  if (stop_locker.TryLock(&process->GetRunLock())) {
339  frame = exe_ctx.GetFramePtr();
340  if (frame) {
342  target, AddressClass::eCode);
343  }
344  }
345  }
346 
347  return addr;
348 }
349 
350 bool SBFrame::SetPC(addr_t new_pc) {
351  LLDB_RECORD_METHOD(bool, SBFrame, SetPC, (lldb::addr_t), new_pc);
352 
353  bool ret_val = false;
354  std::unique_lock<std::recursive_mutex> lock;
355  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
356 
357  Target *target = exe_ctx.GetTargetPtr();
358  Process *process = exe_ctx.GetProcessPtr();
359  if (target && process) {
360  Process::StopLocker stop_locker;
361  if (stop_locker.TryLock(&process->GetRunLock())) {
362  if (StackFrame *frame = exe_ctx.GetFramePtr()) {
363  if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
364  ret_val = reg_ctx_sp->SetPC(new_pc);
365  }
366  }
367  }
368  }
369 
370  return ret_val;
371 }
372 
375 
377  std::unique_lock<std::recursive_mutex> lock;
378  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
379 
380  Target *target = exe_ctx.GetTargetPtr();
381  Process *process = exe_ctx.GetProcessPtr();
382  if (target && process) {
383  Process::StopLocker stop_locker;
384  if (stop_locker.TryLock(&process->GetRunLock())) {
385  if (StackFrame *frame = exe_ctx.GetFramePtr()) {
386  if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
387  addr = reg_ctx_sp->GetSP();
388  }
389  }
390  }
391  }
392 
393  return addr;
394 }
395 
398 
400  std::unique_lock<std::recursive_mutex> lock;
401  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
402 
403  Target *target = exe_ctx.GetTargetPtr();
404  Process *process = exe_ctx.GetProcessPtr();
405  if (target && process) {
406  Process::StopLocker stop_locker;
407  if (stop_locker.TryLock(&process->GetRunLock())) {
408  if (StackFrame *frame = exe_ctx.GetFramePtr()) {
409  if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext()) {
410  addr = reg_ctx_sp->GetFP();
411  }
412  }
413  }
414  }
415 
416  return addr;
417 }
418 
421 
422  SBAddress sb_addr;
423  std::unique_lock<std::recursive_mutex> lock;
424  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
425 
426  StackFrame *frame = exe_ctx.GetFramePtr();
427  Target *target = exe_ctx.GetTargetPtr();
428  Process *process = exe_ctx.GetProcessPtr();
429  if (target && process) {
430  Process::StopLocker stop_locker;
431  if (stop_locker.TryLock(&process->GetRunLock())) {
432  frame = exe_ctx.GetFramePtr();
433  if (frame)
434  sb_addr.SetAddress(frame->GetFrameCodeAddress());
435  }
436  }
437  return LLDB_RECORD_RESULT(sb_addr);
438 }
439 
442 
443  m_opaque_sp->Clear();
444 }
445 
448  (const char *), var_path);
449 
450  SBValue sb_value;
451  std::unique_lock<std::recursive_mutex> lock;
452  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
453 
454  StackFrame *frame = exe_ctx.GetFramePtr();
455  Target *target = exe_ctx.GetTargetPtr();
456  if (frame && target) {
457  lldb::DynamicValueType use_dynamic =
458  frame->CalculateTarget()->GetPreferDynamicValue();
459  sb_value = GetValueForVariablePath(var_path, use_dynamic);
460  }
461  return LLDB_RECORD_RESULT(sb_value);
462 }
463 
465  DynamicValueType use_dynamic) {
467  (const char *, lldb::DynamicValueType), var_path,
468  use_dynamic);
469 
470  SBValue sb_value;
471  if (var_path == nullptr || var_path[0] == '\0') {
472  return LLDB_RECORD_RESULT(sb_value);
473  }
474 
475  std::unique_lock<std::recursive_mutex> lock;
476  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
477 
478  StackFrame *frame = nullptr;
479  Target *target = exe_ctx.GetTargetPtr();
480  Process *process = exe_ctx.GetProcessPtr();
481  if (target && process) {
482  Process::StopLocker stop_locker;
483  if (stop_locker.TryLock(&process->GetRunLock())) {
484  frame = exe_ctx.GetFramePtr();
485  if (frame) {
486  VariableSP var_sp;
487  Status error;
488  ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
489  var_path, eNoDynamicValues,
490  StackFrame::eExpressionPathOptionCheckPtrVsMember |
491  StackFrame::eExpressionPathOptionsAllowDirectIVarAccess,
492  var_sp, error));
493  sb_value.SetSP(value_sp, use_dynamic);
494  }
495  }
496  }
497  return LLDB_RECORD_RESULT(sb_value);
498 }
499 
500 SBValue SBFrame::FindVariable(const char *name) {
502  name);
503 
504  SBValue value;
505  std::unique_lock<std::recursive_mutex> lock;
506  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
507 
508  StackFrame *frame = exe_ctx.GetFramePtr();
509  Target *target = exe_ctx.GetTargetPtr();
510  if (frame && target) {
511  lldb::DynamicValueType use_dynamic =
512  frame->CalculateTarget()->GetPreferDynamicValue();
513  value = FindVariable(name, use_dynamic);
514  }
515  return LLDB_RECORD_RESULT(value);
516 }
517 
519  lldb::DynamicValueType use_dynamic) {
521  (const char *, lldb::DynamicValueType), name, use_dynamic);
522 
523  VariableSP var_sp;
524  SBValue sb_value;
525 
526  if (name == nullptr || name[0] == '\0') {
527  return LLDB_RECORD_RESULT(sb_value);
528  }
529 
530  ValueObjectSP value_sp;
531  std::unique_lock<std::recursive_mutex> lock;
532  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
533 
534  StackFrame *frame = nullptr;
535  Target *target = exe_ctx.GetTargetPtr();
536  Process *process = exe_ctx.GetProcessPtr();
537  if (target && process) {
538  Process::StopLocker stop_locker;
539  if (stop_locker.TryLock(&process->GetRunLock())) {
540  frame = exe_ctx.GetFramePtr();
541  if (frame) {
542  value_sp = frame->FindVariable(ConstString(name));
543 
544  if (value_sp)
545  sb_value.SetSP(value_sp, use_dynamic);
546  }
547  }
548  }
549 
550  return LLDB_RECORD_RESULT(sb_value);
551 }
552 
553 SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
555  (const char *, lldb::ValueType), name, value_type);
556 
557  SBValue value;
558  std::unique_lock<std::recursive_mutex> lock;
559  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
560 
561  StackFrame *frame = exe_ctx.GetFramePtr();
562  Target *target = exe_ctx.GetTargetPtr();
563  if (frame && target) {
564  lldb::DynamicValueType use_dynamic =
565  frame->CalculateTarget()->GetPreferDynamicValue();
566  value = FindValue(name, value_type, use_dynamic);
567  }
568  return LLDB_RECORD_RESULT(value);
569 }
570 
571 SBValue SBFrame::FindValue(const char *name, ValueType value_type,
572  lldb::DynamicValueType use_dynamic) {
574  (const char *, lldb::ValueType, lldb::DynamicValueType),
575  name, value_type, use_dynamic);
576 
577  SBValue sb_value;
578 
579  if (name == nullptr || name[0] == '\0') {
580  return LLDB_RECORD_RESULT(sb_value);
581  }
582 
583  ValueObjectSP value_sp;
584  std::unique_lock<std::recursive_mutex> lock;
585  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
586 
587  StackFrame *frame = nullptr;
588  Target *target = exe_ctx.GetTargetPtr();
589  Process *process = exe_ctx.GetProcessPtr();
590  if (target && process) {
591  Process::StopLocker stop_locker;
592  if (stop_locker.TryLock(&process->GetRunLock())) {
593  frame = exe_ctx.GetFramePtr();
594  if (frame) {
595  VariableList variable_list;
596 
597  switch (value_type) {
598  case eValueTypeVariableGlobal: // global variable
599  case eValueTypeVariableStatic: // static variable
600  case eValueTypeVariableArgument: // function argument variables
601  case eValueTypeVariableLocal: // function local variables
602  case eValueTypeVariableThreadLocal: // thread local variables
603  {
604  SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
605 
606  const bool can_create = true;
607  const bool get_parent_variables = true;
608  const bool stop_if_block_is_inlined_function = true;
609 
610  if (sc.block)
612  can_create, get_parent_variables,
613  stop_if_block_is_inlined_function,
614  [frame](Variable *v) { return v->IsInScope(frame); },
615  &variable_list);
616  if (value_type == eValueTypeVariableGlobal) {
617  const bool get_file_globals = true;
618  VariableList *frame_vars = frame->GetVariableList(get_file_globals);
619  if (frame_vars)
620  frame_vars->AppendVariablesIfUnique(variable_list);
621  }
622  ConstString const_name(name);
623  VariableSP variable_sp(
624  variable_list.FindVariable(const_name, value_type));
625  if (variable_sp) {
626  value_sp = frame->GetValueObjectForFrameVariable(variable_sp,
628  sb_value.SetSP(value_sp, use_dynamic);
629  }
630  } break;
631 
632  case eValueTypeRegister: // stack frame register value
633  {
634  RegisterContextSP reg_ctx(frame->GetRegisterContext());
635  if (reg_ctx) {
636  if (const RegisterInfo *reg_info =
637  reg_ctx->GetRegisterInfoByName(name)) {
638  value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
639  sb_value.SetSP(value_sp);
640  }
641  }
642  } break;
643 
644  case eValueTypeRegisterSet: // A collection of stack frame register
645  // values
646  {
647  RegisterContextSP reg_ctx(frame->GetRegisterContext());
648  if (reg_ctx) {
649  const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
650  for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
651  const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
652  if (reg_set &&
653  ((reg_set->name && strcasecmp(reg_set->name, name) == 0) ||
654  (reg_set->short_name &&
655  strcasecmp(reg_set->short_name, name) == 0))) {
656  value_sp =
657  ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
658  sb_value.SetSP(value_sp);
659  break;
660  }
661  }
662  }
663  } break;
664 
665  case eValueTypeConstResult: // constant result variables
666  {
667  ConstString const_name(name);
668  ExpressionVariableSP expr_var_sp(
669  target->GetPersistentVariable(const_name));
670  if (expr_var_sp) {
671  value_sp = expr_var_sp->GetValueObject();
672  sb_value.SetSP(value_sp, use_dynamic);
673  }
674  } break;
675 
676  default:
677  break;
678  }
679  }
680  }
681  }
682 
683  return LLDB_RECORD_RESULT(sb_value);
684 }
685 
686 bool SBFrame::IsEqual(const SBFrame &that) const {
688  that);
689 
690  lldb::StackFrameSP this_sp = GetFrameSP();
691  lldb::StackFrameSP that_sp = that.GetFrameSP();
692  return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
693 }
694 
695 bool SBFrame::operator==(const SBFrame &rhs) const {
696  LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator==,(const lldb::SBFrame &),
697  rhs);
698 
699  return IsEqual(rhs);
700 }
701 
702 bool SBFrame::operator!=(const SBFrame &rhs) const {
703  LLDB_RECORD_METHOD_CONST(bool, SBFrame, operator!=,(const lldb::SBFrame &),
704  rhs);
705 
706  return !IsEqual(rhs);
707 }
708 
711 
712  std::unique_lock<std::recursive_mutex> lock;
713  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
714 
715  ThreadSP thread_sp(exe_ctx.GetThreadSP());
716  SBThread sb_thread(thread_sp);
717 
718  return LLDB_RECORD_RESULT(sb_thread);
719 }
720 
721 const char *SBFrame::Disassemble() const {
723 
724  const char *disassembly = nullptr;
725  std::unique_lock<std::recursive_mutex> lock;
726  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
727 
728  StackFrame *frame = nullptr;
729  Target *target = exe_ctx.GetTargetPtr();
730  Process *process = exe_ctx.GetProcessPtr();
731  if (target && process) {
732  Process::StopLocker stop_locker;
733  if (stop_locker.TryLock(&process->GetRunLock())) {
734  frame = exe_ctx.GetFramePtr();
735  if (frame) {
736  disassembly = frame->Disassemble();
737  }
738  }
739  }
740 
741  return disassembly;
742 }
743 
744 SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
745  bool in_scope_only) {
747  (bool, bool, bool, bool), arguments, locals, statics,
748  in_scope_only);
749 
750  SBValueList value_list;
751  std::unique_lock<std::recursive_mutex> lock;
752  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
753 
754  StackFrame *frame = exe_ctx.GetFramePtr();
755  Target *target = exe_ctx.GetTargetPtr();
756  if (frame && target) {
757  lldb::DynamicValueType use_dynamic =
758  frame->CalculateTarget()->GetPreferDynamicValue();
759  const bool include_runtime_support_values =
760  target ? target->GetDisplayRuntimeSupportValues() : false;
761 
762  SBVariablesOptions options;
763  options.SetIncludeArguments(arguments);
764  options.SetIncludeLocals(locals);
765  options.SetIncludeStatics(statics);
766  options.SetInScopeOnly(in_scope_only);
767  options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
768  options.SetUseDynamic(use_dynamic);
769 
770  value_list = GetVariables(options);
771  }
772  return LLDB_RECORD_RESULT(value_list);
773 }
774 
775 lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
776  bool statics, bool in_scope_only,
777  lldb::DynamicValueType use_dynamic) {
779  (bool, bool, bool, bool, lldb::DynamicValueType),
780  arguments, locals, statics, in_scope_only, use_dynamic);
781 
782  std::unique_lock<std::recursive_mutex> lock;
783  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
784 
785  Target *target = exe_ctx.GetTargetPtr();
786  const bool include_runtime_support_values =
787  target ? target->GetDisplayRuntimeSupportValues() : false;
788  SBVariablesOptions options;
789  options.SetIncludeArguments(arguments);
790  options.SetIncludeLocals(locals);
791  options.SetIncludeStatics(statics);
792  options.SetInScopeOnly(in_scope_only);
793  options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
794  options.SetUseDynamic(use_dynamic);
795  return LLDB_RECORD_RESULT(GetVariables(options));
796 }
797 
800  (const lldb::SBVariablesOptions &), options);
801 
802  SBValueList value_list;
803  std::unique_lock<std::recursive_mutex> lock;
804  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
805 
806  StackFrame *frame = nullptr;
807  Target *target = exe_ctx.GetTargetPtr();
808 
809  const bool statics = options.GetIncludeStatics();
810  const bool arguments = options.GetIncludeArguments();
811  const bool recognized_arguments =
813  const bool locals = options.GetIncludeLocals();
814  const bool in_scope_only = options.GetInScopeOnly();
815  const bool include_runtime_support_values =
817  const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
818 
819 
820  std::set<VariableSP> variable_set;
821  Process *process = exe_ctx.GetProcessPtr();
822  if (target && process) {
823  Process::StopLocker stop_locker;
824  if (stop_locker.TryLock(&process->GetRunLock())) {
825  frame = exe_ctx.GetFramePtr();
826  if (frame) {
827  VariableList *variable_list = nullptr;
828  variable_list = frame->GetVariableList(true);
829  if (variable_list) {
830  const size_t num_variables = variable_list->GetSize();
831  if (num_variables) {
832  for (const VariableSP &variable_sp : *variable_list) {
833  if (variable_sp) {
834  bool add_variable = false;
835  switch (variable_sp->GetScope()) {
839  add_variable = statics;
840  break;
841 
843  add_variable = arguments;
844  break;
845 
847  add_variable = locals;
848  break;
849 
850  default:
851  break;
852  }
853  if (add_variable) {
854  // Only add variables once so we don't end up with duplicates
855  if (variable_set.find(variable_sp) == variable_set.end())
856  variable_set.insert(variable_sp);
857  else
858  continue;
859 
860  if (in_scope_only && !variable_sp->IsInScope(frame))
861  continue;
862 
863  ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable(
864  variable_sp, eNoDynamicValues));
865 
866  if (!include_runtime_support_values && valobj_sp != nullptr &&
867  valobj_sp->IsRuntimeSupportValue())
868  continue;
869 
870  SBValue value_sb;
871  value_sb.SetSP(valobj_sp, use_dynamic);
872  value_list.Append(value_sb);
873  }
874  }
875  }
876  }
877  }
878  if (recognized_arguments) {
879  auto recognized_frame = frame->GetRecognizedFrame();
880  if (recognized_frame) {
881  ValueObjectListSP recognized_arg_list =
882  recognized_frame->GetRecognizedArguments();
883  if (recognized_arg_list) {
884  for (auto &rec_value_sp : recognized_arg_list->GetObjects()) {
885  SBValue value_sb;
886  value_sb.SetSP(rec_value_sp, use_dynamic);
887  value_list.Append(value_sb);
888  }
889  }
890  }
891  }
892  }
893  }
894  }
895 
896  return LLDB_RECORD_RESULT(value_list);
897 }
898 
901 
902  SBValueList value_list;
903  std::unique_lock<std::recursive_mutex> lock;
904  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
905 
906  StackFrame *frame = nullptr;
907  Target *target = exe_ctx.GetTargetPtr();
908  Process *process = exe_ctx.GetProcessPtr();
909  if (target && process) {
910  Process::StopLocker stop_locker;
911  if (stop_locker.TryLock(&process->GetRunLock())) {
912  frame = exe_ctx.GetFramePtr();
913  if (frame) {
914  RegisterContextSP reg_ctx(frame->GetRegisterContext());
915  if (reg_ctx) {
916  const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
917  for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
918  value_list.Append(
919  ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
920  }
921  }
922  }
923  }
924  }
925 
926  return LLDB_RECORD_RESULT(value_list);
927 }
928 
929 SBValue SBFrame::FindRegister(const char *name) {
931  name);
932 
933  SBValue result;
934  ValueObjectSP value_sp;
935  std::unique_lock<std::recursive_mutex> lock;
936  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
937 
938  StackFrame *frame = nullptr;
939  Target *target = exe_ctx.GetTargetPtr();
940  Process *process = exe_ctx.GetProcessPtr();
941  if (target && process) {
942  Process::StopLocker stop_locker;
943  if (stop_locker.TryLock(&process->GetRunLock())) {
944  frame = exe_ctx.GetFramePtr();
945  if (frame) {
946  RegisterContextSP reg_ctx(frame->GetRegisterContext());
947  if (reg_ctx) {
948  if (const RegisterInfo *reg_info =
949  reg_ctx->GetRegisterInfoByName(name)) {
950  value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
951  result.SetSP(value_sp);
952  }
953  }
954  }
955  }
956  }
957 
958  return LLDB_RECORD_RESULT(result);
959 }
960 
961 bool SBFrame::GetDescription(SBStream &description) {
963  description);
964 
965  Stream &strm = description.ref();
966 
967  std::unique_lock<std::recursive_mutex> lock;
968  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
969 
970  StackFrame *frame;
971  Target *target = exe_ctx.GetTargetPtr();
972  Process *process = exe_ctx.GetProcessPtr();
973  if (target && process) {
974  Process::StopLocker stop_locker;
975  if (stop_locker.TryLock(&process->GetRunLock())) {
976  frame = exe_ctx.GetFramePtr();
977  if (frame) {
978  frame->DumpUsingSettingsFormat(&strm);
979  }
980  }
981 
982  } else
983  strm.PutCString("No value");
984 
985  return true;
986 }
987 
990  expr);
991 
992  SBValue result;
993  std::unique_lock<std::recursive_mutex> lock;
994  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
995 
996  StackFrame *frame = exe_ctx.GetFramePtr();
997  Target *target = exe_ctx.GetTargetPtr();
998  if (frame && target) {
999  SBExpressionOptions options;
1000  lldb::DynamicValueType fetch_dynamic_value =
1001  frame->CalculateTarget()->GetPreferDynamicValue();
1002  options.SetFetchDynamicValue(fetch_dynamic_value);
1003  options.SetUnwindOnError(true);
1004  options.SetIgnoreBreakpoints(true);
1005  if (target->GetLanguage() != eLanguageTypeUnknown)
1006  options.SetLanguage(target->GetLanguage());
1007  else
1008  options.SetLanguage(frame->GetLanguage());
1009  return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
1010  }
1011  return LLDB_RECORD_RESULT(result);
1012 }
1013 
1014 SBValue
1016  lldb::DynamicValueType fetch_dynamic_value) {
1018  (const char *, lldb::DynamicValueType), expr,
1019  fetch_dynamic_value);
1020 
1021  SBExpressionOptions options;
1022  options.SetFetchDynamicValue(fetch_dynamic_value);
1023  options.SetUnwindOnError(true);
1024  options.SetIgnoreBreakpoints(true);
1025  std::unique_lock<std::recursive_mutex> lock;
1026  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1027 
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 LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
1035 }
1036 
1038  lldb::DynamicValueType fetch_dynamic_value,
1039  bool unwind_on_error) {
1041  (const char *, lldb::DynamicValueType, bool), expr,
1042  fetch_dynamic_value, unwind_on_error);
1043 
1044  SBExpressionOptions options;
1045  std::unique_lock<std::recursive_mutex> lock;
1046  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1047 
1048  options.SetFetchDynamicValue(fetch_dynamic_value);
1049  options.SetUnwindOnError(unwind_on_error);
1050  options.SetIgnoreBreakpoints(true);
1051  StackFrame *frame = exe_ctx.GetFramePtr();
1052  Target *target = exe_ctx.GetTargetPtr();
1053  if (target && target->GetLanguage() != eLanguageTypeUnknown)
1054  options.SetLanguage(target->GetLanguage());
1055  else if (frame)
1056  options.SetLanguage(frame->GetLanguage());
1057  return LLDB_RECORD_RESULT(EvaluateExpression(expr, options));
1058 }
1059 
1061  const SBExpressionOptions &options) {
1063  (const char *, const lldb::SBExpressionOptions &), expr,
1064  options);
1065 
1067 
1068  SBValue expr_result;
1069 
1070  if (expr == nullptr || expr[0] == '\0') {
1071  return LLDB_RECORD_RESULT(expr_result);
1072  }
1073 
1074  ValueObjectSP expr_value_sp;
1075 
1076  std::unique_lock<std::recursive_mutex> lock;
1077  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1078 
1079 
1080  StackFrame *frame = nullptr;
1081  Target *target = exe_ctx.GetTargetPtr();
1082  Process *process = exe_ctx.GetProcessPtr();
1083 
1084  if (target && process) {
1085  Process::StopLocker stop_locker;
1086  if (stop_locker.TryLock(&process->GetRunLock())) {
1087  frame = exe_ctx.GetFramePtr();
1088  if (frame) {
1089  std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1090  if (target->GetDisplayExpressionsInCrashlogs()) {
1091  StreamString frame_description;
1092  frame->DumpUsingSettingsFormat(&frame_description);
1093  stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1094  "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1095  "= %u) %s",
1096  expr, options.GetFetchDynamicValue(),
1097  frame_description.GetData());
1098  }
1099 
1100  target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
1101  expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
1102  }
1103  }
1104  }
1105 
1106  LLDB_LOGF(expr_log,
1107  "** [SBFrame::EvaluateExpression] Expression result is "
1108  "%s, summary %s **",
1109  expr_result.GetValue(), expr_result.GetSummary());
1110 
1111  return LLDB_RECORD_RESULT(expr_result);
1112 }
1113 
1116 
1117  return static_cast<const SBFrame *>(this)->IsInlined();
1118 }
1119 
1120 bool SBFrame::IsInlined() const {
1122 
1123  std::unique_lock<std::recursive_mutex> lock;
1124  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1125 
1126  StackFrame *frame = nullptr;
1127  Target *target = exe_ctx.GetTargetPtr();
1128  Process *process = exe_ctx.GetProcessPtr();
1129  if (target && process) {
1130  Process::StopLocker stop_locker;
1131  if (stop_locker.TryLock(&process->GetRunLock())) {
1132  frame = exe_ctx.GetFramePtr();
1133  if (frame) {
1134 
1135  Block *block = frame->GetSymbolContext(eSymbolContextBlock).block;
1136  if (block)
1137  return block->GetContainingInlinedBlock() != nullptr;
1138  }
1139  }
1140  }
1141  return false;
1142 }
1143 
1146 
1147  return static_cast<const SBFrame *>(this)->IsArtificial();
1148 }
1149 
1150 bool SBFrame::IsArtificial() const {
1152 
1153  std::unique_lock<std::recursive_mutex> lock;
1154  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1155 
1156  StackFrame *frame = exe_ctx.GetFramePtr();
1157  if (frame)
1158  return frame->IsArtificial();
1159 
1160  return false;
1161 }
1162 
1165 
1166  return static_cast<const SBFrame *>(this)->GetFunctionName();
1167 }
1168 
1171 
1172  std::unique_lock<std::recursive_mutex> lock;
1173  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1174 
1175  StackFrame *frame = nullptr;
1176  Target *target = exe_ctx.GetTargetPtr();
1177  Process *process = exe_ctx.GetProcessPtr();
1178  if (target && process) {
1179  Process::StopLocker stop_locker;
1180  if (stop_locker.TryLock(&process->GetRunLock())) {
1181  frame = exe_ctx.GetFramePtr();
1182  if (frame) {
1183  return frame->GuessLanguage();
1184  }
1185  }
1186  }
1187  return eLanguageTypeUnknown;
1188 }
1189 
1190 const char *SBFrame::GetFunctionName() const {
1192 
1193  const char *name = nullptr;
1194  std::unique_lock<std::recursive_mutex> lock;
1195  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1196 
1197  StackFrame *frame = nullptr;
1198  Target *target = exe_ctx.GetTargetPtr();
1199  Process *process = exe_ctx.GetProcessPtr();
1200  if (target && process) {
1201  Process::StopLocker stop_locker;
1202  if (stop_locker.TryLock(&process->GetRunLock())) {
1203  frame = exe_ctx.GetFramePtr();
1204  if (frame) {
1205  SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
1206  eSymbolContextBlock |
1207  eSymbolContextSymbol));
1208  if (sc.block) {
1209  Block *inlined_block = sc.block->GetContainingInlinedBlock();
1210  if (inlined_block) {
1211  const InlineFunctionInfo *inlined_info =
1212  inlined_block->GetInlinedFunctionInfo();
1213  name = inlined_info->GetName().AsCString();
1214  }
1215  }
1216 
1217  if (name == nullptr) {
1218  if (sc.function)
1219  name = sc.function->GetName().GetCString();
1220  }
1221 
1222  if (name == nullptr) {
1223  if (sc.symbol)
1224  name = sc.symbol->GetName().GetCString();
1225  }
1226  }
1227  }
1228  }
1229  return name;
1230 }
1231 
1234 
1235  const char *name = nullptr;
1236 
1237  std::unique_lock<std::recursive_mutex> lock;
1238  ExecutionContext exe_ctx(m_opaque_sp.get(), lock);
1239 
1240  StackFrame *frame = nullptr;
1241  Target *target = exe_ctx.GetTargetPtr();
1242  Process *process = exe_ctx.GetProcessPtr();
1243  if (target && process) {
1244  Process::StopLocker stop_locker;
1245  if (stop_locker.TryLock(&process->GetRunLock())) {
1246  frame = exe_ctx.GetFramePtr();
1247  if (frame) {
1248  SymbolContext sc(frame->GetSymbolContext(eSymbolContextFunction |
1249  eSymbolContextBlock |
1250  eSymbolContextSymbol));
1251  if (sc.block) {
1252  Block *inlined_block = sc.block->GetContainingInlinedBlock();
1253  if (inlined_block) {
1254  const InlineFunctionInfo *inlined_info =
1255  inlined_block->GetInlinedFunctionInfo();
1256  name = inlined_info->GetDisplayName().AsCString();
1257  }
1258  }
1259 
1260  if (name == nullptr) {
1261  if (sc.function)
1262  name = sc.function->GetDisplayName().GetCString();
1263  }
1264 
1265  if (name == nullptr) {
1266  if (sc.symbol)
1267  name = sc.symbol->GetDisplayName().GetCString();
1268  }
1269  }
1270  }
1271  }
1272  return name;
1273 }
1274 
1275 namespace lldb_private {
1276 namespace repro {
1277 
1278 template <>
1281  LLDB_REGISTER_CONSTRUCTOR(SBFrame, (const lldb::StackFrameSP &));
1284  SBFrame, operator=,(const lldb::SBFrame &));
1285  LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsValid, ());
1286  LLDB_REGISTER_METHOD_CONST(bool, SBFrame, operator bool, ());
1288  (uint32_t));
1291  ());
1295  LLDB_REGISTER_METHOD_CONST(lldb::SBBlock, SBFrame, GetFrameBlock, ());
1297  LLDB_REGISTER_METHOD_CONST(uint32_t, SBFrame, GetFrameID, ());
1300  LLDB_REGISTER_METHOD(bool, SBFrame, SetPC, (lldb::addr_t));
1304  LLDB_REGISTER_METHOD(void, SBFrame, Clear, ());
1305  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath,
1306  (const char *));
1307  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, GetValueForVariablePath,
1308  (const char *, lldb::DynamicValueType));
1309  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindVariable, (const char *));
1311  (const char *, lldb::DynamicValueType));
1313  (const char *, lldb::ValueType));
1315  lldb::SBValue, SBFrame, FindValue,
1316  (const char *, lldb::ValueType, lldb::DynamicValueType));
1317  LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsEqual, (const lldb::SBFrame &));
1319  SBFrame, operator==,(const lldb::SBFrame &));
1321  SBFrame, operator!=,(const lldb::SBFrame &));
1323  LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, Disassemble, ());
1325  (bool, bool, bool, bool));
1327  (bool, bool, bool, bool, lldb::DynamicValueType));
1329  (const lldb::SBVariablesOptions &));
1330  LLDB_REGISTER_METHOD(lldb::SBValueList, SBFrame, GetRegisters, ());
1331  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, FindRegister, (const char *));
1332  LLDB_REGISTER_METHOD(bool, SBFrame, GetDescription, (lldb::SBStream &));
1333  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
1334  (const char *));
1335  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
1336  (const char *, lldb::DynamicValueType));
1337  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
1338  (const char *, lldb::DynamicValueType, bool));
1339  LLDB_REGISTER_METHOD(lldb::SBValue, SBFrame, EvaluateExpression,
1340  (const char *, const lldb::SBExpressionOptions &));
1341  LLDB_REGISTER_METHOD(bool, SBFrame, IsInlined, ());
1342  LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsInlined, ());
1343  LLDB_REGISTER_METHOD(bool, SBFrame, IsArtificial, ());
1344  LLDB_REGISTER_METHOD_CONST(bool, SBFrame, IsArtificial, ());
1345  LLDB_REGISTER_METHOD(const char *, SBFrame, GetFunctionName, ());
1347  LLDB_REGISTER_METHOD_CONST(const char *, SBFrame, GetFunctionName, ());
1348  LLDB_REGISTER_METHOD(const char *, SBFrame, GetDisplayFunctionName, ());
1349 }
1350 
1351 }
1352 }
lldb::SBFrame::GetThread
lldb::SBThread GetThread() const
Definition: SBFrame.cpp:709
lldb::SBValueList
Definition: SBValueList.h:18
lldb_private::StackFrame::CalculateTarget
lldb::TargetSP CalculateTarget() override
Definition: StackFrame.cpp:1732
Block.h
lldb::SBFrame::GetSP
lldb::addr_t GetSP() const
Definition: SBFrame.cpp:373
lldb::SBFrame::GuessLanguage
lldb::LanguageType GuessLanguage() const
Definition: SBFrame.cpp:1169
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:178
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:187
lldb_private::TargetProperties::GetDisplayExpressionsInCrashlogs
bool GetDisplayExpressionsInCrashlogs() const
Definition: Target.cpp:4216
lldb::SBFrame::FindRegister
lldb::SBValue FindRegister(const char *name)
Definition: SBFrame.cpp:929
lldb::eValueTypeVariableGlobal
@ eValueTypeVariableGlobal
globals variable
Definition: lldb-enumerations.h:317
lldb::SBFrame::GetFrameSP
lldb::StackFrameSP GetFrameSP() const
Definition: SBFrame.cpp:84
lldb::SBFrame::m_opaque_sp
lldb::ExecutionContextRefSP m_opaque_sp
Definition: SBFrame.h:200
lldb_private::InlineFunctionInfo
Definition: Function.h:127
lldb::SBValue::GetValue
const char * GetValue()
Definition: SBValue.cpp:356
lldb::SBCompileUnit
Definition: SBCompileUnit.h:17
lldb::eNoDynamicValues
@ eNoDynamicValues
Definition: lldb-enumerations.h:495
lldb::SBFrame::IsValid
bool IsValid() const
Definition: SBFrame.cpp:92
lldb_private::StackFrame::GetVariableList
VariableList * GetVariableList(bool get_file_globals)
Retrieve the list of variables that are in scope at this StackFrame's pc.
Definition: StackFrame.cpp:422
lldb_private::ExecutionContext::GetProcessPtr
Process * GetProcessPtr() const
Returns a pointer to the process object.
Definition: ExecutionContext.cpp:208
LLDB_RECORD_RESULT
#define LLDB_RECORD_RESULT(Result)
Definition: ReproducerInstrumentation.h:211
Host.h
lldb::SBExpressionOptions::GetFetchDynamicValue
lldb::DynamicValueType GetFetchDynamicValue() const
Definition: SBExpressionOptions.cpp:85
LLDB_RECORD_METHOD_CONST_NO_ARGS
#define LLDB_RECORD_METHOD_CONST_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:168
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:1759
lldb::SBVariablesOptions::GetIncludeLocals
bool GetIncludeLocals() const
Definition: SBVariablesOptions.cpp:145
lldb::SBFrame::operator==
bool operator==(const lldb::SBFrame &rhs) const
Definition: SBFrame.cpp:695
lldb_private::StackFrame::GetFrameCodeAddress
const Address & GetFrameCodeAddress()
Get an Address for the current pc value in this StackFrame.
Definition: StackFrame.cpp:188
SBSymbolContext.h
LLDB_RECORD_METHOD_NO_ARGS
#define LLDB_RECORD_METHOD_NO_ARGS(Result, Class, Method)
Definition: ReproducerInstrumentation.h:165
lldb_private::Function::GetDisplayName
ConstString GetDisplayName() const
Definition: Function.cpp:487
LLDB_LOGF
#define LLDB_LOGF(log,...)
Definition: Log.h:249
lldb_private::Process
Definition: Process.h:341
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:553
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:273
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_RECORD_CONSTRUCTOR_NO_ARGS
#define LLDB_RECORD_CONSTRUCTOR_NO_ARGS(Class)
Definition: ReproducerInstrumentation.h:136
lldb::SBFrame::GetRegisters
lldb::SBValueList GetRegisters()
Definition: SBFrame.cpp:899
lldb::SBFrame::GetPCAddress
lldb::SBAddress GetPCAddress() const
Definition: SBFrame.cpp:419
lldb::SBExpressionOptions::SetUnwindOnError
void SetUnwindOnError(bool unwind=true)
Definition: SBExpressionOptions.cpp:64
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:193
UserExpression.h
LLDB_REGISTER_METHOD_CONST
#define LLDB_REGISTER_METHOD_CONST(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:98
lldb::SBVariablesOptions::GetUseDynamic
lldb::DynamicValueType GetUseDynamic() const
Definition: SBVariablesOptions.cpp:199
lldb::SBSymbolContext::SetSymbolContext
void SetSymbolContext(const lldb_private::SymbolContext *sc_ptr)
Definition: SBSymbolContext.cpp:52
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:1697
lldb::SBBlock::SetPtr
void SetPtr(lldb_private::Block *lldb_object_ptr)
Definition: SBBlock.cpp:163
lldb::addr_t
uint64_t addr_t
Definition: lldb-types.h:83
lldb::SBFrame::GetCompileUnit
lldb::SBCompileUnit GetCompileUnit() const
Definition: SBFrame.cpp:162
lldb::SBAddress::SetAddress
void SetAddress(lldb::SBSection section, lldb::addr_t offset)
Definition: SBAddress.cpp:92
SBReproducerPrivate.h
lldb_private::Process::GetRunLock
ProcessRunLock & GetRunLock()
Definition: Process.cpp:5588
lldb::SBExpressionOptions::ref
lldb_private::EvaluateExpressionOptions & ref() const
Definition: SBExpressionOptions.cpp:284
lldb::SBFrame::GetSymbolContext
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const
Definition: SBFrame.cpp:114
LLDB_REGISTER_CONSTRUCTOR
#define LLDB_REGISTER_CONSTRUCTOR(Class, Signature)
Definition: ReproducerInstrumentation.h:89
lldb_private::SymbolContext
Definition: SymbolContext.h:33
lldb_private::Target
Definition: Target.h:451
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:367
lldb_private::VariableList
Definition: VariableList.h:18
lldb_private::Target::GetPersistentVariable
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition: Target.cpp:2445
lldb::SBFrame::IsInlined
bool IsInlined()
Return true if this frame represents an inlined function.
Definition: SBFrame.cpp:1114
lldb::SBFrame::GetFrameBlock
lldb::SBBlock GetFrameBlock() const
Gets the lexical block that defines the stack frame.
Definition: SBFrame.cpp:255
Process.h
SBExpressionOptions.h
lldb::SBVariablesOptions::GetIncludeRecognizedArguments
bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const
Definition: SBVariablesOptions.cpp:129
Target.h
lldb_private::StackID::GetCallFrameAddress
lldb::addr_t GetCallFrameAddress() const
Definition: StackID.h:35
LIBLLDB_LOG_EXPRESSIONS
#define LIBLLDB_LOG_EXPRESSIONS
Definition: Logging.h:22
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:988
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:280
lldb::SBFrame::GetSymbol
lldb::SBSymbol GetSymbol() const
Definition: SBFrame.cpp:211
lldb::SBFrame
Definition: SBFrame.h:17
LLDB_RECORD_METHOD
#define LLDB_RECORD_METHOD(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:158
lldb::SBSymbol::reset
void reset(lldb_private::Symbol *)
Definition: SBSymbol.cpp:145
SBThread.h
lldb::SBVariablesOptions::GetIncludeStatics
bool GetIncludeStatics() const
Definition: SBVariablesOptions.cpp:158
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:744
lldb::SBFrame::GetCFA
lldb::addr_t GetCFA() const
Definition: SBFrame.cpp:314
lldb::SBModule::SetSP
void SetSP(const ModuleSP &module_sp)
Definition: SBModule.cpp:208
lldb::SBFrame::GetDisplayFunctionName
const char * GetDisplayFunctionName()
Definition: SBFrame.cpp:1232
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:276
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:494
lldb_private::ConstString
Definition: ConstString.h:40
lldb::SBFrame::GetBlock
lldb::SBBlock GetBlock() const
Gets the deepest block that contains the frame PC.
Definition: SBFrame.cpp:234
lldb::SBVariablesOptions::SetInScopeOnly
void SetInScopeOnly(bool)
Definition: SBVariablesOptions.cpp:177
lldb_private::StreamString
Definition: StreamString.h:23
lldb::SBFrame::GetModule
lldb::SBModule GetModule() const
Definition: SBFrame.cpp:137
lldb::SBFrame::IsArtificial
bool IsArtificial()
Definition: SBFrame.cpp:1144
StackID.h
lldb::SBValueList::Append
void Append(const lldb::SBValue &val_obj)
Definition: SBValueList.cpp:127
lldb::SBFrame::operator!=
bool operator!=(const lldb::SBFrame &rhs) const
Definition: SBFrame.cpp:702
lldb_private::GetLogIfAllCategoriesSet
Log * GetLogIfAllCategoriesSet(uint32_t mask)
Definition: Logging.cpp:58
lldb_private::InlineFunctionInfo::GetName
ConstString GetName() const
Definition: Function.cpp:94
lldb::SBFunction
Definition: SBFunction.h:18
lldb::SBFrame::GetDescription
bool GetDescription(lldb::SBStream &description)
Definition: SBFrame.cpp:961
lldb::SBFunction::reset
void reset(lldb_private::Function *lldb_object_ptr)
Definition: SBFunction.cpp:144
lldb_private::repro::RegisterMethods< SBFrame >
void RegisterMethods< SBFrame >(Registry &R)
Definition: SBFrame.cpp:1279
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:500
lldb::DynamicValueType
DynamicValueType
Definition: lldb-enumerations.h:494
lldb::SBFrame::Disassemble
const char * Disassemble() const
Definition: SBFrame.cpp:721
lldb::SBFrame::GetPC
lldb::addr_t GetPC() const
Definition: SBFrame.cpp:326
lldb::eValueTypeVariableArgument
@ eValueTypeVariableArgument
function argument variables
Definition: lldb-enumerations.h:319
lldb::SBFrame::GetFP
lldb::addr_t GetFP() const
Definition: SBFrame.cpp:396
lldb::SBFrame::GetFrameID
uint32_t GetFrameID() const
Definition: SBFrame.cpp:299
lldb::SBFrame::operator=
const lldb::SBFrame & operator=(const lldb::SBFrame &rhs)
Definition: SBFrame.cpp:75
lldb::SBVariablesOptions::GetIncludeRuntimeSupportValues
bool GetIncludeRuntimeSupportValues() const
Definition: SBVariablesOptions.cpp:184
lldb::SBVariablesOptions::GetIncludeArguments
bool GetIncludeArguments() const
Definition: SBVariablesOptions.cpp:115
lldb::SBVariablesOptions::SetIncludeRuntimeSupportValues
void SetIncludeRuntimeSupportValues(bool)
Definition: SBVariablesOptions.cpp:191
Thread.h
lldb_private::TargetProperties::GetDisplayRuntimeSupportValues
bool GetDisplayRuntimeSupportValues() const
Definition: Target.cpp:4259
lldb::SBFrame::GetValueForVariablePath
lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr, DynamicValueType use_dynamic)
Definition: SBFrame.cpp:464
Address.h
lldb::SBFrame::SetPC
bool SetPC(lldb::addr_t new_pc)
Definition: SBFrame.cpp:350
VariableList.h
lldb::SBExpressionOptions::SetLanguage
void SetLanguage(lldb::LanguageType language)
Definition: SBExpressionOptions.cpp:172
lldb::SBVariablesOptions::SetIncludeLocals
void SetIncludeLocals(bool)
Definition: SBVariablesOptions.cpp:151
SBAddress.h
lldb_private::StackFrame::GetStackID
StackID & GetStackID()
Definition: StackFrame.cpp:143
lldb-types.h
lldb::SBExpressionOptions::SetFetchDynamicValue
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
Definition: SBExpressionOptions.cpp:92
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:432
Symbol.h
LLDB_RECORD_CONSTRUCTOR
#define LLDB_RECORD_CONSTRUCTOR(Class, Signature,...)
Definition: ReproducerInstrumentation.h:133
StreamFile.h
lldb_private::repro::Registry
The registry contains a unique mapping between functions and their ID.
Definition: ReproducerInstrumentation.h:517
lldb::SBFrame::~SBFrame
~SBFrame()
lldb::SBExpressionOptions
Definition: SBExpressionOptions.h:18
lldb_private::InlineFunctionInfo::GetDisplayName
ConstString GetDisplayName() const
Definition: Function.cpp:100
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:171
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:2381
lldb::SBValue::GetSummary
const char * GetSummary()
Definition: SBValue.cpp:423
lldb_private::StackFrame::GuessLanguage
lldb::LanguageType GuessLanguage()
Definition: StackFrame.cpp:1192
lldb::SBTarget
class LLDB_API SBTarget
Definition: SBDefines.h:74
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:1185
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:1181
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:259
lldb::SBValue::SetSP
void SetSP(const lldb::ValueObjectSP &sp)
Definition: SBValue.cpp:1098
UINT32_MAX
#define UINT32_MAX
Definition: lldb-defines.h:31
lldb::SBVariablesOptions::SetIncludeStatics
void SetIncludeStatics(bool)
Definition: SBVariablesOptions.cpp:164
lldb::SBFrame::IsEqual
bool IsEqual(const lldb::SBFrame &that) const
Definition: SBFrame.cpp:686
lldb::SBCompileUnit::reset
void reset(lldb_private::CompileUnit *lldb_object_ptr)
Definition: SBCompileUnit.cpp:223
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:86
lldb_private::ConstString::GetCString
const char * GetCString() const
Get the string value as a C string.
Definition: ConstString.h:216
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:206
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:4168
lldb::eValueTypeConstResult
@ eValueTypeConstResult
constant result variables
Definition: lldb-enumerations.h:323
lldb::SBFrame::Clear
void Clear()
Definition: SBFrame.cpp:440
lldb_private::StackFrame::GetRegisterContext
lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
Definition: StackFrame.cpp:1123
lldb::SBLineEntry::SetLineEntry
void SetLineEntry(const lldb_private::LineEntry &lldb_object_ref)
Definition: SBLineEntry.cpp:47
ConstString.h
lldb::SBFrame::GetFunctionName
const char * GetFunctionName()
Get the appropriate function name for this frame.
Definition: SBFrame.cpp:1163
lldb_private::StackFrame::GetRecognizedFrame
lldb::RecognizedStackFrameSP GetRecognizedFrame()
Definition: StackFrame.cpp:1933
ValueObjectVariable.h
Stream.h
lldb::eValueTypeRegister
@ eValueTypeRegister
stack frame register value
Definition: lldb-enumerations.h:321
lldb_private::Log
Definition: Log.h:49
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:173
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:88
lldb::SBStream
Definition: SBStream.h:18
lldb::SBFrame::SBFrame
SBFrame()
Definition: SBFrame.cpp:57
lldb_private::SymbolContext::line_entry
LineEntry line_entry
The LineEntry for a given query.
Definition: SymbolContext.h:322
LLDB_RECORD_METHOD_CONST
#define LLDB_RECORD_METHOD_CONST(Result, Class, Method, Signature,...)
Definition: ReproducerInstrumentation.h:161
Variable.h
lldb_private::Symbol::GetDisplayName
ConstString GetDisplayName() const
Definition: Symbol.cpp:121
lldb::SBVariablesOptions::SetIncludeArguments
void SetIncludeArguments(bool)
Definition: SBVariablesOptions.cpp:122
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:298
lldb_private::Block::GetContainingInlinedBlock
Block * GetContainingInlinedBlock()
Get the inlined block that contains this block.
Definition: Block.cpp:197
lldb_private::ExecutionContext::GetTargetPtr
Target * GetTargetPtr() const
Returns a pointer to the target object.
Definition: ExecutionContext.cpp:200
ExecutionContext.h
lldb::SBExpressionOptions::SetIgnoreBreakpoints
void SetIgnoreBreakpoints(bool ignore=true)
Definition: SBExpressionOptions.cpp:78
LLDB_REGISTER_METHOD
#define LLDB_REGISTER_METHOD(Result, Class, Method, Signature)
Definition: ReproducerInstrumentation.h:93
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:1139