main.c

来自「kaffe Java 解释器语言,源码,Java的子集系统,开放源代码」· C语言 代码 · 共 782 行 · 第 1/2 页

C
782
字号
			exit(0);		}#if defined(__ia64__)		else if (strcmp(argv[i], "-ia32") == 0) {			i++;			/* FIXME: skip, case handled by the calle script */		}#endif		else if ((strcmp(argv[i], "-addclasspath") == 0)			 || (strcmp(argv[i], "-classpath") == 0)			 || (strcmp(argv[i], "-cp") == 0)) {			char	*newcpath;			int      cpathlength;			i++;			if (argv[i] == 0) {				fprintf(stderr, 				    "Error: No path found for %s option.\n",				    argv[i - 1]);				exit(1);			}			cpathlength = ((vmargs.classpath != NULL) ? strlen(vmargs.classpath) : 0)				+ strlen(path_separator)				+ strlen(argv[i])				+ 1;			/* Get longer buffer FIXME:  free the old one */			if ((newcpath = malloc(cpathlength)) == NULL) {				fprintf(stderr,  "Error: out of memory.\n");				exit(1);			}			/* Construct new classpath */			if( vmargs.classpath != 0 )			  	strcpy(newcpath, vmargs.classpath);			else				newcpath[0] = '\0';			strcat(newcpath, path_separator);			strcat(newcpath, argv[i]);			/* set the new classpath */			vmargs.classpath = newcpath;		}		else if (strncmp(argv[i], "-Xbootclasspath/p:", (j=18)) == 0) {			char	*newbootcpath;			int      bootcpathlength;			bootcpathlength = strlen(&argv[i][j])				+ strlen(path_separator)				+ ((vmargs.bootClasspath != NULL) ?					strlen(vmargs.bootClasspath) : 0)				+ 1;			/* Get longer buffer FIXME:  free the old one */			if ((newbootcpath = malloc(bootcpathlength)) == NULL) {				fprintf(stderr,  "Error: out of memory.\n");				exit(1);			}			/* Construct new boot classpath */			strcpy(newbootcpath, &argv[i][j]);			strcat(newbootcpath, path_separator);			if( vmargs.bootClasspath != 0 )			  	strcat(newbootcpath, vmargs.bootClasspath);			/* set the new boot classpath */			vmargs.bootClasspath = newbootcpath;		}		else if ((strncmp(argv[i], "-ss", (j=3)) == 0) 			 || (strncmp(argv[i], "-Xss", (j=4)) == 0)) {			if (argv[i][j] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "Error: No stack size found for -ss option.\n");					exit(1);				}				sz = parseSize(argv[i]);			} else {				sz = parseSize(&argv[i][j]);			}			if (sz < THREADSTACKSIZE) {				fprintf(stderr,  "Warning: Attempt to set stack size smaller than %d - ignored.\n", THREADSTACKSIZE);			}			else {				vmargs.nativeStackSize = sz;			}		}		else if ((strncmp(argv[i], "-mx", (j=3)) == 0)			 || (strncmp(argv[i], "-Xmx", (j=4)) == 0)) {			if (argv[i][j] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "Error: No heap size found for -mx option.\n");					exit(1);				}				vmargs.maxHeapSize = parseSize(argv[i]);			} else {				vmargs.maxHeapSize = parseSize(&argv[i][j]);			}		}		else if ((strncmp(argv[i], "-ms", (j=3)) == 0)			 || (strncmp(argv[i], "-Xms", (j=4)) == 0)) {			if (argv[i][j] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "Error: No heap size found for -ms option.\n");					exit(1);				}				vmargs.minHeapSize = parseSize(argv[i]);			} else {				vmargs.minHeapSize = parseSize(&argv[i][j]);			}		}		else if (strncmp(argv[i], "-as", 3) == 0) {			if (argv[i][3] == 0) {				i++;				if (argv[i] == 0) {					fprintf(stderr,  "Error: No heap size found for -as option.\n");					exit(1);				}				vmargs.allocHeapSize = parseSize(argv[i]);			} else {				vmargs.allocHeapSize = parseSize(&argv[i][3]);			}		}		else if (strcmp(argv[i], "-verify") == 0) {			vmargs.verifyMode = 3;		}		else if (strcmp(argv[i], "-verifyremote") == 0) {			vmargs.verifyMode = 2;		}		else if (strcmp(argv[i], "-noverify") == 0) {			vmargs.verifyMode = 0;		}		else if (strcmp(argv[i], "-verbosegc") == 0) {			vmargs.enableVerboseGC = 1;		}		else if (strcmp(argv[i], "-noclassgc") == 0) {			vmargs.enableClassGC = 0;		}		else if (strcmp(argv[i], "-verbosejit") == 0) {			vmargs.enableVerboseJIT = 1;		}		else if (strcmp(argv[i], "-verbosemem") == 0) {			vmargs.enableVerboseGC = 2;		}		else if (strcmp(argv[i], "-verbosecall") == 0) {			vmargs.enableVerboseCall = 1;		}		else if (strcmp(argv[i], "-verbose") == 0 || strcmp(argv[i], "-v") == 0) {			vmargs.enableVerboseClassloading = 1;		}                else if (strcmp(argv[i], "-jar") == 0) {                        isJar = 1;                }		else if (strncmp(argv[i], "-Xrun", 5) == 0) {			jvm_onload = argv[i];		}#if defined(KAFFE_PROFILER)		else if (strcmp(argv[i], "-prof") == 0) {			profFlag = 1;			vmargs.enableClassGC = 0;		}#endif#if defined(KAFFE_XPROFILER)		else if (strcmp(argv[i], "-Xxprof") == 0) {			xProfFlag = 1;			vmargs.enableClassGC = 0;		}		else if (strcmp(argv[i], "-Xxprof_syms") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"Error: -Xxprof_syms option requires "					"a file name.\n");			}			else if( !profileSymbolFile(argv[i]) )			{				fprintf(stderr, 					"Unable to create profiler symbol "					"file %s.\n",					argv[i]);			}		}		else if (strcmp(argv[i], "-Xxprof_gmon") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"Error: -Xxprof_gmon option requires "					"a file name.\n");			}			else if (!profileGmonFile(argv[i]))			{				fprintf(stderr, 					"Unable to create gmon file %s.\n",					argv[i]);			}		}#endif#if defined(KAFFE_XDEBUGGING)		else if (strcmp(argv[i], "-Xxdebug") == 0) {			/* Use a default name */			machine_debug_filename = "xdb.as";		}		else if (strcmp(argv[i], "-Xxdebug_file") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"Error: -Xxdebug_file option requires "					"a file name.\n");			}			else			{				machine_debug_filename = argv[i];			}		}#endif#if defined(KAFFE_FEEDBACK)		else if (strcmp(argv[i], "-Xfeedback") == 0) {			i++;			if (argv[i] == 0) {				fprintf(stderr, 					"Error: -Xfeedback option requires a "					"file name.\n");			}			else			{				feedback_filename = argv[i];			}		}#endif		else if (strcmp(argv[i], "-nodeadlock") == 0) {			deadlockDetection = 0;		}#if defined(KAFFE_STATS)                else if (strcmp(argv[i], "-vmstats") == 0) {			extern void statsSetMaskStr(char *);                        i++;                        if (argv[i] == 0) { /* forgot second arg */                                fprintf(stderr, 					"Error: -vmstats option requires a "					"second arg.\n");                                exit(1);                        }                        statsSetMaskStr(argv[i]);                }#endif#if defined(KAFFE_VMDEBUG)                else if (strcmp(argv[i], "-vmdebug") == 0) {                        i++;                        if (argv[i] == 0) { /* forgot second arg */                                fprintf(stderr, 					"Error: -vmdebug option requires a "					"debug flag. Use `list' for a list.\n");                                exit(1);                        }                        if (!dbgSetMaskStr(argv[i]))				exit(1);                }#endif		else if (argv[i][1] ==  'D') {			/* Set a property */			prop = malloc(sizeof(userProperty));			assert(prop != 0);			prop->next = userProperties;			userProperties = prop;			for (sz = 2; argv[i][sz] != 0; sz++) {				if (argv[i][sz] == '=') {					argv[i][sz] = 0;					sz++;					break;				}			}			prop->key = &argv[i][2];			prop->value = &argv[i][sz];		}		else if (argv[i][1] == 'X') {			fprintf(stderr, 				"Error: Unrecognized JVM specific option "				"`%s'.\n",				argv[i]);		}		/* The following options are not supported and will be		 * ignored for compatibility purposes.		 */		else if (strcmp(argv[i], "-noasyncgc") == 0 ||		   strcmp(argv[i], "-cs") == 0 ||		   strcmp(argv[i], "-checksource")) {		}		else if (strcmp(argv[i], "-oss") == 0) {			i++;		}		else {			fprintf(stderr,  "Unknown flag: %s\n", argv[i]);		}	}	/* Return first no-flag argument */	return (i);}/* * Print usage message. */staticvoidusage(void){	fprintf(stderr, "usage: kaffe [-options] class\n");	fprintf(stderr, "Options are:\n");	fprintf(stderr, "	-help			Print this message\n");	fprintf(stderr, "	-version		Print version number\n");	fprintf(stderr, "	-fullversion		Print verbose version info\n");#if defined(__ia64__)	fprintf(stderr, "	-ia32			Execute the ia32 version of Kaffe\n");#endif	fprintf(stderr, "	-ss <size>		Maximum native stack size\n");	fprintf(stderr, "	-mx <size> 		Maximum heap size\n");	fprintf(stderr, "	-ms <size> 		Initial heap size\n");	fprintf(stderr, "	-as <size> 		Heap increment\n");	fprintf(stderr, "	-classpath <path>	Set classpath\n");	fprintf(stderr, "       -D<property>=<value>    Set a property\n");	fprintf(stderr, "	-verify *		Verify all bytecode\n");	fprintf(stderr, "	-verifyremote *		Verify bytecode loaded from network\n");	fprintf(stderr, "	-noverify		Do not verify any bytecode\n");	fprintf(stderr, "	-noclassgc		Disable class garbage collection\n");	fprintf(stderr, "	-verbosegc		Print message during garbage collection\n");	fprintf(stderr, "	-v, -verbose		Be verbose\n");	fprintf(stderr, "	-verbosejit		Print message during JIT code generation\n");	fprintf(stderr, "	-verbosemem		Print detailed memory allocation statistics\n");	fprintf(stderr, "	-verbosecall		Print detailed call flow information\n");	fprintf(stderr, "	-nodeadlock		Disable deadlock detection\n");#if defined(KAFFE_PROFILER)	fprintf(stderr, "	-prof			Enable profiling of Java methods\n");#endif#if defined(KAFFE_XPROFILER)	fprintf(stderr, "	-Xxprof			Enable cross language profiling\n");	fprintf(stderr, "	-Xxprof_syms <file>	Name of the profiling symbols file [Default: kaffe-jit-symbols.s]\n");	fprintf(stderr, "	-Xxprof_gmon <file>	Base name for gmon files [Default: xgmon.out]\n");#endif#if defined(KAFFE_XDEBUGGING)	fprintf(stderr, "	-Xxdebug_file <file>	Name of the debugging symbols file\n");#endif#if defined(KAFFE_FEEDBACK)	fprintf(stderr, "	-Xfeedback <file>	The file name to write feedback data to\n");#endif	fprintf(stderr, "	-debug * 		Trace method calls\n");	fprintf(stderr, "	-noasyncgc *		Do not garbage collect asynchronously\n");	fprintf(stderr, "	-cs, -checksource *	Check source against class files\n");	fprintf(stderr, "	-oss <size> *		Maximum java stack size\n");        fprintf(stderr, "	-jar                    Executable is a JAR\n");#ifdef KAFFE_VMDEBUG        fprintf(stderr, "	-vmdebug <flag{,flag}>	Internal VM debugging.  Set flag=list for a list\n");#endif#ifdef KAFFE_STATS        fprintf(stderr, "	-vmstats <flag{,flag}>	Print VM statistics.  Set flag=all for all\n");#endif	fprintf(stderr, "  * Option currently ignored.\n");	fprintf(stderr, "\n");	fprintf(stderr, "Compatibility options:\n");	fprintf(stderr, "	-Xss <size>		Maximum native stack size\n");	fprintf(stderr, "	-Xmx <size> 		Maximum heap size\n");	fprintf(stderr, "	-Xms <size> 		Initial heap size\n");	fprintf(stderr, "	-cp <path> 		Set classpath\n");}staticsize_tparseSize(char* arg){	size_t sz;	char* narg;	sz = strtol(arg, &narg, 0);	switch (narg[0]) {	case 'b': case 'B':		break;	case 'k': case 'K':		sz *= 1024;		break;	case 'm': case 'M':		sz *= 1024 * 1024;		break;	}	return (sz);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?