56#include "llvm/Support/PrettyStackTrace.h"
96 return this->
operator bool();
98SBFrame::operator
bool()
const {
100 llvm::Expected<StoppedExecutionContext> exe_ctx =
115 llvm::Expected<StoppedExecutionContext> exe_ctx =
122 SymbolContextItem scope =
static_cast<SymbolContextItem
>(resolve_scope);
123 if (
StackFrame *frame = exe_ctx->GetFramePtr())
124 sb_sym_ctx = frame->GetSymbolContext(scope);
132 llvm::Expected<StoppedExecutionContext> exe_ctx =
146 sb_module.
SetSP(module_sp);
153 llvm::Expected<StoppedExecutionContext> exe_ctx =
160 if (
StackFrame *frame = exe_ctx->GetFramePtr())
162 frame->GetSymbolContext(eSymbolContextCompUnit).comp_unit);
169 llvm::Expected<StoppedExecutionContext> exe_ctx =
176 if (
StackFrame *frame = exe_ctx->GetFramePtr())
177 return SBFunction(frame->GetSymbolContext(eSymbolContextFunction).function);
184 llvm::Expected<StoppedExecutionContext> exe_ctx =
191 if (
StackFrame *frame = exe_ctx->GetFramePtr())
192 return SBSymbol(frame->GetSymbolContext(eSymbolContextSymbol).symbol);
199 llvm::Expected<StoppedExecutionContext> exe_ctx =
206 if (
StackFrame *frame = exe_ctx->GetFramePtr())
207 return SBBlock(frame->GetSymbolContext(eSymbolContextBlock).block);
214 llvm::Expected<StoppedExecutionContext> exe_ctx =
221 if (
StackFrame *frame = exe_ctx->GetFramePtr())
222 return SBBlock(frame->GetFrameBlock());
229 llvm::Expected<StoppedExecutionContext> exe_ctx =
236 if (
StackFrame *frame = exe_ctx->GetFramePtr())
238 &frame->GetSymbolContext(eSymbolContextLineEntry).line_entry);
245 constexpr uint32_t error_frame_idx =
UINT32_MAX;
247 llvm::Expected<StoppedExecutionContext> exe_ctx =
251 return error_frame_idx;
254 if (
StackFrame *frame = exe_ctx->GetFramePtr())
255 return frame->GetFrameIndex();
256 return error_frame_idx;
262 llvm::Expected<StoppedExecutionContext> exe_ctx =
269 if (
StackFrame *frame = exe_ctx->GetFramePtr())
270 return frame->GetStackID().GetCallFrameAddressWithoutMetadata();
278 llvm::Expected<StoppedExecutionContext> exe_ctx =
285 Target *target = exe_ctx->GetTargetPtr();
286 if (
StackFrame *frame = exe_ctx->GetFramePtr())
296 constexpr bool error_ret_val =
false;
297 llvm::Expected<StoppedExecutionContext> exe_ctx =
301 return error_ret_val;
304 if (
StackFrame *frame = exe_ctx->GetFramePtr())
306 return reg_ctx_sp->SetPC(new_pc);
308 return error_ret_val;
314 llvm::Expected<StoppedExecutionContext> exe_ctx =
321 if (
StackFrame *frame = exe_ctx->GetFramePtr())
323 return reg_ctx_sp->GetSP();
331 llvm::Expected<StoppedExecutionContext> exe_ctx =
338 if (
StackFrame *frame = exe_ctx->GetFramePtr())
340 return reg_ctx_sp->GetFP();
348 llvm::Expected<StoppedExecutionContext> exe_ctx =
355 if (
StackFrame *frame = exe_ctx->GetFramePtr())
356 return SBAddress(frame->GetFrameCodeAddress());
370 llvm::Expected<StoppedExecutionContext> exe_ctx =
377 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
379 frame->CalculateTarget()->GetPreferDynamicValue();
390 if (var_path ==
nullptr || var_path[0] ==
'\0') {
394 llvm::Expected<StoppedExecutionContext> exe_ctx =
401 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
404 ValueObjectSP value_sp(frame->GetValueForVariableExpressionPath(
409 sb_value.
SetSP(value_sp, use_dynamic);
417 llvm::Expected<StoppedExecutionContext> exe_ctx =
424 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
426 frame->CalculateTarget()->GetPreferDynamicValue();
439 if (name ==
nullptr || name[0] ==
'\0') {
443 llvm::Expected<StoppedExecutionContext> exe_ctx =
450 if (
StackFrame *frame = exe_ctx->GetFramePtr())
452 sb_value.
SetSP(value_sp, use_dynamic);
461 llvm::Expected<StoppedExecutionContext> exe_ctx =
468 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
470 frame->CalculateTarget()->GetPreferDynamicValue();
471 value =
FindValue(name, value_type, use_dynamic);
482 if (name ==
nullptr || name[0] ==
'\0') {
487 llvm::Expected<StoppedExecutionContext> exe_ctx =
494 Target *target = exe_ctx->GetTargetPtr();
495 Process *process = exe_ctx->GetProcessPtr();
496 if (target && process) {
497 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
500 switch (value_type) {
507 SymbolContext sc(frame->GetSymbolContext(eSymbolContextBlock));
509 const bool can_create =
true;
510 const bool get_parent_variables =
true;
511 const bool stop_if_block_is_inlined_function =
true;
515 can_create, get_parent_variables,
516 stop_if_block_is_inlined_function,
521 const bool get_file_globals =
true;
522 VariableList *frame_vars = frame->GetVariableList(get_file_globals,
531 value_sp = frame->GetValueObjectForFrameVariable(variable_sp,
533 sb_value.
SetSP(value_sp, use_dynamic);
542 reg_ctx->GetRegisterInfoByName(name)) {
544 sb_value.
SetSP(value_sp);
554 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
555 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
556 const RegisterSet *reg_set = reg_ctx->GetRegisterSet(set_idx);
558 (llvm::StringRef(reg_set->
name).equals_insensitive(name) ||
560 .equals_insensitive(name))) {
563 sb_value.
SetSP(value_sp);
576 value_sp = expr_var_sp->GetValueObject();
577 sb_value.
SetSP(value_sp, use_dynamic);
596 return (this_sp && that_sp && this_sp->GetStackID() == that_sp->GetStackID());
614 llvm::Expected<StoppedExecutionContext> exe_ctx =
621 ThreadSP thread_sp(exe_ctx->GetThreadSP());
630 llvm::Expected<StoppedExecutionContext> exe_ctx =
637 if (
auto *frame = exe_ctx->GetFramePtr())
644 bool in_scope_only) {
648 llvm::Expected<StoppedExecutionContext> exe_ctx =
655 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
656 Target *target = exe_ctx->GetTargetPtr();
658 frame->CalculateTarget()->GetPreferDynamicValue();
659 const bool include_runtime_support_values =
676 bool statics,
bool in_scope_only,
681 llvm::Expected<StoppedExecutionContext> exe_ctx =
688 Target *target = exe_ctx->GetTargetPtr();
689 const bool include_runtime_support_values =
705 llvm::Expected<StoppedExecutionContext> exe_ctx =
713 const bool recognized_arguments =
717 const bool include_runtime_support_values =
721 std::set<VariableSP> variable_set;
722 Process *process = exe_ctx->GetProcessPtr();
724 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
728 variable_list = frame->GetVariableList(
true, &var_error);
729 if (var_error.
Fail())
730 value_list.
SetError(std::move(var_error));
732 const size_t num_variables = variable_list->
GetSize();
734 size_t num_produced = 0;
735 for (
const VariableSP &variable_sp : *variable_list) {
737 "Interrupted getting frame variables with {0} of {1} "
738 "produced.", num_produced, num_variables))
742 bool add_variable =
false;
743 switch (variable_sp->GetScope()) {
747 add_variable = statics;
751 add_variable = arguments;
755 add_variable = locals;
763 if (variable_set.find(variable_sp) == variable_set.end())
764 variable_set.insert(variable_sp);
768 if (in_scope_only && !variable_sp->IsInScope(frame))
771 ValueObjectSP valobj_sp(frame->GetValueObjectForFrameVariable(
774 if (!include_runtime_support_values && valobj_sp !=
nullptr &&
775 valobj_sp->IsRuntimeSupportValue())
779 value_sb.
SetSP(valobj_sp, use_dynamic);
780 value_list.
Append(value_sb);
787 if (recognized_arguments) {
788 auto recognized_frame = frame->GetRecognizedFrame();
789 if (recognized_frame) {
791 recognized_frame->GetRecognizedArguments();
792 if (recognized_arg_list) {
793 for (
auto &rec_value_sp : recognized_arg_list->GetObjects()) {
795 value_sb.
SetSP(rec_value_sp, use_dynamic);
796 value_list.
Append(value_sb);
812 llvm::Expected<StoppedExecutionContext> exe_ctx =
818 Target *target = exe_ctx->GetTargetPtr();
819 Process *process = exe_ctx->GetProcessPtr();
820 if (target && process) {
821 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
824 const uint32_t num_sets = reg_ctx->GetRegisterSetCount();
825 for (uint32_t set_idx = 0; set_idx < num_sets; ++set_idx) {
842 llvm::Expected<StoppedExecutionContext> exe_ctx =
848 Target *target = exe_ctx->GetTargetPtr();
849 Process *process = exe_ctx->GetProcessPtr();
850 if (target && process) {
851 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
855 reg_ctx->GetRegisterInfoByName(name)) {
857 result.
SetSP(value_sp);
871 llvm::Expected<StoppedExecutionContext> exe_ctx =
879 error.SetErrorString(
"The provided SBFormat object is invalid");
883 if (
StackFrame *frame = exe_ctx->GetFramePtr();
886 error.SetErrorStringWithFormat(
887 "It was not possible to generate a frame "
888 "description with the given format string '%s'",
898 llvm::Expected<StoppedExecutionContext> exe_ctx =
902 strm.
PutCString(
"Error: process is not stopped.");
906 if (
StackFrame *frame = exe_ctx->GetFramePtr())
907 frame->DumpUsingSettingsFormat(&strm);
915 llvm::Expected<StoppedExecutionContext> exe_ctx =
931 Target *target = exe_ctx->GetTargetPtr();
933 if (!language && frame)
948 llvm::Expected<StoppedExecutionContext> exe_ctx =
956 Target *target = exe_ctx->GetTargetPtr();
958 if (!language && frame)
966 bool unwind_on_error) {
970 llvm::Expected<StoppedExecutionContext> exe_ctx =
981 Target *target = exe_ctx->GetTargetPtr();
983 if (!language && frame)
991 "process is running.");
995 expr_result.
SetSP(expr_value_sp,
false);
1007 if (expr ==
nullptr || expr[0] ==
'\0') {
1013 llvm::Expected<StoppedExecutionContext> exe_ctx =
1019 Target *target = exe_ctx->GetTargetPtr();
1020 Process *process = exe_ctx->GetProcessPtr();
1021 if (target && process) {
1022 if (
StackFrame *frame = exe_ctx->GetFramePtr()) {
1023 std::unique_ptr<llvm::PrettyStackTraceFormat> stack_trace;
1026 frame->DumpUsingSettingsFormat(&frame_description);
1027 stack_trace = std::make_unique<llvm::PrettyStackTraceFormat>(
1028 "SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value "
1041 expr_result.
SetSP(expr_value_sp,
false);
1047 "** [SBFrame::EvaluateExpression] Expression result is "
1048 "%s, summary %s **",
1052 "** [SBFrame::EvaluateExpression] Expression evaluation failed: "
1063 llvm::Expected<StoppedExecutionContext> exe_ctx =
1087 llvm::Expected<StoppedExecutionContext> exe_ctx =
1094 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1095 return frame->IsInlined();
1108 llvm::Expected<StoppedExecutionContext> exe_ctx =
1115 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1116 return frame->IsArtificial();
1124 llvm::Expected<StoppedExecutionContext> exe_ctx =
1131 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1132 return frame->IsSynthetic();
1140 llvm::Expected<StoppedExecutionContext> exe_ctx =
1147 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1148 return frame->IsHidden();
1162 llvm::Expected<StoppedExecutionContext> exe_ctx =
1169 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1170 return frame->GuessLanguage().AsLanguageType();
1177 llvm::Expected<StoppedExecutionContext> exe_ctx =
1184 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1185 return frame->GetFunctionName();
1192 llvm::Expected<StoppedExecutionContext> exe_ctx =
1199 if (
StackFrame *frame = exe_ctx->GetFramePtr())
1200 return frame->GetDisplayFunctionName();
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.
#define LLDB_INSTRUMENT_VA(...)
#define LLDB_LOGF(log,...)
#define LLDB_LOG_ERROR(log, error,...)
const char * GetCString() const
Get the error string as a NULL terminated UTF8 c-string.
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
lldb::ExecutionContextRefSP m_opaque_sp
lldb::addr_t GetPC() const
const char * GetFunctionName()
Get the appropriate function name for this frame.
lldb::SBValue FindValue(const char *name, ValueType value_type)
Find variables, register sets, registers, or persistent variables using the frame as the scope.
lldb::SBValue GetValueForVariablePath(const char *var_expr_cstr, DynamicValueType use_dynamic)
lldb::SBSymbolContext GetSymbolContext(uint32_t resolve_scope) const
SBError GetDescriptionWithFormat(const SBFormat &format, SBStream &output)
Similar to GetDescription() but the format of the description can be configured via the format parame...
lldb::SBValue FindRegister(const char *name)
bool SetPC(lldb::addr_t new_pc)
lldb::SBValue FindVariable(const char *var_name)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
const char * GetDisplayFunctionName()
bool IsInlined()
Return true if this frame represents an inlined function.
bool operator==(const lldb::SBFrame &rhs) const
lldb::addr_t GetCFA() const
lldb::addr_t GetFP() const
const lldb::SBFrame & operator=(const lldb::SBFrame &rhs)
static SBValue CreateProcessIsRunningExprEvalError()
Return an SBValue containing an error message that warns the process is not currently stopped.
lldb::SBLineEntry GetLineEntry() const
lldb::SBValue EvaluateExpression(const char *expr)
The version that doesn't supply a 'use_dynamic' value will use the target's default.
lldb::SBCompileUnit GetCompileUnit() const
uint32_t GetFrameID() const
lldb::SBAddress GetPCAddress() const
lldb::SBFunction GetFunction() const
lldb::SBBlock GetBlock() const
Gets the deepest block that contains the frame PC.
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.
bool IsEqual(const lldb::SBFrame &that) const
const char * Disassemble() const
void SetFrameSP(const lldb::StackFrameSP &lldb_object_sp)
lldb::SBThread GetThread() const
lldb::SBValueList GetRegisters()
lldb::LanguageType GuessLanguage() const
lldb::SBBlock GetFrameBlock() const
Gets the lexical block that defines the stack frame.
lldb::addr_t GetSP() const
lldb::StackFrameSP GetFrameSP() const
bool IsHidden() const
Return whether a frame recognizer decided this frame should not be displayes in backtraces etc.
SBStructuredData GetLanguageSpecificData() const
Language plugins can use this API to report language-specific runtime information about this compile ...
lldb::SBSymbol GetSymbol() const
lldb::SBModule GetModule() const
bool GetDescription(lldb::SBStream &description)
bool operator!=(const lldb::SBFrame &rhs) const
void SetSP(const ModuleSP &module_sp)
lldb_private::Stream & ref()
StructuredDataImplUP m_impl_up
void Append(const lldb::SBValue &val_obj)
void SetError(lldb_private::Status &&status)
void SetSP(const lldb::ValueObjectSP &sp)
const char * GetSummary()
void SetIncludeRuntimeSupportValues(bool)
bool GetIncludeRuntimeSupportValues() const
void SetIncludeLocals(bool)
void SetIncludeArguments(bool)
lldb::DynamicValueType GetUseDynamic() const
bool GetIncludeArguments() const
void SetInScopeOnly(bool)
bool GetIncludeStatics() const
void SetIncludeStatics(bool)
void SetUseDynamic(lldb::DynamicValueType)
bool GetIncludeLocals() const
bool GetInScopeOnly() const
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.
A uniqued constant string class.
const char * GetCString() const
Get the string value as a C string.
A class to manage flag bits.
Execution context objects refer to objects in the execution of the program that is being debugged.
A plug-in interface definition class for debugging a process.
Target & GetTarget()
Get the target object pointer for this module.
This base class provides an interface to stack frames.
@ eExpressionPathOptionCheckPtrVsMember
@ eExpressionPathOptionsAllowDirectIVarAccess
StructuredData::ObjectSP GetLanguageSpecificData()
Language plugins can use this API to report language-specific runtime information about this compile ...
SourceLanguage GetLanguage()
Query this frame to determine what the default language should be when parsing expressions given the ...
const SymbolContext & GetSymbolContext(lldb::SymbolContextItem resolve_scope)
Provide a SymbolContext for this StackFrame's current pc value.
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.
lldb::TargetSP CalculateTarget() override
static Status FromErrorString(const char *str)
bool Fail() const
Test for error condition.
static Status FromError(llvm::Error error)
Avoid using this in new code. Migrate APIs to llvm::Expected instead.
const char * GetData() const
A stream class that can stream formatted output to a file.
size_t PutCString(llvm::StringRef cstr)
Output a C string to the stream.
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
SourceLanguage GetLanguage() const
bool GetDisplayExpressionsInCrashlogs() const
lldb::addr_t GetOpcodeLoadAddress(lldb::addr_t load_addr, AddressClass addr_class=AddressClass::eInvalid) const
Get load_addr as an opcode for this target.
Debugger & GetDebugger() const
lldb::ExpressionVariableSP GetPersistentVariable(ConstString name)
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)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::ByteOrder byte_order, uint32_t addr_byte_size, lldb::addr_t address=LLDB_INVALID_ADDRESS)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, uint32_t set_idx)
static lldb::ValueObjectSP Create(ExecutionContextScope *exe_scope, lldb::RegisterContextSP ®_ctx_sp, const RegisterInfo *reg_info)
lldb::VariableSP FindVariable(ConstString name, bool include_static_members=true)
size_t AppendVariablesIfUnique(VariableList &var_list)
bool IsInScope(StackFrame *frame)
#define LLDB_INVALID_ADDRESS
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.
std::unique_ptr< T > clone(const std::unique_ptr< T > &src)
llvm::Expected< StoppedExecutionContext > GetStoppedExecutionContext(const ExecutionContextRef *exe_ctx_ref_ptr)
class LLDB_API SBLineEntry
class LLDB_API SBFunction
std::shared_ptr< lldb_private::StackFrame > StackFrameSP
class LLDB_API SBValueList
std::shared_ptr< lldb_private::Thread > ThreadSP
std::shared_ptr< lldb_private::ValueObject > ValueObjectSP
std::shared_ptr< lldb_private::ExpressionVariable > ExpressionVariableSP
LanguageType
Programming language type.
@ eLanguageTypeUnknown
Unknown or invalid language value.
std::shared_ptr< lldb_private::ValueObjectList > ValueObjectListSP
std::shared_ptr< lldb_private::Variable > VariableSP
std::shared_ptr< lldb_private::RegisterContext > RegisterContextSP
std::shared_ptr< lldb_private::Module > ModuleSP
@ 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
class LLDB_API SBCompileUnit
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.