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. (%" PRIu64 " watchpoints)\n", (uint64_t)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();
    }
Example #2
0
    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. (%lu watchpoints)\n", num_watchpoints);
            }
            result.SetStatus (eReturnStatusSuccessFinishNoResult);
        }
        else
        {
            // Particular watchpoints selected; delete them.
            std::vector<uint32_t> wp_ids;
            if (!CommandObjectMultiwordWatchpoint::VerifyWatchpointIDs(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();
    }
Example #3
0
    virtual bool
    Execute (CommandInterpreter &interpreter, 
             Args& args,
             CommandReturnObject &result)
    {
        const size_t argc = args.GetArgumentCount();
        if (argc == 0)
        {
            Log::ListAllLogChannels (&result.GetOutputStream());
            result.SetStatus(eReturnStatusSuccessFinishResult);
        }
        else
        {
            for (size_t i=0; i<argc; ++i)
            {
                Log::Callbacks log_callbacks;

                std::string channel(args.GetArgumentAtIndex(i));
                if (Log::GetLogChannelCallbacks (channel.c_str(), log_callbacks))
                {
                    log_callbacks.list_categories (&result.GetOutputStream());
                    result.SetStatus(eReturnStatusSuccessFinishResult);
                }
                else if (channel == "all")
                {
                    Log::ListAllLogChannels (&result.GetOutputStream());
                    result.SetStatus(eReturnStatusSuccessFinishResult);
                }
                else
                {
                    LogChannelSP log_channel_sp (GetLogChannelPluginForChannel(channel.c_str()));
                    if (log_channel_sp)
                    {
                        log_channel_sp->ListCategories(&result.GetOutputStream());
                        result.SetStatus(eReturnStatusSuccessFinishNoResult);
                    }
                    else
                        result.AppendErrorWithFormat("Invalid log channel '%s'.\n", args.GetArgumentAtIndex(0));
                }
            }
        }
        return result.Succeeded();
    }
Example #4
0
void InternalLink::installTestMCF(DesuraId id, Args args)
{
	std::string branch = args.getArgValue("branch");
	std::string build = args.getArgValue("build");

	MCFBranch iBranch;
	MCFBuild iBuild ;

	if (branch.size() > 0)
		iBranch = MCFBranch::BranchFromInt(Safe::atoi(branch.c_str()));

	if (build.size() > 0)
		iBuild = MCFBuild::BuildFromInt(Safe::atoi(build.c_str()));

	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_INSTALL_TESTMCF, iBranch, iBuild);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for install test mcf [{0}].\n", id.toInt64()));
}
Example #5
0
UnwindLLDB::UnwindLLDB (Thread &thread) :
    Unwind (thread),
    m_frames(),
    m_unwind_complete(false),
    m_user_supplied_trap_handler_functions()
{
    ProcessSP process_sp(thread.GetProcess());
    if (process_sp)
    {
        Args args;
        process_sp->GetTarget().GetUserSpecifiedTrapHandlerNames (args);
        size_t count = args.GetArgumentCount();
        for (size_t i = 0; i < count; i++)
        {
            const char *func_name = args.GetArgumentAtIndex(i);
            m_user_supplied_trap_handler_functions.push_back (ConstString (func_name));
        }
    }
}
Status PlatformAndroidRemoteGDBServer::ConnectRemote(Args &args) {
  m_device_id.clear();

  if (args.GetArgumentCount() != 1)
    return Status(
        "\"platform connect\" takes a single argument: <connect-url>");

  int remote_port;
  llvm::StringRef scheme, host, path;
  const char *url = args.GetArgumentAtIndex(0);
  if (!url)
    return Status("URL is null.");
  if (!UriParser::Parse(url, scheme, host, remote_port, path))
    return Status("Invalid URL: %s", url);
  if (host != "localhost")
    m_device_id = host;

  m_socket_namespace.reset();
  if (scheme == ConnectionFileDescriptor::UNIX_CONNECT_SCHEME)
    m_socket_namespace = AdbClient::UnixSocketNamespaceFileSystem;
  else if (scheme == ConnectionFileDescriptor::UNIX_ABSTRACT_CONNECT_SCHEME)
    m_socket_namespace = AdbClient::UnixSocketNamespaceAbstract;

  std::string connect_url;
  auto error =
      MakeConnectURL(g_remote_platform_pid, (remote_port < 0) ? 0 : remote_port,
                     path, connect_url);

  if (error.Fail())
    return error;

  args.ReplaceArgumentAtIndex(0, connect_url);

  Log *log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_PLATFORM));
  if (log)
    log->Printf("Rewritten platform connect URL: %s", connect_url.c_str());

  error = PlatformRemoteGDBServer::ConnectRemote(args);
  if (error.Fail())
    DeleteForwardPort(g_remote_platform_pid);

  return error;
}
Example #7
0
int main(int argc, char** argv) {
	try {
		Args args;
		if (argc < 2)
			args.printHelp();
		args = Args::read(argc, argv);
		if (args.help_showed)
			return -1;
		App app(args);
		app.run();
	} catch (const Exception& e) {
		return cout << "error: " << e.what() << endl, 1;
	} catch (const exception& e) {
		return cout << "error: " << e.what() << endl, 1;
	} catch (...) {
		return cout << "unknown exception" << endl, 1;
	}
	return 0;
}
Example #8
0
 virtual bool
 DoExecute (Args& command, CommandReturnObject &result)
 {
     SBCommandReturnObject sb_return(&result);
     SBCommandInterpreter sb_interpreter(&m_interpreter);
     SBDebugger debugger_sb(m_interpreter.GetDebugger().shared_from_this());
     bool ret = m_backend->DoExecute (debugger_sb,(char**)command.GetArgumentVector(), sb_return);
     sb_return.Release();
     return ret;
 }
