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::DILMode mode) {
370 LLDB_INSTRUMENT_VA(this, var_path);
371
372 SBValue sb_value;
373 llvm::Expected<StoppedExecutionContext> exe_ctx =
375 if (!exe_ctx) {
376 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
377 return sb_value;
378 }
379
380 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
381 lldb::DynamicValueType use_dynamic =
382 frame->CalculateTarget()->GetPreferDynamicValue();
383 sb_value = GetValueForVariablePath(var_path, use_dynamic, mode);
384 }
385 return sb_value;
386}
387
389 DynamicValueType use_dynamic,
390 lldb::DILMode mode) {
391 LLDB_INSTRUMENT_VA(this, var_path, use_dynamic);
392
393 SBValue sb_value;
394 if (var_path == nullptr || var_path[0] == '\0') {
395 return sb_value;
396 }
397
398 llvm::Expected<StoppedExecutionContext> exe_ctx =
400 if (!exe_ctx) {
401 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
402 return sb_value;
403 }
404
405 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
406 VariableSP var_sp;
408 ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
409 var_path, eNoDynamicValues,
412 var_sp, error, mode));
413 sb_value.SetSP(value_sp, use_dynamic);
414 }
415 return sb_value;
416}
417
419 LLDB_INSTRUMENT_VA(this, name);
420
421 llvm::Expected<StoppedExecutionContext> exe_ctx =
423 if (!exe_ctx) {
424 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
425 return SBValue();
426 }
427
428 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
429 lldb::DynamicValueType use_dynamic =
430 frame->CalculateTarget()->GetPreferDynamicValue();
431 return FindVariable(name, use_dynamic);
432 }
433 return SBValue();
434}
435
437 lldb::DynamicValueType use_dynamic) {
438 LLDB_INSTRUMENT_VA(this, name, use_dynamic);
439
440 VariableSP var_sp;
441 SBValue sb_value;
442
443 if (name == nullptr || name[0] == '\0') {
444 return sb_value;
445 }
446
447 llvm::Expected<StoppedExecutionContext> exe_ctx =
449 if (!exe_ctx) {
450 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
451 return sb_value;
452 }
453
454 if (StackFrame *frame = exe_ctx->GetFramePtr())
455 if (ValueObjectSP value_sp = frame->FindVariable(ConstString(name)))
456 sb_value.SetSP(value_sp, use_dynamic);
457
458 return sb_value;
459}
460
461SBValue SBFrame::FindValue(const char *name, ValueType value_type) {
462 LLDB_INSTRUMENT_VA(this, name, value_type);
463
464 SBValue value;
465 llvm::Expected<StoppedExecutionContext> exe_ctx =
467 if (!exe_ctx) {
468 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
469 return value;
470 }
471
472 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
473 lldb::DynamicValueType use_dynamic =
474 frame->CalculateTarget()->GetPreferDynamicValue();
475 value = FindValue(name, value_type, use_dynamic);
476 }
477 return value;
478}
479
480SBValue SBFrame::FindValue(const char *name, ValueType value_type,
481 lldb::DynamicValueType use_dynamic) {
482 LLDB_INSTRUMENT_VA(this, name, value_type, use_dynamic);
483
484 SBValue sb_value;
485
486 if (name == nullptr || name[0] == '\0') {
487 return sb_value;
488 }
489
490 ValueObjectSP value_sp;
491 llvm::Expected<StoppedExecutionContext> exe_ctx =
493
494 if (!exe_ctx) {
495 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
496 return value_sp;
497 }
498
499 StackFrame *frame = exe_ctx->GetFramePtr();
500 if (!frame)
501 return value_sp;
502
503 VariableList variable_list;
504
505 bool include_synthetic_vars = IsSyntheticValueType(value_type);
506 // Switch on the value_type without the mask, but keep it in the value type so
507 // we can use it later when we look for variables in the list.
508 auto base_value_type = GetBaseValueType(value_type);
509 switch (base_value_type) {
510 case eValueTypeVariableGlobal: // global variable
511 case eValueTypeVariableStatic: // static variable
512 case eValueTypeVariableArgument: // function argument variables
513 case eValueTypeVariableLocal: // function local variables
514 case eValueTypeVariableThreadLocal: { // thread local variables
515 SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
516
517 const bool can_create = true;
518 const bool get_parent_variables = true;
519 const bool stop_if_block_is_inlined_function = true;
520
521 if (sc.block)
523 can_create, get_parent_variables, stop_if_block_is_inlined_function,
524 [frame](Variable *v) { return v->IsInScope(frame); }, &variable_list);
525 // Fetch variables from the frame if we need to get
526 // globals/statics/synthetic variables.
527 if (base_value_type == eValueTypeVariableGlobal ||
528 base_value_type == eValueTypeVariableStatic || include_synthetic_vars) {
529 const bool get_file_globals = true;
530 VariableList *frame_vars = frame->GetVariableList(
531 get_file_globals, include_synthetic_vars, nullptr);
532 if (frame_vars)
533 frame_vars->AppendVariablesIfUnique(variable_list);
534 }
535
536 ConstString const_name(name);
537 VariableSP variable_sp(variable_list.FindVariable(const_name, value_type));
538 if (variable_sp) {
539 value_sp =
541 sb_value.SetSP(value_sp, use_dynamic);
542 }
543 } break;
544
545 case eValueTypeRegister: { // stack frame register value
546 if (RegisterContextSP reg_ctx = frame->GetRegisterContext()) {
547 if (const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name)) {
548 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
549 sb_value.SetSP(value_sp);
550 }
551 }
552 } break;
553
554 case eValueTypeRegisterSet: { // A collection of stack frame register
555 // values
556 if (RegisterContextSP reg_ctx = frame->GetRegisterContext()) {
557 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
558 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
559 const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
560 if (reg_set &&
561 (llvm::StringRef(reg_set->name).equals_insensitive(name) ||
562 llvm::StringRef(reg_set->short_name).equals_insensitive(name))) {
563 value_sp = ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx);
564 sb_value.SetSP(value_sp);
565 break;
566 }
567 }
568 }
569 } break;
570
571 case eValueTypeConstResult: { // constant result variables
572 ConstString const_name(name);
573 Target *target = exe_ctx->GetTargetPtr();
574 ExpressionVariableSP expr_var_sp(target->GetPersistentVariable(const_name));
575 if (expr_var_sp) {
576 value_sp = expr_var_sp->GetValueObject();
577 sb_value.SetSP(value_sp, use_dynamic);
578 }
579 } break;
580
581 default:
582 break;
583 }
584
585 return sb_value;
586}
587
588bool SBFrame::IsEqual(const SBFrame &that) const {
589 LLDB_INSTRUMENT_VA(this, that);
590
591 lldb::StackFrameSP this_sp = GetFrameSP();
592 lldb::StackFrameSP that_sp = that.GetFrameSP();
593 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
594}
595
596bool SBFrame::operator==(const SBFrame &rhs) const {
597 LLDB_INSTRUMENT_VA(this, rhs);
598
599 return IsEqual(rhs);
600}
601
602bool SBFrame::operator!=(const SBFrame &rhs) const {
603 LLDB_INSTRUMENT_VA(this, rhs);
604
605 return !IsEqual(rhs);
606}
607
609 LLDB_INSTRUMENT_VA(this);
610
611 llvm::Expected<StoppedExecutionContext> exe_ctx =
613 if (!exe_ctx) {
614 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
615 return SBThread();
616 }
617
618 ThreadSP thread_sp(exe_ctx->GetThreadSP());
619 SBThread sb_thread(thread_sp);
620
621 return sb_thread;
622}
623
624const char *SBFrame::Disassemble() const {
625 LLDB_INSTRUMENT_VA(this);
626
627 llvm::Expected<StoppedExecutionContext> exe_ctx =
629 if (!exe_ctx) {
630 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
631 return nullptr;
632 }
633
634 if (auto *frame = exe_ctx->GetFramePtr())
635 return ConstString(frame->Disassemble()).GetCString();
636
637 return nullptr;
638}
639
640SBValueList SBFrame::GetVariables(bool arguments, bool locals, bool statics,
641 bool in_scope_only) {
642 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only);
643
644 SBValueList value_list;
645 llvm::Expected<StoppedExecutionContext> exe_ctx =
647 if (!exe_ctx) {
648 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
649 return value_list;
650 }
651
652 if (StackFrame *frame = exe_ctx->GetFramePtr()) {
653 Target *target = exe_ctx->GetTargetPtr();
654 lldb::DynamicValueType use_dynamic =
655 frame->CalculateTarget()->GetPreferDynamicValue();
656 const bool include_runtime_support_values =
658
659 SBVariablesOptions options;
660 options.SetIncludeArguments(arguments);
661 options.SetIncludeLocals(locals);
662 options.SetIncludeStatics(statics);
663 options.SetInScopeOnly(in_scope_only);
664 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
665 options.SetUseDynamic(use_dynamic);
666
667 // Assume that if we have any synthetic variables, they should be included.
668 options.SetIncludeSynthetic(true);
669
670 value_list = GetVariables(options);
671 }
672 return value_list;
673}
674
675lldb::SBValueList SBFrame::GetVariables(bool arguments, bool locals,
676 bool statics, bool in_scope_only,
677 lldb::DynamicValueType use_dynamic) {
678 LLDB_INSTRUMENT_VA(this, arguments, locals, statics, in_scope_only,
679 use_dynamic);
680
681 llvm::Expected<StoppedExecutionContext> exe_ctx =
683 if (!exe_ctx) {
684 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
685 return SBValueList();
686 }
687
688 Target *target = exe_ctx->GetTargetPtr();
689 const bool include_runtime_support_values =
691 SBVariablesOptions options;
692 options.SetIncludeArguments(arguments);
693 options.SetIncludeLocals(locals);
694 options.SetIncludeStatics(statics);
695 options.SetInScopeOnly(in_scope_only);
696 options.SetIncludeRuntimeSupportValues(include_runtime_support_values);
697 options.SetUseDynamic(use_dynamic);
698
699 // Assume that if we have any synthetic variables, they should be included.
700 options.SetIncludeSynthetic(true);
701
702 return GetVariables(options);
703}
704
705/// Returns true if the variable is in any of the requested scopes.
706static bool IsInRequestedScope(bool statics, bool arguments, bool locals,
707 bool synthetic, Variable &var) {
708 auto value_type = var.GetScope();
709 // Check if the variable is synthetic first.
710 bool is_synthetic = IsSyntheticValueType(value_type);
711 if (is_synthetic) {
712 // If the variable is synthetic but we don't want those, then it's
713 // automatically out of scope.
714 if (!synthetic)
715 return false;
716
717 // Get the base value type so the rest of the switch works correctly.
718 value_type = GetBaseValueType(value_type);
719 }
720
721 switch (value_type) {
725 return statics;
726
728 return arguments;
729
731 return locals;
732
733 default:
734 break;
735 }
736
737 // The default for all other value types is is_synthetic. At this point, if
738 // we didn't want synthetic variables we'd have exited by now anyway, so we
739 // must want them. Aside from the modifiers above that should apply equally to
740 // synthetic and normal variables, any other synthetic variable we should
741 // default to showing.
742 return is_synthetic;
743}
744
746
747/// Populates `value_list` with the variables from `frame` according to
748/// `options`. This method checks whether the Debugger received an interrupt
749/// before processing every variable, returning `WasInterrupted::yes` in that
750/// case.
751static std::pair<WasInterrupted, Status> FetchVariablesUnlessInterrupted(
752 const lldb::SBVariablesOptions &options, StackFrame &frame,
753 SBValueList &value_list, Debugger &dbg,
754 std::function<SBValue(ValueObjectSP, bool)> to_sbvalue) {
755 const bool statics = options.GetIncludeStatics();
756 const bool arguments = options.GetIncludeArguments();
757 const bool locals = options.GetIncludeLocals();
758 const bool synthetic = options.GetIncludeSynthetic();
759 const bool in_scope_only = options.GetInScopeOnly();
760 const bool include_runtime_support_values =
762 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
763
764 Status var_error;
765 // Fetch all variables available and filter them later.
766 VariableList *variable_list = frame.GetVariableList(
767 /*get_file_globals=*/true, /*include_synthetic_vars=*/true, &var_error);
768
769 std::set<VariableSP> variable_set;
770
771 if (!variable_list)
772 return {WasInterrupted::No, std::move(var_error)};
773 const size_t num_variables = variable_list->GetSize();
774 size_t num_produced = 0;
775 for (const VariableSP &variable_sp : *variable_list) {
776 if (!variable_sp || !IsInRequestedScope(statics, arguments, locals,
777 synthetic, *variable_sp))
778 continue;
779
781 dbg,
782 "Interrupted getting frame variables with {0} of {1} "
783 "produced.",
784 num_produced, num_variables))
785 return {WasInterrupted::Yes, std::move(var_error)};
786
787 // Only add variables once so we don't end up with duplicates
788 if (variable_set.insert(variable_sp).second == false)
789 continue;
790 if (in_scope_only && !variable_sp->IsInScope(&frame))
791 continue;
792
793 ValueObjectSP valobj_sp(
795
796 if (!include_runtime_support_values && valobj_sp != nullptr &&
797 valobj_sp->IsRuntimeSupportValue())
798 continue;
799
800 value_list.Append(to_sbvalue(valobj_sp, use_dynamic));
801 }
802 num_produced++;
803
804 return {WasInterrupted::No, std::move(var_error)};
805}
806
807/// Populates `value_list` with recognized arguments of `frame` according to
808/// `options`.
809static llvm::SmallVector<ValueObjectSP>
811 SBTarget target) {
812 if (!options.GetIncludeRecognizedArguments(target))
813 return {};
814 RecognizedStackFrameSP recognized_frame = frame.GetRecognizedFrame();
815 if (!recognized_frame)
816 return {};
817
818 ValueObjectListSP recognized_arg_list =
819 recognized_frame->GetRecognizedArguments();
820 if (!recognized_arg_list)
821 return {};
822
823 return llvm::to_vector(recognized_arg_list->GetObjects());
824}
825
827 LLDB_INSTRUMENT_VA(this, options);
828
829 llvm::Expected<StoppedExecutionContext> exe_ctx =
831 if (!exe_ctx) {
832 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
833 return SBValueList();
834 }
835
836 StackFrame *frame = exe_ctx->GetFramePtr();
837 if (!frame)
838 return SBValueList();
839
840 auto valobj_to_sbvalue = [](ValueObjectSP valobj, bool use_dynamic) {
841 SBValue value_sb;
842 value_sb.SetSP(valobj, use_dynamic);
843 return value_sb;
844 };
845 SBValueList value_list;
846 std::pair<WasInterrupted, Status> fetch_result =
847 FetchVariablesUnlessInterrupted(options, *frame, value_list,
848 exe_ctx->GetTargetPtr()->GetDebugger(),
849 valobj_to_sbvalue);
850 if (fetch_result.second.Fail())
851 value_list.SetError(std::move(fetch_result.second));
852
853 if (fetch_result.first == WasInterrupted::Yes)
854 return value_list;
855
856 const lldb::DynamicValueType use_dynamic = options.GetUseDynamic();
857 llvm::SmallVector<ValueObjectSP> args = FetchRecognizedArguments(
858 options, *frame, SBTarget(exe_ctx->GetTargetSP()));
859 for (ValueObjectSP arg : args) {
860 SBValue value_sb;
861 value_sb.SetSP(arg, use_dynamic);
862 value_list.Append(value_sb);
863 }
864 return value_list;
865}
866
868 LLDB_INSTRUMENT_VA(this);
869
870 llvm::Expected<StoppedExecutionContext> exe_ctx =
872 if (!exe_ctx) {
873 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
874 return SBValueList();
875 }
876
877 StackFrame *frame = exe_ctx->GetFramePtr();
878 if (!frame)
879 return SBValueList();
880
881 RegisterContextSP reg_ctx(frame->GetRegisterContext());
882 if (!reg_ctx)
883 return SBValueList();
884
885 SBValueList value_list;
886 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
887 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx)
888 value_list.Append(ValueObjectRegisterSet::Create(frame, reg_ctx, set_idx));
889
890 return value_list;
891}
892
894 LLDB_INSTRUMENT_VA(this, name);
895
896 ValueObjectSP value_sp;
897 llvm::Expected<StoppedExecutionContext> exe_ctx =
899 if (!exe_ctx) {
900 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
901 return SBValue();
902 }
903
904 StackFrame *frame = exe_ctx->GetFramePtr();
905 if (!frame)
906 return SBValue();
907
908 RegisterContextSP reg_ctx(frame->GetRegisterContext());
909 if (!reg_ctx)
910 return SBValue();
911
912 const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(name);
913 if (!reg_info)
914 return SBValue();
915
916 SBValue result;
917 value_sp = ValueObjectRegister::Create(frame, reg_ctx, reg_info);
918 result.SetSP(value_sp);
919
920 return result;
921}
922
924 SBStream &output) {
925 Stream &strm = output.ref();
926
927 llvm::Expected<StoppedExecutionContext> exe_ctx =
929 if (!exe_ctx)
930 return Status::FromError(exe_ctx.takeError());
931
933
934 if (!format) {
935 error.SetErrorString("The provided SBFormat object is invalid");
936 return error;
937 }
938
939 if (StackFrame *frame = exe_ctx->GetFramePtr();
940 frame && frame->DumpUsingFormat(strm, format.GetFormatEntrySP().get()))
941 return error;
942 error.SetErrorStringWithFormat(
943 "It was not possible to generate a frame "
944 "description with the given format string '%s'",
945 format.GetFormatEntrySP()->string.c_str());
946 return error;
947}
948
950 LLDB_INSTRUMENT_VA(this, description);
951
952 Stream &strm = description.ref();
953
954 llvm::Expected<StoppedExecutionContext> exe_ctx =
956 if (!exe_ctx) {
957 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
958 strm.PutCString("Error: process is not stopped.");
959 return true;
960 }
961
962 if (StackFrame *frame = exe_ctx->GetFramePtr())
963 frame->DumpUsingSettingsFormat(&strm);
964
965 return true;
966}
967
969 LLDB_INSTRUMENT_VA(this, expr);
970
971 llvm::Expected<StoppedExecutionContext> exe_ctx =
973 if (!exe_ctx) {
974 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
976 }
977
978 SBExpressionOptions options;
979 StackFrame *frame = exe_ctx->GetFramePtr();
980 if (frame) {
981 lldb::DynamicValueType fetch_dynamic_value =
982 frame->CalculateTarget()->GetPreferDynamicValue();
983 options.SetFetchDynamicValue(fetch_dynamic_value);
984 }
985 options.SetUnwindOnError(true);
986 options.SetIgnoreBreakpoints(true);
987 Target *target = exe_ctx->GetTargetPtr();
988 SourceLanguage language = target->GetLanguage();
989 if (!language && frame)
990 language = frame->GetLanguage();
991 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
992 return EvaluateExpression(expr, options);
993}
994
997 lldb::DynamicValueType fetch_dynamic_value) {
998 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value);
999
1000 SBExpressionOptions options;
1001 options.SetFetchDynamicValue(fetch_dynamic_value);
1002 options.SetUnwindOnError(true);
1003 options.SetIgnoreBreakpoints(true);
1004 llvm::Expected<StoppedExecutionContext> exe_ctx =
1006 if (!exe_ctx) {
1007 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1009 }
1010
1011 StackFrame *frame = exe_ctx->GetFramePtr();
1012 Target *target = exe_ctx->GetTargetPtr();
1013 SourceLanguage language = target->GetLanguage();
1014 if (!language && frame)
1015 language = frame->GetLanguage();
1016 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1017 return EvaluateExpression(expr, options);
1018}
1019
1021 lldb::DynamicValueType fetch_dynamic_value,
1022 bool unwind_on_error) {
1023 LLDB_INSTRUMENT_VA(this, expr, fetch_dynamic_value, unwind_on_error);
1024
1025 SBExpressionOptions options;
1026 llvm::Expected<StoppedExecutionContext> exe_ctx =
1028 if (!exe_ctx) {
1029 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1031 }
1032
1033 options.SetFetchDynamicValue(fetch_dynamic_value);
1034 options.SetUnwindOnError(unwind_on_error);
1035 options.SetIgnoreBreakpoints(true);
1036 StackFrame *frame = exe_ctx->GetFramePtr();
1037 Target *target = exe_ctx->GetTargetPtr();
1038 SourceLanguage language = target->GetLanguage();
1039 if (!language && frame)
1040 language = frame->GetLanguage();
1041 options.SetLanguage((SBSourceLanguageName)language.name, language.version);
1042 return EvaluateExpression(expr, options);
1043}
1044
1046 auto error = Status::FromErrorString("can't evaluate expressions when the "
1047 "process is running.");
1048 ValueObjectSP expr_value_sp =
1049 ValueObjectConstResult::Create(nullptr, std::move(error));
1050 SBValue expr_result;
1051 expr_result.SetSP(expr_value_sp, false);
1052 return expr_result;
1053}
1054
1056 const SBExpressionOptions &options) {
1057 LLDB_INSTRUMENT_VA(this, expr, options);
1058
1059 auto LogResult = [](SBValue expr_result) {
1060 Log *expr_log = GetLog(LLDBLog::Expressions);
1061 if (expr_result.GetError().Success())
1062 LLDB_LOGF(expr_log,
1063 "** [SBFrame::EvaluateExpression] Expression result is "
1064 "%s, summary %s **",
1065 expr_result.GetValue(), expr_result.GetSummary());
1066 else
1067 LLDB_LOGF(
1068 expr_log,
1069 "** [SBFrame::EvaluateExpression] Expression evaluation failed: "
1070 "%s **",
1071 expr_result.GetError().GetCString());
1072 };
1073
1074 if (expr == nullptr || expr[0] == '\0') {
1075 return SBValue();
1076 }
1077
1078 llvm::Expected<StoppedExecutionContext> exe_ctx =
1080 if (!exe_ctx) {
1081 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1083 LogResult(error_result);
1084 return error_result;
1085 }
1086
1087 StackFrame *frame = exe_ctx->GetFramePtr();
1088 if (!frame)
1089 return SBValue();
1090
1091 std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1092 Target *target = exe_ctx->GetTargetPtr();
1093 if (target->GetDisplayExpressionsInCrashlogs()) {
1094 StreamString frame_description;
1095 frame->DumpUsingSettingsFormat(&frame_description);
1096 stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1097 "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1098 "= %u) %s",
1099 expr, options.GetFetchDynamicValue(), frame_description.GetData());
1100 }
1101
1102 ValueObjectSP expr_value_sp;
1103 target->EvaluateExpression(expr, frame, expr_value_sp, options.ref());
1104
1105 SBValue expr_result;
1106 expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue());
1107 LogResult(expr_result);
1108
1109 return expr_result;
1110}
1111
1113 LLDB_INSTRUMENT_VA(this);
1114
1115 SBStructuredData sb_data;
1116 llvm::Expected<StoppedExecutionContext> exe_ctx =
1118 if (!exe_ctx) {
1119 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1120 return sb_data;
1121 }
1122 StackFrame *frame = exe_ctx->GetFramePtr();
1123 if (!frame)
1124 return sb_data;
1125
1127 sb_data.m_impl_up->SetObjectSP(data);
1128 return sb_data;
1129}
1130
1132 LLDB_INSTRUMENT_VA(this);
1133
1134 return static_cast<const SBFrame *>(this)->IsInlined();
1135}
1136
1138 LLDB_INSTRUMENT_VA(this);
1139
1140 llvm::Expected<StoppedExecutionContext> exe_ctx =
1142 if (!exe_ctx) {
1143 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1144 return false;
1145 }
1146
1147 if (StackFrame *frame = exe_ctx->GetFramePtr())
1148 return frame->IsInlined();
1149 return false;
1150}
1151
1153 LLDB_INSTRUMENT_VA(this);
1154
1155 return static_cast<const SBFrame *>(this)->IsArtificial();
1156}
1157
1159 LLDB_INSTRUMENT_VA(this);
1160
1161 llvm::Expected<StoppedExecutionContext> exe_ctx =
1163 if (!exe_ctx) {
1164 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1165 return false;
1166 }
1167
1168 if (StackFrame *frame = exe_ctx->GetFramePtr())
1169 return frame->IsArtificial();
1170
1171 return false;
1172}
1173
1175 LLDB_INSTRUMENT_VA(this);
1176
1177 llvm::Expected<StoppedExecutionContext> exe_ctx =
1179 if (!exe_ctx) {
1180 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1181 return false;
1182 }
1183
1184 if (StackFrame *frame = exe_ctx->GetFramePtr())
1185 return frame->IsSynthetic();
1186
1187 return false;
1188}
1189
1190bool SBFrame::IsHidden() const {
1191 LLDB_INSTRUMENT_VA(this);
1192
1193 llvm::Expected<StoppedExecutionContext> exe_ctx =
1195 if (!exe_ctx) {
1196 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1197 return false;
1198 }
1199
1200 if (StackFrame *frame = exe_ctx->GetFramePtr())
1201 return frame->IsHidden();
1202
1203 return false;
1204}
1205
1207 LLDB_INSTRUMENT_VA(this);
1208
1209 return static_cast<const SBFrame *>(this)->GetFunctionName();
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 eLanguageTypeUnknown;
1220 }
1221
1222 if (StackFrame *frame = exe_ctx->GetFramePtr())
1223 return frame->GuessLanguage().AsLanguageType();
1224 return eLanguageTypeUnknown;
1225}
1226
1227const char *SBFrame::GetFunctionName() const {
1228 LLDB_INSTRUMENT_VA(this);
1229
1230 llvm::Expected<StoppedExecutionContext> exe_ctx =
1232 if (!exe_ctx) {
1233 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1234 return nullptr;
1235 }
1236
1237 if (StackFrame *frame = exe_ctx->GetFramePtr())
1238 return frame->GetFunctionName();
1239 return nullptr;
1240}
1241
1243 LLDB_INSTRUMENT_VA(this);
1244
1245 llvm::Expected<StoppedExecutionContext> exe_ctx =
1247 if (!exe_ctx) {
1248 LLDB_LOG_ERROR(GetLog(LLDBLog::API), exe_ctx.takeError(), "{0}");
1249 return nullptr;
1250 }
1251
1252 if (StackFrame *frame = exe_ctx->GetFramePtr())
1253 return frame->GetDisplayFunctionName();
1254 return nullptr;
1255}
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:494
#define LLDB_INSTRUMENT_VA(...)
#define LLDB_LOGF(log,...)
Definition Log.h:378
#define LLDB_LOG_ERROR(log, error,...)
Definition Log.h:394
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:751
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:706
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:810
WasInterrupted
Definition SBFrame.cpp:745
@ Yes
Definition SBFrame.cpp:745
@ No
Definition SBFrame.cpp:745
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:248
lldb::addr_t GetPC() const
Definition SBFrame.cpp:276
const char * GetFunctionName()
Get the appropriate function name for this frame.
Definition SBFrame.cpp:1206
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:461
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:923
bool IsValid() const
Definition SBFrame.cpp:96
lldb::SBValue FindRegister(const char *name)
Definition SBFrame.cpp:893
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:418
const char * GetDisplayFunctionName()
Definition SBFrame.cpp:1242
bool IsInlined()
Return true if this frame represents an inlined function.
Definition SBFrame.cpp:1131
bool operator==(const lldb::SBFrame &rhs) const
Definition SBFrame.cpp:596
lldb::addr_t GetCFA() const
Definition SBFrame.cpp:261
lldb::addr_t GetFP() const
Definition SBFrame.cpp:330
const lldb::SBFrame & operator=(const lldb::SBFrame &rhs)
Definition SBFrame.cpp:80
lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr, DynamicValueType use_dynamic, lldb::DILMode mode=lldb::eDILModeFull)
Definition SBFrame.cpp:388
static SBValue CreateProcessIsRunningExprEvalError()
Return an SBValue containing an error message that warns the process is not currently stopped.
Definition SBFrame.cpp:1045
lldb::SBLineEntry GetLineEntry() const
Definition SBFrame.cpp:228
friend class SBValue
Definition SBFrame.h:232
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:968
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:231
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:227
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:640
bool IsSynthetic() const
Definition SBFrame.cpp:1174
bool IsEqual(const lldb::SBFrame &that) const
Definition SBFrame.cpp:588
const char * Disassemble() const
Definition SBFrame.cpp:624
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
Definition SBFrame.cpp:92
lldb::SBThread GetThread() const
Definition SBFrame.cpp:608
lldb::SBValueList GetRegisters()
Definition SBFrame.cpp:867
bool IsArtificial()
Definition SBFrame.cpp:1152
lldb::LanguageType GuessLanguage() const
Definition SBFrame.cpp:1212
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:1190
SBStructuredData GetLanguageSpecificData() const
Language plugins can use this API to report language-specific runtime information about this compile ...
Definition SBFrame.cpp:1112
lldb::SBSymbol GetSymbol() const
Definition SBFrame.cpp:183
lldb::SBModule GetModule() const
Definition SBFrame.cpp:131
bool GetDescription(lldb::SBStream &description)
Definition SBFrame.cpp:949
bool operator!=(const lldb::SBFrame &rhs) const
Definition SBFrame.cpp:602
void SetSP(const ModuleSP &module_sp)
Definition SBModule.cpp:218
lldb_private::Stream & ref()
Definition SBStream.cpp:178
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:982
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:436
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:5717
SourceLanguage GetLanguage() const
Definition Target.cpp:5606
bool GetDisplayExpressionsInCrashlogs() const
Definition Target.cpp:5667
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:3066
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
Definition Target.cpp:2985
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:2907
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:283
lldb::ValueType GetScope() const
Definition Variable.h:67
#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:327
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:112
class LLDB_API SBLineEntry
Definition SBDefines.h:86
class LLDB_API SBFunction
Definition SBDefines.h:80
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
std::shared_ptr< lldb_private::RecognizedStackFrame > RecognizedStackFrameSP
class LLDB_API SBValueList
Definition SBDefines.h:136
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:90
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
class LLDB_API SBTarget
Definition SBDefines.h:115
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:135
DILMode
Data Inspection Language (DIL) evaluation modes.
std::shared_ptr< lldb_private::Module > ModuleSP
class LLDB_API SBCompileUnit
Definition SBDefines.h:63
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:614