aboutsummaryrefslogtreecommitdiff
path: root/sys/compat
diff options
context:
space:
mode:
authorJonathan Lemon <jlemon@FreeBSD.org>2001-02-16 16:40:43 +0000
committerJonathan Lemon <jlemon@FreeBSD.org>2001-02-16 16:40:43 +0000
commit2459336973f80184f615d3c1959ce2e65425e303 (patch)
tree1b0c0704eee669947655f061fd3da0dba98b3fd1 /sys/compat
parent4c98f36d9438c32fd8bbbff50405406cc5e210ca (diff)
downloadsrc-2459336973f80184f615d3c1959ce2e65425e303.tar.gz
src-2459336973f80184f615d3c1959ce2e65425e303.zip
Allow debugging output to be controlled on a per-syscall granularity.
Also clean up debugging output in a slightly more uniform fashion. The default behavior remains the same (all debugging output is turned on)
Notes
Notes: svn path=/head/; revision=72543
Diffstat (limited to 'sys/compat')
-rw-r--r--sys/compat/linux/linux_file.c89
-rw-r--r--sys/compat/linux/linux_ioctl.c79
-rw-r--r--sys/compat/linux/linux_mib.c61
-rw-r--r--sys/compat/linux/linux_misc.c121
-rw-r--r--sys/compat/linux/linux_signal.c36
-rw-r--r--sys/compat/linux/linux_stats.c20
6 files changed, 259 insertions, 147 deletions
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 441aeb707b46..492742f2b057 100644
--- a/sys/compat/linux/linux_file.c
+++ b/sys/compat/linux/linux_file.c
@@ -68,8 +68,8 @@ linux_creat(struct proc *p, struct linux_creat_args *args)
CHECKALTCREAT(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): creat(%s, %d)\n",
- p->p_pid, args->path, args->mode);
+ if (ldebug(creat))
+ printf(ARGS(creat, "%s, %d"), args->path, args->mode);
#endif
bsd_open_args.path = args->path;
bsd_open_args.mode = args->mode;
@@ -97,8 +97,9 @@ linux_open(struct proc *p, struct linux_open_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): open(%s, 0x%x, 0x%x)\n",
- p->p_pid, args->path, args->flags, args->mode);
+ if (ldebug(open))
+ printf(ARGS(open, "%s, 0x%x, 0x%x"),
+ args->path, args->flags, args->mode);
#endif
bsd_open_args.flags = 0;
if (args->flags & LINUX_O_RDONLY)
@@ -141,8 +142,8 @@ linux_open(struct proc *p, struct linux_open_args *args)
} else
PROC_UNLOCK(p);
#ifdef DEBUG
- printf("Linux-emul(%d): open returns error %d\n",
- p->p_pid, error);
+ if (ldebug(open))
+ printf(LMSG("open returns error %d"), error);
#endif
return error;
}
@@ -217,8 +218,8 @@ linux_fcntl(struct proc *p, struct linux_fcntl_args *args)
bsd_flock = (struct flock *)stackgap_alloc(&sg, sizeof(struct flock));
#ifdef DEBUG
- printf("Linux-emul(%ld): fcntl(%d, %08x, *)\n", (long)p->p_pid,
- args->fd, args->cmd);
+ if (ldebug(fcntl))
+ printf(ARGS(fcntl, "%d, %08x, *"), args->fd, args->cmd);
#endif
fcntl_args.fd = args->fd;
@@ -329,8 +330,9 @@ linux_lseek(struct proc *p, struct linux_lseek_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): lseek(%d, %ld, %d)\n",
- (long)p->p_pid, args->fdes, args->off, args->whence);
+ if (ldebug(lseek))
+ printf(ARGS(lseek, "%d, %ld, %d"),
+ args->fdes, args->off, args->whence);
#endif
tmp_args.fd = args->fdes;
tmp_args.offset = (off_t)args->off;
@@ -348,8 +350,9 @@ linux_llseek(struct proc *p, struct linux_llseek_args *args)
off_t off;
#ifdef DEBUG
- printf("Linux-emul(%d): llseek(%d, %d:%d, %d)\n",
- p->p_pid, args->fd, args->ohigh, args->olow, args->whence);
+ if (ldebug(llseek))
+ printf(ARGS(llseek, "%d, %d:%d, %d"),
+ args->fd, args->ohigh, args->olow, args->whence);
#endif
off = (args->olow) | (((off_t) args->ohigh) << 32);
@@ -412,8 +415,8 @@ linux_getdents(struct proc *p, struct linux_getdents_args *args)
int ncookies;
#ifdef DEBUG
- printf("Linux-emul(%d): getdents(%d, *, %d)\n",
- p->p_pid, args->fd, args->count);
+ if (ldebug(getdents))
+ printf(ARGS(getdents, "%d, *, %d"), args->fd, args->count);
#endif
if ((error = getvnode(p->p_fd, args->fd, &fp)) != 0) {
return (error);
@@ -580,8 +583,8 @@ linux_access(struct proc *p, struct linux_access_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): access(%s, %d)\n",
- p->p_pid, args->path, args->flags);
+ if (ldebug(access))
+ printf(ARGS(access, "%s, %d"), args->path, args->flags);
#endif
bsd.path = args->path;
bsd.flags = args->flags;
@@ -599,8 +602,8 @@ linux_unlink(struct proc *p, struct linux_unlink_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): unlink(%s)\n",
- p->p_pid, args->path);
+ if (ldebug(unlink))
+ printf(ARGS(unlink, "%s"), args->path);
#endif
bsd.path = args->path;
@@ -617,8 +620,8 @@ linux_chdir(struct proc *p, struct linux_chdir_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): chdir(%s)\n",
- p->p_pid, args->path);
+ if (ldebug(chdir))
+ printf(ARGS(chdir, "%s"), args->path);
#endif
bsd.path = args->path;
@@ -635,8 +638,8 @@ linux_chmod(struct proc *p, struct linux_chmod_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): chmod(%s, %d)\n",
- p->p_pid, args->path, args->mode);
+ if (ldebug(chmod))
+ printf(ARGS(chmod, "%s, %d"), args->path, args->mode);
#endif
bsd.path = args->path;
bsd.mode = args->mode;
@@ -654,8 +657,9 @@ linux_chown(struct proc *p, struct linux_chown_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): chown(%s, %d, %d)\n",
- p->p_pid, args->path, args->uid, args->gid);
+ if (ldebug(chown))
+ printf(ARGS(chown, "%s, %d, %d"),
+ args->path, args->uid, args->gid);
#endif
bsd.path = args->path;
/* XXX size casts here */
@@ -675,8 +679,9 @@ linux_lchown(struct proc *p, struct linux_lchown_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): lchown(%s, %d, %d)\n",
- p->p_pid, args->path, args->uid, args->gid);
+ if (ldebug(lchown))
+ printf(ARGS(lchown, "%s, %d, %d"),
+ args->path, args->uid, args->gid);
#endif
bsd.path = args->path;
/* XXX size casts here */
@@ -696,8 +701,8 @@ linux_mkdir(struct proc *p, struct linux_mkdir_args *args)
CHECKALTCREAT(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): mkdir(%s, %d)\n",
- p->p_pid, args->path, args->mode);
+ if (ldebug(mkdir))
+ printf(ARGS(mkdir, "%s, %d"), args->path, args->mode);
#endif
bsd.path = args->path;
bsd.mode = args->mode;
@@ -715,8 +720,8 @@ linux_rmdir(struct proc *p, struct linux_rmdir_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): rmdir(%s)\n",
- p->p_pid, args->path);
+ if (ldebug(rmdir))
+ printf(ARGS(rmdir, "%s"), args->path);
#endif
bsd.path = args->path;
@@ -734,8 +739,8 @@ linux_rename(struct proc *p, struct linux_rename_args *args)
CHECKALTCREAT(p, &sg, args->to);
#ifdef DEBUG
- printf("Linux-emul(%d): rename(%s, %s)\n",
- p->p_pid, args->from, args->to);
+ if (ldebug(rename))
+ printf(ARGS(rename, "%s, %s"), args->from, args->to);
#endif
bsd.from = args->from;
bsd.to = args->to;
@@ -754,8 +759,8 @@ linux_symlink(struct proc *p, struct linux_symlink_args *args)
CHECKALTCREAT(p, &sg, args->to);
#ifdef DEBUG
- printf("Linux-emul(%d): symlink(%s, %s)\n",
- p->p_pid, args->path, args->to);
+ if (ldebug(symlink))
+ printf(ARGS(symlink, "%s, %s"), args->path, args->to);
#endif
bsd.path = args->path;
bsd.link = args->to;
@@ -773,8 +778,9 @@ linux_readlink(struct proc *p, struct linux_readlink_args *args)
CHECKALTEXIST(p, &sg, args->name);
#ifdef DEBUG
- printf("Linux-emul(%ld): readlink(%s, %p, %d)\n",
- (long)p->p_pid, args->name, (void *)args->buf, args->count);
+ if (ldebug(readlink))
+ printf(ARGS(readlink, "%s, %p, %d"),
+ args->name, (void *)args->buf, args->count);
#endif
bsd.path = args->name;
bsd.buf = args->buf;
@@ -793,8 +799,8 @@ linux_truncate(struct proc *p, struct linux_truncate_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): truncate(%s, %ld)\n",
- p->p_pid, args->path, args->length);
+ if (ldebug(truncate))
+ printf(ARGS(truncate, "%s, %ld"), args->path, args->length);
#endif
bsd.path = args->path;
bsd.length = args->length;
@@ -813,7 +819,8 @@ linux_link(struct proc *p, struct linux_link_args *args)
CHECKALTCREAT(p, &sg, args->to);
#ifdef DEBUG
- printf("Linux-emul(%d): link(%s, %s)\n", p->p_pid, args->path, args->to);
+ if (ldebug(link))
+ printf(ARGS(link, "%s, %s"), args->path, args->to);
#endif
bsd.path = args->path;
@@ -830,8 +837,8 @@ linux_getcwd(struct proc *p, struct linux_getcwd_args *args)
int error, len;
#ifdef DEBUG
- printf("Linux-emul(%ld): getcwd(%p, %ld)\n", (long)p->p_pid,
- args->buf, args->bufsize);
+ if (ldebug(getcwd))
+ printf(ARGS(getcwd, "%p, %ld"), args->buf, args->bufsize);
#endif
sg = stackgap_init();
diff --git a/sys/compat/linux/linux_ioctl.c b/sys/compat/linux/linux_ioctl.c
index f6fae19ba9e9..1cf76cf80d0e 100644
--- a/sys/compat/linux/linux_ioctl.c
+++ b/sys/compat/linux/linux_ioctl.c
@@ -110,7 +110,8 @@ linux_ioctl_disk(struct proc *p, struct linux_ioctl_args *args)
error = fo_ioctl(fp, DIOCGDINFO, (caddr_t)&dl, p);
if (error)
return (error);
- return copyout(&(dl.d_secperunit), (caddr_t)args->arg, sizeof(dl.d_secperunit));
+ return (copyout(&(dl.d_secperunit), (caddr_t)args->arg,
+ sizeof(dl.d_secperunit)));
break;
}
return (ENOIOCTL);
@@ -204,14 +205,16 @@ bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios)
int i;
#ifdef DEBUG
- printf("LINUX: BSD termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag,
- bios->c_ispeed, bios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bios->c_cc[i]);
- printf("\n");
+ if (ldebug(ioctl)) {
+ printf("LINUX: BSD termios structure (input):\n");
+ printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
+ bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag,
+ bios->c_ispeed, bios->c_ospeed);
+ printf("c_cc ");
+ for (i=0; i<NCCS; i++)
+ printf("%02x ", bios->c_cc[i]);
+ printf("\n");
+ }
#endif
lios->c_iflag = 0;
@@ -323,13 +326,16 @@ bsd_to_linux_termios(struct termios *bios, struct linux_termios *lios)
lios->c_line = 0;
#ifdef DEBUG
- printf("LINUX: LINUX termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag,
- lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line);
- printf("c_cc ");
- for (i=0; i<LINUX_NCCS; i++)
- printf("%02x ", lios->c_cc[i]);
- printf("\n");
+ if (ldebug(ioctl)) {
+ printf("LINUX: LINUX termios structure (output):\n");
+ printf("i=%08x o=%08x c=%08x l=%08x line=%d\n",
+ lios->c_iflag, lios->c_oflag, lios->c_cflag,
+ lios->c_lflag, (int)lios->c_line);
+ printf("c_cc ");
+ for (i=0; i<LINUX_NCCS; i++)
+ printf("%02x ", lios->c_cc[i]);
+ printf("\n");
+ }
#endif
}
@@ -339,13 +345,16 @@ linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios)
int i;
#ifdef DEBUG
- printf("LINUX: LINUX termios structure (input):\n");
- printf("i=%08x o=%08x c=%08x l=%08x line=%d\n", lios->c_iflag,
- lios->c_oflag, lios->c_cflag, lios->c_lflag, (int)lios->c_line);
- printf("c_cc ");
- for (i=0; i<LINUX_NCCS; i++)
- printf("%02x ", lios->c_cc[i]);
- printf("\n");
+ if (ldebug(ioctl)) {
+ printf("LINUX: LINUX termios structure (input):\n");
+ printf("i=%08x o=%08x c=%08x l=%08x line=%d\n",
+ lios->c_iflag, lios->c_oflag, lios->c_cflag,
+ lios->c_lflag, (int)lios->c_line);
+ printf("c_cc ");
+ for (i=0; i<LINUX_NCCS; i++)
+ printf("%02x ", lios->c_cc[i]);
+ printf("\n");
+ }
#endif
bios->c_iflag = 0;
@@ -458,14 +467,16 @@ linux_to_bsd_termios(struct linux_termios *lios, struct termios *bios)
linux_to_bsd_speed(lios->c_cflag & LINUX_CBAUD, sptab);
#ifdef DEBUG
- printf("LINUX: BSD termios structure (output):\n");
- printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
- bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag,
- bios->c_ispeed, bios->c_ospeed);
- printf("c_cc ");
- for (i=0; i<NCCS; i++)
- printf("%02x ", bios->c_cc[i]);
- printf("\n");
+ if (ldebug(ioctl)) {
+ printf("LINUX: BSD termios structure (output):\n");
+ printf("i=%08x o=%08x c=%08x l=%08x ispeed=%d ospeed=%d\n",
+ bios->c_iflag, bios->c_oflag, bios->c_cflag, bios->c_lflag,
+ bios->c_ispeed, bios->c_ospeed);
+ printf("c_cc ");
+ for (i=0; i<NCCS; i++)
+ printf("%02x ", bios->c_cc[i]);
+ printf("\n");
+ }
#endif
}
@@ -1419,8 +1430,8 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args)
int error, cmd;
#ifdef DEBUG
- printf("Linux-emul(%ld): ioctl(%d, %04lx, *)\n", (long)p->p_pid,
- args->fd, args->cmd);
+ if (ldebug(ioctl))
+ printf(ARGS(ioctl, "%d, %04lx, *"), args->fd, args->cmd);
#endif
if ((unsigned)args->fd >= fdp->fd_nfiles)
@@ -1440,7 +1451,7 @@ linux_ioctl(struct proc *p, struct linux_ioctl_args *args)
}
}
- printf("linux: 'ioctl' fd=%d, cmd=%x ('%c',%d) not implemented\n",
+ printf("linux: 'ioctl' fd=%d, cmd=0x%x ('%c',%d) not implemented\n",
args->fd, (int)(args->cmd & 0xffff),
(int)(args->cmd & 0xff00) >> 8, (int)(args->cmd & 0xff));
diff --git a/sys/compat/linux/linux_mib.c b/sys/compat/linux/linux_mib.c
index 6d60a8c8f975..8482dd98862b 100644
--- a/sys/compat/linux/linux_mib.c
+++ b/sys/compat/linux/linux_mib.c
@@ -228,3 +228,64 @@ linux_set_oss_version(p, oss_version)
return (0);
}
+
+#ifdef DEBUG
+
+u_char linux_debug_map[howmany(LINUX_SYS_MAXSYSCALL, sizeof(u_char))];
+
+int
+linux_debug(int syscall, int toggle, int global)
+{
+
+ if (global) {
+ char c = toggle ? 0 : 0xff;
+
+ memset(linux_debug_map, c, sizeof(linux_debug_map));
+ return (0);
+ }
+ if (syscall < 0 || syscall >= LINUX_SYS_MAXSYSCALL)
+ return (EINVAL);
+ if (toggle)
+ clrbit(linux_debug_map, syscall);
+ else
+ setbit(linux_debug_map, syscall);
+ return (0);
+}
+
+/*
+ * Usage: sysctl -w linux.debug=<syscall_nr>.<0/1>
+ *
+ * E.g.: sysctl -w linux.debug=21.0
+ *
+ * As a special case, syscall "all" will apply to all syscalls globally.
+ */
+#define LINUX_MAX_DEBUGSTR 16
+static int
+linux_sysctl_debug(SYSCTL_HANDLER_ARGS)
+{
+ char value[LINUX_MAX_DEBUGSTR], *p;
+ int error, sysc, toggle;
+ int global = 0;
+
+ value[0] = '\0';
+ error = sysctl_handle_string(oidp, value, LINUX_MAX_DEBUGSTR, req);
+ if (error || req->newptr == NULL)
+ return (error);
+ for (p = value; *p != '\0' && *p != '.'; p++);
+ if (*p == '\0')
+ return (EINVAL);
+ *p++ = '\0';
+ sysc = strtol(value, NULL, 0);
+ toggle = strtol(p, NULL, 0);
+ if (strcmp(value, "all") == 0)
+ global = 1;
+ error = linux_debug(sysc, toggle, global);
+ return (error);
+}
+
+SYSCTL_PROC(_compat_linux, OID_AUTO, debug,
+ CTLTYPE_STRING | CTLFLAG_RW,
+ 0, 0, linux_sysctl_debug, "A",
+ "Linux debugging control");
+
+#endif /* DEBUG */
diff --git a/sys/compat/linux/linux_misc.c b/sys/compat/linux/linux_misc.c
index 552d5f451de5..3e08d8501f9d 100644
--- a/sys/compat/linux/linux_misc.c
+++ b/sys/compat/linux/linux_misc.c
@@ -100,7 +100,8 @@ linux_alarm(struct proc *p, struct linux_alarm_args *args)
int s;
#ifdef DEBUG
- printf("Linux-emul(%ld): alarm(%u)\n", (long)p->p_pid, args->secs);
+ if (ldebug(alarm))
+ printf(ARGS(alarm, "%u"), args->secs);
#endif
if (args->secs > 100000000)
return EINVAL;
@@ -165,7 +166,8 @@ linux_brk(struct proc *p, struct linux_brk_args *args)
} */ tmp;
#ifdef DEBUG
- printf("Linux-emul(%ld): brk(%p)\n", (long)p->p_pid, (void *)args->dsend);
+ if (ldebug(brk))
+ printf(ARGS(brk, "%p"), (void *)args->dsend);
#endif
old = (vm_offset_t)vm->vm_daddr + ctob(vm->vm_dsize);
new = (vm_offset_t)args->dsend;
@@ -198,7 +200,8 @@ linux_uselib(struct proc *p, struct linux_uselib_args *args)
CHECKALTEXIST(p, &sg, args->library);
#ifdef DEBUG
- printf("Linux-emul(%ld): uselib(%s)\n", (long)p->p_pid, args->library);
+ if (ldebug(uselib))
+ printf(ARGS(uselib, "%s"), args->library);
#endif
a_out = NULL;
@@ -448,10 +451,11 @@ linux_newselect(struct proc *p, struct linux_newselect_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): newselect(%d, %p, %p, %p, %p)\n",
- (long)p->p_pid, args->nfds, (void *)args->readfds,
- (void *)args->writefds, (void *)args->exceptfds,
- (void *)args->timeout);
+ if (ldebug(newselect))
+ printf(ARGS(newselect, "%d, %p, %p, %p, %p"),
+ args->nfds, (void *)args->readfds,
+ (void *)args->writefds, (void *)args->exceptfds,
+ (void *)args->timeout);
#endif
error = 0;
bsa.nd = args->nfds;
@@ -468,8 +472,9 @@ linux_newselect(struct proc *p, struct linux_newselect_args *args)
if ((error = copyin(args->timeout, &utv, sizeof(utv))))
goto select_out;
#ifdef DEBUG
- printf("Linux-emul(%ld): incoming timeout (%ld/%ld)\n",
- (long)p->p_pid, utv.tv_sec, utv.tv_usec);
+ if (ldebug(newselect))
+ printf(LMSG("incoming timeout (%ld/%ld)"),
+ utv.tv_sec, utv.tv_usec);
#endif
if (itimerfix(&utv)) {
/*
@@ -495,7 +500,8 @@ linux_newselect(struct proc *p, struct linux_newselect_args *args)
error = select(p, &bsa);
#ifdef DEBUG
- printf("Linux-emul(%ld): real select returns %d\n", (long)p->p_pid, error);
+ if (ldebug(newselect))
+ printf(LMSG("real select returns %d"), error);
#endif
if (error) {
@@ -524,8 +530,9 @@ linux_newselect(struct proc *p, struct linux_newselect_args *args)
} else
timevalclear(&utv);
#ifdef DEBUG
- printf("Linux-emul(%ld): outgoing timeout (%ld/%ld)\n",
- (long)p->p_pid, utv.tv_sec, utv.tv_usec);
+ if (ldebug(newselect))
+ printf(LMSG("outgoing timeout (%ld/%ld)"),
+ utv.tv_sec, utv.tv_usec);
#endif
if ((error = copyout(&utv, args->timeout, sizeof(utv))))
goto select_out;
@@ -533,7 +540,8 @@ linux_newselect(struct proc *p, struct linux_newselect_args *args)
select_out:
#ifdef DEBUG
- printf("Linux-emul(%ld): newselect_out -> %d\n", (long)p->p_pid, error);
+ if (ldebug(newselect))
+ printf(LMSG("newselect_out -> %d"), error);
#endif
return error;
}
@@ -544,7 +552,8 @@ linux_getpgid(struct proc *p, struct linux_getpgid_args *args)
struct proc *curp;
#ifdef DEBUG
- printf("Linux-emul(%ld): getpgid(%d)\n", (long)p->p_pid, args->pid);
+ if (ldebug(getpgid))
+ printf(ARGS(getpgid, "%d"), args->pid);
#endif
if (args->pid != p->p_pid) {
if (!(curp = pfind(args->pid)))
@@ -566,11 +575,12 @@ linux_mremap(struct proc *p, struct linux_mremap_args *args)
int error = 0;
#ifdef DEBUG
- printf("Linux-emul(%ld): mremap(%p, %08lx, %08lx, %08lx)\n",
- (long)p->p_pid, (void *)args->addr,
- (unsigned long)args->old_len,
- (unsigned long)args->new_len,
- (unsigned long)args->flags);
+ if (ldebug(mremap))
+ printf(ARGS(mremap, "%p, %08lx, %08lx, %08lx"),
+ (void *)args->addr,
+ (unsigned long)args->old_len,
+ (unsigned long)args->new_len,
+ (unsigned long)args->flags);
#endif
args->new_len = round_page(args->new_len);
args->old_len = round_page(args->old_len);
@@ -611,7 +621,8 @@ linux_time(struct proc *p, struct linux_time_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): time(*)\n", (long)p->p_pid);
+ if (ldebug(time))
+ printf(ARGS(time, "*"));
#endif
microtime(&tv);
tm = tv.tv_sec;
@@ -641,7 +652,8 @@ linux_times(struct proc *p, struct linux_times_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): times(*)\n", (long)p->p_pid);
+ if (ldebug(times))
+ printf(ARGS(times, "*"));
#endif
mtx_lock_spin(&sched_lock);
calcru(p, &ru.ru_utime, &ru.ru_stime, NULL);
@@ -669,7 +681,8 @@ linux_newuname(struct proc *p, struct linux_newuname_args *args)
char *osrelease, *osname;
#ifdef DEBUG
- printf("Linux-emul(%ld): newuname(*)\n", (long)p->p_pid);
+ if (ldebug(newuname))
+ printf(ARGS(newuname, "*"));
#endif
osname = linux_get_osname(p);
@@ -708,7 +721,8 @@ linux_utime(struct proc *p, struct linux_utime_args *args)
CHECKALTEXIST(p, &sg, args->fname);
#ifdef DEBUG
- printf("Linux-emul(%ld): utime(%s, *)\n", (long)p->p_pid, args->fname);
+ if (ldebug(utime))
+ printf(ARGS(utime, "%s, *"), args->fname);
#endif
if (args->times) {
if ((error = copyin(args->times, &lut, sizeof lut)))
@@ -746,8 +760,9 @@ linux_waitpid(struct proc *p, struct linux_waitpid_args *args)
int error, tmpstat;
#ifdef DEBUG
- printf("Linux-emul(%ld): waitpid(%d, %p, %d)\n",
- (long)p->p_pid, args->pid, (void *)args->status, args->options);
+ if (ldebug(waitpid))
+ printf(ARGS(waitpid, "%d, %p, %d"),
+ args->pid, (void *)args->status, args->options);
#endif
tmp.pid = args->pid;
tmp.status = args->status;
@@ -788,9 +803,10 @@ linux_wait4(struct proc *p, struct linux_wait4_args *args)
int error, tmpstat;
#ifdef DEBUG
- printf("Linux-emul(%ld): wait4(%d, %p, %d, %p)\n",
- (long)p->p_pid, args->pid, (void *)args->status, args->options,
- (void *)args->rusage);
+ if (ldebug(wait4))
+ printf(ARGS(wait4, "%d, %p, %d, %p"),
+ args->pid, (void *)args->status, args->options,
+ (void *)args->rusage);
#endif
tmp.pid = args->pid;
tmp.status = args->status;
@@ -832,8 +848,9 @@ linux_mknod(struct proc *p, struct linux_mknod_args *args)
CHECKALTCREAT(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%ld): mknod(%s, %d, %d)\n",
- (long)p->p_pid, args->path, args->mode, args->dev);
+ if (ldebug(mknod))
+ printf(ARGS(mknod, "%s, %d, %d"),
+ args->path, args->mode, args->dev);
#endif
if (args->mode & S_IFIFO) {
@@ -855,8 +872,8 @@ int
linux_personality(struct proc *p, struct linux_personality_args *args)
{
#ifdef DEBUG
- printf("Linux-emul(%ld): personality(%d)\n",
- (long)p->p_pid, args->per);
+ if (ldebug(personality))
+ printf(ARGS(personality, "%d"), args->per);
#endif
#ifndef __alpha__
if (args->per != 0)
@@ -879,8 +896,9 @@ linux_setitimer(struct proc *p, struct linux_setitimer_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): setitimer(%p, %p)\n",
- (long)p->p_pid, (void *)args->itv, (void *)args->oitv);
+ if (ldebug(setitimer))
+ printf(ARGS(setitimer, "%p, %p"),
+ (void *)args->itv, (void *)args->oitv);
#endif
bsa.which = args->which;
bsa.itv = args->itv;
@@ -890,10 +908,12 @@ linux_setitimer(struct proc *p, struct linux_setitimer_args *args)
sizeof(foo))))
return error;
#ifdef DEBUG
- printf("setitimer: value: sec: %ld, usec: %ld\n",
- foo.it_value.tv_sec, foo.it_value.tv_usec);
- printf("setitimer: interval: sec: %ld, usec: %ld\n",
- foo.it_interval.tv_sec, foo.it_interval.tv_usec);
+ if (ldebug(setitimer)) {
+ printf("setitimer: value: sec: %ld, usec: %ld\n",
+ foo.it_value.tv_sec, foo.it_value.tv_usec);
+ printf("setitimer: interval: sec: %ld, usec: %ld\n",
+ foo.it_interval.tv_sec, foo.it_interval.tv_usec);
+ }
#endif
}
return setitimer(p, &bsa);
@@ -904,8 +924,8 @@ linux_getitimer(struct proc *p, struct linux_getitimer_args *args)
{
struct getitimer_args bsa;
#ifdef DEBUG
- printf("Linux-emul(%ld): getitimer(%p)\n",
- (long)p->p_pid, (void *)args->itv);
+ if (ldebug(getitimer))
+ printf(ARGS(getitimer, "%p"), (void *)args->itv);
#endif
bsa.which = args->which;
bsa.itv = args->itv;
@@ -1027,8 +1047,9 @@ linux_setrlimit(p, uap)
caddr_t sg = stackgap_init();
#ifdef DEBUG
- printf("Linux-emul(%ld): setrlimit(%d, %p)\n", (long)p->p_pid,
- uap->resource, (void *)uap->rlim);
+ if (ldebug(setrlimit))
+ printf(ARGS(setrlimit, "%d, %p"),
+ uap->resource, (void *)uap->rlim);
#endif
if (uap->resource >= LINUX_RLIM_NLIMITS)
@@ -1059,8 +1080,9 @@ linux_getrlimit(p, uap)
caddr_t sg = stackgap_init();
#ifdef DEBUG
- printf("Linux-emul(%ld): getrlimit(%d, %p)\n", (long)p->p_pid,
- uap->resource, (void *)uap->rlim);
+ if (ldebug(getrlimit))
+ printf(ARGS(getrlimit, "%d, %p"),
+ uap->resource, (void *)uap->rlim);
#endif
if (uap->resource >= LINUX_RLIM_NLIMITS)
@@ -1093,8 +1115,9 @@ linux_sched_setscheduler(p, uap)
struct sched_setscheduler_args bsd;
#ifdef DEBUG
- printf("Linux-emul(%ld): sched_setscheduler(%d, %d, %p)\n",
- (long)p->p_pid, uap->pid, uap->policy, (const void *)uap->param);
+ if (ldebug(sched_setscheduler))
+ printf(ARGS(sched_setscheduler, "%d, %d, %p"),
+ uap->pid, uap->policy, (const void *)uap->param);
#endif
switch (uap->policy) {
@@ -1125,8 +1148,8 @@ linux_sched_getscheduler(p, uap)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): sched_getscheduler(%d)\n",
- (long)p->p_pid, uap->pid);
+ if (ldebug(sched_getscheduler))
+ printf(ARGS(sched_getscheduler, "%d"), uap->pid);
#endif
bsd.pid = uap->pid;
@@ -1158,7 +1181,7 @@ linux_reboot(struct proc *p, struct linux_reboot_args *args)
#ifdef DEBUG
if (ldebug(reboot))
- printf(ARGS(reboot, "%p"), args->opt);
+ printf(ARGS(reboot, "0x%x"), args->opt);
#endif
if (args->opt == REBOOT_CAD_ON || args->opt == REBOOT_CAD_OFF)
return (0);
diff --git a/sys/compat/linux/linux_signal.c b/sys/compat/linux/linux_signal.c
index 7d2d52b030dd..3201da66da7f 100644
--- a/sys/compat/linux/linux_signal.c
+++ b/sys/compat/linux/linux_signal.c
@@ -180,8 +180,9 @@ linux_signal(struct proc *p, struct linux_signal_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): signal(%d, %p)\n",
- (long)p->p_pid, args->sig, (void *)args->handler);
+ if (ldebug(signal))
+ printf(ARGS(signal, "%d, %p"),
+ args->sig, (void *)args->handler);
#endif
nsa.lsa_handler = args->handler;
@@ -202,9 +203,10 @@ linux_rt_sigaction(struct proc *p, struct linux_rt_sigaction_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigaction(%ld, %p, %p, %ld)\n",
- (long)p->p_pid, (long)args->sig, (void *)args->act,
- (void *)args->oact, (long)args->sigsetsize);
+ if (ldebug(rt_sigaction))
+ printf(ARGS(rt_sigaction, "%ld, %p, %p, %ld"),
+ (long)args->sig, (void *)args->act,
+ (void *)args->oact, (long)args->sigsetsize);
#endif
if (args->sigsetsize != sizeof(linux_sigset_t))
@@ -275,7 +277,8 @@ linux_sigprocmask(struct proc *p, struct linux_sigprocmask_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%d): sigprocmask(%d, *, *)\n", p->p_pid, args->how);
+ if (ldebug(sigprocmask))
+ printf(ARGS(sigprocmask, "%d, *, *"), args->how);
#endif
if (args->mask != NULL) {
@@ -306,9 +309,10 @@ linux_rt_sigprocmask(struct proc *p, struct linux_rt_sigprocmask_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigprocmask(%d, %p, %p, %ld)\n",
- (long)p->p_pid, args->how, (void *)args->mask,
- (void *)args->omask, (long)args->sigsetsize);
+ if (ldebug(rt_sigprocmask))
+ printf(ARGS(rt_sigprocmask, "%d, %p, %p, %ld"),
+ args->how, (void *)args->mask,
+ (void *)args->omask, (long)args->sigsetsize);
#endif
if (args->sigsetsize != sizeof(linux_sigset_t))
@@ -338,7 +342,8 @@ linux_siggetmask(struct proc *p, struct linux_siggetmask_args *args)
linux_sigset_t mask;
#ifdef DEBUG
- printf("Linux-emul(%d): siggetmask()\n", p->p_pid);
+ if (ldebug(siggetmask))
+ printf(ARGS(siggetmask, ""));
#endif
PROC_LOCK(p);
@@ -355,8 +360,8 @@ linux_sigsetmask(struct proc *p, struct linux_sigsetmask_args *args)
sigset_t bset;
#ifdef DEBUG
- printf("Linux-emul(%ld): sigsetmask(%08lx)\n",
- (long)p->p_pid, (unsigned long)args->mask);
+ if (ldebug(sigsetmask))
+ printf(ARGS(sigsetmask, "%08lx"), (unsigned long)args->mask);
#endif
PROC_LOCK(p);
@@ -379,7 +384,8 @@ linux_sigpending(struct proc *p, struct linux_sigpending_args *args)
linux_osigset_t mask;
#ifdef DEBUG
- printf("Linux-emul(%d): sigpending(*)\n", p->p_pid);
+ if (ldebug(sigpending))
+ printf(ARGS(sigpending, "*"));
#endif
PROC_LOCK(p);
@@ -401,8 +407,8 @@ linux_kill(struct proc *p, struct linux_kill_args *args)
} */ tmp;
#ifdef DEBUG
- printf("Linux-emul(%d): kill(%d, %d)\n",
- p->p_pid, args->pid, args->signum);
+ if (ldebug(kill))
+ printf(ARGS(kill, "%d, %d"), args->pid, args->signum);
#endif
/*
diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c
index ee31b4fcd808..cd53edafea56 100644
--- a/sys/compat/linux/linux_stats.c
+++ b/sys/compat/linux/linux_stats.c
@@ -149,8 +149,8 @@ linux_newstat(struct proc *p, struct linux_newstat_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%ld): newstat(%s, *)\n", (long)p->p_pid,
- args->path);
+ if (ldebug(newstat))
+ printf(ARGS(newstat, "%s, *"), args->path);
#endif
NDINIT(&nd, LOOKUP, FOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
@@ -186,8 +186,8 @@ linux_newlstat(p, uap)
CHECKALTEXIST(p, &sg, uap->path);
#ifdef DEBUG
- printf("Linux-emul(%ld): newlstat(%s, *)\n", (long)p->p_pid,
- uap->path);
+ if (ldebug(newlstat))
+ printf(ARGS(newlstat, "%s, *"), uap->path);
#endif
NDINIT(&nd, LOOKUP, NOFOLLOW | LOCKLEAF | NOOBJ, UIO_USERSPACE,
@@ -217,7 +217,8 @@ linux_newfstat(struct proc *p, struct linux_newfstat_args *args)
fdp = p->p_fd;
#ifdef DEBUG
- printf("Linux-emul(%ld): newfstat(%d, *)\n", (long)p->p_pid, args->fd);
+ if (ldebug(newfstat))
+ printf(ARGS(newfstat, "%d, *"), args->fd);
#endif
if ((unsigned)args->fd >= fdp->fd_nfiles ||
@@ -308,7 +309,8 @@ linux_statfs(struct proc *p, struct linux_statfs_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): statfs(%s, *)\n", p->p_pid, args->path);
+ if (ldebug(statfs))
+ printf(ARGS(statfs, "%s, *"), args->path);
#endif
ndp = &nd;
NDINIT(ndp, LOOKUP, FOLLOW, UIO_USERSPACE, args->path, curproc);
@@ -347,7 +349,8 @@ linux_fstatfs(struct proc *p, struct linux_fstatfs_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%d): fstatfs(%d, *)\n", p->p_pid, args->fd);
+ if (ldebug(fstatfs))
+ printf(ARGS(fstatfs, "%d, *"), args->fd);
#endif
error = getvnode(p->p_fd, args->fd, &fp);
if (error)
@@ -384,7 +387,8 @@ linux_ustat(p, uap)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): ustat(%d, *)\n", (long)p->p_pid, uap->dev);
+ if (ldebug(ustat))
+ printf(ARGS(ustat, "%d, *"), uap->dev);
#endif
/*