当前位置: 首页>>代码示例>>C++>>正文


C++ CommandReturnObject::AppendError方法代码示例

本文整理汇总了C++中CommandReturnObject::AppendError方法的典型用法代码示例。如果您正苦于以下问题:C++ CommandReturnObject::AppendError方法的具体用法?C++ CommandReturnObject::AppendError怎么用?C++ CommandReturnObject::AppendError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommandReturnObject的用法示例。


在下文中一共展示了CommandReturnObject::AppendError方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static bool
CheckTargetForWatchpointOperations(Target *target, CommandReturnObject &result)
{
    if (target == NULL)
    {
        result.AppendError ("Invalid target.  No existing target or watchpoints.");
        result.SetStatus (eReturnStatusFailed);
        return false;
    }
    bool process_is_valid = target->GetProcessSP() && target->GetProcessSP()->IsAlive();
    if (!process_is_valid)
    {
        result.AppendError ("Thre's no process or it is not alive.");
        result.SetStatus (eReturnStatusFailed);
        return false;
    }
    // Target passes our checks, return true.
    return true;
}
开发者ID:,项目名称:,代码行数:19,代码来源:

示例2:

void 
ScriptInterpreter::CollectDataForWatchpointCommandCallback 
(
    WatchpointOptions *bp_options,
    CommandReturnObject &result
)
{
    result.SetStatus (eReturnStatusFailed);
    result.AppendError ("ScriptInterpreter::GetScriptCommands(StringList &) is not implemented.");
}
开发者ID:CODECOMMUNITY,项目名称:lldb,代码行数:10,代码来源:ScriptInterpreter.cpp

示例3: DoExecute

  bool DoExecute(Args &command, CommandReturnObject &result) override {
    DataExtractor reg_data;
    RegisterContext *reg_ctx = m_exe_ctx.GetRegisterContext();

    if (command.GetArgumentCount() != 2) {
      result.AppendError(
          "register write takes exactly 2 arguments: <reg-name> <value>");
      result.SetStatus(eReturnStatusFailed);
    } else {
      const char *reg_name = command.GetArgumentAtIndex(0);
      const char *value_str = command.GetArgumentAtIndex(1);

      // in most LLDB commands we accept $rbx as the name for register RBX - and
      // here we would
      // reject it and non-existant. we should be more consistent towards the
      // user and allow them
      // to say reg write $rbx - internally, however, we should be strict and
      // not allow ourselves
      // to call our registers $rbx in our own API
      if (reg_name && *reg_name == '$')
        reg_name = reg_name + 1;

      const RegisterInfo *reg_info = reg_ctx->GetRegisterInfoByName(reg_name);

      if (reg_info) {
        RegisterValue reg_value;

        Error error(reg_value.SetValueFromCString(reg_info, value_str));
        if (error.Success()) {
          if (reg_ctx->WriteRegister(reg_info, reg_value)) {
            // Toss all frames and anything else in the thread
            // after a register has been written.
            m_exe_ctx.GetThreadRef().Flush();
            result.SetStatus(eReturnStatusSuccessFinishNoResult);
            return true;
          }
        }
        if (error.AsCString()) {
          result.AppendErrorWithFormat(
              "Failed to write register '%s' with value '%s': %s\n", reg_name,
              value_str, error.AsCString());
        } else {
          result.AppendErrorWithFormat(
              "Failed to write register '%s' with value '%s'", reg_name,
              value_str);
        }
        result.SetStatus(eReturnStatusFailed);
      } else {
        result.AppendErrorWithFormat("Register not found for '%s'.\n",
                                     reg_name);
        result.SetStatus(eReturnStatusFailed);
      }
    }
    return result.Succeeded();
  }
开发者ID:efcs,项目名称:lldb,代码行数:55,代码来源:CommandObjectRegister.cpp

示例4:

 bool
 Execute
 (
     Args& args,
     CommandReturnObject &result
 )
 {
     result.AppendError ("Not yet implemented");
     result.SetStatus (eReturnStatusFailed);
     return false;
 }
开发者ID:eightcien,项目名称:lldb,代码行数:11,代码来源:CommandObjectSource.cpp

