Subject: Extra syscall debugging control
To: None <glass@sun-lamp.cs.berkeley.edu, port-pmax@sun-lamp.cs.berkeley.edu>
From: Arne H Juul <arnej@dsl.unit.no>
List: port-pmax
Date: 08/01/1994 14:46:45
In the course of tracing down things, I found that the
existing syscall debugging was a little too verbose (the
interesting messages scrolled off my screen before
I could read them properly). So I hacked together an
extra table for better control of which syscalls are
traced, and also to print file names for some calls.
This should problably be done a bit more elegantly
with a system call to change the values in the table
and a small program, but you may find this helpful
in the meantime.
Yours,
-arnej
diff -rc /dev/null sys/compat/ultrix/ultrix_debctl.c
*** /dev/null Mon Aug 1 13:25:30 1994
--- sys/compat/ultrix/ultrix_debctl.c Mon Aug 1 06:04:54 1994
***************
*** 0 ****
--- 1,285 ----
+ /*
+ * System call debug control.
+ * Manually created for now.
+ */
+
+ #define PRARG0 1
+ #define IGNSCD 16384
+
+ int ultrix_syscallstringarg[] = {
+ 0, /* 0 = syscall */
+ 0, /* 1 = exit */
+ 0, /* 2 = fork */
+ 0, /* 3 = read */
+ 0, /* 4 = write */
+ PRARG0, /* 5 = sun_open */
+ IGNSCD, /* 6 = close */
+ 0, /* 7 = old_wait */
+ PRARG0, /* 8 = sun_creat */
+ 0, /* 9 = link */
+ 0, /* 10 = unlink */
+ PRARG0, /* 11 = sun_execv */
+ PRARG0, /* 12 = chdir */
+ 0, /* 13 = old sun_time */
+ 0, /* 14 = sun_mknod */
+ PRARG0, /* 15 = chmod */
+ PRARG0, /* 16 = chown */
+ IGNSCD, /* 17 = break */
+ 0, /* 18 = old sun_stat */
+ 0, /* 19 = lseek */
+ IGNSCD, /* 20 = getpid */
+ 0, /* 21 = sun_mount */
+ 0, /* 22 = sun_unmount */
+ 0, /* 23 = old setuid */
+ IGNSCD, /* 24 = getuid */
+ 0, /* 25 = old sun_stime */
+ 0, /* 26 = sun_ptrace */
+ 0, /* 27 = old sun_alarm */
+ 0, /* 28 = old sun_fstat */
+ 0, /* 29 = old sun_pause */
+ 0, /* 30 = old sun_utime */
+ 0, /* 31 = was stty */
+ 0, /* 32 = was gtty */
+ IGNSCD | PRARG0, /* 33 = access */
+ 0, /* 34 = old sun_nice */
+ 0, /* 35 = old sun_ftime */
+ 0, /* 36 = sync */
+ IGNSCD, /* 37 = kill */
+ PRARG0, /* 38 = stat */
+ 0, /* 39 = old sun_setpgrp */
+ 0, /* 40 = lstat */
+ IGNSCD, /* 41 = dup */
+ 0, /* 42 = pipe */
+ 0, /* 43 = old sun_times */
+ 0, /* 44 = profil */
+ 0, /* 45 = nosys */
+ 0, /* 46 = old sun_setgid */
+ 0, /* 47 = getgid */
+ 0, /* 48 = old sun_ssig */
+ 0, /* 49 = reserved for USG */
+ 0, /* 50 = reserved for USG */
+ 0, /* 51 = acct */
+ 0, /* 52 = nosys */
+ 0, /* 53 = syslock */
+ 0, /* 54 = ioctl */
+ 0, /* 55 = reboot */
+ 0, /* 56 = mpxchan */
+ 0, /* 57 = symlink */
+ 0, /* 58 = readlink */
+ PRARG0, /* 59 = execve */
+ 0, /* 60 = umask */
+ 0, /* 61 = chroot */
+ 0, /* 62 = ofstat */
+ 0, /* 63 = nosys */
+ 0, /* 64 = ogetpagesize */
+ 0, /* 65 = mremap */
+ 0, /* 66 = vfork */
+ 0, /* 67 = obsolete vread */
+ 0, /* 68 = obsolete vwrite */
+ 0, /* 69 = sbrk */
+ 0, /* 70 = sstk */
+ 0, /* 71 = mmap */
+ 0, /* 72 = vadvise */
+ 0, /* 73 = munmap */
+ 0, /* 74 = mprotect */
+ 0, /* 75 = madvise */
+ 0, /* 76 = sun_vhangup */
+ 0, /* 77 = old vlimit */
+ 0, /* 78 = mincore */
+ 0, /* 79 = getgroups */
+ 0, /* 80 = setgroups */
+ 0, /* 81 = getpgrp */
+ 0, /* 82 = sun_setpgid */
+ 0, /* 83 = setitimer */
+ 0, /* 84 = sun_wait3 */
+ 0, /* 85 = swapon */
+ 0, /* 86 = getitimer */
+ 0, /* 87 = ogethostname */
+ 0, /* 88 = osethostname */
+ 0, /* 89 = ogetdtablesize */
+ IGNSCD, /* 90 = dup2 */
+ 0, /* 91 = getdopt */
+ 0, /* 92 = fcntl */
+ 0, /* 93 = select */
+ 0, /* 94 = setdopt */
+ 0, /* 95 = fsync */
+ 0, /* 96 = setpriority */
+ 0, /* 97 = socket */
+ 0, /* 98 = connect */
+ 0, /* 99 = oaccept */
+ 0, /* 100 = getpriority */
+ 0, /* 101 = osend */
+ 0, /* 102 = orecv */
+ 0, /* 103 = sigreturn */
+ 0, /* 104 = bind */
+ 0, /* 105 = sun_setsockopt */
+ 0, /* 106 = listen */
+ 0, /* 107 = old vtimes */
+ IGNSCD, /* 108 = osigvec */
+ IGNSCD, /* 109 = osigblock */
+ IGNSCD, /* 110 = osigsetmask */
+ IGNSCD, /* 111 = sigsuspend */
+ 0, /* 112 = osigstack */
+ 0, /* 113 = orecvmsg */
+ 0, /* 114 = osendmsg */
+ 0, /* 115 = obsolete vtrace */
+ 0, /* 116 = gettimeofday */
+ 0, /* 117 = getrusage */
+ 0, /* 118 = getsockopt */
+ 0, /* 119 = resuba */
+ 0, /* 120 = readv */
+ 0, /* 121 = writev */
+ 0, /* 122 = settimeofday */
+ 0, /* 123 = fchown */
+ 0, /* 124 = fchmod */
+ 0, /* 125 = orecvfrom */
+ 0, /* 126 = osetreuid */
+ 0, /* 127 = osetregid */
+ PRARG0, /* 128 = rename */
+ 0, /* 129 = truncate */
+ 0, /* 130 = ftruncate */
+ 0, /* 131 = flock */
+ 0, /* 132 = nosys */
+ 0, /* 133 = sendto */
+ 0, /* 134 = shutdown */
+ 0, /* 135 = socketpair */
+ PRARG0, /* 136 = mkdir */
+ PRARG0, /* 137 = rmdir */
+ 0, /* 138 = utimes */
+ 0, /* 139 = sigreturn */
+ 0, /* 140 = adjtime */
+ 0, /* 141 = ogetpeername */
+ 0, /* 142 = ogethostid */
+ 0, /* 143 = old sethostid */
+ 0, /* 144 = sun_getrlimit */
+ 0, /* 145 = sun_setrlimit */
+ 0, /* 146 = okillpg */
+ 0, /* 147 = nosys */
+ 0, /* 148 = setquota */
+ 0, /* 149 = quota */
+ 0, /* 150 = ogetsockname */
+ 0, /* 151 = sysmips */
+ 0, /* 152 = cacheflush */
+ 0, /* 153 = cachectl */
+ 0, /* 154 = nosys */
+ 0, /* 155 = atomic_op */
+ 0, /* 156 = nosys */
+ 0, /* 157 = nosys */
+ 0, /* 158 = nfssvc */
+ 0, /* 159 = getdirentries */
+ 0, /* 160 = sun_statfs */
+ 0, /* 161 = sun_fstatfs */
+ 0, /* 162 = sun_unmount */
+ 0, /* 163 = async_daemon */
+ 0, /* 164 = getfh */
+ 0, /* 165 = ogetdomainname */
+ 0, /* 166 = osetdomainname */
+ 0, /* 167 = nosys */
+ 0, /* 168 = sun_quotactl */
+ 0, /* 169 = sun_exportfs */
+ 0, /* 170 = sun_mount */
+ 0, /* 171 = hdwconf */
+ #ifdef SYSVMSG
+ 0, /* 172 = msgctl */
+ 0, /* 173 = msgget */
+ 0, /* 174 = msgrcv */
+ 0, /* 175 = msgsnd */
+ #else
+ 0, /* 172 = msgctl */
+ 0, /* 173 = msgget */
+ 0, /* 174 = msgrcv */
+ 0, /* 175 = msgsnd */
+ #endif
+ #ifdef SYSVSEM
+ 0, /* 176 = semctl */
+ 0, /* 177 = semget */
+ 0, /* 178 = semop */
+ #else
+ 0, /* 176 = semctl */
+ 0, /* 177 = semget */
+ 0, /* 178 = semop */
+ #endif
+ 0, /* 179 = sun_uname */
+ #ifdef SYSVSHM
+ 0, /* 180 = shmsys */
+ #else
+ 0, /* 180 = nosys */
+ #endif
+ 0, /* 181 = plock */
+ 0, /* 182 = lockf */
+ 0, /* 183 = sun_ustat */
+ 0, /* 184 = getmnt */
+ 0, /* 185 = notdef */
+ 0, /* 186 = notdef */
+ 0, /* 187 = sun_sigpending */
+ 0, /* 188 = setsid */
+ 0, /* 189 = ultrix_waitpid */
+ 0, /* 190 = nosys */
+ 0, /* 191 = nosys */
+ 0, /* 192 = nosys */
+ 0, /* 193 = nosys */
+ 0, /* 194 = nosys */
+ 0, /* 195 = nosys */
+ 0, /* 196 = nosys */
+ 0, /* 197 = nosys */
+ 0, /* 198 = nosys */
+ 0, /* 199 = nosys */
+ 0, /* 200 = nosys */
+ 0, /* 201 = nosys */
+ 0, /* 202 = nosys */
+ 0, /* 203 = nosys */
+ 0, /* 204 = nosys */
+ 0, /* 205 = nosys */
+ 0, /* 206 = nosys */
+ 0, /* 207 = nosys */
+ 0, /* 208 = nosys */
+ 0, /* 209 = nosys */
+ 0, /* 210 = nosys */
+ 0, /* 211 = nosys */
+ 0, /* 212 = nosys */
+ 0, /* 213 = nosys */
+ 0, /* 214 = nosys */
+ 0, /* 215 = nosys */
+ 0, /* 216 = nosys */
+ 0, /* 217 = nosys */
+ 0, /* 218 = nosys */
+ 0, /* 219 = nosys */
+ 0, /* 220 = nosys */
+ 0, /* 221 = nosys */
+ 0, /* 222 = nosys */
+ 0, /* 223 = nosys */
+ 0, /* 224 = nosys */
+ 0, /* 225 = nosys */
+ 0, /* 226 = nosys */
+ 0, /* 227 = nosys */
+ 0, /* 228 = nosys */
+ 0, /* 229 = nosys */
+ 0, /* 230 = nosys */
+ 0, /* 231 = nosys */
+ 0, /* 232 = nosys */
+ 0, /* 233 = nosys */
+ 0, /* 234 = nosys */
+ 0, /* 235 = nosys */
+ 0, /* 236 = nosys */
+ 0, /* 237 = nosys */
+ 0, /* 238 = nosys */
+ 0, /* 239 = nosys */
+ 0, /* 240 = nosys */
+ 0, /* 241 = nosys */
+ 0, /* 242 = nosys */
+ 0, /* 243 = nosys */
+ 0, /* 244 = nosys */
+ 0, /* 245 = nosys */
+ 0, /* 246 = nosys */
+ 0, /* 247 = nosys */
+ 0, /* 248 = nosys */
+ 0, /* 249 = nosys */
+ 0, /* 250 = nosys */
+ 0, /* 251 = nosys */
+ 0, /* 252 = audctl */
+ 0, /* 253 = audgen */
+ 0, /* 254 = startcpu */
+ 0, /* 255 = stopcpu */
+ 0, /* 256 = ultrix_getsysinfo */
+ 0, /* 257 = ultrix_setsysinfo */
+ };
diff -rc orig/pmax/trap.c sys/arch/pmax/pmax/trap.c
*** orig/pmax/trap.c Wed Jun 15 12:25:23 1994
--- sys/arch/pmax/pmax/trap.c Mon Aug 1 03:36:40 1994
***************
*** 49,54 ****
--- 49,55 ----
#include <sys/syscall.h>
#include <sys/user.h>
#include <sys/buf.h>
+ #include <sys/malloc.h>
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
***************
*** 182,187 ****
--- 183,192 ----
extern struct sysent ultrix_sysent[];
extern int nultrix_sysent;
extern char *ultrix_syscallnames[];
+ extern int ultrix_syscallstringarg[];
+ /* evil hack */
+ #define PRARG0 1
+ #define IGNSCD 16384
#endif
#if defined(COMPAT_ULTRIX) && defined(SYSCALL_DEBUG)
***************
*** 196,202 ****
if (!ultrix_scdebug)
return;
!
printf("proc %d: ultrix syscall ", p->p_pid);
if (code < 0 || code >= nultrix_sysent) {
printf("OUT OF RANGE (%d)", code);
--- 201,211 ----
if (!ultrix_scdebug)
return;
! #ifdef IGNSCD
! if (IGNSCD & ultrix_syscallstringarg[code]) {
! return;
! }
! #endif
printf("proc %d: ultrix syscall ", p->p_pid);
if (code < 0 || code >= nultrix_sysent) {
printf("OUT OF RANGE (%d)", code);
***************
*** 206,211 ****
--- 215,234 ----
printf(" called: %s(", ultrix_syscallnames[code]);
for (i = 0; i < narg; i++)
printf("0x%x, ", args[i]);
+ #ifdef PRARG0
+ if (PRARG0 & ultrix_syscallstringarg[code]) {
+ char *path;
+ int error;
+
+ MALLOC(path, char *, MAXPATHLEN, M_NAMEI, M_WAITOK);
+ if (error = copyinstr((char *)args[0], path, MAXPATHLEN, (u_int*)0)) {
+ printf("[bad err %d]", error);
+ } else {
+ printf("[%s]", path);
+ }
+ FREE(path, M_NAMEI);
+ }
+ #endif
printf(")\n");
}
***************
*** 216,222 ****
{
if (!ultrix_scdebug)
return;
!
printf("proc %d: ultrix syscall ", p->p_pid);
if (code < 0 || code >= nultrix_sysent) {
printf("OUT OF RANGE (%d)", code);
--- 239,249 ----
{
if (!ultrix_scdebug)
return;
! #ifdef IGNSCD
! if (IGNSCD & ultrix_syscallstringarg[code]) {
! return;
! }
! #endif
printf("proc %d: ultrix syscall ", p->p_pid);
if (code < 0 || code >= nultrix_sysent) {
printf("OUT OF RANGE (%d)", code);
diff -rc orig/conf/files.pmax sys/arch/pmax/conf/files.pmax
*** orig/conf/files.pmax Fri Jun 3 12:18:32 1994
--- sys/arch/pmax/conf/files.pmax Mon Aug 1 06:06:18 1994
***************
*** 30,35 ****
--- 30,36 ----
arch/pmax/dev/xcfb.c optional xcfb device-driver
compat/ultrix/ultrix_misc.c optional compat_ultrix
compat/ultrix/ultrix_syscalls.c optional compat_ultrix
+ compat/ultrix/ultrix_debctl.c optional compat_ultrix
compat/ultrix/ultrix_sysent.c optional compat_ultrix
netinet/in_cksum.c optional inet
netns/ns_cksum.c optional ns
------------------------------------------------------------------------------