virtual void AddOptions(cmdline::parser &parser) { parser.add("ignore", 'i', "Do nothing and don't warn about Vulkan layer issues."); parser.add( "system", '\0', "Install layer registration to /etc instead of $HOME/.local (requires root privileges)"); }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &opts) { uint32_t PID = parser.get<uint32_t>("PID"); std::string workingDir = parser.get<string>("working-dir"); std::string logFile = parser.get<string>("capture-file"); std::cout << "Injecting into PID " << PID << std::endl; uint32_t ident = RENDERDOC_InjectIntoProcess(PID, NULL, logFile.empty() ? "" : logFile.c_str(), &opts, parser.exist("wait-for-exit")); if(ident == 0) { std::cerr << "Failed to inject." << std::endl; return 2; } if(parser.exist("wait-for-exit")) { std::cerr << PID << " finished executing." << std::endl; ident = 0; } else { std::cerr << "Launched as ID " << ident << std::endl; } return ident; }
virtual void AddOptions(cmdline::parser &parser) { parser.add("ignore", 'i', "Do nothing and don't warn about Vulkan layer issues."); parser.add( "system", '\0', "Install layer registration to /etc instead of $HOME/.local (requires root privileges)"); parser.add("dry-run", 'n', "Don't perform any actions, instead print what would happen."); }
virtual void AddOptions(cmdline::parser &parser) { parser.add<uint32_t>("pid", 0, ""); parser.add<string>("log", 0, ""); parser.add<string>("capopts", 0, ""); parser.stop_at_rest(true); }
void parse_option(cmdline::parser& cmd_parser, int argc, char** argv) { // add specified type of variable. // 1st argument is long name // 2nd argument is short name (no short name if '\0' specified) // 3rd argument is description // 4th argument is mandatory (optional. default is false) // 5th argument is default value (optional. it used when mandatory is false) // cmd_parser.add<std::string>("relation-file", '\0', "Relation file name", false, ""); // Parameter cmd_parser.add<std::string>("method", '\0', "consistency preserving method", false, "none", cmdline::oneof<std::string>("optimistic", "2pl", "snapshot", "none")); cmd_parser.add<int>("txn-joint-count", '\0', "Joint count for txn", false, 1); cmd_parser.add<useconds_t>("update-interval", '\0', "update interval", false, 1000); cmd_parser.add<useconds_t>("update-time", '\0', "time needed to update a relation", false, 10); cmd_parser.add<useconds_t>("purchase-interval", '\0', "Purchase interval", false, 1000); cmd_parser.add<int>("purchase-count", '\0', "Purchase count", false, 1000); cmd_parser.add<int>("goods-count", '\0', "Goods count", false, 1000); cmd_parser.add<int>("max-price", '\0', "Max price for purchases", false, 100000); cmd_parser.add<int>("min-price", '\0', "Min price for purchases", false, 1000); cmd_parser.add<bool>("reuse-snapshot", '\0', "Reuse snapshot when possible", false, true); // Finish! cmd_parser.parse_check(argc, argv); }
virtual void AddOptions(cmdline::parser &parser) { parser.add("daemon", 'd', "Go into the background."); parser.add<string>( "host", 'h', "The interface to listen on. By default listens on all interfaces", false, ""); parser.add<uint32_t>("port", 'p', "The port to listen on.", false, RENDERDOC_GetDefaultRemoteServerPort()); }
void send2supervisor( const string& cmd, const string& type, const string& name, const string& zkhosts, const cmdline::parser& argv) { pfi::lang::shared_ptr<jubatus::common::lock_service> ls_( jubatus::common::create_lock_service("zk", zkhosts, 10, "/dev/null")); vector<string> list; jubatus::framework::server_argv server_option; if (cmd == "start") { string path0 = name.substr(name.find_first_of("/") + 1); string path; jubatus::common::build_actor_path( path, type, path0.substr(0, path0.find_first_of("/"))); ls_->create(path); path += "/nodes"; ls_->create(path); server_option.bind_if = argv.get<std::string>("listen_if"); server_option.threadnum = argv.get<int>("thread"); server_option.timeout = argv.get<int>("timeout"); server_option.program_name = type; server_option.z = zkhosts; server_option.name = name; server_option.datadir = argv.get<std::string>("datadir"); server_option.logdir = argv.get<std::string>("logdir"); server_option.loglevel = argv.get<int>("loglevel"); server_option.join = argv.exist("join"); server_option.interval_sec = argv.get<int>("interval_sec"); server_option.interval_count = argv.get<int>("interval_count"); } ls_->list(jubatus::common::JUBAVISOR_BASE_PATH, list); if (list.empty()) { LOG(INFO) << "no server to " << cmd << " " << name; exit(-1); } unsigned int N = argv.get<unsigned int>("num"); if (N == 0) { N = list.size(); } vector<string>::const_iterator it; unsigned int n = N / list.size(); for (it = list.begin(); it != list.end(); ++it) { do_request(cmd, name, *it, n, server_option); } n = N % list.size(); for (size_t i = 0; i < n; ++i) { do_request(cmd, name, *it, n, server_option); } }
void specifyCommandLineParameters(cmdline::parser &cmdOpt) { cmdOpt.add<std::string>(CFG, 'c', "configuration file", true, ""); cmdOpt.add<std::string>(IN, 'i', "dataset input file", true, ""); cmdOpt.add<std::string>(OUT, 'o', "cluster output file", false, ""); cmdOpt.add<std::string>(LOGF, 'l', "log file", false, ""); cmdOpt.add<char>(SEP, 's', "separator in output file", false, ','); cmdOpt.add(SKIP, 'S', "skip faulty records"); }
virtual void AddOptions(cmdline::parser &parser) { parser.set_footer("<capture.rdc>"); parser.add<uint32_t>("width", 'w', "The preview window width.", false, 1280); parser.add<uint32_t>("height", 'h', "The preview window height.", false, 720); parser.add<string>("remote-host", 0, "Instead of replaying locally, replay on this host over the network.", false); parser.add<uint32_t>("remote-port", 0, "If --remote-host is set, use this port.", false, RENDERDOC_GetDefaultRemoteServerPort()); }
virtual void AddOptions(cmdline::parser &parser) { parser.set_footer("<filename.rdc>"); parser.add<string>("out", 'o', "The output filename to save the file to", true, "filename.jpg"); parser.add<string>("format", 'f', "The format of the output file. If empty, detected from filename", false, "", cmdline::oneof<string>("jpg", "png", "bmp", "tga")); parser.add<uint32_t>( "max-size", 's', "The maximum dimension of the thumbnail. Default is 0, which is unlimited.", false, 0); }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &opts) { if(parser.rest().empty()) { std::cerr << "Error: capture command requires an executable to launch." << std::endl << std::endl << parser.usage(); return 0; } std::string executable = parser.rest()[0]; std::string workingDir = parser.get<string>("working-dir"); std::string cmdLine; std::string logFile = parser.get<string>("capture-file"); for(size_t i = 1; i < parser.rest().size(); i++) { if(!cmdLine.empty()) cmdLine += ' '; cmdLine += EscapeArgument(parser.rest()[i]); } std::cout << "Launching '" << executable << "'"; if(!cmdLine.empty()) std::cout << " with params: " << cmdLine; std::cout << std::endl; uint32_t ident = RENDERDOC_ExecuteAndInject( executable.c_str(), workingDir.empty() ? "" : workingDir.c_str(), cmdLine.empty() ? "" : cmdLine.c_str(), NULL, logFile.empty() ? "" : logFile.c_str(), &opts, parser.exist("wait-for-exit")); if(ident == 0) { std::cerr << "Failed to create & inject." << std::endl; return 2; } if(parser.exist("wait-for-exit")) { std::cerr << "'" << executable << "' finished executing." << std::endl; ident = 0; } else { std::cerr << "Launched as ID " << ident << std::endl; } return ident; }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { bool ignore = (parser.exist("ignore")); if(ignore) { std::cout << "Not fixing vulkan layer issues, and suppressing future warnings." << std::endl; std::cout << "To undo, remove '$HOME/.renderdoc/ignore_vulkan_layer_issues'." << std::endl; string ignorePath = string(getenv("HOME")) + "/.renderdoc/"; mkdir(ignorePath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); ignorePath += "ignore_vulkan_layer"; FILE *f = fopen(ignorePath.c_str(), "w"); if(f) { fputs("This file suppresses any checks for vulkan layer issues.\n", f); fputs("Delete this file to restore default checking.\n", f); fclose(f); } else { std::cerr << "Couldn't create '$HOME/.renderdoc/ignore_vulkan_layer_issues'." << std::endl; } return 0; } RENDERDOC_UpdateVulkanLayerRegistration(parser.exist("system")); return 0; }
void init_cmdline(cmdline::parser& cmd) { #ifdef __X86 #define LOADER_DLL_NAME "loader32.dll" #else #define LOADER_DLL_NAME "loader64.dll" #endif cmd.add<string>("type", 't', "inject type (start, open or hook)", true, "", cmdline::oneof<string>("start", "open", "hook")); cmd.add<string>("file", 'f', "path of executable file (when start)", false, ""); cmd.add<string>("file-param", '\0', "parameters of executable (when start)", false, ""); cmd.add<int>("pid", 'p', "process id (when open)", false, 0); cmd.add<string>("injectee", 'i', "path of injectee, dll or so", true, ""); cmd.add<string>("loader-dll-name", '\0', "name of the loader dll", false, LOADER_DLL_NAME); cmd.add<string>("hook-type", 'h', "Windows hook type (when hook)", false, "", cmdline::oneof<string>("keyboard", "msg", "callback")); cmd.add("no-eustia", '\0', "only inject the module"); }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { string host = parser.get<string>("host"); uint32_t port = parser.get<uint32_t>("port"); std::cerr << "Spawning a replay host listening on " << (host.empty() ? "*" : host) << ":" << port << "..." << std::endl; if(parser.exist("daemon")) { std::cerr << "Detaching." << std::endl; Daemonise(); } usingKillSignal = true; RENDERDOC_BecomeRemoteServer(host.empty() ? NULL : host.c_str(), port, &killSignal); std::cerr << std::endl << "Cleaning up from replay hosting." << std::endl; return 0; }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { if(parser.rest().empty()) { std::cerr << "Error: capture command requires a filename to load." << std::endl << std::endl << parser.usage(); return 0; } string filename = parser.rest()[0]; if(parser.exist("remote-host")) { std::cout << "Replaying '" << filename << "' on " << parser.get<string>("remote-host") << ":" << parser.get<uint32_t>("remote-port") << "." << std::endl; RemoteServer *remote = NULL; ReplayCreateStatus status = RENDERDOC_CreateRemoteServerConnection( parser.get<string>("remote-host").c_str(), parser.get<uint32_t>("remote-port"), &remote); if(remote == NULL || status != eReplayCreate_Success) { std::cerr << "Error: Couldn't connect to " << parser.get<string>("remote-host") << ":" << parser.get<uint32_t>("remote-port") << "." << std::endl; std::cerr << " Have you run renderdoccmd remoteserver on '" << parser.get<string>("remote-host") << "'?" << std::endl; return 1; } std::cerr << "Copying capture file to remote server" << std::endl; float progress = 0.0f; rdctype::str remotePath = remote->CopyCaptureToRemote(filename.c_str(), &progress); ReplayRenderer *renderer = NULL; status = remote->OpenCapture(~0U, remotePath.elems, &progress, &renderer); if(status == eReplayCreate_Success) { DisplayRendererPreview(renderer, parser.get<uint32_t>("width"), parser.get<uint32_t>("height")); remote->CloseCapture(renderer); } else { std::cerr << "Couldn't load and replay '" << filename << "'." << std::endl; } remote->ShutdownConnection(); } else { std::cout << "Replaying '" << filename << "' locally.." << std::endl; float progress = 0.0f; ReplayRenderer *renderer = NULL; ReplayCreateStatus status = RENDERDOC_CreateReplayRenderer(filename.c_str(), &progress, &renderer); if(status == eReplayCreate_Success) { DisplayRendererPreview(renderer, parser.get<uint32_t>("width"), parser.get<uint32_t>("height")); renderer->Shutdown(); } else { std::cerr << "Couldn't load and replay '" << filename << "'." << std::endl; } } return 0; }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { bool ignore = (parser.exist("ignore")); if(ignore) { std::cout << "Not fixing vulkan layer issues, and suppressing future warnings." << std::endl; std::cout << "To undo, remove '$HOME/.renderdoc/ignore_vulkan_layer_issues'." << std::endl; string ignorePath = string(getenv("HOME")) + "/.renderdoc/"; mkdir(ignorePath.c_str(), S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH); ignorePath += "ignore_vulkan_layer"; FILE *f = fopen(ignorePath.c_str(), "w"); if(f) { fputs("This file suppresses any checks for vulkan layer issues.\n", f); fputs("Delete this file to restore default checking.\n", f); fclose(f); } else { std::cerr << "Couldn't create '$HOME/.renderdoc/ignore_vulkan_layer_issues'." << std::endl; } return 0; } bool system = (parser.exist("system")); bool dryrun = (parser.exist("dry-run")); // if we want to install to the system and there's a registration in $HOME, delete it if(system && homeExists) { std::cout << "Removing '" << layerRegistrationPath[HOME] << "'" << std::endl; if(!dryrun) { int ret = unlink(layerRegistrationPath[HOME].c_str()); if(ret < 0) { const char *const errtext = strerror(errno); std::cout << "Error - " << errtext << std::endl; } } } // and vice-versa if(!system && etcExists) { std::cout << "Removing '" << layerRegistrationPath[ETC] << "'" << std::endl; if(!dryrun) { int ret = unlink(layerRegistrationPath[ETC].c_str()); if(ret < 0) { const char *const errtext = strerror(errno); std::cout << "Error - " << errtext << std::endl; } } } int idx = system ? ETC : HOME; string path = GetSOFromJSON(layerRegistrationPath[idx]); if(path != libPath) { if((system && !etcExists) || (!system && !homeExists)) { std::cout << "Registering '" << layerRegistrationPath[idx] << "'" << std::endl; } else { std::cout << "Updating '" << layerRegistrationPath[idx] << "'" << std::endl; if(path == "") { std::cout << " JSON is corrupt or unrecognised, replacing with valid JSON pointing" << std::endl; std::cout << " to '" << libPath << "'" << std::endl; } else { std::cout << " Repointing from '" << path << "'" << std::endl; std::cout << " to '" << libPath << "'" << std::endl; } } if(!dryrun) { FILE *f = fopen(layerRegistrationPath[idx].c_str(), "w"); if(f) { fputs(GenerateJSON(libPath).c_str(), f); fclose(f); } else { const char *const errtext = strerror(errno); std::cout << "Error - " << errtext << std::endl; } } } return 0; }
virtual void AddOptions(cmdline::parser &parser) { parser.set_footer("<executable> [program arguments]"); parser.stop_at_rest(true); }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { CaptureOptions cmdopts; readCapOpts(parser.get<string>("capopts").c_str(), &cmdopts); std::vector<std::string> rest = parser.rest(); if(rest.size() % 3 != 0) { std::cerr << "Invalid generated cap32for64 command rest.size() == " << rest.size() << std::endl; return 0; } int numEnvs = int(rest.size() / 3); void *env = RENDERDOC_MakeEnvironmentModificationList(numEnvs); for(int i = 0; i < numEnvs; i++) { string typeString = rest[i * 3 + 0]; EnvironmentModificationType type = eEnvMod_Set; EnvironmentSeparator sep = eEnvSep_None; if(typeString == "+env-replace") { type = eEnvMod_Set; sep = eEnvSep_None; } else if(typeString == "+env-append-platform") { type = eEnvMod_Append; sep = eEnvSep_Platform; } else if(typeString == "+env-append-semicolon") { type = eEnvMod_Append; sep = eEnvSep_SemiColon; } else if(typeString == "+env-append-colon") { type = eEnvMod_Append; sep = eEnvSep_Colon; } else if(typeString == "+env-append") { type = eEnvMod_Append; sep = eEnvSep_None; } else if(typeString == "+env-prepend-platform") { type = eEnvMod_Prepend; sep = eEnvSep_Platform; } else if(typeString == "+env-prepend-semicolon") { type = eEnvMod_Prepend; sep = eEnvSep_SemiColon; } else if(typeString == "+env-prepend-colon") { type = eEnvMod_Prepend; sep = eEnvSep_Colon; } else if(typeString == "+env-prepend") { type = eEnvMod_Prepend; sep = eEnvSep_None; } else { std::cerr << "Invalid generated cap32for64 env '" << rest[i * 3 + 0] << std::endl; RENDERDOC_FreeEnvironmentModificationList(env); return 0; } RENDERDOC_SetEnvironmentModification(env, i, rest[i * 3 + 1].c_str(), rest[i * 3 + 2].c_str(), type, sep); } int ret = RENDERDOC_InjectIntoProcess(parser.get<uint32_t>("pid"), env, parser.get<string>("log").c_str(), &cmdopts, false); RENDERDOC_FreeEnvironmentModificationList(env); return ret; }
virtual int Execute(cmdline::parser &parser, const CaptureOptions &) { if(parser.rest().empty()) { std::cerr << "Error: thumb command requires a capture filename." << std::endl << std::endl << parser.usage(); return 0; } string filename = parser.rest()[0]; string outfile = parser.get<string>("out"); string format = parser.get<string>("format"); FileType type = eFileType_JPG; if(format == "png") { type = eFileType_PNG; } else if(format == "tga") { type = eFileType_TGA; } else if(format == "bmp") { type = eFileType_BMP; } else { const char *dot = strrchr(outfile.c_str(), '.'); if(dot != NULL && strstr(dot, "png")) type = eFileType_PNG; else if(dot != NULL && strstr(dot, "tga")) type = eFileType_TGA; else if(dot != NULL && strstr(dot, "bmp")) type = eFileType_BMP; else std::cerr << "Couldn't guess format from '" << outfile << "', defaulting to jpg." << std::endl; } rdctype::array<byte> buf; bool32 ret = RENDERDOC_GetThumbnail(filename.c_str(), type, parser.get<uint32_t>("max-size"), &buf); if(!ret) { std::cerr << "Couldn't fetch the thumbnail in '" << filename << "'" << std::endl; } else { FILE *f = fopen(outfile.c_str(), "wb"); if(!f) { std::cerr << "Couldn't open destination file '" << outfile << "'" << std::endl; } else { fwrite(buf.elems, 1, buf.count, f); fclose(f); std::cout << "Wrote thumbnail from '" << filename << "' to '" << outfile << "'." << std::endl; } } return 0; }