Пример #1
0
/**
 * The "gdbstub" command
 *
 * @v argc		Argument count
 * @v argv		Argument list
 * @ret rc		Return status code
 */
static int gdbstub_exec ( int argc, char **argv ) {
	struct gdbstub_options opts;
	struct gdb_transport *trans;
	int rc;

	/* Parse options */
	if ( ( rc = parse_options ( argc, argv, &gdbstub_cmd, &opts ) ) != 0 )
		return rc;

	/* Parse transport name */
	if ( ( rc = parse_gdb_transport ( argv[optind++], &trans ) ) != 0 )
		return rc;

	/* Initialise transport */
	if ( trans->init ) {
		if ( ( rc = trans->init ( argc - optind,
					  &argv[optind] ) ) != 0 ) {
			return rc;
		}
	}

	/* Enter GDB stub */
	gdbstub_start ( trans );

	return 0;
}
Пример #2
0
/**
 * The "gdbstub" command
 *
 * @v argc		Argument count
 * @v argv		Argument list
 * @ret rc		Exit code
 */
static int gdbstub_exec ( int argc, char **argv ) {
	static struct option longopts[] = {
		{ "help", 0, NULL, 'h' },
		{ NULL, 0, NULL, 0 },
	};
	const char *trans_name;
	struct gdb_transport *trans;
	int c;

	/* Parse options */
	while ( ( c = getopt_long ( argc, argv, "h", longopts, NULL ) ) >= 0 ){
		switch ( c ) {
		case 'h':
			/* Display help text */
		default:
			/* Unrecognised/invalid option */
			gdbstub_syntax ( argv );
			return 1;
		}
	}

	/* At least one argument */
	if ( optind == argc ) {
		gdbstub_syntax ( argv );
		return 1;
	}

	trans_name = argv[optind++];

	/* Initialise transport */
	trans = find_gdb_transport ( trans_name );
	if ( !trans ) {
		printf ( "%s: no such transport (is it compiled in?)\n", trans_name );
		return 1;
	}

	if ( trans->init ) {
		if ( trans->init ( argc - optind, &argv[optind] ) != 0 ) {
			return 1;
		}
	}

	/* Enter GDB stub */
	gdbstub_start ( trans );
	return 0;
}