本文整理汇总了C++中Process::GetState方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::GetState方法的具体用法?C++ Process::GetState怎么用?C++ Process::GetState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::GetState方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
bool
CommandObject::CheckFlags (CommandReturnObject &result)
{
if (GetFlags().AnySet (CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
{
Process *process = m_interpreter.GetExecutionContext().GetProcessPtr();
if (process == NULL)
{
// A process that is not running is considered paused.
if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
{
result.AppendError ("Process must exist.");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
else
{
StateType state = process->GetState();
switch (state)
{
case eStateInvalid:
case eStateSuspended:
case eStateCrashed:
case eStateStopped:
break;
case eStateConnected:
case eStateAttaching:
case eStateLaunching:
case eStateDetached:
case eStateExited:
case eStateUnloaded:
if (GetFlags().Test(CommandObject::eFlagProcessMustBeLaunched))
{
result.AppendError ("Process must be launched.");
result.SetStatus (eReturnStatusFailed);
return false;
}
break;
case eStateRunning:
case eStateStepping:
if (GetFlags().Test(CommandObject::eFlagProcessMustBePaused))
{
result.AppendError ("Process is running. Use 'process interrupt' to pause execution.");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
}
}
return true;
}
示例2: ExpressionVariable
lldb::ExpressionResults
GoUserExpression::DoExecute(DiagnosticManager &diagnostic_manager,
ExecutionContext &exe_ctx,
const EvaluateExpressionOptions &options,
lldb::UserExpressionSP &shared_ptr_to_me,
lldb::ExpressionVariableSP &result) {
Log *log(lldb_private::GetLogIfAnyCategoriesSet(LIBLLDB_LOG_EXPRESSIONS |
LIBLLDB_LOG_STEP));
lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
Process *process = exe_ctx.GetProcessPtr();
Target *target = exe_ctx.GetTargetPtr();
if (target == nullptr || process == nullptr ||
process->GetState() != lldb::eStateStopped) {
if (execution_policy == eExecutionPolicyAlways) {
if (log)
log->Printf("== [GoUserExpression::Evaluate] Expression may not run, "
"but is not constant ==");
diagnostic_manager.PutCString(eDiagnosticSeverityError,
"expression needed to run but couldn't");
return execution_results;
}
}
m_interpreter->set_use_dynamic(options.GetUseDynamic());
ValueObjectSP result_val_sp = m_interpreter->Evaluate(exe_ctx);
Error err = m_interpreter->error();
m_interpreter.reset();
if (!result_val_sp) {
const char *error_cstr = err.AsCString();
if (error_cstr && error_cstr[0])
diagnostic_manager.PutCString(eDiagnosticSeverityError, error_cstr);
else
diagnostic_manager.PutCString(eDiagnosticSeverityError,
"expression can't be interpreted or run");
return lldb::eExpressionDiscarded;
}
result.reset(new ExpressionVariable(ExpressionVariable::eKindGo));
result->m_live_sp = result->m_frozen_sp = result_val_sp;
result->m_flags |= ExpressionVariable::EVIsProgramReference;
PersistentExpressionState *pv =
target->GetPersistentExpressionStateForLanguage(eLanguageTypeGo);
if (pv != nullptr) {
result->SetName(pv->GetNextPersistentVariableName());
pv->AddVariable(result);
}
return lldb::eExpressionCompleted;
}
示例3: user_expression_sp
lldb::ExpressionResults
ClangUserExpression::Evaluate (ExecutionContext &exe_ctx,
const EvaluateExpressionOptions& options,
const char *expr_cstr,
const char *expr_prefix,
lldb::ValueObjectSP &result_valobj_sp,
Error &error)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
const lldb::LanguageType language = options.GetLanguage();
const ResultType desired_type = options.DoesCoerceToId() ? ClangUserExpression::eResultTypeId : ClangUserExpression::eResultTypeAny;
lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
Process *process = exe_ctx.GetProcessPtr();
if (process == NULL || process->GetState() != lldb::eStateStopped)
{
if (execution_policy == eExecutionPolicyAlways)
{
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
error.SetErrorString ("expression needed to run but couldn't");
return execution_results;
}
}
if (process == NULL || !process->CanJIT())
execution_policy = eExecutionPolicyNever;
ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix, language, desired_type));
StreamString error_stream;
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
const bool keep_expression_in_memory = true;
const bool generate_debug_info = options.GetGenerateDebugInfo();
if (options.InvokeCancelCallback (lldb::eExpressionEvaluationParse))
{
error.SetErrorString ("expression interrupted by callback before parse");
result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
return lldb::eExpressionInterrupted;
}
if (!user_expression_sp->Parse (error_stream,
exe_ctx,
execution_policy,
keep_expression_in_memory,
generate_debug_info))
{
if (error_stream.GetString().empty())
error.SetExpressionError (lldb::eExpressionParseError, "expression failed to parse, unknown error");
else
error.SetExpressionError (lldb::eExpressionParseError, error_stream.GetString().c_str());
}
else
{
lldb::ClangExpressionVariableSP expr_result;
if (execution_policy == eExecutionPolicyNever &&
!user_expression_sp->CanInterpret())
{
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
if (error_stream.GetString().empty())
error.SetExpressionError (lldb::eExpressionSetupError, "expression needed to run but couldn't");
}
else
{
if (options.InvokeCancelCallback (lldb::eExpressionEvaluationExecution))
{
error.SetExpressionError (lldb::eExpressionInterrupted, "expression interrupted by callback before execution");
result_valobj_sp = ValueObjectConstResult::Create (exe_ctx.GetBestExecutionContextScope(), error);
return lldb::eExpressionInterrupted;
}
error_stream.GetString().clear();
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Executing expression ==");
execution_results = user_expression_sp->Execute (error_stream,
exe_ctx,
options,
user_expression_sp,
expr_result);
if (options.GetResultIsInternal())
{
process->GetTarget().GetPersistentVariables().RemovePersistentVariable (expr_result);
}
if (execution_results != lldb::eExpressionCompleted)
//.........这里部分代码省略.........
示例4: UpdateProcesses
unsigned int ProcessManager::UpdateProcesses(const float deltaMs)
{
unsigned short int successCount = 0;
unsigned short int failCount = 0;
ProcessList::iterator it = m_processList.begin();
while (it != m_processList.end())
{
Process* pCurrProcess = (*it);
ProcessList::iterator thisIt = it;
it++;
if (pCurrProcess->GetState() == Process::UNINITIALIZED)
{
pCurrProcess->VOnInit();
}
if (pCurrProcess->GetState() == Process::RUNNING)
{
pCurrProcess->VOnUpdate(deltaMs);
}
if (pCurrProcess->IsDead())
{
switch (pCurrProcess->GetState())
{
case Process::SUCCEEDED:
{
pCurrProcess->VOnSuccess();
Process* pChild = pCurrProcess->RemoveChild();
if (pChild)
{
AttachProcess(pChild);
}
else
{
successCount++;
}
break;
}
case Process::FAILED:
{
pCurrProcess->VOnFail();
failCount++;
break;
}
case Process::ABORTED:
{
pCurrProcess->VOnAbort();
failCount++;
break;
}
}
m_processList.erase(thisIt);
}
}
return ((successCount << 16) | failCount);
}
示例5: user_expression_sp
ExecutionResults
ClangUserExpression::EvaluateWithError (ExecutionContext &exe_ctx,
lldb_private::ExecutionPolicy execution_policy,
lldb::LanguageType language,
ResultType desired_type,
bool unwind_on_error,
bool ignore_breakpoints,
const char *expr_cstr,
const char *expr_prefix,
lldb::ValueObjectSP &result_valobj_sp,
Error &error,
bool run_others,
uint32_t timeout_usec)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
ExecutionResults execution_results = eExecutionSetupError;
Process *process = exe_ctx.GetProcessPtr();
if (process == NULL || process->GetState() != lldb::eStateStopped)
{
if (execution_policy == eExecutionPolicyAlways)
{
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
error.SetErrorString ("expression needed to run but couldn't");
return execution_results;
}
}
if (process == NULL || !process->CanJIT())
execution_policy = eExecutionPolicyNever;
ClangUserExpressionSP user_expression_sp (new ClangUserExpression (expr_cstr, expr_prefix, language, desired_type));
StreamString error_stream;
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
const bool keep_expression_in_memory = true;
if (!user_expression_sp->Parse (error_stream, exe_ctx, execution_policy, keep_expression_in_memory))
{
if (error_stream.GetString().empty())
error.SetErrorString ("expression failed to parse, unknown error");
else
error.SetErrorString (error_stream.GetString().c_str());
}
else
{
lldb::ClangExpressionVariableSP expr_result;
if (execution_policy == eExecutionPolicyNever &&
!user_expression_sp->CanInterpret())
{
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Expression may not run, but is not constant ==");
if (error_stream.GetString().empty())
error.SetErrorString ("expression needed to run but couldn't");
}
else
{
error_stream.GetString().clear();
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Executing expression ==");
execution_results = user_expression_sp->Execute (error_stream,
exe_ctx,
unwind_on_error,
ignore_breakpoints,
user_expression_sp,
expr_result,
run_others,
timeout_usec);
if (execution_results != eExecutionCompleted)
{
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Execution completed abnormally ==");
if (error_stream.GetString().empty())
error.SetErrorString ("expression failed to execute, unknown error");
else
error.SetErrorString (error_stream.GetString().c_str());
}
else
{
if (expr_result)
{
result_valobj_sp = expr_result->GetValueObject();
if (log)
log->Printf("== [ClangUserExpression::Evaluate] Execution completed normally with result %s ==", result_valobj_sp->GetValueAsCString());
}
//.........这里部分代码省略.........
示例6: execution_thread_pusher
lldb::ExpressionResults
UserExpression::Evaluate (ExecutionContext &exe_ctx,
const EvaluateExpressionOptions& options,
const char *expr_cstr,
const char *expr_prefix,
lldb::ValueObjectSP &result_valobj_sp,
Error &error,
uint32_t line_offset,
std::string *fixed_expression,
lldb::ModuleSP *jit_module_sp_ptr)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
lldb::LanguageType language = options.GetLanguage();
const ResultType desired_type = options.DoesCoerceToId() ? UserExpression::eResultTypeId : UserExpression::eResultTypeAny;
lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
Target *target = exe_ctx.GetTargetPtr();
if (!target)
{
if (log)
log->Printf("== [UserExpression::Evaluate] Passed a NULL target, can't run expressions.");
return lldb::eExpressionSetupError;
}
Process *process = exe_ctx.GetProcessPtr();
if (process == NULL || process->GetState() != lldb::eStateStopped)
{
if (execution_policy == eExecutionPolicyAlways)
{
if (log)
log->Printf("== [UserExpression::Evaluate] Expression may not run, but is not constant ==");
error.SetErrorString ("expression needed to run but couldn't");
return execution_results;
}
}
if (process == NULL || !process->CanJIT())
execution_policy = eExecutionPolicyNever;
// We need to set the expression execution thread here, turns out parse can call functions in the process of
// looking up symbols, which will escape the context set by exe_ctx passed to Execute.
lldb::ThreadSP thread_sp = exe_ctx.GetThreadSP();
ThreadList::ExpressionExecutionThreadPusher execution_thread_pusher(thread_sp);
const char *full_prefix = NULL;
const char *option_prefix = options.GetPrefix();
std::string full_prefix_storage;
if (expr_prefix && option_prefix)
{
full_prefix_storage.assign(expr_prefix);
full_prefix_storage.append(option_prefix);
if (!full_prefix_storage.empty())
full_prefix = full_prefix_storage.c_str();
}
else if (expr_prefix)
full_prefix = expr_prefix;
else
full_prefix = option_prefix;
// If the language was not specified in the expression command,
// set it to the language in the target's properties if
// specified, else default to the langage for the frame.
if (language == lldb::eLanguageTypeUnknown)
{
if (target->GetLanguage() != lldb::eLanguageTypeUnknown)
language = target->GetLanguage();
else if (StackFrame *frame = exe_ctx.GetFramePtr())
language = frame->GetLanguage();
}
lldb::UserExpressionSP user_expression_sp(target->GetUserExpressionForLanguage (expr_cstr,
full_prefix,
language,
desired_type,
options,
error));
if (error.Fail())
{
if (log)
log->Printf ("== [UserExpression::Evaluate] Getting expression: %s ==", error.AsCString());
return lldb::eExpressionSetupError;
}
if (log)
log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
const bool keep_expression_in_memory = true;
const bool generate_debug_info = options.GetGenerateDebugInfo();
if (options.InvokeCancelCallback (lldb::eExpressionEvaluationParse))
{
error.SetErrorString ("expression interrupted by callback before parse");
result_valobj_sp = ValueObjectConstResult::Create(exe_ctx.GetBestExecutionContextScope(), error);
return lldb::eExpressionInterrupted;
}
//.........这里部分代码省略.........
示例7: if
lldb::ExpressionResults
UserExpression::Evaluate (ExecutionContext &exe_ctx,
const EvaluateExpressionOptions& options,
const char *expr_cstr,
const char *expr_prefix,
lldb::ValueObjectSP &result_valobj_sp,
Error &error,
uint32_t line_offset,
lldb::ModuleSP *jit_module_sp_ptr)
{
Log *log(lldb_private::GetLogIfAnyCategoriesSet (LIBLLDB_LOG_EXPRESSIONS | LIBLLDB_LOG_STEP));
lldb_private::ExecutionPolicy execution_policy = options.GetExecutionPolicy();
lldb::LanguageType language = options.GetLanguage();
const ResultType desired_type = options.DoesCoerceToId() ? UserExpression::eResultTypeId : UserExpression::eResultTypeAny;
lldb::ExpressionResults execution_results = lldb::eExpressionSetupError;
Target *target = exe_ctx.GetTargetPtr();
if (!target)
{
if (log)
log->Printf("== [UserExpression::Evaluate] Passed a NULL target, can't run expressions.");
return lldb::eExpressionSetupError;
}
Process *process = exe_ctx.GetProcessPtr();
if (process == NULL || process->GetState() != lldb::eStateStopped)
{
if (execution_policy == eExecutionPolicyAlways)
{
if (log)
log->Printf("== [UserExpression::Evaluate] Expression may not run, but is not constant ==");
error.SetErrorString ("expression needed to run but couldn't");
return execution_results;
}
}
if (process == NULL || !process->CanJIT())
execution_policy = eExecutionPolicyNever;
const char *full_prefix = NULL;
const char *option_prefix = options.GetPrefix();
std::string full_prefix_storage;
if (expr_prefix && option_prefix)
{
full_prefix_storage.assign(expr_prefix);
full_prefix_storage.append(option_prefix);
if (!full_prefix_storage.empty())
full_prefix = full_prefix_storage.c_str();
}
else if (expr_prefix)
full_prefix = expr_prefix;
else
full_prefix = option_prefix;
// If the language was not specified in the expression command,
// set it to the language in the target's properties if
// specified, else default to the langage for the frame.
if (language == lldb::eLanguageTypeUnknown)
{
if (target->GetLanguage() != lldb::eLanguageTypeUnknown)
language = target->GetLanguage();
else if (StackFrame *frame = exe_ctx.GetFramePtr())
language = frame->GetLanguage();
}
// If the language was not specified in the expression command,
// set it to the language in the target's properties if
// specified, else default to the langage for the frame.
if (language == lldb::eLanguageTypeUnknown)
{
if (target->GetLanguage() != lldb::eLanguageTypeUnknown)
language = target->GetLanguage();
else if (StackFrame *frame = exe_ctx.GetFramePtr())
language = frame->GetLanguage();
}
lldb::UserExpressionSP user_expression_sp(target->GetUserExpressionForLanguage (expr_cstr,
full_prefix,
language,
desired_type,
options,
error));
if (error.Fail())
{
if (log)
log->Printf ("== [UserExpression::Evaluate] Getting expression: %s ==", error.AsCString());
return lldb::eExpressionSetupError;
}
StreamString error_stream;
if (log)
log->Printf("== [UserExpression::Evaluate] Parsing expression %s ==", expr_cstr);
const bool keep_expression_in_memory = true;
//.........这里部分代码省略.........
示例8: Execute
bool
CommandObject::ExecuteWithOptions
(
CommandInterpreter &interpreter,
Args& args,
CommandReturnObject &result
)
{
for (size_t i = 0; i < args.GetArgumentCount(); ++i)
{
const char *tmp_str = args.GetArgumentAtIndex (i);
if (tmp_str[0] == '`') // back-quote
args.ReplaceArgumentAtIndex (i, interpreter.ProcessEmbeddedScriptCommands (tmp_str));
}
Process *process = interpreter.GetDebugger().GetExecutionContext().process;
if (process == NULL)
{
if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched | CommandObject::eFlagProcessMustBePaused))
{
result.AppendError ("Process must exist.");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
else
{
StateType state = process->GetState();
switch (state)
{
case eStateAttaching:
case eStateLaunching:
case eStateSuspended:
case eStateCrashed:
case eStateStopped:
break;
case eStateDetached:
case eStateExited:
case eStateUnloaded:
if (GetFlags().IsSet(CommandObject::eFlagProcessMustBeLaunched))
{
result.AppendError ("Process must be launched.");
result.SetStatus (eReturnStatusFailed);
return false;
}
break;
case eStateRunning:
case eStateStepping:
if (GetFlags().IsSet(CommandObject::eFlagProcessMustBePaused))
{
result.AppendError ("Process is running. Use 'process interrupt' to pause execution.");
result.SetStatus (eReturnStatusFailed);
return false;
}
}
}
if (!ParseOptions (interpreter, args, result))
return false;
// Call the command-specific version of 'Execute', passing it the already processed arguments.
return Execute (interpreter, args, result);
}