Example #9
0
 std::string logArgs2String(const Args &args)
 {
     std::string message;
     for (int i = 0; i < args.Length(); i++) {
         ::v8::HandleScope scope;
         ::v8::String::Utf8Value str(args[i]);
         message += *str;
     }
     return message;
 }
/*******************************************************************
 * Function Name: CalculateLocationPriorProbs
 * Return Type 	: ProbImg
 * Created On	: Jul 15, 2013
 * Created By 	: hrushi
 * Comments		: Calculates the prior probability of an
 * Arguments	: const vector<ProbImg>& vPrbImgs, const Args& args
 *******************************************************************/
int PriorProb::CalculateLocationPriorProbs( const vector<ProbImg>& vPrbImgs, const Args& args )
{
	ProbImg CombinedProbImg = vPrbImgs.at(0) + vPrbImgs.at(1);
	CombinedProbImg = CombinedProbImg + vPrbImgs.at(2);

	m_LocationPriorProb = CombinedProbImg;
	m_LocationPriorProb.Display(DISP_DELAY);

	string FolderPath = args.GetTrainFolderPath();
	if( FolderPath.length() == 0 )
	{
		FolderPath = args.GetSearchFolderPath();
	}
	const string ImgPath = FolderPath + LOC_PRIOR_PROB_IMGNAME;
	m_LocationPriorProb.SetImagePath(ImgPath);
	m_LocationPriorProb.Write( ImgPath );

	return EXIT_SUCCESS;
}
Example #11
0
bool
CommandObject::ParseOptions
(
    CommandInterpreter &interpreter,
    Args& args,
    CommandReturnObject &result
)
{
    // See if the subclass has options?
    Options *options = GetOptions();
    if (options != NULL)
    {
        Error error;
        options->ResetOptionValues();

        // 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.Fail() || !options->VerifyOptions (result))
        {
            const char *error_cstr = error.AsCString();
            if (error_cstr)
            {
                // We got an error string, lets use that
                result.GetErrorStream().PutCString(error_cstr);
            }
            else
            {
                // No error string, output the usage information into result
                options->GenerateOptionUsage (result.GetErrorStream(), this);
            }
            // Set the return status to failed (this was an error).
            result.SetStatus (eReturnStatusFailed);
            return false;
        }
    }
    return true;
}
Example #12
0
	integer ServiceApp::start(const Args & args)
	{
		StdError serr;

		
		if (args.length() < 3) return onCommandLineError(args);
		try {
			appname = args[0];
			String instanceName = args[1];
			if (instanceName == defaultInstanceName)  instanceName = getDefaultInstanceName(appname);
			StringA command = String::getUtf8(args[2]);;
			instance = ProgInstance(instanceName);
			Args rmargs(const_cast<ConstStrW *>(args.data()+3),args.length()-3);
			stopCommand = false;
			return startCommand(command,rmargs,serr);
		} catch (...) {
			return onStartError(serr);
		}
	}
    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 modified.");
            result.SetStatus(eReturnStatusFailed);
            return false;
        }

        if (command.GetArgumentCount() == 0)
        {
            WatchpointSP wp_sp = target->GetLastCreatedWatchpoint();
            wp_sp->SetCondition(m_options.m_condition.c_str());
            result.SetStatus (eReturnStatusSuccessFinishNoResult);
        }
        else
        {
            // Particular watchpoints selected; set condition on 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)
            {
                WatchpointSP wp_sp = watchpoints.FindByID(wp_ids[i]);
                if (wp_sp)
                {
                    wp_sp->SetCondition(m_options.m_condition.c_str());
                    ++count;
                }
            }
            result.AppendMessageWithFormat("%d watchpoints modified.\n",count);
            result.SetStatus (eReturnStatusSuccessFinishNoResult);
        }

        return result.Succeeded();
    }
