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
17#include "lldb/lldb-types.h"
18
19#include "Utils.h"
20#include "lldb/Core/Address.h"
21#include "lldb/Core/Debugger.h"
24#include "lldb/Host/Host.h"
25#include "lldb/Symbol/Block.h"
27#include "lldb/Symbol/Symbol.h"
32#include "lldb/Target/Process.h"
36#include "lldb/Target/StackID.h"
37#include "lldb/Target/Target.h"
38#include "lldb/Target/Thread.h"
42#include "lldb/Utility/Stream.h"
46
47#include "lldb/API/SBAddress.h"
48#include "lldb/API/SBDebugger.h"
50#include "lldb/API/SBFormat.h"
51#include "lldb/API/SBStream.h"
54#include "lldb/API/SBThread.h"
55#include "lldb/API/SBValue.h"
57
58#include "llvm/Support/PrettyStackTrace.h"
59
60using namespace lldb;
61using namespace lldb_private;
62
66
67SBFrame::SBFrame(const StackFrameSP &lldb_object_sp)
68 : m_opaque_sp(new ExecutionContextRef(lldb_object_sp)) {
69 LLDB_INSTRUMENT_VA(this, lldb_object_sp);
70}
71
73 LLDB_INSTRUMENT_VA(this, rhs);
74
76}
77
78SBFrame::~SBFrame() = default;
79
81 LLDB_INSTRUMENT_VA(this, rhs);
82
83 if (this != &rhs)
85 return *this;
86}
87
89 return (m_opaque_sp ? m_opaque_sp->GetFrameSP() : StackFrameSP());
90}
91
92void SBFrame::SetFrameSP(const StackFrameSP &lldb_object_sp) {
93 return m_opaque_sp->SetFrameSP(lldb_object_sp);
94}
95
96bool SBFrame::IsValid() const {
98 return this->operator bool();
99}
100SBFrame::operator bool() const {
101 LLDB_INSTRUMENT_VA(this);
102 llvm::Expected<StoppedExecutionContext> exe_ctx =
104 if (!exe_ctx) {
105 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
106 return false;
107 }
108
109 return GetFrameSP().get() != nullptr;
110}
111
112SBSymbolContext SBFrame::GetSymbolContext(uint32_t resolve_scope) const {
113 LLDB_INSTRUMENT_VA(this, resolve_scope);
114
115 SBSymbolContext sb_sym_ctx;
116
117 llvm::Expected<StoppedExecutionContext> exe_ctx =
119 if (!exe_ctx) {
120 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
121 return sb_sym_ctx;
122 }
123
124 SymbolContextItem scope = static_cast<SymbolContextItem>(resolve_scope);
125 if (StackFrame *frame = exe_ctx->GetFramePtr())
126 sb_sym_ctx = frame->GetSymbolContext(scope);
127
128 return sb_sym_ctx;
129}
130
132 LLDB_INSTRUMENT_VA(this);
133
134 llvm::Expected<StoppedExecutionContext> exe_ctx =
136 if (!exe_ctx) {
137 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
138 return SBModule();
139 }
140
141 ModuleSP module_sp;
142 StackFrame *frame = exe_ctx->GetFramePtr();
143 if (!frame)
144 return SBModule();
145
146 SBModule sb_module;
147 module_sp = frame->GetSymbolContext(eSymbolContextModule).module_sp;
148 sb_module.SetSP(module_sp);
149 return sb_module;
150}
151
153 LLDB_INSTRUMENT_VA(this);
154
155 llvm::Expected<StoppedExecutionContext> exe_ctx =
157 if (!exe_ctx) {
158 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
159 return SBCompileUnit();
160 }
161
162 if (StackFrame *frame = exe_ctx->GetFramePtr())
163 return SBCompileUnit(
164 frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
165 return SBCompileUnit();
166}
167
169 LLDB_INSTRUMENT_VA(this);
170
171 llvm::Expected<StoppedExecutionContext> exe_ctx =
173 if (!exe_ctx) {
174 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
175 return SBFunction();
176 }
177
178 if (StackFrame *frame = exe_ctx->GetFramePtr())
179 return SBFunction(frame->GetSymbolContext(eSymbolContextFunction).function);
180 return SBFunction();
181}
182
184 LLDB_INSTRUMENT_VA(this);
185
186 llvm::Expected<StoppedExecutionContext> exe_ctx =
188 if (!exe_ctx) {
189 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
190 return SBSymbol();
191 }
192
193 if (StackFrame *frame = exe_ctx->GetFramePtr())
194 return SBSymbol(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
195 return SBSymbol();
196}
197
199 LLDB_INSTRUMENT_VA(this);
200
201 llvm::Expected<StoppedExecutionContext> exe_ctx =
203 if (!exe_ctx) {
204 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
205 return SBBlock();
206 }
207
208 if (StackFrame *frame = exe_ctx->GetFramePtr())
209 return SBBlock(frame->GetSymbolContext(eSymbolContextBlock).block);
210 return SBBlock();
211}
212
214 LLDB_INSTRUMENT_VA(this);
215
216 llvm::Expected<StoppedExecutionContext> exe_ctx =
218 if (!exe_ctx) {
219 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
220 return SBBlock();
221 }
222
223 if (StackFrame *frame = exe_ctx->GetFramePtr())
224 return SBBlock(frame->GetFrameBlock());
225 return SBBlock();
226}
227
229 LLDB_INSTRUMENT_VA(this);
230
231 llvm::Expected<StoppedExecutionContext> exe_ctx =
233 if (!exe_ctx) {
234 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
235 return SBLineEntry();
236 }
237
238 if (StackFrame *frame = exe_ctx->GetFramePtr())
239 return SBLineEntry(
240 &frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
241 return SBLineEntry();
242}
243
244uint32_t SBFrame::GetFrameID() const {
245 LLDB_INSTRUMENT_VA(this);
246
247 constexpr uint32_t error_frame_idx = UINT32_MAX;
248
249 llvm::Expected<StoppedExecutionContext> exe_ctx =
251 if (!exe_ctx) {
252 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
253 return error_frame_idx;
254 }
255
256 if (StackFrame *frame = exe_ctx->GetFramePtr())
257 return frame->GetFrameIndex();
258 return error_frame_idx;
259}
260
262 LLDB_INSTRUMENT_VA(this);
263
264 llvm::Expected<StoppedExecutionContext> exe_ctx =
266 if (!exe_ctx) {
267 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
269 }
270
271 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
272 const StackID &id = frame->GetStackID();
273 // A tail call frame's StackID borrows the CFA of the frame that replaced
274 // it.
275 if (id.GetTailCallDepth())
277 return id.GetCallFrameAddressWithoutMetadata();
278 }
280}
281
283 LLDB_INSTRUMENT_VA(this);
284
286 llvm::Expected<StoppedExecutionContext> exe_ctx =
288 if (!exe_ctx) {
289 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
290 return addr;
291 }
292
293 Target *target = exe_ctx->GetTargetPtr();
294 if (StackFrame *frame = exe_ctx->GetFramePtr())
295 return frame->GetFrameCodeAddress().GetOpcodeLoadAddress(
296 target, AddressClass::eCode);
297
298 return addr;
299}
300
301bool SBFrame::SetPC(addr_t new_pc) {
302 LLDB_INSTRUMENT_VA(this, new_pc);
303
304 constexpr bool error_ret_val = false;
305 llvm::Expected<StoppedExecutionContext> exe_ctx =
307 if (!exe_ctx) {
308 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
309 return error_ret_val;
310 }
311
312 if (StackFrame *frame = exe_ctx->GetFramePtr())
313 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext())
314 return reg_ctx_sp->SetPC(new_pc);
315
316 return error_ret_val;
317}
318
320 LLDB_INSTRUMENT_VA(this);
321
322 llvm::Expected<StoppedExecutionContext> exe_ctx =
324 if (!exe_ctx) {
325 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
327 }
328
329 if (StackFrame *frame = exe_ctx->GetFramePtr())
330 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext())
331 return reg_ctx_sp->GetSP();
332
334}
335
337 LLDB_INSTRUMENT_VA(this);
338
339 llvm::Expected<StoppedExecutionContext> exe_ctx =
341 if (!exe_ctx) {
342 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
344 }
345
346 if (StackFrame *frame = exe_ctx->GetFramePtr())
347 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext())
348 return reg_ctx_sp->GetFP();
349
351}
352
354 LLDB_INSTRUMENT_VA(this);
355
356 llvm::Expected<StoppedExecutionContext> exe_ctx =
358 if (!exe_ctx) {
359 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
360 return SBAddress();
361 }
362
363 if (StackFrame *frame = exe_ctx->GetFramePtr())
364 return SBAddress(frame->GetFrameCodeAddress());
365 return SBAddress();
366}
367
369 LLDB_INSTRUMENT_VA(this);
370
371 m_opaque_sp->Clear();
372}
373
375 LLDB_INSTRUMENT_VA(this, var_path);
376
377 SBValue sb_value;
378 llvm::Expected<StoppedExecutionContext> exe_ctx =
380 if (!exe_ctx) {
381 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
382 return sb_value;
383 }
384
385 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
386 lldb::DynamicValueType use_dynamic =
387 frame->CalculateTarget()->GetPreferDynamicValue();
388 sb_value = GetValueForVariablePath(var_path, use_dynamic);
389 }
390 return sb_value;
391}
392
394 DynamicValueType use_dynamic) {
395 LLDB_INSTRUMENT_VA(this, var_path, use_dynamic);
396
397 SBValue sb_value;
398 if (var_path == nullptr || var_path[0] == '\0') {
399 return sb_value;
400 }
401
402 llvm::Expected<StoppedExecutionContext> exe_ctx =
404 if (!exe_ctx) {
405 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
406 return sb_value;
407 }
408
409 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
410 VariableSP var_sp;
412 ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
413 var_path, eNoDynamicValues,
416 var_sp, error, lldb::eDILModeFull));
417 sb_value.SetSP(value_sp, use_dynamic);
418 }
419 return sb_value;
420}
421
423 lldb::DILMode mode) {
424 LLDB_INSTRUMENT_VA(this, var_path, mode);
425
426 SBValue sb_value;
427 llvm::Expected<StoppedExecutionContext> exe_ctx =
429 if (!exe_ctx) {
430 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
431 return sb_value;
432 }
433
434 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
435 lldb::DynamicValueType use_dynamic =
436 frame->CalculateTarget()->GetPreferDynamicValue();
437 sb_value = GetValueForVariablePathWithMode(var_path, mode, use_dynamic);
438 }
439 return sb_value;
440}
441
443 const char *var_path, lldb::DILMode mode, DynamicValueType use_dynamic) {
444 LLDB_INSTRUMENT_VA(this, var_path, mode, use_dynamic);
445
446 SBValue sb_value;
447 if (var_path == nullptr || var_path[0] == '\0') {
448 return sb_value;
449 }
450
451 llvm::Expected<StoppedExecutionContext> exe_ctx =
453 if (!exe_ctx) {
454 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
455 return sb_value;
456 }
457
458 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
459 VariableSP var_sp;
461 ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
462 var_path, eNoDynamicValues,
465 var_sp, error, mode));
466 sb_value.SetSP(value_sp, use_dynamic);
467 }
468 return sb_value;
469}
470
472 LLDB_INSTRUMENT_VA(this, name);
473
474 llvm::Expected<StoppedExecutionContext> exe_ctx =
476 if (!exe_ctx) {
477 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
478 return SBValue();
479 }
480
481 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
482 lldb::DynamicValueType use_dynamic =
483 frame->CalculateTarget()->GetPreferDynamicValue();
484 return FindVariable(name, use_dynamic);
485 }
486 return SBValue();
487}
488
490 lldb::DynamicValueType use_dynamic) {
491 LLDB_INSTRUMENT_VA(this, name, use_dynamic);
492
493 VariableSP var_sp;
494 SBValue sb_value;
495
496 if (name == nullptr || name[0] == '\0') {
497 return sb_value;
498 }
499
500 llvm::Expected<StoppedExecutionContext> exe_ctx =
502 if (!exe_ctx) {
503 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
504 return sb_value;
505 }
506
507 if (StackFrame *frame = exe_ctx->GetFramePtr())
508 if (ValueObjectSP value_sp = frame->FindVariable(ConstString(name)))
509 sb_value.SetSP(value_sp, use_dynamic);
510
511 return sb_value;
512}
513
514SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
515 LLDB_INSTRUMENT_VA(this, name, value_type);
516
517 SBValue value;
518 llvm::Expected<StoppedExecutionContext> exe_ctx =
520 if (!exe_ctx) {
521 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
522 return value;
523 }
524
525 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
526 lldb::DynamicValueType use_dynamic =
527 frame->CalculateTarget()->GetPreferDynamicValue();
528 value = FindValue(name, value_type, use_dynamic);
529 }
530 return value;
531}
532
533SBValue SBFrame::FindValue(const char *name, ValueType value_type,
534 lldb::DynamicValueType use_dynamic) {
535 LLDB_INSTRUMENT_VA(this, name, value_type, use_dynamic);
536
537 SBValue sb_value;
538
539 if (name == nullptr || name[0] == '\0') {
540 return sb_value;
541 }
542
543 ValueObjectSP value_sp;
544 llvm::Expected<StoppedExecutionContext> exe_ctx =
546
547 if (!exe_ctx) {
548 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
549 return value_sp;
550 }
551
552 StackFrame *frame = exe_ctx->GetFramePtr();
553 if (!frame)
554 return value_sp;
555
556 VariableList variable_list;
557
558 bool include_synthetic_vars = IsSyntheticValueType(value_type);
559 // Switch on the value_type without the mask, but keep it in the value type so
560 // we can use it later when we look for variables in the list.
561 auto base_value_type = GetBaseValueType(value_type);
562 switch (base_value_type) {
563 case eValueTypeVariableGlobal: // global variable
564 case eValueTypeVariableStatic: // static variable
565 case eValueTypeVariableArgument: // function argument variables
566 case eValueTypeVariableLocal: // function local variables
567 case eValueTypeVariableThreadLocal: { // thread local variables
568 SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
569
570 const bool can_create = true;
571 const bool get_parent_variables = true;
572 const bool stop_if_block_is_inlined_function = true;
573
574 if (sc.block)
576 can_create, get_parent_variables, stop_if_block_is_inlined_function,
577 [frame](Variable *v) { return v->IsInScope(frame); }, &variable_list);
578 // Fetch variables from the frame if we need to get
579 // globals/statics/synthetic variables.
580 if (base_value_type == eValueTypeVariableGlobal ||
581 base_value_type == eValueTypeVariableStatic || include_synthetic_vars) {
582 const bool get_file_globals = true;
583 VariableList *frame_vars = frame->GetVariableList(
584 get_file_globals, include_synthetic_vars, nullptr);
585 if (frame_vars)
586 frame_vars->AppendVariablesIfUnique(variable_list);
587 }
588
589 ConstString const_name(name);
590 VariableSP variable_sp(variable_list.FindVariable(const_name, value_type));
591 if (variable_sp) {
592 value_sp =
594 sb_value.SetSP(value_sp, use_dynamic);
595 }
596 } break;
597
598 case eValueTypeRegister: { // stack frame register value
599 if (RegisterContextSP reg_ctx = frame->GetRegisterContext()) {
600 if (const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name)) {
601 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
602 sb_value.SetSP(value_sp);
603 }
604 }
605 } break;
606
607 case eValueTypeRegisterSet: { // A collection of stack frame register
608 // values
609 if (RegisterContextSP reg_ctx = frame->GetRegisterContext()) {
610 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
611 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
612 const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
613 if (reg_set &&
614 (llvm::StringRef(reg_set->name).equals_insensitive(name) ||
615 llvm::StringRef(reg_set->short_name).equals_insensitive(name))) {
616 value_sp = ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
617 sb_value.SetSP(value_sp);
618 break;
619 }
620 }
621 }
622 } break;
623
624 case eValueTypeConstResult: { // constant result variables
625 ConstString const_name(name);
626 Target *target = exe_ctx->GetTargetPtr();
627 ExpressionVariableSP expr_var_sp(target->GetPersistentVariable(const_name));
628 if (expr_var_sp) {
629 value_sp = expr_var_sp->GetValueObject();
630 sb_value.SetSP(value_sp, use_dynamic);
631 }
632 } break;
633
634 default:
635 break;
636 }
637
638 return sb_value;
639}
640
641bool SBFrame::IsEqual(const SBFrame &that) const {
642 LLDB_INSTRUMENT_VA(this, that);
643
644 lldb::StackFrameSP this_sp = GetFrameSP();
645 lldb::StackFrameSP that_sp = that.GetFrameSP();
646 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
647}
648
649bool SBFrame::operator==(const SBFrame &rhs) const {
650 LLDB_INSTRUMENT_VA(this, rhs);
651
652 return IsEqual(rhs);
653}
654
655bool SBFrame::operator!=(const SBFrame &rhs) const {
656 LLDB_INSTRUMENT_VA(this, rhs);
657
658 return !IsEqual(rhs);
659}
660
662 LLDB_INSTRUMENT_VA(this);
663
664 llvm::Expected<StoppedExecutionContext> exe_ctx =
666 if (!exe_ctx) {
667 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
668 return SBThread();
669 }
670
671 ThreadSP thread_sp(exe_ctx->GetThreadSP());
672 SBThread sb_thread(thread_sp);
673
674 return sb_thread;
675}
676
677const char *SBFrame::Disassemble() const {
678 LLDB_INSTRUMENT_VA(this);
679
680 llvm::Expected<StoppedExecutionContext> exe_ctx =
682 if (!exe_ctx) {
683 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
684 return nullptr;
685 }
686
687 if (auto *frame = exe_ctx->GetFramePtr())
688 return GetDebuggerStringPool(exe_ctx->GetTargetRef())
689 .Intern(frame->Disassemble());
690
691 return nullptr;
692}
693
694SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
695 bool in_scope_only) {
696 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only);
697
698 SBValueList value_list;
699 llvm::Expected<StoppedExecutionContext> exe_ctx =
701 if (!exe_ctx) {
702 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
703 return value_list;
704 }
705
706 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
707 Target *target = exe_ctx->GetTargetPtr();
708 lldb::DynamicValueType use_dynamic =
709 frame->CalculateTarget()->GetPreferDynamicValue();
710 const bool include_runtime_support_values =
712
713 SBVariablesOptions options;
714 options.SetIncludeArguments(arguments);
715 options.SetIncludeLocals(locals);
716 options.SetIncludeStatics(statics);
717 options.SetInScopeOnly(in_scope_only);
718 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
719 options.SetUseDynamic(use_dynamic);
720
721 // Assume that if we have any synthetic variables, they should be included.
722 options.SetIncludeSynthetic(true);
723
724 value_list = GetVariables(options);
725 }
726 return value_list;
727}
728
729lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
730 bool statics, bool in_scope_only,
731 lldb::DynamicValueType use_dynamic) {
732 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only,
733 use_dynamic);
734
735 llvm::Expected<StoppedExecutionContext> exe_ctx =
737 if (!exe_ctx) {
738 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
739 return SBValueList();
740 }
741
742 Target *target = exe_ctx->GetTargetPtr();
743 const bool include_runtime_support_values =
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 // Assume that if we have any synthetic variables, they should be included.
754 options.SetIncludeSynthetic(true);
755
756 return GetVariables(options);
757}
758
759/// Returns true if the variable is in any of the requested scopes.
760static bool IsInRequestedScope(bool statics, bool arguments, bool locals,
761 bool synthetic, Variable &var) {
762 auto value_type = var.GetScope();
763 // Check if the variable is synthetic first.
764 bool is_synthetic = IsSyntheticValueType(value_type);
765 if (is_synthetic) {
766 // If the variable is synthetic but we don't want those, then it's
767 // automatically out of scope.
768 if (!synthetic)
769 return false;
770
771 // Get the base value type so the rest of the switch works correctly.
772 value_type = GetBaseValueType(value_type);
773 }
774
775 switch (value_type) {
779 return statics;
780
782 return arguments;
783
785 return locals;
786
787 default:
788 break;
789 }
790
791 // The default for all other value types is is_synthetic. At this point, if
792 // we didn't want synthetic variables we'd have exited by now anyway, so we
793 // must want them. Aside from the modifiers above that should apply equally to
794 // synthetic and normal variables, any other synthetic variable we should
795 // default to showing.
796 return is_synthetic;
797}
798
800
801/// Populates `value_list` with the variables from `frame` according to
802/// `options`. This method checks whether the Debugger received an interrupt
803/// before processing every variable, returning `WasInterrupted::yes` in that
804/// case.
805static std::pair<WasInterrupted, Status> FetchVariablesUnlessInterrupted(
806 const lldb::SBVariablesOptions &options, StackFrame &frame,
807 SBValueList &value_list, Debugger &dbg,
808 std::function<SBValue(ValueObjectSP, bool)> to_sbvalue) {
809 const bool statics = options.GetIncludeStatics();
810 const bool arguments = options.GetIncludeArguments();
811 const bool locals = options.GetIncludeLocals();
812 const bool synthetic = options.GetIncludeSynthetic();
813 const bool in_scope_only = options.GetInScopeOnly();
814 const bool include_runtime_support_values =
816 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
817
818 Status var_error;
819 // Fetch all variables available and filter them later.
820 VariableList *variable_list = frame.GetVariableList(
821 /*get_file_globals=*/true, /*include_synthetic_vars=*/true, &var_error);
822
823 std::set<VariableSP> variable_set;
824
825 if (!variable_list)
826 return {WasInterrupted::No, std::move(var_error)};
827 const size_t num_variables = variable_list->GetSize();
828 size_t num_produced = 0;
829 for (const VariableSP &variable_sp : *variable_list) {
830 if (!variable_sp || !IsInRequestedScope(statics, arguments, locals,
831 synthetic, *variable_sp))
832 continue;
833
835 dbg,
836 "Interrupted getting frame variables with {0} of {1} "
837 "produced.",
838 num_produced, num_variables))
839 return {WasInterrupted::Yes, std::move(var_error)};
840
841 // Only add variables once so we don't end up with duplicates
842 if (variable_set.insert(variable_sp).second == false)
843 continue;
844 if (in_scope_only && !variable_sp->IsInScope(&frame))
845 continue;
846
847 ValueObjectSP valobj_sp(
849
850 if (!include_runtime_support_values && valobj_sp != nullptr &&
851 valobj_sp->IsRuntimeSupportValue())
852 continue;
853
854 value_list.Append(to_sbvalue(valobj_sp, use_dynamic));
855 }
856 num_produced++;
857
858 return {WasInterrupted::No, std::move(var_error)};
859}
860
861/// Populates `value_list` with recognized arguments of `frame` according to
862/// `options`.
863static llvm::SmallVector<ValueObjectSP>
865 SBTarget target) {
866 if (!options.GetIncludeRecognizedArguments(target))
867 return {};
868 RecognizedStackFrameSP recognized_frame = frame.GetRecognizedFrame();
869 if (!recognized_frame)
870 return {};
871
872 ValueObjectListSP recognized_arg_list =
873 recognized_frame->GetRecognizedArguments();
874 if (!recognized_arg_list)
875 return {};
876
877 return llvm::to_vector(recognized_arg_list->GetObjects());
878}
879
881 LLDB_INSTRUMENT_VA(this, options);
882
883 llvm::Expected<StoppedExecutionContext> exe_ctx =
885 if (!exe_ctx) {
886 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
887 return SBValueList();
888 }
889
890 StackFrame *frame = exe_ctx->GetFramePtr();
891 if (!frame)
892 return SBValueList();
893
894 auto valobj_to_sbvalue = [](ValueObjectSP valobj, bool use_dynamic) {
895 SBValue value_sb;
896 value_sb.SetSP(valobj, use_dynamic);
897 return value_sb;
898 };
899 SBValueList value_list;
900 std::pair<WasInterrupted, Status> fetch_result =
901 FetchVariablesUnlessInterrupted(options, *frame, value_list,
902 exe_ctx->GetTargetPtr()->GetDebugger(),
903 valobj_to_sbvalue);
904 if (fetch_result.second.Fail())
905 value_list.SetError(std::move(fetch_result.second));
906
907 if (fetch_result.first == WasInterrupted::Yes)
908 return value_list;
909
910 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
911 llvm::SmallVector<ValueObjectSP> args = FetchRecognizedArguments(
912 options, *frame, SBTarget(exe_ctx->GetTargetSP()));
913 for (ValueObjectSP arg : args) {
914 SBValue value_sb;
915 value_sb.SetSP(arg, use_dynamic);
916 value_list.Append(value_sb);
917 }
918 return value_list;
919}
920
922 LLDB_INSTRUMENT_VA(this);
923
924 llvm::Expected<StoppedExecutionContext> exe_ctx =
926 if (!exe_ctx) {
927 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
928 return SBValueList();
929 }
930
931 StackFrame *frame = exe_ctx->GetFramePtr();
932 if (!frame)
933 return SBValueList();
934
935 RegisterContextSP reg_ctx(frame->GetRegisterContext());
936 if (!reg_ctx)
937 return SBValueList();
938
939 SBValueList value_list;
940 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
941 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
942 value_list.Append(ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
943
944 return value_list;
945}
946
948 LLDB_INSTRUMENT_VA(this, name);
949
950 ValueObjectSP value_sp;
951 llvm::Expected<StoppedExecutionContext> exe_ctx =
953 if (!exe_ctx) {
954 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
955 return SBValue();
956 }
957
958 StackFrame *frame = exe_ctx->GetFramePtr();
959 if (!frame)
960 return SBValue();
961
962 RegisterContextSP reg_ctx(frame->GetRegisterContext());
963 if (!reg_ctx)
964 return SBValue();
965
966 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
967 if (!reg_info)
968 return SBValue();
969
970 SBValue result;
971 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
972 result.SetSP(value_sp);
973
974 return result;
975}
976
978 SBStream &output) {
979 Stream &strm = output.ref();
980
981 llvm::Expected<StoppedExecutionContext> exe_ctx =
983 if (!exe_ctx)
984 return Status::FromError(exe_ctx.takeError());
985
987
988 if (!format) {
989 error.SetErrorString("The provided SBFormat object is invalid");
990 return error;
991 }
992
993 if (StackFrame *frame = exe_ctx->GetFramePtr();
994 frame && frame->DumpUsingFormat(strm, format.GetFormatEntrySP().get()))
995 return error;
996 error.SetErrorStringWithFormat(
997 "It was not possible to generate a frame "
998 "description with the given format string '%s'",
999 format.GetFormatEntrySP()->string.c_str());
1000 return error;
1001}
1002
1004 LLDB_INSTRUMENT_VA(this, description);
1005
1006 Stream &strm = description.ref();
1007
1008 llvm::Expected<StoppedExecutionContext> exe_ctx =
1010 if (!exe_ctx) {
1011 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1012 strm.PutCString("Error: process is not stopped.");
1013 return true;
1014 }
1015
1016 if (StackFrame *frame = exe_ctx->GetFramePtr())
1017 frame->DumpUsingSettingsFormat(&strm);
1018
1019 return true;
1020}
1021
1023 LLDB_INSTRUMENT_VA(this, expr);
1024
1025 llvm::Expected<StoppedExecutionContext> exe_ctx =
1027 if (!exe_ctx) {
1028 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1030 }
1031
1032 SBExpressionOptions options;
1033 StackFrame *frame = exe_ctx->GetFramePtr();
1034 if (frame) {
1035 lldb::DynamicValueType fetch_dynamic_value =
1036 frame->CalculateTarget()->GetPreferDynamicValue();
1037 options.SetFetchDynamicValue(fetch_dynamic_value);
1038 }
1039 options.SetUnwindOnError(true);
1040 options.SetIgnoreBreakpoints(true);
1041 Target *target = exe_ctx->GetTargetPtr();
1042 SourceLanguage language = target->GetLanguage();
1043 if (!language && frame)
1044 language = frame->GetLanguage();
1045 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1046 return EvaluateExpression(expr, options);
1047}
1048
1049SBValue
1051 lldb::DynamicValueType fetch_dynamic_value) {
1052 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value);
1053
1054 SBExpressionOptions options;
1055 options.SetFetchDynamicValue(fetch_dynamic_value);
1056 options.SetUnwindOnError(true);
1057 options.SetIgnoreBreakpoints(true);
1058 llvm::Expected<StoppedExecutionContext> exe_ctx =
1060 if (!exe_ctx) {
1061 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1063 }
1064
1065 StackFrame *frame = exe_ctx->GetFramePtr();
1066 Target *target = exe_ctx->GetTargetPtr();
1067 SourceLanguage language = target->GetLanguage();
1068 if (!language && frame)
1069 language = frame->GetLanguage();
1070 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1071 return EvaluateExpression(expr, options);
1072}
1073
1075 lldb::DynamicValueType fetch_dynamic_value,
1076 bool unwind_on_error) {
1077 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value, unwind_on_error);
1078
1079 SBExpressionOptions options;
1080 llvm::Expected<StoppedExecutionContext> exe_ctx =
1082 if (!exe_ctx) {
1083 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1085 }
1086
1087 options.SetFetchDynamicValue(fetch_dynamic_value);
1088 options.SetUnwindOnError(unwind_on_error);
1089 options.SetIgnoreBreakpoints(true);
1090 StackFrame *frame = exe_ctx->GetFramePtr();
1091 Target *target = exe_ctx->GetTargetPtr();
1092 SourceLanguage language = target->GetLanguage();
1093 if (!language && frame)
1094 language = frame->GetLanguage();
1095 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1096 return EvaluateExpression(expr, options);
1097}
1098
1100 auto error = Status::FromErrorString("can't evaluate expressions when the "
1101 "process is running.");
1102 ValueObjectSP expr_value_sp =
1103 ValueObjectConstResult::Create(nullptr, std::move(error));
1104 SBValue expr_result;
1105 expr_result.SetSP(expr_value_sp, false);
1106 return expr_result;
1107}
1108
1110 const SBExpressionOptions &options) {
1111 LLDB_INSTRUMENT_VA(this, expr, options);
1112
1113 auto LogResult = [](SBValue expr_result) {
1114 Log *expr_log = GetLog(LLDBLog::Expressions);
1115 if (expr_result.GetError().Success())
1116 LLDB_LOGF(expr_log,
1117 "** [SBFrame::EvaluateExpression] Expression result is "
1118 "%s, summary %s **",
1119 expr_result.GetValue(), expr_result.GetSummary());
1120 else
1121 LLDB_LOGF(
1122 expr_log,
1123 "** [SBFrame::EvaluateExpression] Expression evaluation failed: "
1124 "%s **",
1125 expr_result.GetError().GetCString());
1126 };
1127
1128 if (expr == nullptr || expr[0] == '\0') {
1129 return SBValue();
1130 }
1131
1132 llvm::Expected<StoppedExecutionContext> exe_ctx =
1134 if (!exe_ctx) {
1135 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1137 LogResult(error_result);
1138 return error_result;
1139 }
1140
1141 StackFrame *frame = exe_ctx->GetFramePtr();
1142 if (!frame)
1143 return SBValue();
1144
1145 std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1146 Target *target = exe_ctx->GetTargetPtr();
1147 if (target->GetDisplayExpressionsInCrashlogs()) {
1148 StreamString frame_description;
1149 frame->DumpUsingSettingsFormat(&frame_description);
1150 stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1151 "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1152 "= %u) %s",
1153 expr, options.GetFetchDynamicValue(), frame_description.GetData());
1154 }
1155
1156 ValueObjectSP expr_value_sp;
1157 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
1158
1159 SBValue expr_result;
1160 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
1161 LogResult(expr_result);
1162
1163 return expr_result;
1164}
1165
1167 LLDB_INSTRUMENT_VA(this);
1168
1169 SBStructuredData sb_data;
1170 llvm::Expected<StoppedExecutionContext> exe_ctx =
1172 if (!exe_ctx) {
1173 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1174 return sb_data;
1175 }
1176 StackFrame *frame = exe_ctx->GetFramePtr();
1177 if (!frame)
1178 return sb_data;
1179
1181 sb_data.m_impl_up->SetObjectSP(data);
1182 return sb_data;
1183}
1184
1186 LLDB_INSTRUMENT_VA(this);
1187
1188 return static_cast<const SBFrame *>(this)->IsInlined();
1189}
1190
1192 LLDB_INSTRUMENT_VA(this);
1193
1194 llvm::Expected<StoppedExecutionContext> exe_ctx =
1196 if (!exe_ctx) {
1197 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1198 return false;
1199 }
1200
1201 if (StackFrame *frame = exe_ctx->GetFramePtr())
1202 return frame->IsInlined();
1203 return false;
1204}
1205
1207 LLDB_INSTRUMENT_VA(this);
1208
1209 return static_cast<const SBFrame *>(this)->IsArtificial();
1210}
1211
1213 LLDB_INSTRUMENT_VA(this);
1214
1215 llvm::Expected<StoppedExecutionContext> exe_ctx =
1217 if (!exe_ctx) {
1218 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1219 return false;
1220 }
1221
1222 if (StackFrame *frame = exe_ctx->GetFramePtr())
1223 return frame->IsArtificial();
1224
1225 return false;
1226}
1227
1229 LLDB_INSTRUMENT_VA(this);
1230
1231 llvm::Expected<StoppedExecutionContext> exe_ctx =
1233 if (!exe_ctx) {
1234 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1235 return false;
1236 }
1237
1238 if (StackFrame *frame = exe_ctx->GetFramePtr())
1239 return frame->IsSynthetic();
1240
1241 return false;
1242}
1243
1244bool SBFrame::IsHidden() const {
1245 LLDB_INSTRUMENT_VA(this);
1246
1247 llvm::Expected<StoppedExecutionContext> exe_ctx =
1249 if (!exe_ctx) {
1250 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1251 return false;
1252 }
1253
1254 if (StackFrame *frame = exe_ctx->GetFramePtr())
1255 return frame->IsHidden();
1256
1257 return false;
1258}
1259
1261 LLDB_INSTRUMENT_VA(this);
1262
1263 return static_cast<const SBFrame *>(this)->GetFunctionName();
1264}
1265
1267 LLDB_INSTRUMENT_VA(this);
1268
1269 llvm::Expected<StoppedExecutionContext> exe_ctx =
1271 if (!exe_ctx) {
1272 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1273 return eLanguageTypeUnknown;
1274 }
1275
1276 if (StackFrame *frame = exe_ctx->GetFramePtr())
1277 return frame->GuessLanguage().AsLanguageType();
1278 return eLanguageTypeUnknown;
1279}
1280
1281const char *SBFrame::GetFunctionName() const {
1282 LLDB_INSTRUMENT_VA(this);
1283
1284 llvm::Expected<StoppedExecutionContext> exe_ctx =
1286 if (!exe_ctx) {
1287 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1288 return nullptr;
1289 }
1290
1291 if (StackFrame *frame = exe_ctx->GetFramePtr())
1292 return GetDebuggerStringPool(exe_ctx->GetTargetRef())
1293 .Intern(frame->GetFunctionName());
1294 return nullptr;
1295}
1296
1298 LLDB_INSTRUMENT_VA(this);
1299
1300 llvm::Expected<StoppedExecutionContext> exe_ctx =
1302 if (!exe_ctx) {
1303 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1304 return nullptr;
1305 }
1306
1307 if (StackFrame *frame = exe_ctx->GetFramePtr())
1308 return GetDebuggerStringPool(exe_ctx->GetTargetRef())
1309 .Intern(frame->GetDisplayFunctionName());
1310 return nullptr;
1311}
static llvm::raw_ostream & error(Stream &strm)
#define INTERRUPT_REQUESTED(debugger,...)
This handy define will keep you from having to generate a report for the interruption by hand.
Definition Debugger.h:532
#define LLDB_INSTRUMENT_VA(...)
#define LLDB_LOGF(log,...)
Definition Log.h:389
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:405
static std::pair< WasInterrupted, Status > FetchVariablesUnlessInterrupted(const lldb::SBVariablesOptions &options, StackFrame &frame, SBValueList &value_list, Debugger &dbg, std::function< SBValue(ValueObjectSP, bool)> to_sbvalue)
Populates value_list with the variables from frame according to options.
Definition SBFrame.cpp:805
static bool IsInRequestedScope(bool statics, bool arguments, bool locals, bool synthetic, Variable &var)
Returns true if the variable is in any of the requested scopes.
Definition SBFrame.cpp:760
static llvm::SmallVector< ValueObjectSP > FetchRecognizedArguments(const SBVariablesOptions &options, StackFrame &frame, SBTarget target)
Populates value_list with recognized arguments of frame according to options.
Definition SBFrame.cpp:864
WasInterrupted
Definition SBFrame.cpp:799
@ Yes
Definition SBFrame.cpp:799
@ No
Definition SBFrame.cpp:799
void SetFetchDynamicValue(lldb::DynamicValueType dynamic=lldb::eDynamicCanRunTarget)
void SetLanguage(lldb::LanguageType language)
lldb_private::EvaluateExpressionOptions & ref() const
void SetIgnoreBreakpoints(bool ignore=true)
void SetUnwindOnError(bool unwind=true)
lldb::DynamicValueType GetFetchDynamicValue() const
Class that represents a format string that can be used to generate descriptions of objects like frame...
Definition SBFormat.h:28
lldb::FormatEntrySP GetFormatEntrySP() const
Definition SBFormat.cpp:44
lldb::ExecutionContextRefSP m_opaque_sp
Definition SBFrame.h:250
lldb::addr_t GetPC() const
Definition SBFrame.cpp:282
const char * GetFunctionName()
Get the appropriate function name for this frame.
Definition SBFrame.cpp:1260
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:514
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const
Definition SBFrame.cpp:112
SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output)
Similar to GetDescription() but the format of the description can be configured via the format parame...
Definition SBFrame.cpp:977
bool IsValid() const
Definition SBFrame.cpp:96
lldb::SBValue FindRegister(const char *name)
Definition SBFrame.cpp:947
bool SetPC(lldb::addr_t new_pc)
Definition SBFrame.cpp:301
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:471
const char * GetDisplayFunctionName()
Definition SBFrame.cpp:1297
bool IsInlined()
Return true if this frame represents an inlined function.
Definition SBFrame.cpp:1185
bool operator==(const lldb::SBFrame &rhs) const
Definition SBFrame.cpp:649
lldb::addr_t GetCFA() const
Definition SBFrame.cpp:261
lldb::SBValue GetValueForVariablePathWithMode(const char *var_path, lldb::DILMode mode, DynamicValueType use_dynamic)
Like GetValueForVariablePath(), but using the DIL mode mode.
Definition SBFrame.cpp:442
lldb::addr_t GetFP() const
Definition SBFrame.cpp:336
const lldb::SBFrame & operator=(const lldb::SBFrame &rhs)
Definition SBFrame.cpp:80
static SBValue CreateProcessIsRunningExprEvalError()
Return an SBValue containing an error message that warns the process is not currently stopped.
Definition SBFrame.cpp:1099
lldb::SBLineEntry GetLineEntry() const
Definition SBFrame.cpp:228
friend class SBValue
Definition SBFrame.h:234
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:1022
lldb::SBCompileUnit GetCompileUnit() const
Definition SBFrame.cpp:152
uint32_t GetFrameID() const
Definition SBFrame.cpp:244
lldb::SBAddress GetPCAddress() const
Definition SBFrame.cpp:353
friend class SBThread
Definition SBFrame.h:233
lldb::SBFunction GetFunction() const
Definition SBFrame.cpp:168
lldb::SBBlock GetBlock() const
Gets the deepest block that contains the frame PC.
Definition SBFrame.cpp:198
friend class SBBlock
Definition SBFrame.h:229
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:694
bool IsSynthetic() const
Definition SBFrame.cpp:1228
bool IsEqual(const lldb::SBFrame &that) const
Definition SBFrame.cpp:641
const char * Disassemble() const
Definition SBFrame.cpp:677
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition SBFrame.cpp:92
lldb::SBValue GetValueForVariablePath(const char *var_path, DynamicValueType use_dynamic)
Create an SBValue from a simple expression, evaluated by the Data Inspection Language (DIL).
Definition SBFrame.cpp:393
lldb::SBThread GetThread() const
Definition SBFrame.cpp:661
lldb::SBValueList GetRegisters()
Definition SBFrame.cpp:921
bool IsArtificial()
Definition SBFrame.cpp:1206
lldb::LanguageType GuessLanguage() const
Definition SBFrame.cpp:1266
lldb::SBBlock GetFrameBlock() const
Gets the lexical block that defines the stack frame.
Definition SBFrame.cpp:213
lldb::addr_t GetSP() const
Definition SBFrame.cpp:319
lldb::StackFrameSP GetFrameSP() const
Definition SBFrame.cpp:88
bool IsHidden() const
Return whether a frame recognizer decided this frame should not be displayes in backtraces etc.
Definition SBFrame.cpp:1244
SBStructuredData GetLanguageSpecificData() const
Language plugins can use this API to report language-specific runtime information about this compile ...
Definition SBFrame.cpp:1166
lldb::SBSymbol GetSymbol() const
Definition SBFrame.cpp:183
lldb::SBModule GetModule() const
Definition SBFrame.cpp:131
bool GetDescription(lldb::SBStream &description)
Definition SBFrame.cpp:1003
bool operator!=(const lldb::SBFrame &rhs) const
Definition SBFrame.cpp:655
void SetSP(const ModuleSP &module_sp)
Definition SBModule.cpp:210
lldb_private::Stream & ref()
Definition SBStream.cpp:179
StructuredDataImplUP m_impl_up
void Append(const lldb::SBValue &val_obj)
void SetError(lldb_private::Status &&status)
void SetSP(const lldb::ValueObjectSP &sp)
Definition SBValue.cpp:1093
lldb::DynamicValueType GetUseDynamic() const
void SetUseDynamic(lldb::DynamicValueType)
bool GetIncludeRecognizedArguments(const lldb::SBTarget &) const
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:426
A uniqued constant string class.
Definition ConstString.h:40
A class to manage flag bits.
Definition Debugger.h:106
Execution context objects refer to objects in the execution of the program that is being debugged.
This base class provides an interface to stack frames.
Definition StackFrame.h:44
@ eExpressionPathOptionsAllowDirectIVarAccess
Definition StackFrame.h:56
virtual const char * GetFunctionName()
Get the frame's demangled name.
virtual bool IsHidden()
Query whether this frame should be hidden from backtraces.
virtual bool IsSynthetic() const
Query whether this frame is synthetic.
virtual bool IsInlined()
Query whether this frame is a concrete frame on the call stack, or if it is an inlined frame derived ...
virtual SourceLanguage GuessLanguage()
Similar to GetLanguage(), but is allowed to take a potentially incorrect guess if exact information i...
virtual lldb::RegisterContextSP GetRegisterContext()
Get the RegisterContext for this frame, if possible.
virtual StructuredData::ObjectSP GetLanguageSpecificData()
Language plugins can use this API to report language-specific runtime information about this compile ...
virtual SourceLanguage GetLanguage()
Query this frame to determine what the default language should be when parsing expressions given the ...
virtual lldb::ValueObjectSP GetValueObjectForFrameVariable(const lldb::VariableSP &variable_sp, lldb::DynamicValueType use_dynamic)
Create a ValueObject for a given Variable in this StackFrame.
virtual VariableList * GetVariableList(bool get_file_globals, bool include_synthetic_vars, Status *error_ptr)
Retrieve the list of variables whose scope either:
virtual const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
virtual const char * GetDisplayFunctionName()
Get the frame's demangled display name.
virtual bool IsArtificial() const
Query whether this frame is artificial (e.g a synthesized result of inferring missing tail call frame...
virtual void DumpUsingSettingsFormat(Stream *strm, bool show_unique=false, const llvm::StringRef frame_marker="")
Print a description for this frame using the frame-format formatter settings.
virtual bool DumpUsingFormat(Stream &strm, const lldb_private::FormatEntity::Entry *format, llvm::StringRef frame_marker={})
Print a description of this frame using the provided frame format.
virtual lldb::RecognizedStackFrameSP GetRecognizedFrame()
lldb::TargetSP CalculateTarget() override
An error handling class.
Definition Status.h:118
static Status FromErrorString(const char *str)
Definition Status.h:141
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
Definition Status.cpp:136
const char * GetData() const
A stream class that can stream formatted output to a file.
Definition Stream.h:28
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
Definition Stream.cpp:63
const char * Intern(llvm::StringRef str) const
Definition StringPool.h:78
std::shared_ptr< Object > ObjectSP
Defines a symbol context baton that can be handed other debug core functions.
Block * block
The Block for a given query.
lldb::ModuleSP module_sp
The Module for a given query.
bool GetDisplayRuntimeSupportValues() const
Definition Target.cpp:5981
SourceLanguage GetLanguage() const
Definition Target.cpp:5863
bool GetDisplayExpressionsInCrashlogs() const
Definition Target.cpp:5931
lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, AddressClass addr_class=AddressClass::eInvalid) const
Get load_addr as an opcode for this target.
Definition Target.cpp:3178
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition Target.cpp:3097
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:3029
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS, ValueObjectManager *manager=nullptr)
These routines create ValueObjectConstResult ValueObjects from various data sources.
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, uint32_t set_idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP &reg_ctx_sp, const RegisterInfo *reg_info)
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true) const
size_t AppendVariablesIfUnique(VariableList &var_list)
bool IsInScope(StackFrame *frame)
Definition Variable.cpp:286
lldb::ValueType GetScope() const
Definition Variable.h:69
#define LLDB_INVALID_ADDRESS
#define UINT32_MAX
A class that represents a running process on the host machine.
Log * GetLog(Cat mask)
Retrieve the Log object for the channel associated with the given log enum.
Definition Log.h:338
constexpr bool IsSyntheticValueType(lldb::ValueType vt)
Return true if vt represents a synthetic value, false if not.
Definition ValueType.h:27
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
Definition Utils.h:25
constexpr lldb::ValueType GetBaseValueType(lldb::ValueType vt)
Get the base value type - for when we don't care if the value is synthetic or not,...
Definition ValueType.h:17
StringPoolRef GetDebuggerStringPool(const Target &target)
Strings interned here live as long as target's debugger.
Definition Utils.h:21
llvm::Expected< StoppedExecutionContext > GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr)
class LLDB_API SBSymbol
Definition SBDefines.h:115
class LLDB_API SBLineEntry
Definition SBDefines.h:88
class LLDB_API SBFunction
Definition SBDefines.h:81
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
class LLDB_API SBValueList
Definition SBDefines.h:139
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
class LLDB_API SBModule
Definition SBDefines.h:92
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
class LLDB_API SBTarget
Definition SBDefines.h:118
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
std::shared_ptr< lldb_private::Variable > VariableSP
class LLDB_API SBAddress
Definition SBDefines.h:45
@ eValueTypeVariableGlobal
globals variable
@ eValueTypeConstResult
constant result variables
@ eValueTypeVariableLocal
function local variables
@ eValueTypeVariableArgument
function argument variables
@ eValueTypeRegister
stack frame register value
@ eValueTypeVariableStatic
static variable
@ eValueTypeRegisterSet
A collection of stack frame register values.
@ eValueTypeVariableThreadLocal
thread local storage variable
uint64_t addr_t
Definition lldb-types.h:80
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
class LLDB_API SBValue
Definition SBDefines.h:138
DILMode
Data Inspection Language (DIL) evaluation modes.
@ eDILModeFull
Allowed: everything supported by DIL.
std::shared_ptr< lldb_private::Module > ModuleSP
class LLDB_API SBCompileUnit
Definition SBDefines.h:64
Every register is described in detail including its name, alternate name (optional),...
Registers are grouped into register sets.
const char * name
Name of this register set.
const char * short_name
A short name for this register set.
A type-erased pair of llvm::dwarf::SourceLanguageName and version.
lldb::LanguageType AsLanguageType() const
Definition Language.cpp:619