int main() { Core_init(); const UnitTest tests[] = { unit_test(test_c64_vice_init), unit_test(test_c64_vice_fail_connect), unit_test(test_c64_vice_connect), unit_test(test_c64_vice_start_executable), unit_test(test_c64_vice_get_registers), unit_test(test_c64_vice_step_cpu), unit_test(test_c64_vice_get_disassembly), unit_test(test_c64_vice_get_memory), unit_test(test_c64_vice_basic_breakpoint), unit_test(test_c64_vice_breakpoint_cond), unit_test(test_c64_vice_callstack), //unit_test(test_c64_vice_set_memory), }; int test = run_tests(tests); if (s_viceHandle) Process_kill(s_viceHandle); return test; }
void Process_free(Process_T *P) { assert(P && *P); FREE((*P)->working_directory); if (Process_isRunning(*P)) Process_kill(*P); closeParentPipes(*P); closeStreams(*P); FREE(*P); }
void sigHandler( Signal *s ) { int PID; Process *p = NULL; Signal *t; gotSignal = 1; /* * Switch that takes care of the signal that was caught */ switch( Signal_getNum(s) ) { /* * Message from the child */ case SIGCHLD: PID = Signal_getCaller(s); switch( Signal_getCode(s) ) { /* * Child exited */ case CLD_EXITED: printf("\nCHILD exited: PID %d\n", PID ); p = ProcControl_removePID( PID ); if( p != NULL ) { Process_wait( p, PROCESS_NOWAIT ); Process_free( p ); } else { if( RUNNING ) { Process_free( RUNNING ); } } if( p == RUNNING ) RUNNING = NULL; break; /* * Child got killed */ case CLD_KILLED: printf("\nCHILD killed: PID %d\n", PID ); p = ProcControl_removePID( PID ); if( p != NULL ) { Process_wait( p, PROCESS_NOWAIT ); Process_free( p ); } if( p == RUNNING ) RUNNING = NULL; break; /* * Child got suspended */ case CLD_STOPPED: p = ProcControl_getPID( PID ); if( p != NULL ) { printf("\nSuspended %d ", Process_getPID(p) ); Process_printCommand( p, stdout ); printf("\n"); } else { fprintf( stderr, "Process stopped that wasn't in" "List: %d\n", PID ); } break; case CLD_CONTINUED: fprintf(stderr, "LOOOOOOO\n"); break; } break; /* * Caught the Cntrol-Z * * We need to suspend the child */ case SIGTSTP: if( RUNNING != NULL ) { Process_suspend( RUNNING ); RUNNING = NULL; } else { printf("\n"); } break; /* * Ctrl-C - we need to kill the current child */ case SIGINT: if( RUNNING != NULL ) { Process_kill( RUNNING ); } else { printf("\n"); } break; /* * Seg fault handler */ case SIGSEGV: fprintf(stderr, "\nSeg fault!!!\n"); exit(-1); } }