int stub_main(int arch_reason) { int ret; int gdb_signal; gdb_signal = decode_signal(arch_reason); /* Do not announce stop reply if we were detached. */ if (isattached) { send_stop_reply(gdb_signal); } /* We are now attached. */ isattached = 1; do { int cmd; char *p; while (getpkt(&pktbuf[0], sizeof(pktbuf)) < 1); p = &pktbuf[0]; cmd = *p; if ('?' == cmd) { send_stop_reply(gdb_signal); ret = 0; } else if ('c' == cmd) { ret = handle_c(p); } else if ('s' == cmd) { ret = handle_s(p); } else if ('D' == cmd) { ret = handle_D(p); if (ret & CMD_LEAVE) { isattached = 0; } } else if ('g' == cmd) { ret = handle_g(p); } else if ('G' == cmd) { ret = handle_G(p); } else if ('P' == cmd) { ret = handle_P(p); } else if ('m' == cmd) { ret = handle_m(p); } else if ('M' == cmd) { ret = handle_M(p); } else { /* * For any command not supported by the stub, an empty * response ('$#00') should be returned. */ p = ""; ret = CMD_REPLY; } if (ret & CMD_REPLY) { putpkt(p); } } while (!(ret & CMD_LEAVE)); return ret; }
bool ContextSample::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { for (_i=_skipFirstArgs; _i < argc; _i++) { if (isUsed(_i - _skipFirstArgs)) { continue; } else if (strcmp(_argv[_i], "-s") == 0) { if (!handle_s()) return false; } } return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs); }
bool ContextFisher::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { _argc = argc; _argv = argv; _skipFirstArgs = skipFirstArgs; if (_argc < 2) { setShowHelp(true); return false; } setProgram(_programNames[argv[0]]); _argsProcessed.resize(_argc - _skipFirstArgs, false); for (_i=_skipFirstArgs; _i < argc; _i++) { if (isUsed(_i - _skipFirstArgs)) { continue; } else if (strcmp(_argv[_i], "-s") == 0) { if (!handle_s()) return false; } else if (strcmp(_argv[_i], "-S") == 0) { if (!handle_S()) return false; } else if (strcmp(_argv[_i], "-exclude") == 0) { if (!handle_exclude()) return false; } if (strcmp(_argv[_i], "-g") == 0) { if (!handle_g()) return false; } if(strcmp(_argv[_i], "-m") == 0) { markUsed(_i - _skipFirstArgs); setUseMergedIntervals(true); } } return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs); }
bool ContextMerge::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { _argc = argc; _argv = argv; _skipFirstArgs = skipFirstArgs; setProgram(_programNames[argv[0]]); _argsProcessed.resize(_argc - _skipFirstArgs, false); for (_i=_skipFirstArgs; _i < argc; _i++) { if (isUsed(_i - _skipFirstArgs)) { continue; } else if (strcmp(_argv[_i], "-n") == 0) { if (!handle_n()) return false; } else if (strcmp(_argv[_i], "-nms") == 0) { if (!handle_nms()) return false; } else if (strcmp(_argv[_i], "-scores") == 0) { if (!handle_scores()) return false; } else if (strcmp(_argv[_i], "-delim") == 0) { if (!handle_delim()) return false; } else if (strcmp(_argv[_i], "-d") == 0) { if (!handle_d()) return false; } else if (strcmp(_argv[_i], "-s") == 0) { if (!handle_s()) return false; } else if (strcmp(_argv[_i], "-S") == 0) { if (!handle_S()) return false; } } return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs); }
bool ContextSample::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { _argc = argc; _argv = argv; _skipFirstArgs = skipFirstArgs; if (_argc < 2) { setShowHelp(true); return false; } setProgram(_programNames[argv[0]]); _argsProcessed.resize(_argc - _skipFirstArgs, false); for (_i=_skipFirstArgs; _i < argc; _i++) { if (isUsed(_i - _skipFirstArgs)) { continue; } else if (strcmp(_argv[_i], "-s") == 0) { if (!handle_s()) return false; } } return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs); }
bool ContextIntersect::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { _argc = argc; _argv = argv; _skipFirstArgs = skipFirstArgs; if (_argc < 2) { setShowHelp(true); return false; } setProgram(_programNames[argv[0]]); _argsProcessed.resize(_argc - _skipFirstArgs, false); for (_i=_skipFirstArgs; _i < argc; _i++) { if (isUsed(_i - _skipFirstArgs)) { continue; } if (strcmp(_argv[_i], "-a") == 0) { if (!handle_a()) return false; } else if (strcmp(_argv[_i], "-abam") == 0) { if (!handle_abam()) return false; } else if (strcmp(_argv[_i], "-b") == 0) { if (!handle_b()) return false; } else if (strcmp(_argv[_i], "-names") == 0) { if (!handle_names()) return false; } else if (strcmp(_argv[_i], "-filenames") == 0) { if (!handle_filenames()) return false; } else if (strcmp(_argv[_i], "-u") == 0) { if (!handle_u()) return false; } else if (strcmp(_argv[_i], "-f") == 0) { if (!handle_f()) return false; } else if (strcmp(_argv[_i], "-wa") == 0) { if (!handle_wa()) return false; } else if (strcmp(_argv[_i], "-wao") == 0) { if (!handle_wao()) return false; } else if (strcmp(_argv[_i], "-wb") == 0) { if (!handle_wb()) return false; } else if (strcmp(_argv[_i], "-wo") == 0) { if (!handle_wo()) return false; } else if (strcmp(_argv[_i], "-c") == 0) { if (!handle_c()) return false; } else if(strcmp(_argv[_i], "-r") == 0) { if (!handle_r()) return false; } else if (strcmp(_argv[_i], "-v") == 0) { if (!handle_v()) return false; } else if (strcmp(_argv[_i], "-s") == 0) { if (!handle_s()) return false; } else if (strcmp(_argv[_i], "-S") == 0) { if (!handle_S()) return false; } else if (strcmp(_argv[_i], "-loj") == 0) { if (!handle_loj()) return false; } } return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs); }
bool ContextIntersect::parseCmdArgs(int argc, char **argv, int skipFirstArgs) { for (_i=_skipFirstArgs; _i < argc; _i++) { if (isUsed(_i - _skipFirstArgs)) { continue; } if (strcmp(_argv[_i], "-a") == 0) { if (!handle_a()) return false; } else if (strcmp(_argv[_i], "-abam") == 0) { if (!handle_abam()) return false; } else if (strcmp(_argv[_i], "-b") == 0) { if (!handle_b()) return false; } else if (strcmp(_argv[_i], "-names") == 0) { if (!handle_names()) return false; } else if (strcmp(_argv[_i], "-filenames") == 0) { if (!handle_filenames()) return false; } else if (strcmp(_argv[_i], "-u") == 0) { if (!handle_u()) return false; } else if (strcmp(_argv[_i], "-f") == 0) { if (!handle_f()) return false; } else if (strcmp(_argv[_i], "-F") == 0) { if (!handle_F()) return false; } else if (strcmp(_argv[_i], "-wa") == 0) { if (!handle_wa()) return false; } else if (strcmp(_argv[_i], "-wao") == 0) { if (!handle_wao()) return false; } else if (strcmp(_argv[_i], "-wb") == 0) { if (!handle_wb()) return false; } else if (strcmp(_argv[_i], "-wo") == 0) { if (!handle_wo()) return false; } else if (strcmp(_argv[_i], "-c") == 0) { if (!handle_c()) return false; } else if(strcmp(_argv[_i], "-r") == 0) { if (!handle_r()) return false; } else if(strcmp(_argv[_i], "-e") == 0) { if (!handle_e()) return false; } else if (strcmp(_argv[_i], "-v") == 0) { if (!handle_v()) return false; } else if (strcmp(_argv[_i], "-s") == 0) { if (!handle_s()) return false; } else if (strcmp(_argv[_i], "-S") == 0) { if (!handle_S()) return false; } else if (strcmp(_argv[_i], "-loj") == 0) { if (!handle_loj()) return false; } } return ContextBase::parseCmdArgs(argc, argv, _skipFirstArgs); }
/* ////////////////////////////////////////////////////////////////////////// */ int mmu_args_process_user_input(mmu_args_t *a, int argc, char **argv) { int c; int rc = MMU_FAILURE; char **tmp_argv = NULL; if (NULL == (tmp_argv = mmu_args_dup_argv(argc, argv))) { MMU_OOR_COMPLAIN(); return MMU_FAILURE_OOR; } while (-1 != (c = getopt_long_only(argc, tmp_argv, opt_string, long_opts, NULL))) { switch (c) { case 's': /* samples-per-sec */ if (MMU_SUCCESS != (rc = handle_s(a, c, optarg))) { goto show_usage; } break; case 't': /* sample-time */ if (MMU_SUCCESS != (rc = handle_t(a, c, optarg))) { goto show_usage; } break; case 'w': /* enable workload */ if (MMU_SUCCESS != (rc = handle_w(a))) { goto show_usage; } break; case 'h': /* help! */ mmu_args_usage(); rc = MMU_SUCCESS_EXIT_SUCCESS; goto cleanup; break; case 'v': /* version, please */ showver(); rc = MMU_SUCCESS_EXIT_SUCCESS; goto cleanup; break; default: goto show_usage; } } if (optind < argc) { fprintf(stderr, MMU_ERR_PREFIX"unrecognized input: \"%s\"\n", tmp_argv[optind]); goto show_usage; } /* all is well */ rc = MMU_SUCCESS; goto cleanup; show_usage: mmu_args_usage(); rc = MMU_FAILURE_INVALID_USER_INPUT; cleanup: if (NULL != tmp_argv) { mmu_args_free_dup_argv(tmp_argv); } return rc; }