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


C++ CommandReturnObject类代码示例

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


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

示例1: VerifyOptions

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:CodaFi,项目名称:swift-lldb,代码行数:41,代码来源:Options.cpp

示例2: DoExecute

 bool
 DoExecute (Args& command, CommandReturnObject &result)
 {
     typedef void (*LLDBCommandPluginInit) (lldb::SBDebugger debugger);
     
     size_t argc = command.GetArgumentCount();
     
     if (argc != 1)
     {
         result.AppendError ("'plugin load' requires one argument");
         result.SetStatus (eReturnStatusFailed);
         return false;
     }
     
     const char* path = command.GetArgumentAtIndex(0);
     
     Error error;
     
     FileSpec dylib_fspec(path,true);
     
     if (m_interpreter.GetDebugger().LoadPlugin(dylib_fspec, error))
         result.SetStatus(eReturnStatusSuccessFinishResult);
     else
     {
         result.AppendError(error.AsCString());
         result.SetStatus(eReturnStatusFailed);
     }
     
     return result.Succeeded();
 }
开发者ID:ChaosJohn,项目名称:freebsd,代码行数:30,代码来源:CommandObjectPlugin.cpp

示例3: DoExecute

  bool DoExecute(Args &command, CommandReturnObject &result) override {
    Thread *thread = m_exe_ctx.GetThreadPtr();
    StackFrameSP frame_sp = thread->GetSelectedFrame();

    ValueObjectSP valobj_sp;

    if (m_options.address.hasValue()) {
      if (m_options.reg.hasValue() || m_options.offset.hasValue()) {
        result.AppendError(
            "`frame diagnose --address` is incompatible with other arguments.");
        result.SetStatus(eReturnStatusFailed);
        return false;
      }
      valobj_sp = frame_sp->GuessValueForAddress(m_options.address.getValue());
    } else if (m_options.reg.hasValue()) {
      valobj_sp = frame_sp->GuessValueForRegisterAndOffset(
          m_options.reg.getValue(), m_options.offset.getValueOr(0));
    } else {
      StopInfoSP stop_info_sp = thread->GetStopInfo();
      if (!stop_info_sp) {
        result.AppendError("No arguments provided, and no stop info.");
        result.SetStatus(eReturnStatusFailed);
        return false;
      }

      valobj_sp = StopInfo::GetCrashingDereference(stop_info_sp);
    }

    if (!valobj_sp) {
      result.AppendError("No diagnosis available.");
      result.SetStatus(eReturnStatusFailed);
      return false;
    }

    const bool qualify_cxx_base_classes = false;

    DumpValueObjectOptions::DeclPrintingHelper helper =
        [&valobj_sp, qualify_cxx_base_classes](
            ConstString type, ConstString var,
            const DumpValueObjectOptions &opts, Stream &stream) -> bool {
      const ValueObject::GetExpressionPathFormat format = ValueObject::
          GetExpressionPathFormat::eGetExpressionPathFormatHonorPointers;
      valobj_sp->GetExpressionPath(stream, qualify_cxx_base_classes, format);
      stream.PutCString(" =");
      return true;
    };

    DumpValueObjectOptions options;
    options.SetDeclPrintingHelper(helper);
    ValueObjectPrinter printer(valobj_sp.get(), &result.GetOutputStream(),
                               options);
    printer.PrintValueObject();

    return true;
  }
开发者ID:efcs,项目名称:lldb,代码行数:55,代码来源:CommandObjectFrame.cpp

示例4: io_handler_sp

bool
CommandObjectGUI::DoExecute (Args& args, CommandReturnObject &result)
{
#ifndef LLDB_DISABLE_CURSES
    if (args.GetArgumentCount() == 0)
    {
        Debugger &debugger = m_interpreter.GetDebugger();

        lldb::StreamFileSP input_sp = debugger.GetInputFile();
        if (input_sp &&
            input_sp->GetFile().GetIsRealTerminal() &&
            input_sp->GetFile().GetIsInteractive())
        {
            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 requires an interactive terminal.");
            result.SetStatus (eReturnStatusFailed);
        }
    }
    else
    {
        result.AppendError("the gui command takes no arguments.");
        result.SetStatus (eReturnStatusFailed);
    }
    return true;
#else
    result.AppendError("lldb was not build with gui support");
    return false;
#endif
}
开发者ID:CODECOMMUNITY,项目名称:lldb,代码行数:35,代码来源:CommandObjectGUI.cpp

