int main(void) {
    type_t tau;

    init_type_table(&types, 0);
    init_variables();
    init_types();

    // pair(A) = (tuple A A)
    tau = pair_type(var[0], var[0]);
    test_macro("pair", 1, var, tau);

    // triple(B) = (tuple B B B)
    tau = triple_type(var[1], var[1], var[1]);
    test_macro("triple", 1, var+1, tau);

    // test(C, D) = bool
    test_macro("test", 2, var+2, base[0]);

    // fun(E, F) = (-> (tuple E E) F)
    tau = pair_type(var[4], var[4]);
    tau = function_type(&types, var[5], 1, &tau);
    test_macro("fun", 2, var+4, tau);

    // two constructors
    test_constructor("mk_type2", 2);
    test_constructor("mk_type3", 3);

    printf("\n====== TYPES ========\n");
    print_type_table(stdout, &types);
    printf("\n===== MACROS ========\n");
    print_type_macros(stdout, &types);
    printf("===\n\n");

    // creation after remove
    // vector[G] = (-> int G)
    tau = int_type(&types);
    tau = function_type(&types, var[6], 1, &tau);
    test_macro("vector", 1, var+6, tau);

    // matrix[H] = (-> int int H)
    tau = int_type(&types);
    tau = binary_ftype(tau, tau, var[7]);
    test_macro("matrix", 1, var+7, tau);

    printf("\n====== TYPES ========\n");
    print_type_table(stdout, &types);
    printf("\n===== MACROS ========\n");
    print_type_macros(stdout, &types);
    printf("===\n\n");

    delete_type_table(&types);

    return 0;
}
Beispiel #2
0
int main(void) {
  init_type_table(&types, 10);
  init_value_table(&vtbl, 0, &types);
  init_fresh_val_maker(&maker, &vtbl);

  init_base_types();

  test_base_types();

  delete_fresh_val_maker(&maker);
  delete_value_table(&vtbl);
  delete_type_table(&types);

  return 0;
}
Beispiel #3
0
int main() {
  init_type_table(&types, 10);
  init_pstore(&store, &types);

  test1();
  test2();
  test3();
  test4();
  test5();
  test6();

  delete_pstore(&store);
  delete_type_table(&types);

  return 0;
}
Beispiel #4
0
int main(void) {
  init_type_table(&types, 10);
  init_value_table(&vtbl, 0, &types);

  init_base_types();
  test_base_types();
  test_pairs(1000);
  test_triples(1000);
  test_unary_functions(1000);
  test_bin_functions(1000);
  test_deep_type();

  delete_value_table(&vtbl);
  delete_type_table(&types);

  return 0;
}
Beispiel #5
0
int read_stab_entries(int fd, Elf32_Ehdr *header, unsigned char *buffer)
{
    int i=0;
    Elf32_Shdr *section;
	Elf32_Shdr *stab_section, *stabstr_section;
	struct stab stab;
	unsigned char *stabstr_buf;
	int num_entries;
	struct stab_entry *entry;
	
	stab_section = NULL;
	stabstr_section = NULL;

    section = (Elf32_Shdr*)mdb_zalloc(sizeof(Elf32_Shdr), UM_SLEEP);

    lseek(fd, header->e_shoff, SEEK_SET);
    for (i=0; i < header->e_shnum; i++) {
        read(fd, section, sizeof(Elf32_Shdr));
        if (strcmp((char*) (buffer + section->sh_name), ".stab.excl")==0) {
            stab_section = section;
			break;
		}
    }

	if (stab_section == NULL) {
		printf("No debugging information found\n");
		return -1;
	}

	section = (Elf32_Shdr*)mdb_zalloc(sizeof(Elf32_Shdr), UM_SLEEP);
    lseek(fd, header->e_shoff, SEEK_SET);
    for (i=0; i < header->e_shnum; i++) {
        read(fd, section, sizeof(Elf32_Shdr));
        if (strcmp((char*)(buffer + section->sh_name), ".stab.exclstr")==0) {
            stabstr_section = section;
			break;
		}
    }
	if (stabstr_section == NULL) {
		printf("No debugging information found\n");
		return -1;	
	}
	stabstr_buf = (unsigned char *)mdb_alloc(stabstr_section->sh_size, UM_SLEEP);		
	lseek(fd, stabstr_section->sh_offset, SEEK_SET);
	read(fd, stabstr_buf, stabstr_section->sh_size);

	lseek(fd, stab_section->sh_offset, SEEK_SET);		
	num_entries = stab_section->sh_size / stab_section->sh_entsize;
	printf("Number of stab entries are %d\n", num_entries);
	i=0;
	while (i<num_entries)
 	{
		read(fd, &stab, sizeof(struct stab));
		if (stab.n_type != 128) {
			i++;
			continue;
		}

		entry = (struct stab_entry *)mdb_zalloc(sizeof(struct stab_entry), UM_SLEEP);
		entry->type = stab.n_type;
		entry->other = stab.n_other;
		entry->desc = stab.n_desc;
		entry->value = stab.n_value;
		entry->str = (stabstr_buf + stab.n_strx);

		add_stab_entry(entry);
		i++;
	}

    init_type_table();
    entry = stabs_list_head;
    while (entry != NULL) {
		 /* printf("%s\n", entry->str); */
        parse_stab_entry(entry);
        entry = entry->next;
    }

    process_forward_refs();
	free_stab_entry_list();
	mdb_free(stabstr_buf, stabstr_section->sh_size);
	mdb_free(stab_section, sizeof(Elf32_Shdr));
	mdb_free(stabstr_section, sizeof(Elf32_Shdr));
	return 0;
}