本文整理汇总了C++中Args::GetArgumentCount方法的典型用法代码示例。如果您正苦于以下问题:C++ Args::GetArgumentCount方法的具体用法?C++ Args::GetArgumentCount怎么用?C++ Args::GetArgumentCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args::GetArgumentCount方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(ArgsTest, AppendArguments) {
Args args;
const char *argv[] = {"1", "2", nullptr};
const char *argv2[] = {"3", "4", nullptr};
args.AppendArguments(argv);
ASSERT_EQ(2u, args.GetArgumentCount());
EXPECT_STREQ("1", args.GetArgumentVector()[0]);
EXPECT_STREQ("2", args.GetArgumentVector()[1]);
EXPECT_EQ(nullptr, args.GetArgumentVector()[2]);
EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
EXPECT_STREQ("2", args.GetArgumentAtIndex(1));
args.AppendArguments(argv2);
ASSERT_EQ(4u, args.GetArgumentCount());
EXPECT_STREQ("1", args.GetArgumentVector()[0]);
EXPECT_STREQ("2", args.GetArgumentVector()[1]);
EXPECT_STREQ("3", args.GetArgumentVector()[2]);
EXPECT_STREQ("4", args.GetArgumentVector()[3]);
EXPECT_EQ(nullptr, args.GetArgumentVector()[4]);
EXPECT_STREQ("1", args.GetArgumentAtIndex(0));
EXPECT_STREQ("2", args.GetArgumentAtIndex(1));
EXPECT_STREQ("3", args.GetArgumentAtIndex(2));
EXPECT_STREQ("4", args.GetArgumentAtIndex(3));
}
示例2: DoExecute
bool DoExecute(Args &args, CommandReturnObject &result) override {
result.SetStatus(eReturnStatusFailed);
if (args.GetArgumentCount() == 1) {
llvm::StringRef sub_command = args.GetArgumentAtIndex(0);
if (sub_command.equals_lower("enable")) {
Timer::SetDisplayDepth(UINT32_MAX);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else if (sub_command.equals_lower("disable")) {
Timer::DumpCategoryTimes(&result.GetOutputStream());
Timer::SetDisplayDepth(0);
result.SetStatus(eReturnStatusSuccessFinishResult);
} else if (sub_command.equals_lower("dump")) {
Timer::DumpCategoryTimes(&result.GetOutputStream());
result.SetStatus(eReturnStatusSuccessFinishResult);
} else if (sub_command.equals_lower("reset")) {
Timer::ResetCategoryTimes();
result.SetStatus(eReturnStatusSuccessFinishResult);
}
} else if (args.GetArgumentCount() == 2) {
llvm::StringRef sub_command = args.GetArgumentAtIndex(0);
llvm::StringRef param = args.GetArgumentAtIndex(1);
if (sub_command.equals_lower("enable")) {
uint32_t depth;
if (param.consumeInteger(0, depth)) {
result.AppendError(
"Could not convert enable depth to an unsigned integer.");
} else {
Timer::SetDisplayDepth(depth);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
} else if (sub_command.equals_lower("increment")) {
bool success;
bool increment = Args::StringToBoolean(param, false, &success);
if (success) {
Timer::SetQuiet(!increment);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
} else
result.AppendError("Could not convert increment value to boolean.");
}
}
if (!result.Succeeded()) {
result.AppendError("Missing subcommand");
result.AppendErrorWithFormat("Usage: %s\n", m_cmd_syntax.c_str());
}
return result.Succeeded();
}
示例3: AppendArgument
void
Args::AppendArguments (const Args &rhs)
{
const size_t rhs_argc = rhs.GetArgumentCount();
for (size_t i=0; i<rhs_argc; ++i)
AppendArgument(rhs.GetArgumentAtIndex(i));
}
示例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
}
示例5: Error
Error
PlatformAndroidRemoteGDBServer::ConnectRemote (Args& args)
{
m_device_id.clear();
if (args.GetArgumentCount() != 1)
return Error("\"platform connect\" takes a single argument: <connect-url>");
int port;
std::string scheme, host, path;
const char *url = args.GetArgumentAtIndex (0);
if (!url)
return Error("URL is null.");
if (!UriParser::Parse (url, scheme, host, port, path))
return Error("Invalid URL: %s", url);
if (scheme == "adb")
m_device_id = host;
Error error = ForwardPortWithAdb(port, m_device_id);
if (error.Fail())
return error;
m_port_forwards[g_remote_platform_pid] = port;
error = PlatformRemoteGDBServer::ConnectRemote(args);
if (error.Fail ())
DeleteForwardPort (g_remote_platform_pid);
return error;
}
示例6: void
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();
}
示例7: if
void
LogChannelDWARF::Disable (Args &categories, Stream *feedback_strm)
{
if (!m_log_sp)
return;
g_log_channel = this;
uint32_t flag_bits = m_log_sp->GetMask().Get();
const size_t argc = categories.GetArgumentCount();
for (size_t i = 0; i < argc; ++i)
{
const char *arg = categories.GetArgumentAtIndex(i);
if (::strcasecmp (arg, "all") == 0 ) flag_bits &= ~DWARF_LOG_ALL;
else if (::strcasecmp (arg, "info") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_INFO;
else if (::strcasecmp (arg, "line") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_LINE;
else if (::strcasecmp (arg, "pubnames") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_PUBNAMES;
else if (::strcasecmp (arg, "pubtypes") == 0 ) flag_bits &= ~DWARF_LOG_DEBUG_PUBTYPES;
else if (::strcasecmp (arg, "default") == 0 ) flag_bits &= ~DWARF_LOG_DEFAULT;
else
{
feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
ListCategories (feedback_strm);
}
}
if (flag_bits == 0)
Delete ();
else
m_log_sp->GetMask().Reset (flag_bits);
return;
}
示例8: channel
virtual bool
DoExecute (Args& args,
CommandReturnObject &result)
{
if (args.GetArgumentCount() < 2)
{
result.AppendErrorWithFormat("%s takes a log channel and one or more log types.\n", m_cmd_name.c_str());
}
else
{
std::string channel(args.GetArgumentAtIndex(0));
args.Shift (); // Shift off the channel
char log_file[PATH_MAX];
if (m_options.log_file)
m_options.log_file.GetPath(log_file, sizeof(log_file));
else
log_file[0] = '\0';
bool success = m_interpreter.GetDebugger().EnableLog (channel.c_str(),
args.GetConstArgumentVector(),
log_file,
m_options.log_options,
result.GetErrorStream());
if (success)
result.SetStatus (eReturnStatusSuccessFinishNoResult);
else
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例9: exe_ctx
virtual bool
Execute
(
Args& command,
CommandReturnObject &result
)
{
DataExtractor reg_data;
ExecutionContext exe_ctx(m_interpreter.GetDebugger().GetExecutionContext());
RegisterContext *reg_context = exe_ctx.GetRegisterContext ();
if (reg_context)
{
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);
const RegisterInfo *reg_info = reg_context->GetRegisterInfoByName(reg_name);
if (reg_info)
{
Scalar scalar;
Error error(scalar.SetValueFromCString (value_str, reg_info->encoding, reg_info->byte_size));
if (error.Success())
{
if (reg_context->WriteRegisterValue(reg_info->kinds[eRegisterKindLLDB], scalar))
{
result.SetStatus (eReturnStatusSuccessFinishNoResult);
return true;
}
}
else
{
result.AppendErrorWithFormat ("Failed to write register '%s' with value '%s': %s\n",
reg_name,
value_str,
error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
result.AppendErrorWithFormat ("Register not found for '%s'.\n", reg_name);
result.SetStatus (eReturnStatusFailed);
}
}
}
else
{
result.AppendError ("no current frame");
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例10:
Error ObjCLanguageRuntime::ObjCExceptionPrecondition::ConfigurePrecondition(
Args &args) {
Error error;
if (args.GetArgumentCount() > 0)
error.SetErrorString(
"The ObjC Exception breakpoint doesn't support extra options.");
return error;
}
示例11: log
LogSP
ProcessPOSIXLog::EnableLog (StreamSP &log_stream_sp, uint32_t log_options, Args &args, Stream *feedback_strm)
{
// Try see if there already is a log - that way we can reuse its settings.
// We could reuse the log in toto, but we don't know that the stream is the same.
uint32_t flag_bits = 0;
LogSP log(GetLog ());
if (log)
flag_bits = log->GetMask().Get();
// Now make a new log with this stream if one was provided
if (log_stream_sp)
{
log = make_shared<Log>(log_stream_sp);
GetLog () = log;
}
if (log)
{
bool got_unknown_category = false;
const size_t argc = args.GetArgumentCount();
for (size_t i=0; i<argc; ++i)
{
const char *arg = args.GetArgumentAtIndex(i);
if (::strcasecmp (arg, "all") == 0 ) flag_bits |= POSIX_LOG_ALL;
else if (::strcasecmp (arg, "async") == 0 ) flag_bits |= POSIX_LOG_ASYNC;
else if (::strncasecmp (arg, "break", 5) == 0 ) flag_bits |= POSIX_LOG_BREAKPOINTS;
else if (::strncasecmp (arg, "comm", 4) == 0 ) flag_bits |= POSIX_LOG_COMM;
else if (::strcasecmp (arg, "default") == 0 ) flag_bits |= POSIX_LOG_DEFAULT;
else if (::strcasecmp (arg, "packets") == 0 ) flag_bits |= POSIX_LOG_PACKETS;
else if (::strcasecmp (arg, "memory") == 0 ) flag_bits |= POSIX_LOG_MEMORY;
else if (::strcasecmp (arg, "data-short") == 0 ) flag_bits |= POSIX_LOG_MEMORY_DATA_SHORT;
else if (::strcasecmp (arg, "data-long") == 0 ) flag_bits |= POSIX_LOG_MEMORY_DATA_LONG;
else if (::strcasecmp (arg, "process") == 0 ) flag_bits |= POSIX_LOG_PROCESS;
else if (::strcasecmp (arg, "ptrace") == 0 ) flag_bits |= POSIX_LOG_PTRACE;
else if (::strcasecmp (arg, "registers") == 0 ) flag_bits |= POSIX_LOG_REGISTERS;
else if (::strcasecmp (arg, "step") == 0 ) flag_bits |= POSIX_LOG_STEP;
else if (::strcasecmp (arg, "thread") == 0 ) flag_bits |= POSIX_LOG_THREAD;
else if (::strcasecmp (arg, "verbose") == 0 ) flag_bits |= POSIX_LOG_VERBOSE;
else if (::strncasecmp (arg, "watch", 5) == 0 ) flag_bits |= POSIX_LOG_WATCHPOINTS;
else
{
feedback_strm->Printf("error: unrecognized log category '%s'\n", arg);
if (got_unknown_category == false)
{
got_unknown_category = true;
ListLogCategories (feedback_strm);
}
}
}
if (flag_bits == 0)
flag_bits = POSIX_LOG_DEFAULT;
log->GetMask().Reset(flag_bits);
log->GetOptions().Reset(log_options);
}
return log;
}
示例12: platform_sp
virtual bool
DoExecute (Args& args, CommandReturnObject &result)
{
PlatformSP platform_sp (m_interpreter.GetDebugger().GetPlatformList().GetSelectedPlatform());
if (platform_sp)
{
if (args.GetArgumentCount() == 0)
{
Error error;
if (platform_sp->IsConnected())
{
// Cache the instance name if there is one since we are
// about to disconnect and the name might go with it.
const char *hostname_cstr = platform_sp->GetHostname();
std::string hostname;
if (hostname_cstr)
hostname.assign (hostname_cstr);
error = platform_sp->DisconnectRemote ();
if (error.Success())
{
Stream &ostrm = result.GetOutputStream();
if (hostname.empty())
ostrm.Printf ("Disconnected from \"%s\"\n", platform_sp->GetShortPluginName());
else
ostrm.Printf ("Disconnected from \"%s\"\n", hostname.c_str());
result.SetStatus (eReturnStatusSuccessFinishResult);
}
else
{
result.AppendErrorWithFormat ("%s", error.AsCString());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
// Not connected...
result.AppendErrorWithFormat ("not connected to '%s'", platform_sp->GetShortPluginName());
result.SetStatus (eReturnStatusFailed);
}
}
else
{
// Bad args
result.AppendError ("\"platform disconnect\" doesn't take any arguments");
result.SetStatus (eReturnStatusFailed);
}
}
else
{
result.AppendError ("no platform is currently selected");
result.SetStatus (eReturnStatusFailed);
}
return result.Succeeded();
}
示例13: DoExecute
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be disabled.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
// No watchpoint selected; disable all currently set watchpoints.
if (target->DisableAllWatchpoints())
{
result.AppendMessageWithFormat("All watchpoints disabled. (%zu watchpoints)\n", num_watchpoints);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
else
{
result.AppendError("Disable all watchpoints failed\n");
result.SetStatus(eReturnStatusFailed);
}
}
else
{
// Particular watchpoints selected; disable them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
if (target->DisableWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints disabled.\n", count);
result.SetStatus(eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例14: DoExecute
virtual bool
DoExecute (Args& command, CommandReturnObject &result)
{
Target *target = m_interpreter.GetDebugger().GetSelectedTarget().get();
if (!CheckTargetForWatchpointOperations(target, result))
return false;
Mutex::Locker locker;
target->GetWatchpointList().GetListMutex(locker);
const WatchpointList &watchpoints = target->GetWatchpointList();
size_t num_watchpoints = watchpoints.GetSize();
if (num_watchpoints == 0)
{
result.AppendError("No watchpoints exist to be deleted.");
result.SetStatus(eReturnStatusFailed);
return false;
}
if (command.GetArgumentCount() == 0)
{
if (!m_interpreter.Confirm("About to delete all watchpoints, do you want to do that?", true))
{
result.AppendMessage("Operation cancelled...");
}
else
{
target->RemoveAllWatchpoints();
result.AppendMessageWithFormat("All watchpoints removed. (%" PRIu64 " watchpoints)\n", (uint64_t)num_watchpoints);
}
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
else
{
// Particular watchpoints selected; delete them.
std::vector<uint32_t> wp_ids;
if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(target, command, wp_ids))
{
result.AppendError("Invalid watchpoints specification.");
result.SetStatus(eReturnStatusFailed);
return false;
}
int count = 0;
const size_t size = wp_ids.size();
for (size_t i = 0; i < size; ++i)
if (target->RemoveWatchpointByID(wp_ids[i]))
++count;
result.AppendMessageWithFormat("%d watchpoints deleted.\n",count);
result.SetStatus (eReturnStatusSuccessFinishNoResult);
}
return result.Succeeded();
}
示例15: 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();
}