home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 3 / 3998 / mem.c < prev    next >
C/C++ Source or Header  |  1991-09-08  |  2KB  |  142 lines

  1. /*
  2.  * @(#)mem.c    1.5 91/09/05
  3.  */
  4.  
  5. #include <stdio.h>
  6. #include <sys/types.h>
  7. #include <sys/ptrace.h>
  8. #include <sys/file.h>
  9. #include <sys/stat.h>
  10. #include <sys/time.h>
  11. #include <sys/mman.h>
  12.  
  13. #include "defs.h"
  14.  
  15. int
  16. sys_brk(tcp)
  17. struct tcb *tcp;
  18. {
  19.     if (entering(tcp)) {
  20.         fprintf(outf, "%x", tcp->u_args[0]);
  21.     }
  22.     return 0;
  23. }
  24.  
  25. int
  26. sys_sbrk(tcp)
  27. struct tcb *tcp;
  28. {
  29.     if (entering(tcp)) {
  30.         fprintf(outf, "%u", tcp->u_args[0]);
  31.     }
  32.     return RVAL_HEX;
  33. }
  34.  
  35. static Xlat mmap_prot[] = {
  36.     PROT_READ,    "READ",
  37.     PROT_WRITE,    "WRITE",
  38.     PROT_EXEC,    "EXEC",
  39.     PROT_NONE,    "NONE",
  40.     0,        NULL,
  41. };
  42. static Xlat mmap_flags[] = {
  43.     MAP_SHARED,     "SHARED",
  44.     MAP_PRIVATE,     "PRIVATE",
  45.     MAP_FIXED,     "FIXED",
  46.     MAP_RENAME,     "RENAME",
  47.     MAP_NORESERVE,     "NORESERVE",
  48.     0,        NULL,
  49. };
  50.  
  51. int
  52. sys_smmap(tcp)
  53. struct tcb *tcp;
  54. {
  55.     Xlat *x;
  56.  
  57.     if (entering(tcp)) {
  58.         /* addr */
  59.         fprintf(outf, "%#x, ", tcp->u_args[0]);
  60.         /* len */
  61.         fprintf(outf, "%u, ", tcp->u_args[1]);
  62.         /* prot */
  63.         printflags(mmap_prot, tcp->u_args[2]);
  64.         fprintf(outf, ", ");
  65.         /* flags */
  66.         printxval(mmap_flags, tcp->u_args[3] & MAP_TYPE, "MAP_???");
  67.         addflags(mmap_flags,
  68.                 tcp->u_args[3] & (~_MAP_NEW & ~MAP_TYPE));
  69.         /* fd */
  70.         fprintf(outf, ", %u, ", tcp->u_args[4]);
  71.         /* offset */
  72.         fprintf(outf, "%#x", tcp->u_args[5]);
  73.     }
  74.     return RVAL_HEX;
  75. }
  76.  
  77. int
  78. sys_munmap(tcp)
  79. struct tcb *tcp;
  80. {
  81.     if (entering(tcp)) {
  82.         /* addr */
  83.         fprintf(outf, "%#x, ", tcp->u_args[0]);
  84.         /* len */
  85.         fprintf(outf, ", %u, ", tcp->u_args[1]);
  86.     }
  87.     return 0;
  88. }
  89.  
  90. int
  91. sys_mprotect(tcp)
  92. struct tcb *tcp;
  93. {
  94.     if (entering(tcp)) {
  95.         /* addr */
  96.         fprintf(outf, "%#x", tcp->u_args[0]);
  97.         /* len */
  98.         fprintf(outf, ", %u, ", tcp->u_args[1]);
  99.         /* prot */
  100.         printflags(mmap_prot, tcp->u_args[2]);
  101.     }
  102.     return 0;
  103. }
  104.  
  105. static Xlat mctl_funcs[] = {
  106.     MC_LOCK,    "LOCK",
  107.     MC_LOCKAS,    "LOCKAS",
  108.     MC_SYNC,    "SYNC",
  109.     MC_UNLOCK,    "UNLOCK",
  110.     MC_UNLOCKAS,    "UNLOCKAS",
  111.     0,        NULL,
  112. };
  113.  
  114. int
  115. sys_mctl(tcp)
  116. struct tcb *tcp;
  117. {
  118.     int arg, function;
  119.  
  120.     if (entering(tcp)) {
  121.         /* addr */
  122.         fprintf(outf, "%#x", tcp->u_args[0]);
  123.         /* len */
  124.         fprintf(outf, ", %u, ", tcp->u_args[1]);
  125.         /* function */
  126.         function = tcp->u_args[2];
  127.         printflags(mctl_funcs, function);
  128.         /* arg */
  129.         arg = tcp->u_args[3];
  130.         if (function == MC_SYNC)
  131.             fprintf(outf, ", %s", arg==MS_ASYNC?"ASYNC":(
  132.                         arg==MS_INVALIDATE?"INVALIDATE":
  133.                             "MS_???"
  134.                         )
  135.             );
  136.         else
  137.             fprintf(outf, ", %#x", arg);
  138.     }
  139.     return 0;
  140. }
  141.  
  142.