Exemplo n.º 1
0
/*
 * Session initialization
 */
int
DbgInit(session **sess, int argc, char *argv[])
{
	session *		s;
	
	*sess = s = (session *)malloc(sizeof(session));
	
	if (sdm_init(argc, argv) < 0) {
		return -1;
	}

	s->sess_procs = sdm_route_get_size() - 1;

	tmp_idset = sdm_set_new();
	tmp_bitset = bitset_new(s->sess_procs);

	sdm_aggregate_set_completion_callback(session_event_handler, (void *)s);

	return 0;
}
Exemplo n.º 2
0
/*
 * Main entry point for MPI parallel debugger.
 *
 * @arg	--debugger=type			select backend debugger
 * @arg	--debugger_path=path	set backend debugger path
 * @arg	--port=port				port number to listen on/connect to
 * @arg	--host=host				host to connect to
 * @arg	--proxy=proxy_type		type of proxy connection to use
 * @arg --master				master process
 * @arg --server=id				server process with rank 'id'
 */
int
main(int argc, char *argv[])
{
	int 			ch;
	int				port = PTP_PROXY_TCP_PORT;
	char *			host = NULL;
	char *			debugger_str = DEFAULT_BACKEND;
	char *			proxy_str = DEFAULT_PROXY;
	char *			path = NULL;
	proxy *			p;
	dbg_backend *	d;
#ifdef _AIX
	int				n;
	char *			cp;
#endif

#ifndef _AIX
	while ((ch = getopt_long(argc, argv, shortopts, longopts, NULL)) != -1) {
		if (ch == 0) {
			switch (opt_type) {
			case OPT_TYPE_DEBUGGER:
				debugger_str = optarg;
				break;
			case OPT_TYPE_DEBUGGER_PATH:
				path = optarg;
				break;
			case OPT_TYPE_PROXY:
				proxy_str = optarg;
				break;
			case OPT_TYPE_PORT:
				port = (int)strtol(optarg, NULL, 10);
				break;
			case OPT_TYPE_HOST:
				host = optarg;
				break;
			case OPT_TYPE_MASTER:
			case OPT_TYPE_SERVER:
				break;
#ifdef DEBUG
			case OPT_TYPE_DEBUG:
				if (optarg == NULL)
					debug_level = DEBUG_LEVEL_ALL;
				else
					debug_level = (int)strtol(optarg, NULL, 10);
				break;
#endif /* DEBUG */
			}
		} else {
			fprintf(stderr,
				"sdm [--debugger=value] [--debugger_path=path]\n"
				"    [--proxy=proxy]\n"
				"    [--host=host_name] [--port=port]\n"
				"	 [--master]\n"
				"    [--server=rank]\n"
#ifdef DEBUG
				"    [--debug[=level]]\n"
#endif /* DEBUG */
			);
			return 1;
		}
	}
#else
		/*
		 * AIX does not support GNU style getopt with long options.
		 * Parse options by string comparison instead.
		 */
	n = 1;
	while (n < argc) {
		cp = strchr(argv[n], '=');
		if (cp == NULL) {
			if (strcmp(argv[n], "--master") == 0 ||
				strncmp(argv[n], "--server", 8) == 0) {
				/* No action required */
#ifdef DEBUG
			} else if (strcmp(argv[n], "--debug") == 0) {
				debug_level = DEBUG_LEVEL_ALL;
#endif
			}
			else {
				fprintf(stderr,
					"sdm [--debugger=value] [--debugger_path=path]\n"
					"    [--proxy=proxy]\n"
					"    [--host=host_name] [--port=port]\n"
					"	 [--master]\n"
					"    [--server=rank]\n"
#ifdef DEBUG
					"    [--debug[=level]]\n"
#endif /* DEBUG */
				);
				return 1;
			}
		}
		else {
			*cp = '\0';
			if (strncmp(argv[n], "--debugger", 10) == 0) {
				debugger_str = strdup(cp + 1);
			}
			else if (strncmp(argv[n], "--debugger_path", 15) == 0) {
				path = strdup(cp + 1);
			}
			else if (strncmp(argv[n], "--proxy", 7) == 0) {
				proxy_str = strdup(cp + 1);
			}
			else if (strncmp(argv[n], "--port", 6) == 0) {
				port = (int) strtol(cp + 1, NULL, 10);
			}
			else if (strncmp(argv[n], "--host", 6) == 0) {
				host = strdup(cp + 1);
			}
#ifdef DEBUG
			else if (strncmp(argv[n], "--debug", 7) == 0) {
				debug_level = (int) strtol(cp + 1, NULL, 10);
			}
#endif
			else {
				fprintf(stderr,
					"sdm [--debugger=value] [--debugger_path=path]\n"
					"    [--proxy=proxy]\n"
					"    [--host=host_name] [--port=port]\n"
					"	 [--master]\n"
					"    [--server=rank]\n"
#ifdef DEBUG
					"    [--debug[=level]]\n"
#endif /* DEBUG */
				);
				return 1;
			}
		}
		n = n + 1;
	}
#endif

	if (find_dbg_backend(debugger_str, &d) < 0) {
		fprintf(stderr, "No such backend: \"%s\"\n", debugger_str);
		return 1;
	}

	if (path != NULL) {
		backend_set_path(d, path);
	}

	if (find_proxy(proxy_str, &p) < 0) {
		fprintf(stderr,"No such proxy: \"%s\"\n", proxy_str);
		return 1;
	}

	if (sdm_init(argc, argv) < 0) {
		DEBUG_PRINTS(DEBUG_LEVEL_STARTUP, "sdm_init failed\n");
		return 1;
	}

	if (sdm_route_get_id() == SDM_MASTER) {
		DEBUG_PRINTS(DEBUG_LEVEL_STARTUP, "starting client\n");
		master(proxy_str, host, port);
	} else {
		DEBUG_PRINTF(DEBUG_LEVEL_STARTUP, "starting task %d\n", sdm_route_get_id());
		server(d);
	}

	DEBUG_PRINTS(DEBUG_LEVEL_STARTUP, "all finished\n");

	sdm_finalize();

	return 0;
}