Esempio n. 1
0
debug_view *debug_view_manager::alloc_view(debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate)
{
	switch (type)
	{
		case DVT_CONSOLE:
			return append(global_alloc(debug_view_console(machine(), osdupdate, osdprivate)));

		case DVT_STATE:
			return append(global_alloc(debug_view_state(machine(), osdupdate, osdprivate)));

		case DVT_DISASSEMBLY:
			return append(global_alloc(debug_view_disasm(machine(), osdupdate, osdprivate)));

		case DVT_MEMORY:
			return append(global_alloc(debug_view_memory(machine(), osdupdate, osdprivate)));

		case DVT_LOG:
			return append(global_alloc(debug_view_log(machine(), osdupdate, osdprivate)));

		case DVT_BREAK_POINTS:
			return append(global_alloc(debug_view_breakpoints(machine(), osdupdate, osdprivate)));

		case DVT_WATCH_POINTS:
			return append(global_alloc(debug_view_watchpoints(machine(), osdupdate, osdprivate)));

		default:
			fatalerror("Attempt to create invalid debug view type %d\n", type);
	}
	return nullptr;
}
Esempio n. 2
0
debug_view *debug_view_manager::alloc_view(debug_view_type type, debug_view_osd_update_func osdupdate, void *osdprivate)
{
	switch (type)
	{
		case DVT_CONSOLE:
			return append(auto_alloc(&m_machine, debug_view_console(m_machine, osdupdate, osdprivate)));

		case DVT_STATE:
			return append(auto_alloc(&m_machine, debug_view_state(m_machine, osdupdate, osdprivate)));

		case DVT_DISASSEMBLY:
			return append(auto_alloc(&m_machine, debug_view_disasm(m_machine, osdupdate, osdprivate)));

		case DVT_MEMORY:
			return append(auto_alloc(&m_machine, debug_view_memory(m_machine, osdupdate, osdprivate)));

		case DVT_LOG:
			return append(auto_alloc(&m_machine, debug_view_log(m_machine, osdupdate, osdprivate)));

		case DVT_TIMERS:
//          return append(auto_alloc(&m_machine, debug_view_timers(m_machine, osdupdate, osdprivate)));

		case DVT_ALLOCS:
//          return append(auto_alloc(&m_machine, debug_view_allocs(m_machine, osdupdate, osdprivate)));

		default:
			fatalerror("Attempt to create invalid debug view type %d\n", type);
	}
	return NULL;
}
Esempio n. 3
0
File: vm.c Progetto: endeav0r/ravm
int main (int argc, char * argv[]) {
    char * filename = NULL;
    char * output_filename = NULL;
    int opt_god_mode = 0;
    int c;
    int memory_view_offset = VM_MEMORY_SIZE - 32;
    int memory_view_bytes  = 32;
    int print_info = 0;
    int step = 0;
    int error;
    struct _vm * vm;
    
    while ((c = getopt(argc, argv, "b:gi:m:o:sp")) != -1) {
        switch (c) {
            case 'b' :
                memory_view_bytes = strtoul(optarg, NULL, 16);
                break;
            case 'g' :
                opt_god_mode = 1;
                break;
            case 'i' :
                filename = optarg;
                break;
            case 'm' :
                memory_view_offset = strtoul(optarg, NULL, 16);
                break;
            case 'o' :
                output_filename = optarg;
                break;
            case 'p' :
                print_info = 1;
                break;
            case 's' :
                step = 1;
                print_info = 1;
                break;
            case '?' :
                if ((optopt == 'f') || (optopt == 'o')) {
                    fprintf(stderr, "option %c requires argument\n", optopt);
                    exit(0);
                }
                else {
                    fprintf(stderr, "Unknown option: %c\n", optopt);
                    exit(0);
                }
        }
    }
    
    if (filename == NULL) {
        fprintf(stderr, "Usage: %s [-ps] [-o output] -i image\n", argv[0]);
        fprintf(stderr, "Runs an assembled image for the rnp_vm\n");
        fprintf(stderr, "\n");
        fprintf(stderr, "  -b [hex]   BYTES of memory to view in debug output\n");
        fprintf(stderr, "  -g         god mode allows visualization of memory\n");
        fprintf(stderr, "  -i [path]  path to IMAGE\n");
        fprintf(stderr, "  -m [hex]   OFFSET in memory to view in debug output\n");
        fprintf(stderr, "  -o [path]  path to OUTPUT memory dump at HLT\n");
        fprintf(stderr, "  -p         PRINT info at each step\n");
        fprintf(stderr, "  -s         STEP through instruction (implies PRINT)\n");
        exit(0);
    }
    
    vm = (struct _vm *) malloc(sizeof(struct _vm));
    vm_initialize(vm);
    
    if ((error = image_load(vm, filename)) != 0) {
        fprintf(stderr, "error %d\n", error);
        exit(error);
    }
    
    if (opt_god_mode) {
        god_mode(vm);
    }
    else {    
        if (step | print_info)
            vm->step = 1;

        if (print_info) {
            debug_view_memory(vm,
                              memory_view_offset,
                              memory_view_bytes);
            debug_view_registers(vm);
            fflush(stdout);
            printf("%s\n", debug_instruction_description(&(vm->memory[vm->IP])));
            printf("\n");
        }

        while (vm_run(vm)) {
            if (print_info) {
                debug_view_memory(vm,
                                  memory_view_offset,
                                  memory_view_bytes);
                debug_view_registers(vm);
                fflush(stdout);
                printf("%s\n", debug_instruction_description(&(vm->memory[vm->IP])));
                printf("\n");
            }
            if (step) getc(stdin);
        }
    }
    
    if (output_filename != NULL) {
        if ((error = image_dump(vm, output_filename)) != 0) {
            fprintf(stderr, "error dumping memory to file: %d\n", error);
            exit(error);
        }
    }
    
    free(vm);
    
    return 0;
}