示例#1
0
文件: main.c 项目: jmp3833/SE350
/*
 * Main driver program.
 * The arguments are ignored.
 */
int main ( int ac, char **av ) {
 
    read_file() ;
    initialize_ordered_list() ;
    build_huffman_tree();
    traverse_tree( ol_remove(), "" ) ;
    print_codes() ;

    exit(0) ;
}
示例#2
0
// ------------------------------------------------------------------
// ciMethod::load_code
//
// Load the bytecodes and exception handler table for this method.
void ciMethod::load_code() {
  VM_ENTRY_MARK;
  assert(is_loaded(), "only loaded methods have code");

  methodOop me = get_methodOop();
  Arena* arena = CURRENT_THREAD_ENV->arena();

  // Load the bytecodes.
  _code = (address)arena->Amalloc(code_size());
  memcpy(_code, me->code_base(), code_size());

  // Revert any breakpoint bytecodes in ci's copy
  if (me->number_of_breakpoints() > 0) {
    BreakpointInfo* bp = instanceKlass::cast(me->method_holder())->breakpoints();
    for (; bp != NULL; bp = bp->next()) {
      if (bp->match(me)) {
        code_at_put(bp->bci(), bp->orig_bytecode());
      }
    }
  }

  // And load the exception table.
  typeArrayOop exc_table = me->exception_table();

  // Allocate one extra spot in our list of exceptions.  This
  // last entry will be used to represent the possibility that
  // an exception escapes the method.  See ciExceptionHandlerStream
  // for details.
  _exception_handlers =
    (ciExceptionHandler**)arena->Amalloc(sizeof(ciExceptionHandler*)
                                         * (_handler_count + 1));
  if (_handler_count > 0) {
    for (int i=0; i<_handler_count; i++) {
      int base = i*4;
      _exception_handlers[i] = new (arena) ciExceptionHandler(
                                holder(),
            /* start    */      exc_table->int_at(base),
            /* limit    */      exc_table->int_at(base+1),
            /* goto pc  */      exc_table->int_at(base+2),
            /* cp index */      exc_table->int_at(base+3));
    }
  }

  // Put an entry at the end of our list to represent the possibility
  // of exceptional exit.
  _exception_handlers[_handler_count] =
    new (arena) ciExceptionHandler(holder(), 0, code_size(), -1, 0);

  if (CIPrintMethodCodes) {
    print_codes();
  }
}
示例#3
0
文件: main.c 项目: djs55/ocfs2-tools
/*
 * read_options()
 *
 */
static int read_options(int argc, char **argv)
{
	int i, c, listcode = 0, showmkfs = 0;
	int ret = 0;

	progname = basename(argv[0]);

	if (argc < 2)
		usage();

	while (1) {
		c = getopt(argc, argv, "lnc:C:N:L:M");
		if (c == -1)
			break;

		switch (c) {
		case 'c':	/* corrupt code string */
			ret = parse_corrupt_codes(optarg);
			break;

		case 'l':
			print_codes();
			break;

		case 'L':
			listcode = 1;
		case 'C':	/* corrupt code number */
			ret = atoi(optarg);
			if (ret < NUM_FSCK_TYPE)
				corrupt[ret] = 1;
			else {
				fprintf(stderr, "Corrupt code \"%d\" is not "
					"supported.\n", ret);
				exit(-1);
			}
			break;

		case 'M':	/* mkfs features */
			showmkfs = 1;
			break;

		case 'n':
			fprintf(stdout, "%d\n", NUM_FSCK_TYPE);
			exit(NUM_FSCK_TYPE);

		case 'N':	/* slotnum */
			slotnum = strtoul(optarg, NULL, 0);
			break;

		default:
			ret = -1;
			goto out;
		}
	}

	if (listcode) {
		for (i = 0; i < NUM_FSCK_TYPE; i++) {
			if (corrupt[i]) {
				fprintf(stdout, "%s\n",
					prompt_codes[i].pc_codestr);
				listcode = 0;
				break;
			}
		}
		exit(listcode);
	}

#define MKFS_PARAMS_FIX		\
	"-b 4096 -C 4096 --fs-feature-level=max-features -J size=16M "	\
	"-L fswreck -M local"

	if (showmkfs) {
		for (i = 0; i < NUM_FSCK_TYPE; i++) {
			if (corrupt[i]) {
				fprintf(stdout, MKFS_PARAMS_FIX);
				fprintf(stdout, " -N %d",
					prompt_codes[i].pc_slots);
				if (strlen(prompt_codes[i].pc_fsfeat))
					fprintf(stdout, " --fs-features=%s",
						prompt_codes[i].pc_fsfeat);
				fprintf(stdout, "\n");
				showmkfs = 0;
				break;
			}
		}
		exit(showmkfs);
	}

	if (optind >= argc || !argv[optind]) {
		ret = -1;
		goto out;
	}

	device = argv[optind];

out:
	if (ret < 0)
		usage();

	return ret;
}