本文整理汇总了C++中StackFrame::GetValueObjectForFrameVariable方法的典型用法代码示例。如果您正苦于以下问题:C++ StackFrame::GetValueObjectForFrameVariable方法的具体用法?C++ StackFrame::GetValueObjectForFrameVariable怎么用?C++ StackFrame::GetValueObjectForFrameVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StackFrame
的用法示例。
在下文中一共展示了StackFrame::GetValueObjectForFrameVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DoExecute
bool DoExecute(Args &command, CommandReturnObject &result) override {
// No need to check "frame" for validity as eCommandRequiresFrame ensures it
// is valid
StackFrame *frame = m_exe_ctx.GetFramePtr();
Stream &s = result.GetOutputStream();
// Be careful about the stack frame, if any summary formatter runs code, it
// might clear the StackFrameList
// for the thread. So hold onto a shared pointer to the frame so it stays
// alive.
VariableList *variable_list =
frame->GetVariableList(m_option_variable.show_globals);
VariableSP var_sp;
ValueObjectSP valobj_sp;
const char *name_cstr = nullptr;
size_t idx;
TypeSummaryImplSP summary_format_sp;
if (!m_option_variable.summary.IsCurrentValueEmpty())
DataVisualization::NamedSummaryFormats::GetSummaryFormat(
ConstString(m_option_variable.summary.GetCurrentValue()),
summary_format_sp);
else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
summary_format_sp.reset(new StringSummaryFormat(
TypeSummaryImpl::Flags(),
m_option_variable.summary_string.GetCurrentValue()));
DumpValueObjectOptions options(m_varobj_options.GetAsDumpOptions(
eLanguageRuntimeDescriptionDisplayVerbosityFull, eFormatDefault,
summary_format_sp));
const SymbolContext &sym_ctx =
frame->GetSymbolContext(eSymbolContextFunction);
if (sym_ctx.function && sym_ctx.function->IsTopLevelFunction())
m_option_variable.show_globals = true;
if (variable_list) {
const Format format = m_option_format.GetFormat();
options.SetFormat(format);
if (!command.empty()) {
VariableList regex_var_list;
// If we have any args to the variable command, we will make
// variable objects from them...
for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != nullptr;
++idx) {
if (m_option_variable.use_regex) {
const size_t regex_start_index = regex_var_list.GetSize();
llvm::StringRef name_str(name_cstr);
RegularExpression regex(name_str);
if (regex.Compile(name_str)) {
size_t num_matches = 0;
const size_t num_new_regex_vars =
variable_list->AppendVariablesIfUnique(regex, regex_var_list,
num_matches);
if (num_new_regex_vars > 0) {
for (size_t regex_idx = regex_start_index,
end_index = regex_var_list.GetSize();
regex_idx < end_index; ++regex_idx) {
var_sp = regex_var_list.GetVariableAtIndex(regex_idx);
if (var_sp) {
valobj_sp = frame->GetValueObjectForFrameVariable(
var_sp, m_varobj_options.use_dynamic);
if (valobj_sp) {
// if (format
// !=
// eFormatDefault)
// valobj_sp->SetFormat
// (format);
std::string scope_string;
if (m_option_variable.show_scope)
scope_string = GetScopeString(var_sp).str();
if (!scope_string.empty())
s.PutCString(scope_string);
if (m_option_variable.show_decl &&
var_sp->GetDeclaration().GetFile()) {
bool show_fullpaths = false;
bool show_module = true;
if (var_sp->DumpDeclaration(&s, show_fullpaths,
show_module))
s.PutCString(": ");
}
valobj_sp->Dump(result.GetOutputStream(), options);
}
}
}
} else if (num_matches == 0) {
result.GetErrorStream().Printf("error: no variables matched "
"the regular expression '%s'.\n",
name_cstr);
}
} else {
//.........这里部分代码省略.........
示例2: exe_ctx
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
StackFrame *frame = exe_ctx.GetFramePtr();
if (frame == NULL)
{
result.AppendError ("you must be stopped in a valid stack frame to view frame variables.");
result.SetStatus (eReturnStatusFailed);
return false;
}
Stream &s = result.GetOutputStream();
bool get_file_globals = true;
// Be careful about the stack frame, if any summary formatter runs code, it might clear the StackFrameList
// for the thread. So hold onto a shared pointer to the frame so it stays alive.
VariableList *variable_list = frame->GetVariableList (get_file_globals);
VariableSP var_sp;
ValueObjectSP valobj_sp;
const char *name_cstr = NULL;
size_t idx;
TypeSummaryImplSP summary_format_sp;
if (!m_option_variable.summary.IsCurrentValueEmpty())
DataVisualization::NamedSummaryFormats::GetSummaryFormat(ConstString(m_option_variable.summary.GetCurrentValue()), summary_format_sp);
else if (!m_option_variable.summary_string.IsCurrentValueEmpty())
summary_format_sp.reset(new StringSummaryFormat(TypeSummaryImpl::Flags(),m_option_variable.summary_string.GetCurrentValue()));
ValueObject::DumpValueObjectOptions options;
options.SetMaximumPointerDepth(m_varobj_options.ptr_depth)
.SetMaximumDepth(m_varobj_options.max_depth)
.SetShowTypes(m_varobj_options.show_types)
.SetShowLocation(m_varobj_options.show_location)
.SetUseObjectiveC(m_varobj_options.use_objc)
.SetUseDynamicType(m_varobj_options.use_dynamic)
.SetUseSyntheticValue(m_varobj_options.use_synth)
.SetFlatOutput(m_varobj_options.flat_output)
.SetOmitSummaryDepth(m_varobj_options.no_summary_depth)
.SetIgnoreCap(m_varobj_options.ignore_cap)
.SetSummary(summary_format_sp);
if (m_varobj_options.be_raw)
options.SetRawDisplay(true);
if (variable_list)
{
const Format format = m_option_format.GetFormat();
options.SetFormat(format);
if (command.GetArgumentCount() > 0)
{
VariableList regex_var_list;
// If we have any args to the variable command, we will make
// variable objects from them...
for (idx = 0; (name_cstr = command.GetArgumentAtIndex(idx)) != NULL; ++idx)
{
if (m_option_variable.use_regex)
{
const uint32_t regex_start_index = regex_var_list.GetSize();
RegularExpression regex (name_cstr);
if (regex.Compile(name_cstr))
{
size_t num_matches = 0;
const size_t num_new_regex_vars = variable_list->AppendVariablesIfUnique(regex,
regex_var_list,
num_matches);
if (num_new_regex_vars > 0)
{
for (uint32_t regex_idx = regex_start_index, end_index = regex_var_list.GetSize();
regex_idx < end_index;
++regex_idx)
{
var_sp = regex_var_list.GetVariableAtIndex (regex_idx);
if (var_sp)
{
valobj_sp = frame->GetValueObjectForFrameVariable (var_sp, m_varobj_options.use_dynamic);
if (valobj_sp)
{
// if (format != eFormatDefault)
// valobj_sp->SetFormat (format);
if (m_option_variable.show_decl && var_sp->GetDeclaration ().GetFile())
{
bool show_fullpaths = false;
bool show_module = true;
if (var_sp->DumpDeclaration(&s, show_fullpaths, show_module))
s.PutCString (": ");
}
ValueObject::DumpValueObject (result.GetOutputStream(),
valobj_sp.get(),
options);
}
}
//.........这里部分代码省略.........
示例3: log
SBValue
SBFrame::FindVariable (const char *name, lldb::DynamicValueType use_dynamic)
{
LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API));
VariableSP var_sp;
SBValue sb_value;
if (name == NULL || name[0] == '\0')
{
if (log)
log->Printf ("SBFrame::FindVariable called with empty name");
return sb_value;
}
ValueObjectSP value_sp;
Mutex::Locker api_locker;
ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker);
StackFrame *frame = NULL;
Target *target = exe_ctx.GetTargetPtr();
Process *process = exe_ctx.GetProcessPtr();
if (target && process)
{
Process::StopLocker stop_locker;
if (stop_locker.TryLock(&process->GetRunLock()))
{
frame = exe_ctx.GetFramePtr();
if (frame)
{
VariableList variable_list;
SymbolContext sc (frame->GetSymbolContext (eSymbolContextBlock));
if (sc.block)
{
const bool can_create = true;
const bool get_parent_variables = true;
const bool stop_if_block_is_inlined_function = true;
if (sc.block->AppendVariables (can_create,
get_parent_variables,
stop_if_block_is_inlined_function,
&variable_list))
{
var_sp = variable_list.FindVariable (ConstString(name));
}
}
if (var_sp)
{
value_sp = frame->GetValueObjectForFrameVariable(var_sp, eNoDynamicValues);
sb_value.SetSP(value_sp, use_dynamic);
}
}
else
{
if (log)
log->Printf ("SBFrame::FindVariable () => error: could not reconstruct frame object for this SBFrame.");
}
}
else
{
if (log)
log->Printf ("SBFrame::FindVariable () => error: process is running");
}
}
if (log)
log->Printf ("SBFrame(%p)::FindVariable (name=\"%s\") => SBValue(%p)",
frame, name, value_sp.get());
return sb_value;
}