示例5: DoExecute

 bool
 DoExecute(Args& command, CommandReturnObject &result) override
 {
     bool demangled_any = false;
     bool error_any = false;
     for (size_t i = 0; i < command.GetArgumentCount(); i++)
     {
         auto arg = command.GetArgumentAtIndex(i);
         if (arg && *arg)
         {
             ConstString mangled_cs(arg);
             
             // the actual Mangled class should be strict about this, but on the command line
             // if you're copying mangled names out of 'nm' on Darwin, they will come out with
             // an extra underscore - be willing to strip this on behalf of the user
             // This is the moral equivalent of the -_/-n options to c++filt
             if (mangled_cs.GetStringRef().startswith("__Z"))
                 mangled_cs.SetCString(arg+1);
             
             Mangled mangled(mangled_cs, true);
             if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus)
             {
                 ConstString demangled(mangled.GetDisplayDemangledName(lldb::eLanguageTypeC_plus_plus));
                 demangled_any = true;
                 result.AppendMessageWithFormat("%s ---> %s\n", arg, demangled.GetCString());
             }
             else
             {
                 error_any = true;
                 result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n", arg);
             }
         }
     }
     
     result.SetStatus(error_any ? lldb::eReturnStatusFailed :
                      (demangled_any ? lldb::eReturnStatusSuccessFinishResult : lldb::eReturnStatusSuccessFinishNoResult));
     return result.Succeeded();
 }
开发者ID:Mr-Kumar-Abhishek,项目名称:swift-lldb,代码行数:38,代码来源:ItaniumABILanguageRuntime.cpp

示例6:

bool
CommandObjectShow::Execute
(
    CommandInterpreter &interpreter,
    Args& command,
    CommandReturnObject &result
)
{
    CommandInterpreter::VariableMap::iterator pos;

    if (command.GetArgumentCount())
    {
        // The user requested to see the value of a particular variable.

        const char *var_name = command.GetArgumentAtIndex(0);
        StateVariable *var = interpreter.GetStateVariable(var_name);
        if (var)
        {
            var->AppendVariableInformation (result);
            result.SetStatus (eReturnStatusSuccessFinishNoResult);
        }
        else
        {
            result.AppendErrorWithFormat ("Unrecognized variable '%s'; cannot do 'show' command.\n", var_name);
            result.SetStatus (eReturnStatusFailed);
        }
    }
    else
    {
        // The user didn't specify a particular variable, so show the values of all of them.
        interpreter.ShowVariableValues(result);
        result.SetStatus (eReturnStatusSuccessFinishNoResult);
    }

    return result.Succeeded();
}
开发者ID:ice799,项目名称:lldb,代码行数:36,代码来源:CommandObjectShow.cpp

示例7: DoExecute

  bool DoExecute(Args &command, CommandReturnObject &result) override {
    bool demangled_any = false;
    bool error_any = false;
    for (auto &entry : command.entries()) {
      if (entry.ref.empty())
        continue;

      // the actual Mangled class should be strict about this, but on the
      // command line if you're copying mangled names out of 'nm' on Darwin,
      // they will come out with an extra underscore - be willing to strip
      // this on behalf of the user.   This is the moral equivalent of the -_/-n
      // options to c++filt
      auto name = entry.ref;
      if (name.startswith("__Z"))
        name = name.drop_front();

      Mangled mangled(name, true);
      if (mangled.GuessLanguage() == lldb::eLanguageTypeC_plus_plus) {
        ConstString demangled(
            mangled.GetDisplayDemangledName(lldb::eLanguageTypeC_plus_plus));
        demangled_any = true;
        result.AppendMessageWithFormat("%s ---> %s\n", entry.ref.str().c_str(),
                                       demangled.GetCString());
      } else {
        error_any = true;
        result.AppendErrorWithFormat("%s is not a valid C++ mangled name\n",
                                     entry.ref.str().c_str());
      }
    }

    result.SetStatus(
        error_any ? lldb::eReturnStatusFailed
                  : (demangled_any ? lldb::eReturnStatusSuccessFinishResult
                                   : lldb::eReturnStatusSuccessFinishNoResult));
    return result.Succeeded();
  }
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:36,代码来源:ItaniumABILanguageRuntime.cpp

示例8: DoExecute

 bool DoExecute(Args &command, CommandReturnObject &result) override {
     Stream &stream = result.GetOutputStream();
     RenderScriptRuntime *runtime = static_cast<RenderScriptRuntime *>(
                                        m_exe_ctx.GetProcessPtr()->GetLanguageRuntime(
                                            eLanguageTypeExtRenderScript));
     assert(runtime);
     auto &target = m_exe_ctx.GetTargetSP();
     bool stop_on_all = false;
     const llvm::StringRef long_stop_all("--stop-on-all"), short_stop_all("-a");
     std::vector<ConstString> sites;
     sites.reserve(command.GetArgumentCount());
     for (size_t i = 0; i < command.GetArgumentCount(); ++i) {
         const auto arg = command.GetArgumentAtIndex(i);
         if (long_stop_all == arg || short_stop_all == arg)
             stop_on_all = true;
         else
             sites.push_back(ConstString(arg));
     }
     for (const auto &name : sites) {
         runtime->PlaceBreakpointOnScriptGroup(target, stream, name, stop_on_all);
     }
     result.SetStatus(eReturnStatusSuccessFinishResult);
     return true;
 }