Example #14
0
bool
LogChannelDWARF::Enable
(
    StreamSP &log_stream_sp,
    uint32_t log_options,
    Stream *feedback_strm,  // Feedback stream for argument errors etc
    const Args &categories  // The categories to enable within this logging stream, if empty, enable default set
)
{
    Delete ();

    m_log_sp.reset(new Log (log_stream_sp));
    g_log_channel = this;
    uint32_t flag_bits = 0;
    bool got_unknown_category = false;
    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);
            if (got_unknown_category == false)
            {
                got_unknown_category = true;
                ListCategories (feedback_strm);
            }
        }
    }
    if (flag_bits == 0)
        flag_bits = DWARF_LOG_DEFAULT;
    m_log_sp->GetMask().Reset(flag_bits);
    m_log_sp->GetOptions().Reset(log_options);
    return m_log_sp.get() != NULL;
}
Example #15
0
    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();
    }
Example #16
0
void InternalLink::verifyItem(DesuraId id, Args args)
{
	bool showForm = args.getArgValue("show") != "false";

	UI::Forms::ItemForm* form = showItemForm(id, UI::Forms::INSTALL_ACTION::IA_VERIFY, showForm);

	if (!form)
		Warning(gcString("Cant find item (or item not ready) for verify [{0}].\n", id.toInt64()));
	else if (showForm == false)
		form->Show(false);
}
Example #17
0
void InternalLink::showSettings(Args &args)
{
	gcString c(GetGCThemeManager()->getWebPage("settings"));

	if (args.containsArg("tab"))
	{
		gcString tab = args.getArgValue("tab");

		if (tab == "cip")
			tab = "games";

		c += "#" + tab;
	}
	else
	{
		c += "#general";
	}

	g_pMainApp->loadUrl(c.c_str(), SUPPORT);
}
Error
PlatformRemoteGDBServer::ConnectRemote (Args& args)
{
    Error error;
    if (IsConnected())
    {
        error.SetErrorStringWithFormat ("the platform is already connected to '%s', execute 'platform disconnect' to close the current connection", 
                                        GetHostname());
    }
    else
    {
        if (args.GetArgumentCount() == 1)
        {
            const char *url = args.GetArgumentAtIndex(0);
            m_gdb_client.SetConnection (new ConnectionFileDescriptor());
            const ConnectionStatus status = m_gdb_client.Connect(url, &error);
            if (status == eConnectionStatusSuccess)
            {
                if (m_gdb_client.HandshakeWithServer(&error))
                {
                    m_gdb_client.GetHostInfo();
                    // If a working directory was set prior to connecting, send it down now
                    if (m_working_dir)
                        m_gdb_client.SetWorkingDir(m_working_dir.GetCString());
                }
                else
                {
                    m_gdb_client.Disconnect();
                    if (error.Success())
                        error.SetErrorString("handshake failed");
                }
            }
        }
        else
        {
            error.SetErrorString ("\"platform connect\" takes a single argument: <connect-url>");
        }
    }

    return error;
}
Error PlatformRemoteGDBServer::ConnectRemote(Args &args) {
  Error error;
  if (IsConnected()) {
    error.SetErrorStringWithFormat("the platform is already connected to '%s', "
                                   "execute 'platform disconnect' to close the "
                                   "current connection",
                                   GetHostname());
  } else {
    if (args.GetArgumentCount() == 1) {
      m_gdb_client.SetConnection(new ConnectionFileDescriptor());
      // we're going to reuse the hostname when we connect to the debugserver
      int port;
      std::string path;
      const char *url = args.GetArgumentAtIndex(0);
      if (!url)
        return Error("URL is null.");
      if (!UriParser::Parse(url, m_platform_scheme, m_platform_hostname, port,
                            path))
        return Error("Invalid URL: %s", url);

      const ConnectionStatus status = m_gdb_client.Connect(url, &error);
      if (status == eConnectionStatusSuccess) {
        if (m_gdb_client.HandshakeWithServer(&error)) {
          m_gdb_client.GetHostInfo();
          // If a working directory was set prior to connecting, send it down
          // now
          if (m_working_dir)
            m_gdb_client.SetWorkingDir(m_working_dir);
        } else {
          m_gdb_client.Disconnect();
          if (error.Success())
            error.SetErrorString("handshake failed");
        }
      }
    } else {
      error.SetErrorString(
          "\"platform connect\" takes a single argument: <connect-url>");
    }
  }
  return error;
}
void GetDocumentsCommand::execute(Args &args, Environment &env)
{
	if(args.size() != 1 && args.size() != 2) {
		throw CommandException("Wrong number of arguments");
	}
	env.testContainer();
	env.deleteResults();

	XmlValue value;
	if(args.size() == 2) {
		value = args[1];
	}

	if(env.txn()) {
		env.results() = new XmlResults(
			env.container()->lookupIndex(
				*env.txn(),
				env.context(),
				DbXml::metaDataNamespace_uri,
				DbXml::metaDataName_name,
				"node-metadata-equality-string",
				value, DBXML_LAZY_DOCS));
	} else {
		env.results() = new XmlResults(
			env.container()->lookupIndex(
				env.context(),
				DbXml::metaDataNamespace_uri,
				DbXml::metaDataName_name,
				"node-metadata-equality-string",
				value, DBXML_LAZY_DOCS));
	}

	if(env.context().getEvaluationType() == XmlQueryContext::Eager) {
		if(env.verbose())
			cout << (unsigned int)env.results()->size()
			     << " documents found" << endl << endl;
	} else {
		if(env.verbose())
			cout << "Lazy getDocuments completed" << endl << endl;
	}
}
Example #21
0
File: comm.cpp Project: gabn/fslurp
void
Comm::serialDeviceInit(Args& args)
{
	struct termios	termio;
	const char*	deviceName = args.getSerialPortName();
	const char*	baudRate = args.getBaudRate();

	if ((fd_ = open(deviceName, O_RDWR|O_NOCTTY)) == -1)
	{
		Args::dieMessage(
			Args::ExitCommFailure,
			"open of %s failed: %s\n",
			deviceName,
			strerror(errno));
	}

	if (tcflush(fd_, TCIFLUSH) == -1)
	{
		Args::dieMessage(
			Args::ExitCommFailure,
			"tcflush failed: %s\n",
			strerror(errno));
	}

	memset(&termio, 0, sizeof (termio));

	termio.c_cflag = getBaudRateFlag(baudRate) | CS8 | CLOCAL | CREAD;
	termio.c_iflag = IGNPAR;
	termio.c_oflag = 0;
	termio.c_lflag = 0;
	termio.c_cc[VMIN] = 0;
	termio.c_cc[VTIME] = 1;

	if (tcsetattr(fd_, TCSANOW, &termio) == -1)
	{
		Args::dieMessage(
			Args::ExitCommFailure,
			"tcsetattr failed: %s\n",
			strerror(errno));
	}
}
Example #22
0
// The main function: parse input and scene, render, quit
int main( int argc, char *argv[] )
{
	Args* args = Args::instance();

    // parse the command line arguments
    args->parse( argc, argv );
	// parse the scene
    SceneParser* scene   = new SceneParser( args->input_file );
	// construct tracer
    RayTracer* rayTracer = new RayTracer( scene, args->bounces );

	// render!
    render( rayTracer, scene, args );

	// clean up
	delete rayTracer;
    delete scene;
    delete args;

    return 0;
}
Example #23
0
static void
ParseCommandLine(Args &args)
{
  path = args.ExpectNextPath();

#ifdef USE_GDI
  TCHAR *endptr;
  unsigned _id = ParseUnsigned(path.c_str(), &endptr);
  if (StringIsEmpty(endptr))
    id = ResourceId(_id);
#endif
}
Example #24
0
  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 {
      auto reg_name = command[0].ref;
      auto value_str = command[1].ref;

      // 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
      reg_name.consume_front("$");

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

      if (reg_info) {
        RegisterValue reg_value;

        Status error(reg_value.SetValueFromString(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.str().c_str(), value_str.str().c_str(),
              error.AsCString());
        } else {
          result.AppendErrorWithFormat(
              "Failed to write register '%s' with value '%s'",
              reg_name.str().c_str(), value_str.str().c_str());
        }
        result.SetStatus(eReturnStatusFailed);
      } else {
        result.AppendErrorWithFormat("Register not found for '%s'.\n",
                                     reg_name.str().c_str());
        result.SetStatus(eReturnStatusFailed);
      }
    }
    return result.Succeeded();
  }
