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 return frame->GetStackID().GetCallFrameAddressWithoutMetadata();
274}
275
277 LLDB_INSTRUMENT_VA(this);
278
280 llvm::Expected<StoppedExecutionContext> exe_ctx =
282 if (!exe_ctx) {
283 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
284 return addr;
285 }
286
287 Target *target = exe_ctx->GetTargetPtr();
288 if (StackFrame *frame = exe_ctx->GetFramePtr())
289 return frame->GetFrameCodeAddress().GetOpcodeLoadAddress(
290 target, AddressClass::eCode);
291
292 return addr;
293}
294
295bool SBFrame::SetPC(addr_t new_pc) {
296 LLDB_INSTRUMENT_VA(this, new_pc);
297
298 constexpr bool error_ret_val = false;
299 llvm::Expected<StoppedExecutionContext> exe_ctx =
301 if (!exe_ctx) {
302 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
303 return error_ret_val;
304 }
305
306 if (StackFrame *frame = exe_ctx->GetFramePtr())
307 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext())
308 return reg_ctx_sp->SetPC(new_pc);
309
310 return error_ret_val;
311}
312
314 LLDB_INSTRUMENT_VA(this);
315
316 llvm::Expected<StoppedExecutionContext> exe_ctx =
318 if (!exe_ctx) {
319 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
321 }
322
323 if (StackFrame *frame = exe_ctx->GetFramePtr())
324 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext())
325 return reg_ctx_sp->GetSP();
326
328}
329
331 LLDB_INSTRUMENT_VA(this);
332
333 llvm::Expected<StoppedExecutionContext> exe_ctx =
335 if (!exe_ctx) {
336 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
338 }
339
340 if (StackFrame *frame = exe_ctx->GetFramePtr())
341 if (RegisterContextSP reg_ctx_sp = frame->GetRegisterContext())
342 return reg_ctx_sp->GetFP();
343
345}
346
348 LLDB_INSTRUMENT_VA(this);
349
350 llvm::Expected<StoppedExecutionContext> exe_ctx =
352 if (!exe_ctx) {
353 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
354 return SBAddress();
355 }
356
357 if (StackFrame *frame = exe_ctx->GetFramePtr())
358 return SBAddress(frame->GetFrameCodeAddress());
359 return SBAddress();
360}
361
363 LLDB_INSTRUMENT_VA(this);
364
365 m_opaque_sp->Clear();
366}
367
369 LLDB_INSTRUMENT_VA(this, var_path);
370
371 SBValue sb_value;
372 llvm::Expected<StoppedExecutionContext> exe_ctx =
374 if (!exe_ctx) {
375 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
376 return sb_value;
377 }
378
379 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
380 lldb::DynamicValueType use_dynamic =
381 frame->CalculateTarget()->GetPreferDynamicValue();
382 sb_value = GetValueForVariablePath(var_path, use_dynamic);
383 }
384 return sb_value;
385}
386
388 DynamicValueType use_dynamic) {
389 LLDB_INSTRUMENT_VA(this, var_path, use_dynamic);
390
391 SBValue sb_value;
392 if (var_path == nullptr || var_path[0] == '\0') {
393 return sb_value;
394 }
395
396 llvm::Expected<StoppedExecutionContext> exe_ctx =
398 if (!exe_ctx) {
399 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
400 return sb_value;
401 }
402
403 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
404 VariableSP var_sp;
406 ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
407 var_path, eNoDynamicValues,
410 var_sp, error, lldb::eDILModeFull));
411 sb_value.SetSP(value_sp, use_dynamic);
412 }
413 return sb_value;
414}
415
417 lldb::DILMode mode) {
418 LLDB_INSTRUMENT_VA(this, var_path, mode);
419
420 SBValue sb_value;
421 llvm::Expected<StoppedExecutionContext> exe_ctx =
423 if (!exe_ctx) {
424 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
425 return sb_value;
426 }
427
428 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
429 lldb::DynamicValueType use_dynamic =
430 frame->CalculateTarget()->GetPreferDynamicValue();
431 sb_value = GetValueForVariablePathWithMode(var_path, mode, use_dynamic);
432 }
433 return sb_value;
434}
435
437 const char *var_path, lldb::DILMode mode, DynamicValueType use_dynamic) {
438 LLDB_INSTRUMENT_VA(this, var_path, mode, use_dynamic);
439
440 SBValue sb_value;
441 if (var_path == nullptr || var_path[0] == '\0') {
442 return sb_value;
443 }
444
445 llvm::Expected<StoppedExecutionContext> exe_ctx =
447 if (!exe_ctx) {
448 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
449 return sb_value;
450 }
451
452 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
453 VariableSP var_sp;
455 ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
456 var_path, eNoDynamicValues,
459 var_sp, error, mode));
460 sb_value.SetSP(value_sp, use_dynamic);
461 }
462 return sb_value;
463}
464
466 LLDB_INSTRUMENT_VA(this, name);
467
468 llvm::Expected<StoppedExecutionContext> exe_ctx =
470 if (!exe_ctx) {
471 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
472 return SBValue();
473 }
474
475 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
476 lldb::DynamicValueType use_dynamic =
477 frame->CalculateTarget()->GetPreferDynamicValue();
478 return FindVariable(name, use_dynamic);
479 }
480 return SBValue();
481}
482
484 lldb::DynamicValueType use_dynamic) {
485 LLDB_INSTRUMENT_VA(this, name, use_dynamic);
486
487 VariableSP var_sp;
488 SBValue sb_value;
489
490 if (name == nullptr || name[0] == '\0') {
491 return sb_value;
492 }
493
494 llvm::Expected<StoppedExecutionContext> exe_ctx =
496 if (!exe_ctx) {
497 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
498 return sb_value;
499 }
500
501 if (StackFrame *frame = exe_ctx->GetFramePtr())
502 if (ValueObjectSP value_sp = frame->FindVariable(ConstString(name)))
503 sb_value.SetSP(value_sp, use_dynamic);
504
505 return sb_value;
506}
507
508SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
509 LLDB_INSTRUMENT_VA(this, name, value_type);
510
511 SBValue value;
512 llvm::Expected<StoppedExecutionContext> exe_ctx =
514 if (!exe_ctx) {
515 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
516 return value;
517 }
518
519 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
520 lldb::DynamicValueType use_dynamic =
521 frame->CalculateTarget()->GetPreferDynamicValue();
522 value = FindValue(name, value_type, use_dynamic);
523 }
524 return value;
525}
526
527SBValue SBFrame::FindValue(const char *name, ValueType value_type,
528 lldb::DynamicValueType use_dynamic) {
529 LLDB_INSTRUMENT_VA(this, name, value_type, use_dynamic);
530
531 SBValue sb_value;
532
533 if (name == nullptr || name[0] == '\0') {
534 return sb_value;
535 }
536
537 ValueObjectSP value_sp;
538 llvm::Expected<StoppedExecutionContext> exe_ctx =
540
541 if (!exe_ctx) {
542 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
543 return value_sp;
544 }
545
546 StackFrame *frame = exe_ctx->GetFramePtr();
547 if (!frame)
548 return value_sp;
549
550 VariableList variable_list;
551
552 bool include_synthetic_vars = IsSyntheticValueType(value_type);
553 // Switch on the value_type without the mask, but keep it in the value type so
554 // we can use it later when we look for variables in the list.
555 auto base_value_type = GetBaseValueType(value_type);
556 switch (base_value_type) {
557 case eValueTypeVariableGlobal: // global variable
558 case eValueTypeVariableStatic: // static variable
559 case eValueTypeVariableArgument: // function argument variables
560 case eValueTypeVariableLocal: // function local variables
561 case eValueTypeVariableThreadLocal: { // thread local variables
562 SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
563
564 const bool can_create = true;
565 const bool get_parent_variables = true;
566 const bool stop_if_block_is_inlined_function = true;
567
568 if (sc.block)
570 can_create, get_parent_variables, stop_if_block_is_inlined_function,
571 [frame](Variable *v) { return v->IsInScope(frame); }, &variable_list);
572 // Fetch variables from the frame if we need to get
573 // globals/statics/synthetic variables.
574 if (base_value_type == eValueTypeVariableGlobal ||
575 base_value_type == eValueTypeVariableStatic || include_synthetic_vars) {
576 const bool get_file_globals = true;
577 VariableList *frame_vars = frame->GetVariableList(
578 get_file_globals, include_synthetic_vars, nullptr);
579 if (frame_vars)
580 frame_vars->AppendVariablesIfUnique(variable_list);
581 }
582
583 ConstString const_name(name);
584 VariableSP variable_sp(variable_list.FindVariable(const_name, value_type));
585 if (variable_sp) {
586 value_sp =
588 sb_value.SetSP(value_sp, use_dynamic);
589 }
590 } break;
591
592 case eValueTypeRegister: { // stack frame register value
593 if (RegisterContextSP reg_ctx = frame->GetRegisterContext()) {
594 if (const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name)) {
595 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
596 sb_value.SetSP(value_sp);
597 }
598 }
599 } break;
600
601 case eValueTypeRegisterSet: { // A collection of stack frame register
602 // values
603 if (RegisterContextSP reg_ctx = frame->GetRegisterContext()) {
604 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
605 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
606 const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
607 if (reg_set &&
608 (llvm::StringRef(reg_set->name).equals_insensitive(name) ||
609 llvm::StringRef(reg_set->short_name).equals_insensitive(name))) {
610 value_sp = ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
611 sb_value.SetSP(value_sp);
612 break;
613 }
614 }
615 }
616 } break;
617
618 case eValueTypeConstResult: { // constant result variables
619 ConstString const_name(name);
620 Target *target = exe_ctx->GetTargetPtr();
621 ExpressionVariableSP expr_var_sp(target->GetPersistentVariable(const_name));
622 if (expr_var_sp) {
623 value_sp = expr_var_sp->GetValueObject();
624 sb_value.SetSP(value_sp, use_dynamic);
625 }
626 } break;
627
628 default:
629 break;
630 }
631
632 return sb_value;
633}
634
635bool SBFrame::IsEqual(const SBFrame &that) const {
636 LLDB_INSTRUMENT_VA(this, that);
637
638 lldb::StackFrameSP this_sp = GetFrameSP();
639 lldb::StackFrameSP that_sp = that.GetFrameSP();
640 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
641}
642
643bool SBFrame::operator==(const SBFrame &rhs) const {
644 LLDB_INSTRUMENT_VA(this, rhs);
645
646 return IsEqual(rhs);
647}
648
649bool SBFrame::operator!=(const SBFrame &rhs) const {
650 LLDB_INSTRUMENT_VA(this, rhs);
651
652 return !IsEqual(rhs);
653}
654
656 LLDB_INSTRUMENT_VA(this);
657
658 llvm::Expected<StoppedExecutionContext> exe_ctx =
660 if (!exe_ctx) {
661 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
662 return SBThread();
663 }
664
665 ThreadSP thread_sp(exe_ctx->GetThreadSP());
666 SBThread sb_thread(thread_sp);
667
668 return sb_thread;
669}
670
671const char *SBFrame::Disassemble() const {
672 LLDB_INSTRUMENT_VA(this);
673
674 llvm::Expected<StoppedExecutionContext> exe_ctx =
676 if (!exe_ctx) {
677 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
678 return nullptr;
679 }
680
681 if (auto *frame = exe_ctx->GetFramePtr())
682 return ConstString(frame->Disassemble()).GetCString();
683
684 return nullptr;
685}
686
687SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
688 bool in_scope_only) {
689 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only);
690
691 SBValueList value_list;
692 llvm::Expected<StoppedExecutionContext> exe_ctx =
694 if (!exe_ctx) {
695 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
696 return value_list;
697 }
698
699 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
700 Target *target = exe_ctx->GetTargetPtr();
701 lldb::DynamicValueType use_dynamic =
702 frame->CalculateTarget()->GetPreferDynamicValue();
703 const bool include_runtime_support_values =
705
706 SBVariablesOptions options;
707 options.SetIncludeArguments(arguments);
708 options.SetIncludeLocals(locals);
709 options.SetIncludeStatics(statics);
710 options.SetInScopeOnly(in_scope_only);
711 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
712 options.SetUseDynamic(use_dynamic);
713
714 // Assume that if we have any synthetic variables, they should be included.
715 options.SetIncludeSynthetic(true);
716
717 value_list = GetVariables(options);
718 }
719 return value_list;
720}
721
722lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
723 bool statics, bool in_scope_only,
724 lldb::DynamicValueType use_dynamic) {
725 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only,
726 use_dynamic);
727
728 llvm::Expected<StoppedExecutionContext> exe_ctx =
730 if (!exe_ctx) {
731 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
732 return SBValueList();
733 }
734
735 Target *target = exe_ctx->GetTargetPtr();
736 const bool include_runtime_support_values =
738 SBVariablesOptions options;
739 options.SetIncludeArguments(arguments);
740 options.SetIncludeLocals(locals);
741 options.SetIncludeStatics(statics);
742 options.SetInScopeOnly(in_scope_only);
743 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
744 options.SetUseDynamic(use_dynamic);
745
746 // Assume that if we have any synthetic variables, they should be included.
747 options.SetIncludeSynthetic(true);
748
749 return GetVariables(options);
750}
751
752/// Returns true if the variable is in any of the requested scopes.
753static bool IsInRequestedScope(bool statics, bool arguments, bool locals,
754 bool synthetic, Variable &var) {
755 auto value_type = var.GetScope();
756 // Check if the variable is synthetic first.
757 bool is_synthetic = IsSyntheticValueType(value_type);
758 if (is_synthetic) {
759 // If the variable is synthetic but we don't want those, then it's
760 // automatically out of scope.
761 if (!synthetic)
762 return false;
763
764 // Get the base value type so the rest of the switch works correctly.
765 value_type = GetBaseValueType(value_type);
766 }
767
768 switch (value_type) {
772 return statics;
773
775 return arguments;
776
778 return locals;
779
780 default:
781 break;
782 }
783
784 // The default for all other value types is is_synthetic. At this point, if
785 // we didn't want synthetic variables we'd have exited by now anyway, so we
786 // must want them. Aside from the modifiers above that should apply equally to
787 // synthetic and normal variables, any other synthetic variable we should
788 // default to showing.
789 return is_synthetic;
790}
791
793
794/// Populates `value_list` with the variables from `frame` according to
795/// `options`. This method checks whether the Debugger received an interrupt
796/// before processing every variable, returning `WasInterrupted::yes` in that
797/// case.
798static std::pair<WasInterrupted, Status> FetchVariablesUnlessInterrupted(
799 const lldb::SBVariablesOptions &options, StackFrame &frame,
800 SBValueList &value_list, Debugger &dbg,
801 std::function<SBValue(ValueObjectSP, bool)> to_sbvalue) {
802 const bool statics = options.GetIncludeStatics();
803 const bool arguments = options.GetIncludeArguments();
804 const bool locals = options.GetIncludeLocals();
805 const bool synthetic = options.GetIncludeSynthetic();
806 const bool in_scope_only = options.GetInScopeOnly();
807 const bool include_runtime_support_values =
809 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
810
811 Status var_error;
812 // Fetch all variables available and filter them later.
813 VariableList *variable_list = frame.GetVariableList(
814 /*get_file_globals=*/true, /*include_synthetic_vars=*/true, &var_error);
815
816 std::set<VariableSP> variable_set;
817
818 if (!variable_list)
819 return {WasInterrupted::No, std::move(var_error)};
820 const size_t num_variables = variable_list->GetSize();
821 size_t num_produced = 0;
822 for (const VariableSP &variable_sp : *variable_list) {
823 if (!variable_sp || !IsInRequestedScope(statics, arguments, locals,
824 synthetic, *variable_sp))
825 continue;
826
828 dbg,
829 "Interrupted getting frame variables with {0} of {1} "
830 "produced.",
831 num_produced, num_variables))
832 return {WasInterrupted::Yes, std::move(var_error)};
833
834 // Only add variables once so we don't end up with duplicates
835 if (variable_set.insert(variable_sp).second == false)
836 continue;
837 if (in_scope_only && !variable_sp->IsInScope(&frame))
838 continue;
839
840 ValueObjectSP valobj_sp(
842
843 if (!include_runtime_support_values && valobj_sp != nullptr &&
844 valobj_sp->IsRuntimeSupportValue())
845 continue;
846
847 value_list.Append(to_sbvalue(valobj_sp, use_dynamic));
848 }
849 num_produced++;
850
851 return {WasInterrupted::No, std::move(var_error)};
852}
853
854/// Populates `value_list` with recognized arguments of `frame` according to
855/// `options`.
856static llvm::SmallVector<ValueObjectSP>
858 SBTarget target) {
859 if (!options.GetIncludeRecognizedArguments(target))
860 return {};
861 RecognizedStackFrameSP recognized_frame = frame.GetRecognizedFrame();
862 if (!recognized_frame)
863 return {};
864
865 ValueObjectListSP recognized_arg_list =
866 recognized_frame->GetRecognizedArguments();
867 if (!recognized_arg_list)
868 return {};
869
870 return llvm::to_vector(recognized_arg_list->GetObjects());
871}
872
874 LLDB_INSTRUMENT_VA(this, options);
875
876 llvm::Expected<StoppedExecutionContext> exe_ctx =
878 if (!exe_ctx) {
879 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
880 return SBValueList();
881 }
882
883 StackFrame *frame = exe_ctx->GetFramePtr();
884 if (!frame)
885 return SBValueList();
886
887 auto valobj_to_sbvalue = [](ValueObjectSP valobj, bool use_dynamic) {
888 SBValue value_sb;
889 value_sb.SetSP(valobj, use_dynamic);
890 return value_sb;
891 };
892 SBValueList value_list;
893 std::pair<WasInterrupted, Status> fetch_result =
894 FetchVariablesUnlessInterrupted(options, *frame, value_list,
895 exe_ctx->GetTargetPtr()->GetDebugger(),
896 valobj_to_sbvalue);
897 if (fetch_result.second.Fail())
898 value_list.SetError(std::move(fetch_result.second));
899
900 if (fetch_result.first == WasInterrupted::Yes)
901 return value_list;
902
903 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
904 llvm::SmallVector<ValueObjectSP> args = FetchRecognizedArguments(
905 options, *frame, SBTarget(exe_ctx->GetTargetSP()));
906 for (ValueObjectSP arg : args) {
907 SBValue value_sb;
908 value_sb.SetSP(arg, use_dynamic);
909 value_list.Append(value_sb);
910 }
911 return value_list;
912}
913
915 LLDB_INSTRUMENT_VA(this);
916
917 llvm::Expected<StoppedExecutionContext> exe_ctx =
919 if (!exe_ctx) {
920 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
921 return SBValueList();
922 }
923
924 StackFrame *frame = exe_ctx->GetFramePtr();
925 if (!frame)
926 return SBValueList();
927
928 RegisterContextSP reg_ctx(frame->GetRegisterContext());
929 if (!reg_ctx)
930 return SBValueList();
931
932 SBValueList value_list;
933 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
934 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
935 value_list.Append(ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
936
937 return value_list;
938}
939
941 LLDB_INSTRUMENT_VA(this, name);
942
943 ValueObjectSP value_sp;
944 llvm::Expected<StoppedExecutionContext> exe_ctx =
946 if (!exe_ctx) {
947 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
948 return SBValue();
949 }
950
951 StackFrame *frame = exe_ctx->GetFramePtr();
952 if (!frame)
953 return SBValue();
954
955 RegisterContextSP reg_ctx(frame->GetRegisterContext());
956 if (!reg_ctx)
957 return SBValue();
958
959 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
960 if (!reg_info)
961 return SBValue();
962
963 SBValue result;
964 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
965 result.SetSP(value_sp);
966
967 return result;
968}
969
971 SBStream &output) {
972 Stream &strm = output.ref();
973
974 llvm::Expected<StoppedExecutionContext> exe_ctx =
976 if (!exe_ctx)
977 return Status::FromError(exe_ctx.takeError());
978
980
981 if (!format) {
982 error.SetErrorString("The provided SBFormat object is invalid");
983 return error;
984 }
985
986 if (StackFrame *frame = exe_ctx->GetFramePtr();
987 frame && frame->DumpUsingFormat(strm, format.GetFormatEntrySP().get()))
988 return error;
989 error.SetErrorStringWithFormat(
990 "It was not possible to generate a frame "
991 "description with the given format string '%s'",
992 format.GetFormatEntrySP()->string.c_str());
993 return error;
994}
995
997 LLDB_INSTRUMENT_VA(this, description);
998
999 Stream &strm = description.ref();
1000
1001 llvm::Expected<StoppedExecutionContext> exe_ctx =
1003 if (!exe_ctx) {
1004 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1005 strm.PutCString("Error: process is not stopped.");
1006 return true;
1007 }
1008
1009 if (StackFrame *frame = exe_ctx->GetFramePtr())
1010 frame->DumpUsingSettingsFormat(&strm);
1011
1012 return true;
1013}
1014
1016 LLDB_INSTRUMENT_VA(this, expr);
1017
1018 llvm::Expected<StoppedExecutionContext> exe_ctx =
1020 if (!exe_ctx) {
1021 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1023 }
1024
1025 SBExpressionOptions options;
1026 StackFrame *frame = exe_ctx->GetFramePtr();
1027 if (frame) {
1028 lldb::DynamicValueType fetch_dynamic_value =
1029 frame->CalculateTarget()->GetPreferDynamicValue();
1030 options.SetFetchDynamicValue(fetch_dynamic_value);
1031 }
1032 options.SetUnwindOnError(true);
1033 options.SetIgnoreBreakpoints(true);
1034 Target *target = exe_ctx->GetTargetPtr();
1035 SourceLanguage language = target->GetLanguage();
1036 if (!language && frame)
1037 language = frame->GetLanguage();
1038 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1039 return EvaluateExpression(expr, options);
1040}
1041
1042SBValue
1044 lldb::DynamicValueType fetch_dynamic_value) {
1045 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value);
1046
1047 SBExpressionOptions options;
1048 options.SetFetchDynamicValue(fetch_dynamic_value);
1049 options.SetUnwindOnError(true);
1050 options.SetIgnoreBreakpoints(true);
1051 llvm::Expected<StoppedExecutionContext> exe_ctx =
1053 if (!exe_ctx) {
1054 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1056 }
1057
1058 StackFrame *frame = exe_ctx->GetFramePtr();
1059 Target *target = exe_ctx->GetTargetPtr();
1060 SourceLanguage language = target->GetLanguage();
1061 if (!language && frame)
1062 language = frame->GetLanguage();
1063 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1064 return EvaluateExpression(expr, options);
1065}
1066
1068 lldb::DynamicValueType fetch_dynamic_value,
1069 bool unwind_on_error) {
1070 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value, unwind_on_error);
1071
1072 SBExpressionOptions options;
1073 llvm::Expected<StoppedExecutionContext> exe_ctx =
1075 if (!exe_ctx) {
1076 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1078 }
1079
1080 options.SetFetchDynamicValue(fetch_dynamic_value);
1081 options.SetUnwindOnError(unwind_on_error);
1082 options.SetIgnoreBreakpoints(true);
1083 StackFrame *frame = exe_ctx->GetFramePtr();
1084 Target *target = exe_ctx->GetTargetPtr();
1085 SourceLanguage language = target->GetLanguage();
1086 if (!language && frame)
1087 language = frame->GetLanguage();
1088 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1089 return EvaluateExpression(expr, options);
1090}
1091
1093 auto error = Status::FromErrorString("can't evaluate expressions when the "
1094 "process is running.");
1095 ValueObjectSP expr_value_sp =
1096 ValueObjectConstResult::Create(nullptr, std::move(error));
1097 SBValue expr_result;
1098 expr_result.SetSP(expr_value_sp, false);
1099 return expr_result;
1100}
1101
1103 const SBExpressionOptions &options) {
1104 LLDB_INSTRUMENT_VA(this, expr, options);
1105
1106 auto LogResult = [](SBValue expr_result) {
1107 Log *expr_log = GetLog(LLDBLog::Expressions);
1108 if (expr_result.GetError().Success())
1109 LLDB_LOGF(expr_log,
1110 "** [SBFrame::EvaluateExpression] Expression result is "
1111 "%s, summary %s **",
1112 expr_result.GetValue(), expr_result.GetSummary());
1113 else
1114 LLDB_LOGF(
1115 expr_log,
1116 "** [SBFrame::EvaluateExpression] Expression evaluation failed: "
1117 "%s **",
1118 expr_result.GetError().GetCString());
1119 };
1120
1121 if (expr == nullptr || expr[0] == '\0') {
1122 return SBValue();
1123 }
1124
1125 llvm::Expected<StoppedExecutionContext> exe_ctx =
1127 if (!exe_ctx) {
1128 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1130 LogResult(error_result);
1131 return error_result;
1132 }
1133
1134 StackFrame *frame = exe_ctx->GetFramePtr();
1135 if (!frame)
1136 return SBValue();
1137
1138 std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1139 Target *target = exe_ctx->GetTargetPtr();
1140 if (target->GetDisplayExpressionsInCrashlogs()) {
1141 StreamString frame_description;
1142 frame->DumpUsingSettingsFormat(&frame_description);
1143 stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1144 "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1145 "= %u) %s",
1146 expr, options.GetFetchDynamicValue(), frame_description.GetData());
1147 }
1148
1149 ValueObjectSP expr_value_sp;
1150 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
1151
1152 SBValue expr_result;
1153 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
1154 LogResult(expr_result);
1155
1156 return expr_result;
1157}
1158
1160 LLDB_INSTRUMENT_VA(this);
1161
1162 SBStructuredData sb_data;
1163 llvm::Expected<StoppedExecutionContext> exe_ctx =
1165 if (!exe_ctx) {
1166 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1167 return sb_data;
1168 }
1169 StackFrame *frame = exe_ctx->GetFramePtr();
1170 if (!frame)
1171 return sb_data;
1172
1174 sb_data.m_impl_up->SetObjectSP(data);
1175 return sb_data;
1176}
1177
1179 LLDB_INSTRUMENT_VA(this);
1180
1181 return static_cast<const SBFrame *>(this)->IsInlined();
1182}
1183
1185 LLDB_INSTRUMENT_VA(this);
1186
1187 llvm::Expected<StoppedExecutionContext> exe_ctx =
1189 if (!exe_ctx) {
1190 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1191 return false;
1192 }
1193
1194 if (StackFrame *frame = exe_ctx->GetFramePtr())
1195 return frame->IsInlined();
1196 return false;
1197}
1198
1200 LLDB_INSTRUMENT_VA(this);
1201
1202 return static_cast<const SBFrame *>(this)->IsArtificial();
1203}
1204
1206 LLDB_INSTRUMENT_VA(this);
1207
1208 llvm::Expected<StoppedExecutionContext> exe_ctx =
1210 if (!exe_ctx) {
1211 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1212 return false;
1213 }
1214
1215 if (StackFrame *frame = exe_ctx->GetFramePtr())
1216 return frame->IsArtificial();
1217
1218 return false;
1219}
1220
1222 LLDB_INSTRUMENT_VA(this);
1223
1224 llvm::Expected<StoppedExecutionContext> exe_ctx =
1226 if (!exe_ctx) {
1227 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1228 return false;
1229 }
1230
1231 if (StackFrame *frame = exe_ctx->GetFramePtr())
1232 return frame->IsSynthetic();
1233
1234 return false;
1235}
1236
1237bool SBFrame::IsHidden() const {
1238 LLDB_INSTRUMENT_VA(this);
1239
1240 llvm::Expected<StoppedExecutionContext> exe_ctx =
1242 if (!exe_ctx) {
1243 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1244 return false;
1245 }
1246
1247 if (StackFrame *frame = exe_ctx->GetFramePtr())
1248 return frame->IsHidden();
1249
1250 return false;
1251}
1252
1254 LLDB_INSTRUMENT_VA(this);
1255
1256 return static_cast<const SBFrame *>(this)->GetFunctionName();
1257}
1258
1260 LLDB_INSTRUMENT_VA(this);
1261
1262 llvm::Expected<StoppedExecutionContext> exe_ctx =
1264 if (!exe_ctx) {
1265 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1266 return eLanguageTypeUnknown;
1267 }
1268
1269 if (StackFrame *frame = exe_ctx->GetFramePtr())
1270 return frame->GuessLanguage().AsLanguageType();
1271 return eLanguageTypeUnknown;
1272}
1273
1274const char *SBFrame::GetFunctionName() const {
1275 LLDB_INSTRUMENT_VA(this);
1276
1277 llvm::Expected<StoppedExecutionContext> exe_ctx =
1279 if (!exe_ctx) {
1280 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1281 return nullptr;
1282 }
1283
1284 if (StackFrame *frame = exe_ctx->GetFramePtr())
1285 return frame->GetFunctionName();
1286 return nullptr;
1287}
1288
1290 LLDB_INSTRUMENT_VA(this);
1291
1292 llvm::Expected<StoppedExecutionContext> exe_ctx =
1294 if (!exe_ctx) {
1295 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1296 return nullptr;
1297 }
1298
1299 if (StackFrame *frame = exe_ctx->GetFramePtr())
1300 return frame->GetDisplayFunctionName();
1301 return nullptr;
1302}
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:502
#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:798
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:753
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:857
WasInterrupted
Definition SBFrame.cpp:792
@ Yes
Definition SBFrame.cpp:792
@ No
Definition SBFrame.cpp:792
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:251
lldb::addr_t GetPC() const
Definition SBFrame.cpp:276
const char * GetFunctionName()
Get the appropriate function name for this frame.
Definition SBFrame.cpp:1253
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:508
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:970
bool IsValid() const
Definition SBFrame.cpp:96
lldb::SBValue FindRegister(const char *name)
Definition SBFrame.cpp:940
bool SetPC(lldb::addr_t new_pc)
Definition SBFrame.cpp:295
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:465
const char * GetDisplayFunctionName()
Definition SBFrame.cpp:1289
bool IsInlined()
Return true if this frame represents an inlined function.
Definition SBFrame.cpp:1178
bool operator==(const lldb::SBFrame &rhs) const
Definition SBFrame.cpp:643
lldb::addr_t GetCFA() const
Definition SBFrame.cpp:261
lldb::SBValue GetValueForVariablePathWithMode(const char *var_path, lldb::DILMode mode, DynamicValueType use_dynamic)
Definition SBFrame.cpp:436
lldb::addr_t GetFP() const
Definition SBFrame.cpp:330
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:1092
lldb::SBLineEntry GetLineEntry() const
Definition SBFrame.cpp:228
friend class SBValue
Definition SBFrame.h:235
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:1015
lldb::SBCompileUnit GetCompileUnit() const
Definition SBFrame.cpp:152
uint32_t GetFrameID() const
Definition SBFrame.cpp:244
lldb::SBAddress GetPCAddress() const
Definition SBFrame.cpp:347
friend class SBThread
Definition SBFrame.h:234
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:230
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:687
bool IsSynthetic() const
Definition SBFrame.cpp:1221
bool IsEqual(const lldb::SBFrame &that) const
Definition SBFrame.cpp:635
const char * Disassemble() const
Definition SBFrame.cpp:671
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition SBFrame.cpp:92
lldb::SBValue GetValueForVariablePath(const char *var_path, DynamicValueType use_dynamic)
Definition SBFrame.cpp:387
lldb::SBThread GetThread() const
Definition SBFrame.cpp:655
lldb::SBValueList GetRegisters()
Definition SBFrame.cpp:914
bool IsArtificial()
Definition SBFrame.cpp:1199
lldb::LanguageType GuessLanguage() const
Definition SBFrame.cpp:1259
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:313
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:1237
SBStructuredData GetLanguageSpecificData() const
Language plugins can use this API to report language-specific runtime information about this compile ...
Definition SBFrame.cpp:1159
lldb::SBSymbol GetSymbol() const
Definition SBFrame.cpp:183
lldb::SBModule GetModule() const
Definition SBFrame.cpp:131
bool GetDescription(lldb::SBStream &description)
Definition SBFrame.cpp:996
bool operator!=(const lldb::SBFrame &rhs) const
Definition SBFrame.cpp:649
void SetSP(const ModuleSP &module_sp)
Definition SBModule.cpp:218
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:1027
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
const char * GetCString() const
Get the string value as a C string.
A class to manage flag bits.
Definition Debugger.h:100
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
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:5784
SourceLanguage GetLanguage() const
Definition Target.cpp:5673
bool GetDisplayExpressionsInCrashlogs() const
Definition Target.cpp:5734
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:3110
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition Target.cpp:3029
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:2951
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:289
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:17
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
llvm::Expected< StoppedExecutionContext > GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr)
class LLDB_API SBSymbol
Definition SBDefines.h:114
class LLDB_API SBLineEntry
Definition SBDefines.h:87
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:138
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:91
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
class LLDB_API SBTarget
Definition SBDefines.h:117
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:137
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:628