开发者ID:kraj,项目名称:lldb,代码行数:24,代码来源:RenderScriptScriptGroup.cpp

示例9: 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;
}
开发者ID:filcab,项目名称:lldb,代码行数:55,代码来源:CommandObject.cpp

示例10: regex_match

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)
        {
            RegularExpression::Match regex_match(m_max_matches);

            if (pos->regex.Execute (command, &regex_match))
            {
                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 (regex_match.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!
                if (m_interpreter.GetExpandRegexAliases())
                    result.GetOutputStream().Printf("%s\n", new_command.c_str());
                // Pass in true for "no context switching".  The command that called us should have set up the context
                // appropriately, we shouldn't have to redo that.
                return m_interpreter.HandleCommand(new_command.c_str(), eLazyBoolCalculate, result, nullptr, true, true);
            }
        }
        result.SetStatus(eReturnStatusFailed);
        if (GetSyntax() != nullptr)
            result.AppendError (GetSyntax());
        else
            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:CODECOMMUNITY,项目名称:lldb,代码行数:54,代码来源:CommandObjectRegexCommand.cpp

示例11: DoExecute

 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

示例12: DoExecute

    virtual bool
    DoExecute (Args& args,
             CommandReturnObject &result)
    {
        const size_t argc = args.GetArgumentCount();
        if (argc == 0)
        {
            result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
        }
        else
        {
            Log::Callbacks log_callbacks;

            std::string channel(args.GetArgumentAtIndex(0));
            args.Shift ();  // Shift off the channel
            if (Log::GetLogChannelCallbacks (ConstString(channel.c_str()), log_callbacks))
            {
                log_callbacks.disable (args.GetConstArgumentVector(), &result.GetErrorStream());
                result.SetStatus(eReturnStatusSuccessFinishNoResult);
            }
            else if (channel == "all")
            {
                Log::DisableAllLogChannels(&result.GetErrorStream());
            }
            else
            {
                LogChannelSP log_channel_sp (LogChannel::FindPlugin(channel.c_str()));
                if (log_channel_sp)
                {
                    log_channel_sp->Disable(args.GetConstArgumentVector(), &result.GetErrorStream());
                    result.SetStatus(eReturnStatusSuccessFinishNoResult);
                }
                else
                    result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
            }
        }
        return result.Succeeded();
    }
开发者ID:CTSRD-CHERI,项目名称:lldb,代码行数:38,代码来源:CommandObjectLog.cpp

示例13: init_file

void
CommandInterpreter::SourceInitFile (bool in_cwd, CommandReturnObject &result)
{
    const char *init_file_path = in_cwd ? "./.lldbinit" : "~/.lldbinit";
    FileSpec init_file (init_file_path);
    // If the file exists, tell HandleCommand to 'source' it; this will do the actual broadcasting
    // of the commands back to any appropriate listener (see CommandObjectSource::Execute for more details).

    if (init_file.Exists())
    {
        char path[PATH_MAX];
        init_file.GetPath(path, sizeof(path));
        StreamString source_command;
        source_command.Printf ("source '%s'", path);
        HandleCommand (source_command.GetData(), false, result);
    }
    else
    {
        // nothing to be done if the file doesn't exist
        result.SetStatus(eReturnStatusSuccessFinishNoResult);
    }
}
开发者ID:ice799,项目名称:lldb,代码行数:22,代码来源:CommandInterpreter.cpp

示例14: DoExecute

  bool DoExecute(Args &command, CommandReturnObject &result) override {
    if (!command.empty()) {
      result.AppendErrorWithFormat("'%s' takes no arguments",
                                   m_cmd_name.c_str());
      return false;
    }

    auto &r = repro::Reproducer::Instance();
    if (r.GetGenerator()) {
      result.GetOutputStream() << "Reproducer is in capture mode.\n";
    } else if (r.GetLoader()) {
      result.GetOutputStream() << "Reproducer is in replay mode.\n";
    } else {
      result.GetOutputStream() << "Reproducer is off.\n";
    }

    result.SetStatus(eReturnStatusSuccessFinishResult);
    return result.Succeeded();
  }
开发者ID:,项目名称:,代码行数:19,代码来源:

示例15: 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


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