示例5: DoExecute

  bool DoExecute(Args &command, CommandReturnObject &result) override {
    Target *target = GetSelectedOrDummyTarget();

    if (!target->GetCollectingStats()) {
      result.AppendError("need to enable statistics before disabling them");
      result.SetStatus(eReturnStatusFailed);
      return false;
    }

    target->SetCollectingStats(false);
    result.SetStatus(eReturnStatusSuccessFinishResult);
    return true;
  }
开发者ID:llvm-project,项目名称:lldb,代码行数:13,代码来源:CommandObjectStats.cpp

示例6: DoExecute

  bool DoExecute(Args &command, CommandReturnObject &result) override {
    size_t argc = command.GetArgumentCount();

    if (argc != 1) {
      result.AppendError("'plugin load' requires one argument");
      result.SetStatus(eReturnStatusFailed);
      return false;
    }

    Status error;

    FileSpec dylib_fspec(command[0].ref, true);

    if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error))
      result.SetStatus(eReturnStatusSuccessFinishResult);
    else {
      result.AppendError(error.AsCString());
      result.SetStatus(eReturnStatusFailed);
    }

    return result.Succeeded();
  }
开发者ID:2trill2spill,项目名称:freebsd,代码行数:22,代码来源:CommandObjectPlugin.cpp

示例7: platform_sp

 virtual bool
 DoExecute (Args& args, CommandReturnObject &result)
 {
     if (args.GetArgumentCount() == 1)
     {
         const char *platform_name = args.GetArgumentAtIndex (0);
         if (platform_name && platform_name[0])
         {
             const bool select = true;
             m_platform_options.SetPlatformName (platform_name);
             Error error;
             ArchSpec platform_arch;
             PlatformSP platform_sp (m_platform_options.CreatePlatformWithOptions (m_interpreter, ArchSpec(), select, error, platform_arch));
             if (platform_sp)
             {
                 platform_sp->GetStatus (result.GetOutputStream());
                 result.SetStatus (eReturnStatusSuccessFinishResult);
             }
             else
             {
                 result.AppendError(error.AsCString());
                 result.SetStatus (eReturnStatusFailed);
             }
         }
         else
         {
             result.AppendError ("invalid platform name");
             result.SetStatus (eReturnStatusFailed);
         }
     }
     else
     {
         result.AppendError ("platform create takes a platform name as an argument\n");
         result.SetStatus (eReturnStatusFailed);
     }
     return result.Succeeded();
 }
开发者ID:jevinskie,项目名称:llvm-lldb,代码行数:37,代码来源:CommandObjectPlatform.cpp

示例8: GetOptions

bool
CommandObject::ParseOptions
(
    Args& args,
    CommandReturnObject &result
)
{
    // See if the subclass has options?
    Options *options = GetOptions();
    if (options != NULL)
    {
        Error error;
        options->NotifyOptionParsingStarting();

        // ParseOptions calls getopt_long, which always skips the zero'th item in the array and starts at position 1,
        // so we need to push a dummy value into position zero.
        args.Unshift("dummy_string");
        error = args.ParseOptions (*options);

        // The "dummy_string" will have already been removed by ParseOptions,
        // so no need to remove it.

        if (error.Success())
            error = options->NotifyOptionParsingFinished();

        if (error.Success())
        {
            if (options->VerifyOptions (result))
                return true;
        }
        else
        {
            const char *error_cstr = error.AsCString();
            if (error_cstr)
            {
                // We got an error string, lets use that
                result.AppendError(error_cstr);
            }
            else
            {
                // No error string, output the usage information into result
                options->GenerateOptionUsage (result.GetErrorStream(), this);
            }
        }
        result.SetStatus (eReturnStatusFailed);
        return false;
    }
    return true;
}
开发者ID:filcab,项目名称:lldb,代码行数:49,代码来源:CommandObject.cpp

示例9:

bool
CommandObjectVersion::DoExecute (Args& args, CommandReturnObject &result)
{
    if (args.GetArgumentCount() == 0)
    {
        result.AppendMessageWithFormat ("%s\n", lldb_private::GetVersion());
        result.SetStatus (eReturnStatusSuccessFinishResult);
    }
    else
    {
        result.AppendError("the version command takes no arguments.");
        result.SetStatus (eReturnStatusFailed);
    }
    return true;
}
开发者ID:Aj0Ay,项目名称:lldb,代码行数:15,代码来源:CommandObjectVersion.cpp

