lldb::SBValue SBValue::CreateValueFromExpression (const char *name, const char* expression) { SBExpressionOptions options; options.ref().SetKeepInMemory(true); return CreateValueFromExpression (name, expression, options); }
SBValue SBFrame::EvaluateExpression (const char *expr, lldb::DynamicValueType fetch_dynamic_value, bool unwind_on_error) { SBExpressionOptions options; options.SetFetchDynamicValue (fetch_dynamic_value); options.SetUnwindOnError (unwind_on_error); return EvaluateExpression (expr, options); }
SBValue SBFrame::EvaluateExpression (const char *expr) { SBValue result; ExecutionContext exe_ctx(m_opaque_sp.get()); StackFrame *frame = exe_ctx.GetFramePtr(); Target *target = exe_ctx.GetTargetPtr(); if (frame && target) { SBExpressionOptions options; lldb::DynamicValueType fetch_dynamic_value = frame->CalculateTarget()->GetPreferDynamicValue(); options.SetFetchDynamicValue (fetch_dynamic_value); options.SetUnwindOnError (true); return EvaluateExpression (expr, options); } return result; }
lldb::SBValue SBValue::CreateValueFromExpression (const char *name, const char *expression, SBExpressionOptions &options) { Log *log(lldb_private::GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); lldb::SBValue sb_value; ValueLocker locker; lldb::ValueObjectSP value_sp(GetSP(locker)); lldb::ValueObjectSP new_value_sp; if (value_sp) { ExecutionContext exe_ctx (value_sp->GetExecutionContextRef()); Target* target = exe_ctx.GetTargetPtr(); if (target) { options.ref().SetKeepInMemory(true); target->EvaluateExpression (expression, exe_ctx.GetFramePtr(), new_value_sp, options.ref()); if (new_value_sp) { new_value_sp->SetName(ConstString(name)); sb_value.SetSP(new_value_sp); } } } if (log) { if (new_value_sp) log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => SBValue (%p)", value_sp.get(), name, expression, new_value_sp.get()); else log->Printf ("SBValue(%p)::CreateValueFromExpression(name=\"%s\", expression=\"%s\") => NULL", value_sp.get(), name, expression); } return sb_value; }
lldb::SBValue SBFrame::EvaluateExpression (const char *expr, const SBExpressionOptions &options) { LogSP log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_API)); LogSP expr_log(GetLogIfAllCategoriesSet (LIBLLDB_LOG_EXPRESSIONS)); ExecutionResults exe_results = eExecutionSetupError; SBValue expr_result; if (expr == NULL || expr[0] == '\0') { if (log) log->Printf ("SBFrame::EvaluateExpression called with an empty expression"); return expr_result; } ValueObjectSP expr_value_sp; Mutex::Locker api_locker; ExecutionContext exe_ctx (m_opaque_sp.get(), api_locker); if (log) log->Printf ("SBFrame()::EvaluateExpression (expr=\"%s\")...", expr); 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) { #ifdef LLDB_CONFIGURATION_DEBUG StreamString frame_description; frame->DumpUsingSettingsFormat (&frame_description); Host::SetCrashDescriptionWithFormat ("SBFrame::EvaluateExpression (expr = \"%s\", fetch_dynamic_value = %u) %s", expr, options.GetFetchDynamicValue(), frame_description.GetString().c_str()); #endif exe_results = target->EvaluateExpression (expr, frame, expr_value_sp, options.ref()); expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); #ifdef LLDB_CONFIGURATION_DEBUG Host::SetCrashDescription (NULL); #endif } else { if (log) log->Printf ("SBFrame::EvaluateExpression () => error: could not reconstruct frame object for this SBFrame."); } } else { if (log) log->Printf ("SBFrame::EvaluateExpression () => error: process is running"); } } #ifndef LLDB_DISABLE_PYTHON if (expr_log) expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is %s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); if (log) log->Printf ("SBFrame(%p)::EvaluateExpression (expr=\"%s\") => SBValue(%p) (execution result=%d)", frame, expr, expr_value_sp.get(), exe_results); #endif return expr_result; }
SBExpressionOptions::SBExpressionOptions(const SBExpressionOptions &rhs) { m_opaque_ap.reset(new EvaluateExpressionOptions()); *(m_opaque_ap.get()) = rhs.ref(); }