/*===========================================================================* * do_mm_exit * *===========================================================================*/ PUBLIC int do_mm_exit() { /* Perform the exit(status) system call. The real work is done by mm_exit(), * which is also called when a process is killed by a signal. */ mm_exit(mp, status); return(E_NO_MESSAGE); /* can't communicate from beyond the grave */ }
/*===========================================================================* * do_mm_exit * *===========================================================================*/ PUBLIC int do_mm_exit() { /* Perform the exit(status) system call. The real work is done by mm_exit(), * which is also called when a process is killed by a signal. */ mm_exit(mp, status); dont_reply = TRUE; /* don't reply to newly terminated process */ return(OK); /* pro forma return code */ }
int main() { mm_init(); char *str = "hello world!"; char *p = mm_malloc(strlen(str) + 1); //void *p = NULL; if (p == NULL) { mm_dump(); printf("mm_malloc failed\n"); } else { strcpy(p, str); mm_dump(); mm_free(p); mm_dump(); } mm_exit(); return 0; }
/*===========================================================================* * do_trace * *===========================================================================*/ PUBLIC int do_trace() { register struct mproc *child; /* the T_OK call is made by the child fork of the debugger before it execs * the process to be traced */ if (request == T_OK) {/* enable tracing by parent for this process */ mp->mp_flags |= TRACED; mm_out.m2_l2 = 0; return(OK); } if ((child = findproc(pid)) == NIL_MPROC || !(child->mp_flags & STOPPED)) { return(ESRCH); } /* all the other calls are made by the parent fork of the debugger to * control execution of the child */ switch (request) { case T_EXIT: /* exit */ mm_exit(child, (int)data); mm_out.m2_l2 = 0; return(OK); case T_RESUME: case T_STEP: /* resume execution */ if (data < 0 || data > _NSIG) return(EIO); if (data > 0) { /* issue signal */ child->mp_flags &= ~TRACED; /* so signal is not diverted */ sig_proc(child, (int) data); child->mp_flags |= TRACED; } child->mp_flags &= ~STOPPED; break; } if (sys_trace(request, (int) (child - mproc), taddr, &data) != OK) return(-errno); mm_out.m2_l2 = data; return(OK); }