示例10: ProcessAliasOptionsArgs

static bool ProcessAliasOptionsArgs(lldb::CommandObjectSP &cmd_obj_sp,
                                    const char *options_args,
                                    OptionArgVectorSP &option_arg_vector_sp) {
  bool success = true;
  OptionArgVector *option_arg_vector = option_arg_vector_sp.get();

  if (!options_args || (strlen(options_args) < 1))
    return true;

  std::string options_string(options_args);
  Args args(options_args);
  CommandReturnObject result;
  // Check to see if the command being aliased can take any command options.
  Options *options = cmd_obj_sp->GetOptions();
  if (options) {
    // See if any options were specified as part of the alias;  if so, handle
    // them appropriately.
    ExecutionContext exe_ctx =
        cmd_obj_sp->GetCommandInterpreter().GetExecutionContext();
    options->NotifyOptionParsingStarting(&exe_ctx);
    args.Unshift("dummy_arg");
    args.ParseAliasOptions(*options, result, option_arg_vector, options_string);
    args.Shift();
    if (result.Succeeded())
      options->VerifyPartialOptions(result);
    if (!result.Succeeded() &&
        result.GetStatus() != lldb::eReturnStatusStarted) {
      result.AppendError("Unable to create requested alias.\n");
      return false;
    }
  }

  if (!options_string.empty()) {
    if (cmd_obj_sp->WantsRawCommandString())
      option_arg_vector->push_back(
          OptionArgPair("<argument>", OptionArgValue(-1, options_string)));
    else {
      const size_t argc = args.GetArgumentCount();
      for (size_t i = 0; i < argc; ++i)
        if (strcmp(args.GetArgumentAtIndex(i), "") != 0)
          option_arg_vector->push_back(OptionArgPair(
              "<argument>",
              OptionArgValue(-1, std::string(args.GetArgumentAtIndex(i)))));
    }
  }

  return success;
}
开发者ID:karwa,项目名称:swift-lldb,代码行数:48,代码来源:CommandAlias.cpp

示例11: new_command

bool
CommandObjectRegexCommand::DoExecute
(
    const char *command,
    CommandReturnObject &result
)
{
    if (command)
    {
        EntryCollection::const_iterator pos, end = m_entries.end();
        for (pos = m_entries.begin(); pos != end; ++pos)
        {
            if (pos->regex.Execute (command, m_max_matches))
            {
                std::string new_command(pos->command);
                std::string match_str;
                char percent_var[8];
                size_t idx, percent_var_idx;
                for (uint32_t match_idx=1; match_idx <= m_max_matches; ++match_idx)
                {
                    if (pos->regex.GetMatchAtIndex (command, match_idx, match_str))
                    {
                        const int percent_var_len = ::snprintf (percent_var, sizeof(percent_var), "%%%u", match_idx);
                        for (idx = 0; (percent_var_idx = new_command.find(percent_var, idx)) != std::string::npos; )
                        {
                            new_command.erase(percent_var_idx, percent_var_len);
                            new_command.insert(percent_var_idx, match_str);
                            idx += percent_var_idx + match_str.size();
                        }
                    }
                }
                // Interpret the new command and return this as the result!
                result.GetOutputStream().Printf("%s\n", new_command.c_str());
                return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result);
            }
        }
        result.SetStatus(eReturnStatusFailed);
        result.AppendErrorWithFormat ("Command contents '%s' failed to match any regular expression in the '%s' regex command.\n",
                                      command,
                                      m_cmd_name.c_str());
        return false;
    }
    result.AppendError("empty command passed to regular expression command");
    result.SetStatus(eReturnStatusFailed);
    return false;
}
开发者ID:ztianjin,项目名称:lldb,代码行数:46,代码来源:CommandObjectRegexCommand.cpp

示例12: io_handler_sp