Error
PlatformAndroidRemoteGDBServer::ConnectRemote (Args& args)
{
    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 (!UriParser::Parse (url, scheme, host, port, path))
        return Error ("invalid uri");

    std::string device_id;
    Error error = ForwardPortWithAdb (port, device_id);
    if (error.Fail ())
        return error;

    m_port_forwards[g_remote_platform_pid] = std::make_pair (port, device_id);

    return PlatformRemoteGDBServer::ConnectRemote (args);
}
Example #26
0
void ParticleSurface::renderWireframeHomogeneous	
   (RenderDevice* 	                    rd,
    const Array<shared_ptr<Surface>>& 	surfaceArray,
    const Color4&                       color,
    bool                                previous) const {

    rd->pushState(); {
        rd->setDepthWrite(false);
        rd->setDepthTest(RenderDevice::DEPTH_LEQUAL);
        rd->setRenderMode(RenderDevice::RENDER_WIREFRAME);
        rd->setPolygonOffset(-0.5f);
        Args args;
        args.setUniform("wireframeColor", color);
        const Vector3& csz = rd->cameraToWorldMatrix().lookVector();
        setShaderArgs(args, surfaceArray, false, csz);
        Projection proj(rd->projectionMatrix());
        args.setUniform("nearPlaneZ", proj.nearPlaneZ());
        LAUNCH_SHADER_WITH_HINT("ParticleSurface_wireframe.*", args, name());

    } rd->popState();
}
Example #27
0
void FlagImpl<std::string>::Parse( Args & args )
{
     for( Args::iterator arg = args.begin(); arg != args.end(); ++arg )
     {
          if( !arg->compare( GetFlag() ))
          {
               if( IsAlreadySet() ) // если флаг задан( уже встречалс¤ среди переданных аргументов )
                    throw exception::ErrBadArgs();
               Args::iterator flag = arg; // первый аргумент - флаг
               Args::iterator opt = ++arg; // следущий за ним аргумент - опци¤ 
               if( opt == args.end() )
                    throw exception::ErrBadArgs();
               SetVal( *opt );
               SetIsAlreadySet(); // выставл¤ем признак того, что данный флаг уже задан( защита от дублировани¤ )
               // удал¤ем из списка аргументов считанные флаг и опцию
               args.erase( flag ); 
               args.erase( opt );
               break;
          }
     }
}
Example #28
0
    CompletionResult CompleteArgument(const Args& args, int argNum) {
        CommandMap& commands = GetCommandMap();

        commandLog.Debug("Completing argument %i of '%s'", argNum, args.ConcatArgs(0));

        if (args.Argc() == 0) {
            return {};
        }

        if (argNum > 0) {
            const std::string& cmdName = args.Argv(0);

            auto it = commands.find(cmdName);
            if (it == commands.end()) {
                return {};
            }

            std::string prefix;
            if (argNum < args.Argc()) {
                prefix = args.Argv(argNum);
            }

            return it->second.cmd->Complete(argNum, args, prefix);
        } else {
            return CompleteCommandNames(args.Argv(0));
        }
    }
