예제 #1
0
파일: cmd.c 프로젝트: endofexclusive/astub
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;
}
예제 #2
0
bool ContextClosest::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], "-c") == 0) {
			//bypass intersect's use of the -c option, because -c
			//means writeCount for intersect, but means columns for map.
			if (!ContextBase::handle_c()) return false;
		}
        else if (strcmp(_argv[_i], "-d") == 0) {
           if (!handle_d()) return false;
        }
        else if (strcmp(_argv[_i], "-D") == 0) {
        	if (!handle_D()) return false;
        }
        else if (strcmp(_argv[_i], "-io") == 0) {
        	if (!handle_io()) return false;
        }
        else if (strcmp(_argv[_i], "-iu") == 0) {
        	if (!handle_iu()) return false;
        }
        else if (strcmp(_argv[_i], "-id") == 0) {
        	if (!handle_id()) return false;
        }
        else if (strcmp(_argv[_i], "-N") == 0) {
        	if (!handle_N()) return false;
        }
        else if (strcmp(_argv[_i], "-t") == 0) {
        	if (!handle_t()) return false;
        }
        else if (strcmp(_argv[_i], "-mdb") == 0) {
        	if (!handle_mdb()) return false;
        }

	}
	return ContextIntersect::parseCmdArgs(argc, argv, _skipFirstArgs);
}