bool
CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
{
    if (args.GetArgumentCount() == 0)
    {
        Debugger &debugger = m_interpreter.GetDebugger();
        IOHandlerSP io_handler_sp (new IOHandlerCursesGUI (debugger));
        if (io_handler_sp)
            debugger.PushIOHandler(io_handler_sp);
        result.SetStatus (eReturnStatusSuccessFinishResult);
    }
    else
    {
        result.AppendError("the gui command takes no arguments.");
        result.SetStatus (eReturnStatusFailed);
    }
    return true;
}
开发者ID:czchen,项目名称:lldb,代码行数:18,代码来源:CommandObjectGUI.cpp

示例13: exe_ctx

 bool
 DoExecute (Args& command,
          CommandReturnObject &result)
 {
     ExecutionContext exe_ctx(m_interpreter.GetExecutionContext());
     StackFrame *frame = exe_ctx.GetFramePtr();
     if (frame)
     {
         frame->DumpUsingSettingsFormat (&result.GetOutputStream());
         result.SetStatus (eReturnStatusSuccessFinishResult);
     }
     else
     {
         result.AppendError ("no current frame");
         result.SetStatus (eReturnStatusFailed);
     }
     return result.Succeeded();
 }
开发者ID:filcab,项目名称:lldb,代码行数:18,代码来源:CommandObjectFrame.cpp

示例14: GetRequiredOptions

bool
Options::VerifyOptions (CommandReturnObject &result)
{
    bool options_are_valid = false;

    int num_levels = GetRequiredOptions().size();
    if (num_levels)
    {
        for (int i = 0; i < num_levels && !options_are_valid; ++i)
        {
            // This is the correct set of options if:  1). m_seen_options contains all of m_required_options[i]
            // (i.e. all the required options at this level are a subset of m_seen_options); AND
            // 2). { m_seen_options - m_required_options[i] is a subset of m_options_options[i] (i.e. all the rest of
            // m_seen_options are in the set of optional options at this level.

            // Check to see if all of m_required_options[i] are a subset of m_seen_options
            if (IsASubset (GetRequiredOptions()[i], m_seen_options))
            {
                // Construct the set difference: remaining_options = {m_seen_options} - {m_required_options[i]}
                OptionSet remaining_options;
                OptionsSetDiff (m_seen_options, GetRequiredOptions()[i], remaining_options);
                // Check to see if remaining_options is a subset of m_optional_options[i]
                if (IsASubset (remaining_options, GetOptionalOptions()[i]))
                    options_are_valid = true;
            }
        }
    }
    else
    {
        options_are_valid = true;
    }

    if (options_are_valid)
    {
        result.SetStatus (eReturnStatusSuccessFinishNoResult);
    }
    else
    {
        result.AppendError ("invalid combination of options for the given command");
        result.SetStatus (eReturnStatusFailed);
    }

    return options_are_valid;
}
开发者ID:2asoft,项目名称:freebsd,代码行数:44,代码来源:Options.cpp

示例15: if

    virtual bool
    Execute (CommandInterpreter &interpreter, 
             Args& args,
             CommandReturnObject &result)
    {
        const size_t argc = args.GetArgumentCount();
        result.SetStatus(eReturnStatusFailed);

        if (argc == 1)
        {
            const char *sub_command = args.GetArgumentAtIndex(0);

            if (strcasecmp(sub_command, "enable") == 0)
            {
                Timer::SetDisplayDepth (UINT32_MAX);
                result.SetStatus(eReturnStatusSuccessFinishNoResult);
            }
            else if (strcasecmp(sub_command, "disable") == 0)
            {
                Timer::DumpCategoryTimes (&result.GetOutputStream());
                Timer::SetDisplayDepth (0);
                result.SetStatus(eReturnStatusSuccessFinishResult);
            }
            else if (strcasecmp(sub_command, "dump") == 0)
            {
                Timer::DumpCategoryTimes (&result.GetOutputStream());
                result.SetStatus(eReturnStatusSuccessFinishResult);
            }
            else if (strcasecmp(sub_command, "reset") == 0)
            {
                Timer::ResetCategoryTimes ();
                result.SetStatus(eReturnStatusSuccessFinishResult);
            }

        }
        if (!result.Succeeded())
        {
            result.AppendError("Missing subcommand");
            result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
        }
        return result.Succeeded();
    }
开发者ID:ice799,项目名称:lldb,代码行数:42,代码来源:CommandObjectLog.cpp


注:本文中的CommandReturnObject::AppendError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。