/*******************************************************************
 * Function Name: LoadChipMap
 * Return Type 	: mp_Str_vStr
 * Created On	: Nov 4, 2013
 * Created By 	: hrushi
 * Comments		: Save the chips
 * Arguments	: const Args& args
 *******************************************************************/
mp_Str_vStr AlgoTrain::LoadChipMap( const Args& args) const
{
	mp_Str_vStr Retmp;

	cv::FileStorage fsLblChips2;
	vector<string> Categories, ImPaths;

	string TrainFldrPath = args.GetTrainFolderPath();

	if( TrainFldrPath.length() == 0)
	{
		TrainFldrPath = args.GetSearchFolderPath();
	}

	const string LblPath = TrainFldrPath + CHIP_FILE_LIST;
	cout << "Reading " << LblPath << endl;

	if(!fs::exists(LblPath))
	{
		cerr << "File Path " << LblPath << " Not found" << endl;
		throw ERR_INVALID_PATH;
	}


	fsLblChips2.open(LblPath, cv::FileStorage::READ);

	fsLblChips2["Categories"] >> Categories;


	for(UINT i = 0;  i < Categories.size(); i++ )
	{
		vector<string> vImgNames;
		fsLblChips2[Categories.at(i)] >> vImgNames;
		Retmp[Categories.at(i)] = vImgNames;
	}

	fsLblChips2.release();

	return Retmp;
}
Example #30
0
// GetInputFiles
//------------------------------------------------------------------------------
void LinkerNode::GetInputFiles( Node * n, Args & fullArgs, const AString & pre, const AString & post ) const
{
    if ( n->GetType() == Node::LIBRARY_NODE )
    {
        const bool linkObjectsInsteadOfLibs = m_LinkerLinkObjects;

        if ( linkObjectsInsteadOfLibs )
        {
            LibraryNode * ln = n->CastTo< LibraryNode >();
            ln->GetInputFiles( fullArgs, pre, post, linkObjectsInsteadOfLibs );
        }
        else
        {
            // not building a DLL, so link the lib directly
            fullArgs += pre;
            fullArgs += n->GetName();
            fullArgs += post;
        }
    }
    else if ( n->GetType() == Node::OBJECT_LIST_NODE )
    {
        const bool linkObjectsInsteadOfLibs = m_LinkerLinkObjects;

        ObjectListNode * ol = n->CastTo< ObjectListNode >();
        ol->GetInputFiles( fullArgs, pre, post, linkObjectsInsteadOfLibs );
    }
    else if ( n->GetType() == Node::DLL_NODE )
    {
        // for a DLL, link to the import library
        DLLNode * dllNode = n->CastTo< DLLNode >();
        AStackString<> importLibName;
        dllNode->GetImportLibName( importLibName );
        fullArgs += pre;
        fullArgs += importLibName;
        fullArgs += post;
    }
    else if ( n->GetType() == Node::COPY_FILE_NODE )
    {
        CopyFileNode * copyNode = n->CastTo< CopyFileNode >();
        Node * srcNode = copyNode->GetSourceNode();
        GetInputFiles( srcNode, fullArgs, pre, post );
    }
    else
    {
        // link anything else directly
        fullArgs += pre;
        fullArgs += n->GetName();
        fullArgs += post;
    }

    fullArgs.AddDelimiter();
}