summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/alpha/linux/linux.h8
-rw-r--r--sys/alpha/linux/linux_machdep.c80
-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
-rw-r--r--sys/i386/linux/linux.h8
-rw-r--r--sys/i386/linux/linux_machdep.c68
-rw-r--r--sys/i386/linux/linux_sysvec.c36
11 files changed, 379 insertions, 227 deletions
diff --git a/sys/alpha/linux/linux.h b/sys/alpha/linux/linux.h
index 92628e9..a11baaa 100644
--- a/sys/alpha/linux/linux.h
+++ b/sys/alpha/linux/linux.h
@@ -33,6 +33,14 @@
#include <alpha/linux/linux_syscall.h>
+/*
+ * debugging support
+ */
+extern u_char linux_debug_map[];
+#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
+#define ARGS(nm, fmt) "Linux-emul(%ld): "#nm"("fmt")\n", (long)p->p_pid
+#define LMSG(fmt) "Linux-emul(%ld): "fmt"\n", (long)p->p_pid
+
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_LINUX);
#endif
diff --git a/sys/alpha/linux/linux_machdep.c b/sys/alpha/linux/linux_machdep.c
index 3829a4b..902a81c 100644
--- a/sys/alpha/linux/linux_machdep.c
+++ b/sys/alpha/linux/linux_machdep.c
@@ -65,8 +65,8 @@ linux_execve(struct proc *p, struct linux_execve_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): execve(%s)\n",
- p->p_pid, args->path);
+ if (ldebug(execve))
+ printf(ARGS(execve, "%s"), args->path);
#endif
bsd.fname = args->path;
bsd.argv = args->argp;
@@ -80,7 +80,8 @@ linux_fork(struct proc *p, struct linux_fork_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): fork()\n", (long)p->p_pid);
+ if (ldebug(fork))
+ printf(ARGS(fork, ""));
#endif
if ((error = fork(p, (struct fork_args *)args)) != 0)
return (error);
@@ -97,7 +98,8 @@ linux_vfork(struct proc *p, struct linux_vfork_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): vfork()\n", (long)p->p_pid);
+ if (ldebug(vfork))
+ printf(ARGS(vfork, ""));
#endif
if ((error = vfork(p, (struct vfork_args *)args)) != 0)
return (error);
@@ -123,12 +125,12 @@ linux_clone(struct proc *p, struct linux_clone_args *args)
struct rfork_args rf_args;
#ifdef DEBUG
- if (args->flags & CLONE_PID)
- printf("linux_clone(%ld): CLONE_PID not yet supported\n",
- (long)p->p_pid);
- uprintf("linux_clone(%ld): invoked with flags 0x%x and stack %p\n",
- (long)p->p_pid, (unsigned int)args->flags,
- args->stack);
+ if (ldebug(clone)) {
+ printf(ARGS(clone, "flags %x, stack %x"),
+ (unsigned int)args->flags, (unsigned int)args->stack);
+ if (args->flags & CLONE_PID)
+ printf(LMSG("CLONE_PID not yet supported"));
+ }
#endif
if (!args->stack)
@@ -168,8 +170,9 @@ linux_clone(struct proc *p, struct linux_clone_args *args)
p2->p_addr->u_pcb.pcb_hw.apcb_usp = (unsigned long)args->stack;
#ifdef DEBUG
- uprintf ("linux_clone(%ld): successful rfork to %ld, stack %p, sig = %d\n",
-(long)p->p_pid, (long)p2->p_pid, args->stack, exit_signal);
+ if (ldebug(clone))
+ printf(LMSG("clone: successful rfork to %ld, stack %p sig = %d"),
+ (long)p2->p_pid, args->stack, exit_signal);
#endif
return (0);
@@ -194,9 +197,11 @@ linux_mmap(struct proc *p, struct linux_mmap_args *linux_args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): mmap(%p, 0x%lx, 0x%x, 0x%x, 0x%x, 0x%lx)\n",
- (long)p->p_pid, (void *)linux_args->addr, linux_args->len,
- linux_args->prot, linux_args->flags, linux_args->fd, linux_args->pos);
+ if (ldebug(mmap))
+ printf(ARGS(mmap, "%p, 0x%lx, 0x%x, 0x%x, 0x%x, 0x%lx"),
+ (void *)linux_args->addr, linux_args->len,
+ linux_args->prot, linux_args->flags, linux_args->fd,
+ linux_args->pos);
#endif
bsd_args.prot = linux_args->prot | PROT_READ; /* always required */
@@ -265,21 +270,21 @@ linux_mmap(struct proc *p, struct linux_mmap_args *linux_args)
bsd_args.pad = 0;
#ifdef DEBUG
- printf("Linux-emul(%ld): mmap(%p, 0x%lx, 0x%x, 0x%x, 0x%x, 0x%lx)\n",
- (long)p->p_pid,
- (void *)bsd_args.addr,
- bsd_args.len,
- bsd_args.prot,
- bsd_args.flags,
- bsd_args.fd,
- bsd_args.pos);
+ if (ldebug(mmap))
+ printf(ARGS(mmap, "%p, 0x%lx, 0x%x, 0x%x, 0x%x, 0x%lx)",
+ (void *)bsd_args.addr,
+ bsd_args.len,
+ bsd_args.prot,
+ bsd_args.flags,
+ bsd_args.fd,
+ bsd_args.pos);
#endif
if (bsd_args.addr == 0)
bsd_args.addr = (caddr_t)0x40000000UL;
error = mmap(p, &bsd_args);
#ifdef DEBUG
- printf("Linux-emul(%ld): mmap returns %d, 0x%lx\n",
- (long)p->p_pid, error, p->p_retval[0]);
+ if (ldebug(mmap))
+ printf(LMSG("mmap returns %d, 0x%lx", error, p->p_retval[0]);
#endif
return (error);
}
@@ -298,8 +303,9 @@ linux_rt_sigsuspend(p, uap)
sg = stackgap_init();
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigsuspend(%p, %d)\n", (long)p->p_pid,
- (void *)uap->newset, uap->sigsetsize);
+ if (ldebug(rt_sigsuspend))
+ printf(ARGS(rt_sigsuspend, "%p, %d"),
+ (void *)uap->newset, uap->sigsetsize);
#endif
if (uap->sigsetsize != sizeof(linux_sigset_t))
return (EINVAL);
@@ -321,8 +327,9 @@ linux_mprotect(p, uap)
{
#ifdef DEBUG
- printf("Linux-emul(%ld): mprotect(%p, 0x%lx, 0x%x)\n",
- (long)p->p_pid, (void *)uap->addr, uap->len, uap->prot);
+ if (ldebug(mprotect))
+ printf(ARGS(mprotect, "%p, 0x%lx, 0x%x)",
+ (void *)uap->addr, uap->len, uap->prot);
#endif
return (mprotect(p, (void *)uap));
}
@@ -334,8 +341,9 @@ linux_munmap(p, uap)
{
#ifdef DEBUG
- printf("Linux-emul(%ld): munmap(%p, 0x%lx)\n",
- (long)p->p_pid, (void *)uap->addr, uap->len);
+ if (ldebug(munmap))
+ printf(ARGS(munmap, "%p, 0x%lx",
+ (void *)uap->addr, uap->len);
#endif
return (munmap(p, (void *)uap));
}
@@ -373,8 +381,9 @@ linux_setrlimit(p, uap)
int error;
#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)
return EINVAL;
@@ -398,8 +407,9 @@ linux_getrlimit(p, uap)
u_int which;
#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)
return EINVAL;
diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c
index 441aeb7..492742f 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 f6fae19..1cf76cf 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 6d60a8c..8482dd9 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 552d5f4..3e08d85 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 7d2d52b..3201da6 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 ee31b4f..cd53eda 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
/*
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index 88371d4..fab3e29 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -35,6 +35,14 @@
#include <i386/linux/linux_syscall.h>
+/*
+ * debugging support
+ */
+extern u_char linux_debug_map[];
+#define ldebug(name) isclr(linux_debug_map, LINUX_SYS_linux_ ## name)
+#define ARGS(nm, fmt) "Linux-emul(%ld): "#nm"("fmt")\n", (long)p->p_pid
+#define LMSG(fmt) "Linux-emul(%ld): "fmt"\n", (long)p->p_pid
+
#ifdef MALLOC_DECLARE
MALLOC_DECLARE(M_LINUX);
#endif
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index 73c816c..bb07a27 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -107,8 +107,8 @@ linux_execve(struct proc *p, struct linux_execve_args *args)
CHECKALTEXIST(p, &sg, args->path);
#ifdef DEBUG
- printf("Linux-emul(%d): execve(%s)\n",
- p->p_pid, args->path);
+ if (ldebug(execve))
+ printf(ARGS(execve, "%s"), args->path);
#endif
bsd.fname = args->path;
@@ -157,7 +157,8 @@ linux_select(struct proc *p, struct linux_select_args *args)
int error;
#ifdef SELECT_DEBUG
- printf("Linux-emul(%ld): select(%x)\n", (long)p->p_pid, args->ptr);
+ if (ldebug(select))
+ printf(ARGS(select, "%x"), args->ptr);
#endif
error = copyin(args->ptr, &linux_args, sizeof(linux_args));
@@ -178,7 +179,8 @@ linux_fork(struct proc *p, struct linux_fork_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): fork()\n", (long)p->p_pid);
+ if (ldebug(fork))
+ printf(ARGS(fork, ""));
#endif
if ((error = fork(p, (struct fork_args *)args)) != 0)
@@ -195,7 +197,8 @@ linux_vfork(struct proc *p, struct linux_vfork_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): vfork()\n", (long)p->p_pid);
+ if (ldebug(vfork))
+ printf(ARGS(vfork, ""));
#endif
if ((error = vfork(p, (struct vfork_args *)args)) != 0)
@@ -222,12 +225,12 @@ linux_clone(struct proc *p, struct linux_clone_args *args)
struct rfork_args rf_args;
#ifdef DEBUG
- if (args->flags & CLONE_PID)
- printf("linux_clone(%ld): CLONE_PID not yet supported\n",
- (long)p->p_pid);
- printf("linux_clone(%ld): invoked with flags %x and stack %x\n",
- (long)p->p_pid, (unsigned int)args->flags,
- (unsigned int)args->stack);
+ if (ldebug(clone)) {
+ printf(ARGS(clone, "flags %x, stack %x"),
+ (unsigned int)args->flags, (unsigned int)args->stack);
+ if (args->flags & CLONE_PID)
+ printf(LMSG("CLONE_PID not yet supported"));
+ }
#endif
if (!args->stack)
@@ -267,8 +270,9 @@ linux_clone(struct proc *p, struct linux_clone_args *args)
p2->p_md.md_regs->tf_esp = (unsigned int)args->stack;
#ifdef DEBUG
- printf ("linux_clone(%ld): successful rfork to %ld\n", (long)p->p_pid,
- (long)p2->p_pid);
+ if (ldebug(clone))
+ printf(LMSG("clone: successful rfork to %ld"),
+ (long)p2->p_pid);
#endif
return (0);
@@ -307,9 +311,10 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args)
return (error);
#ifdef DEBUG
- printf("Linux-emul(%ld): mmap(%p, %d, %d, 0x%08x, %d, %d)",
- (long)p->p_pid, (void *)linux_args.addr, linux_args.len,
- linux_args.prot, linux_args.flags, linux_args.fd, linux_args.pos);
+ if (ldebug(mmap))
+ printf(ARGS(mmap, "%p, %d, %d, 0x%08x, %d, %d"),
+ (void *)linux_args.addr, linux_args.len, linux_args.prot,
+ linux_args.flags, linux_args.fd, linux_args.pos);
#endif
bsd_args.flags = 0;
@@ -396,9 +401,10 @@ linux_mmap(struct proc *p, struct linux_mmap_args *args)
bsd_args.pad = 0;
#ifdef DEBUG
- printf("-> (%p, %d, %d, 0x%08x, %d, %d)\n", (void *)bsd_args.addr,
- bsd_args.len, bsd_args.prot, bsd_args.flags, bsd_args.fd,
- (int)bsd_args.pos);
+ if (ldebug(mmap))
+ printf("-> (%p, %d, %d, 0x%08x, %d, %d)\n",
+ (void *)bsd_args.addr, bsd_args.len, bsd_args.prot,
+ bsd_args.flags, bsd_args.fd, (int)bsd_args.pos);
#endif
return (mmap(p, &bsd_args));
@@ -411,7 +417,8 @@ linux_pipe(struct proc *p, struct linux_pipe_args *args)
int reg_edx;
#ifdef DEBUG
- printf("Linux-emul(%ld): pipe(*)\n", (long)p->p_pid);
+ if (ldebug(pipe))
+ printf(ARGS(pipe, "*"));
#endif
reg_edx = p->p_retval[1];
@@ -543,8 +550,9 @@ linux_sigaction(struct proc *p, struct linux_sigaction_args *args)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): sigaction(%d, %p, %p)\n", (long)p->p_pid,
- args->sig, (void *)args->nsa, (void *)args->osa);
+ if (ldebug(sigaction))
+ printf(ARGS(sigaction, "%d, %p, %p"),
+ args->sig, (void *)args->nsa, (void *)args->osa);
#endif
if (args->nsa != NULL) {
@@ -586,8 +594,8 @@ linux_sigsuspend(struct proc *p, struct linux_sigsuspend_args *args)
caddr_t sg = stackgap_init();
#ifdef DEBUG
- printf("Linux-emul(%ld): sigsuspend(%08lx)\n",
- (long)p->p_pid, (unsigned long)args->mask);
+ if (ldebug(sigsuspend))
+ printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask);
#endif
sigmask = stackgap_alloc(&sg, sizeof(sigset_t));
@@ -610,8 +618,9 @@ linux_rt_sigsuspend(p, uap)
int error;
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigsuspend(%p, %d)\n", (long)p->p_pid,
- (void *)uap->newset, uap->sigsetsize);
+ if (ldebug(rt_sigsuspend))
+ printf(ARGS(rt_sigsuspend, "%p, %d"),
+ (void *)uap->newset, uap->sigsetsize);
#endif
if (uap->sigsetsize != sizeof(linux_sigset_t))
@@ -635,7 +644,8 @@ linux_pause(struct proc *p, struct linux_pause_args *args)
caddr_t sg = stackgap_init();
#ifdef DEBUG
- printf("Linux-emul(%d): pause()\n", p->p_pid);
+ if (ldebug(pause))
+ printf(ARGS(pause, ""));
#endif
sigmask = stackgap_alloc(&sg, sizeof(sigset_t));
@@ -658,8 +668,8 @@ linux_sigaltstack(p, uap)
caddr_t sg = stackgap_init();
#ifdef DEBUG
- printf("Linux-emul(%ld): sigaltstack(%p, %p)\n",
- (long)p->p_pid, uap->uss, uap->uoss);
+ if (ldebug(sigaltstack))
+ printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss);
#endif
if (uap->uss == NULL) {
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index 5ba0b68..09b682f 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -213,8 +213,9 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
oonstack = sigonstack(regs->tf_esp);
#ifdef DEBUG
- printf("Linux-emul(%ld): linux_rt_sendsig(%p, %d, %p, %lu)\n",
- (long)p->p_pid, catcher, sig, (void*)mask, code);
+ if (ldebug(sigreturn))
+ printf(ARGS(rt_sendsig, "%p, %d, %p, %lu"),
+ catcher, sig, (void*)mask, code);
#endif
/*
* Allocate space for the signal handler context.
@@ -247,8 +248,9 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
SIGDELSET(p->p_sigmask, SIGILL);
PROC_UNLOCK(p);
#ifdef DEBUG
- printf("Linux-emul(%ld): linux_rt_sendsig -- bad stack %p, "
- "oonstack=%x\n", (long)p->p_pid, fp, oonstack);
+ if (ldebug(sigreturn))
+ printf(LMSG("rt_sendsig: bad stack %p, oonstack=%x"),
+ fp, oonstack);
#endif
psignal(p, SIGILL);
return;
@@ -307,10 +309,10 @@ linux_rt_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
frame.sf_sc.uc_mcontext.sc_trapno = code; /* XXX ???? */
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, "
- "mask: 0x%x\n", (long)p->p_pid, frame.sf_sc.uc_stack.ss_flags,
- p->p_sigstk.ss_sp, p->p_sigstk.ss_size,
- frame.sf_sc.uc_mcontext.sc_mask);
+ if (ldebug(sigreturn))
+ printf(LMSG("rt_sendsig flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x"),
+ frame.sf_sc.uc_stack.ss_flags, p->p_sigstk.ss_sp,
+ p->p_sigstk.ss_size, frame.sf_sc.uc_mcontext.sc_mask);
#endif
if (copyout(&frame, fp, sizeof(frame)) != 0) {
@@ -368,8 +370,9 @@ linux_sendsig(sig_t catcher, int sig, sigset_t *mask, u_long code)
oonstack = sigonstack(regs->tf_esp);
#ifdef DEBUG
- printf("Linux-emul(%ld): linux_sendsig(%p, %d, %p, %lu)\n",
- (long)p->p_pid, catcher, sig, (void*)mask, code);
+ if (ldebug(sigreturn))
+ printf(ARGS(sendsig, "%p, %d, %p, %lu"),
+ catcher, sig, (void*)mask, code);
#endif
/*
@@ -492,8 +495,8 @@ linux_sigreturn(p, args)
regs = p->p_md.md_regs;
#ifdef DEBUG
- printf("Linux-emul(%ld): linux_sigreturn(%p)\n",
- (long)p->p_pid, (void *)args->sfp);
+ if (ldebug(sigreturn))
+ printf(ARGS(sigreturn, "%p"), (void *)args->sfp);
#endif
/*
* The trampoline code hands us the sigframe.
@@ -591,8 +594,8 @@ linux_rt_sigreturn(p, args)
regs = p->p_md.md_regs;
#ifdef DEBUG
- printf("Linux-emul(%ld): linux_rt_sigreturn(%p)\n",
- (long)p->p_pid, (void *)args->ucp);
+ if (ldebug(rt_sigreturn))
+ printf(ARGS(rt_sigreturn, "%p"), (void *)args->ucp);
#endif
/*
* The trampoline code hands us the ucontext.
@@ -669,8 +672,9 @@ linux_rt_sigreturn(p, args)
ss->ss_flags = linux_to_bsd_sigaltstack(lss->ss_flags);
#ifdef DEBUG
- printf("Linux-emul(%ld): rt_sigret flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x\n",
- (long)p->p_pid, ss->ss_flags, ss->ss_sp, ss->ss_size, context->sc_mask);
+ if (ldebug(rt_sigreturn))
+ printf(LMSG("rt_sigret flags: 0x%x, sp: %p, ss: 0x%x, mask: 0x%x"),
+ ss->ss_flags, ss->ss_sp, ss->ss_size, context->sc_mask);
#endif
sasargs.ss = ss;
sasargs.oss = NULL;
OpenPOWER on IntegriCloud