home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#)mem.c 2.5 92/01/21
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <sys/types.h>
- #include <sys/ptrace.h>
- #include <sys/file.h>
- #include <sys/stat.h>
- #include <sys/time.h>
- #include <sys/mman.h>
-
- #include "defs.h"
-
- int
- sys_brk(tcp)
- struct tcb *tcp;
- {
- if (entering(tcp)) {
- tprintf("%#x", tcp->u_args[0]);
- }
- return 0;
- }
-
- int
- sys_sbrk(tcp)
- struct tcb *tcp;
- {
- if (entering(tcp)) {
- tprintf("%u", tcp->u_args[0]);
- }
- return RVAL_HEX;
- }
-
- static Xlat mmap_prot[] = {
- PROT_READ, "READ",
- PROT_WRITE, "WRITE",
- PROT_EXEC, "EXEC",
- PROT_NONE, "NONE",
- 0, NULL,
- };
- static Xlat mmap_flags[] = {
- MAP_SHARED, "SHARED",
- MAP_PRIVATE, "PRIVATE",
- MAP_FIXED, "FIXED",
- #ifdef MAP_RENAME
- MAP_RENAME, "RENAME",
- #endif
- #ifdef MAP_NORESERVE
- MAP_NORESERVE, "NORESERVE",
- #endif
- 0, NULL,
- };
-
- int
- sys_smmap(tcp)
- struct tcb *tcp;
- {
- if (entering(tcp)) {
- /* addr */
- tprintf("%#x, ", tcp->u_args[0]);
- /* len */
- tprintf("%u, ", tcp->u_args[1]);
- /* prot */
- if (!printflags(mmap_prot, tcp->u_args[2]))
- tprintf("PROT_???");
- tprintf(", ");
- /* flags */
- printxval(mmap_flags, tcp->u_args[3] & MAP_TYPE, "MAP_???");
- (void)addflags(mmap_flags,
- tcp->u_args[3] & (~_MAP_NEW & ~MAP_TYPE));
- /* fd */
- tprintf(", %u, ", tcp->u_args[4]);
- /* offset */
- tprintf("%#x", tcp->u_args[5]);
- }
- return RVAL_HEX;
- }
-
- int
- sys_munmap(tcp)
- struct tcb *tcp;
- {
- if (entering(tcp)) {
- tprintf("%#x, %u", tcp->u_args[0], tcp->u_args[1]);
- }
- return 0;
- }
-
- int
- sys_mprotect(tcp)
- struct tcb *tcp;
- {
- if (entering(tcp)) {
- /* addr */
- tprintf("%#x", tcp->u_args[0]);
- /* len */
- tprintf(", %u, ", tcp->u_args[1]);
- /* prot */
- if (!printflags(mmap_prot, tcp->u_args[2]))
- tprintf("PROT_???");
- }
- return 0;
- }
-
- static Xlat mctl_funcs[] = {
- MC_LOCK, "LOCK",
- MC_LOCKAS, "LOCKAS",
- MC_SYNC, "SYNC",
- MC_UNLOCK, "UNLOCK",
- MC_UNLOCKAS, "UNLOCKAS",
- 0, NULL,
- };
- static Xlat mctl_lockas[] = {
- MCL_CURRENT, "CURRENT",
- MCL_FUTURE, "FUTURE",
- 0, NULL,
- };
- static Xlat mctl_sync[] = {
- MS_ASYNC, "ASYNC",
- MS_INVALIDATE, "INVALIDATE",
- 0, NULL,
- };
-
- int
- sys_mctl(tcp)
- struct tcb *tcp;
- {
- int arg, function;
-
- if (entering(tcp)) {
- /* addr */
- tprintf("%#x", tcp->u_args[0]);
- /* len */
- tprintf(", %u, ", tcp->u_args[1]);
- /* function */
- function = tcp->u_args[2];
- if (!printflags(mctl_funcs, function))
- tprintf("MC_???");
- /* arg */
- arg = tcp->u_args[3];
- tprintf(", ");
- switch (function) {
- case MC_SYNC:
- if (!printflags(mctl_sync, arg))
- tprintf("MS_???");
- break;
- case MC_LOCKAS:
- if (!printflags(mctl_lockas, arg))
- tprintf("MCL_???");
- break;
- default:
- tprintf("%#x", arg);
- break;
- }
- }
- return 0;
- }
-
- int
- sys_mincore(tcp)
- struct tcb *tcp;
- {
- int i, len;
- char *vec = (char *)0;
-
- if (entering(tcp)) {
- tprintf("%#x, %u, ", tcp->u_args[0], tcp->u_args[1]);
- } else {
- len = tcp->u_args[1];
- if (syserror(tcp) || tcp->u_args[2] == 0 ||
- (vec = malloc((u_int)len)) == NULL ||
- umove(tcp->pid, tcp->u_args[2], len, vec) < 0)
- tprintf("%#x", tcp->u_args[2]);
- else
- for (i = 0; i < len; i++) {
- if (!verbose && i >= max_str_len) {
- tprintf("..");
- break;
- }
- tprintf((vec[i]&1)?"1":"0");
- }
-
- if (vec) free(vec);
- }
- return 0;
- }
-
- int
- sys_getpagesize(tcp)
- struct tcb *tcp;
- {
- if (exiting(tcp))
- return RVAL_HEX;
- return 0;
- }
-