test/clone.c: minor fixup

Another bunch of patches from John Hughes merged:
signal.c:
+ SVR4 printcontext(): sigset_t != sigset_t*
+ getcontext returns a value, so print on exit of syscall
+ add UC_FP to ucontext_flags for OS writers that can't spell
+ sys_signal(): special case SIG_{ERR,DFL,IGN}
+ decode_subcall(): only do subcall range checking when needed
bunch of UnixWare updates
aclocal.m4, acconfig.h, configure.in: add test for long long type
This commit is contained in:
Wichert Akkerman 2000-08-10 02:14:04 +00:00
parent e381610a00
commit 16a03d2e97
15 changed files with 377 additions and 20 deletions

View File

@ -1,3 +1,16 @@
2000-08-09 Wichert Akkerman <wakkerma@debian.org>
* test/clone.c: minor fixup
* Another bunch of patches from John Hughes merged:
* signal.c:
+ SVR4 printcontext(): sigset_t != sigset_t*
+ getcontext returns a value, so print on exit of syscall
+ add UC_FP to ucontext_flags for OS writers that can't spell
+ sys_signal(): special case SIG_{ERR,DFL,IGN}
+ decode_subcall(): only do subcall range checking when needed
* bunch of UnixWare updates
* aclocal.m4, acconfig.h, configure.in: add test for long long type
2000-07-04 Wichert Akkerman <wakkerma@debian.org>
* net.c: add SOL_PACKET and SOL_RAW socket options, update

View File

@ -71,3 +71,6 @@
/* Define if stat64 is available in asm/stat.h. */
#undef HAVE_STAT64
/* Define if yor compilers know abuot long long */
#undef HAVE_LONG_LONG

15
aclocal.m4 vendored
View File

@ -299,3 +299,18 @@ then
AC_DEFINE(HAVE_STAT64)
fi
])
dnl ### A macro to determine whether we have long long
AC_DEFUN(AC_LONG_LONG,
[AC_MSG_CHECKING(for long long)
AC_CACHE_VAL(ac_cv_type_long_long,
[AC_TRY_COMPILE([],
[long long x = 20;],
ac_cv_type_long_long=yes,
ac_cv_type_long_long=no)])
AC_MSG_RESULT($ac_cv_type_long_long)
if test "$ac_cv_type_long_long" = yes
then
AC_DEFINE(HAVE_LONG_LONG)
fi
])

View File

@ -143,6 +143,7 @@ AC_TYPE_GETGROUPS
AC_HEADER_MAJOR
AC_SIG_ATOMIC_T
AC_STAT64
AC_LONG_LONG
if test x$OPSYS != xLINUX; then
AC_CHECK_LIB(nsl, main)
fi

7
defs.h
View File

@ -158,7 +158,7 @@ extern int mp_ioctl (int f, int c, void *a, int s);
#define IOCTL_STATUS(t) \
pread (t->pfd_stat, &t->status, sizeof t->status, 0)
#define IOCTL_WSTOP(t) \
(IOCTL (t->pfd, PCWSTOP, NULL) < 0 ? -1 : \
(IOCTL (t->pfd, PCWSTOP, (char *)NULL) < 0 ? -1 : \
IOCTL_STATUS (t))
#define PR_WHY pr_lwp.pr_why
#define PR_WHAT pr_lwp.pr_what
@ -194,6 +194,9 @@ struct tcb {
long u_arg[MAX_ARGS]; /* System call arguments */
int u_error; /* Error code */
long u_rval; /* (first) return value */
#ifdef HAVE_LONG_LONG
long long u_lrval; /* long long return value */
#endif
FILE *outf; /* Output file for this process */
const char *auxstr; /* Auxiliary info from syscall (see RVAL_STR) */
struct timeval stime; /* System time usage as of last process wait */
@ -266,6 +269,8 @@ struct xlat {
#define RVAL_HEX 001 /* hex format */
#define RVAL_OCTAL 002 /* octal format */
#define RVAL_UDECIMAL 003 /* unsigned decimal format */
#define RVAL_LDECIMAL 004 /* long long format */
/* Maybe add long long hex, octal, unsigned */
#define RVAL_MASK 007 /* mask for these values */
#define RVAL_STR 010 /* Print `auxstr' field after return val */

17
file.c
View File

@ -1741,3 +1741,20 @@ struct tcb *tcp;
}
#endif /* HAVE_SYS_ASYNCH_H */
#if UNIXWARE >= 7
int
sys_lseek64 (tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
long long offset = * (long long *) & tcp->u_arg [1];
if (tcp->u_arg[3] == SEEK_SET)
tprintf("%ld, %llu, ", tcp->u_arg[0], offset);
else
tprintf("%ld, %lld, ", tcp->u_arg[0], offset);
printxval(whence, tcp->u_arg[3], "SEEK_???");
}
return RVAL_LDECIMAL;
}
#endif

159
net.c
View File

@ -72,6 +72,10 @@
#define PF_UNSPEC AF_UNSPEC
#endif
#if UNIXWARE >= 7
#define HAVE_SENDMSG 1 /* HACK - *FIXME* */
#endif
#ifdef LINUX
/* Under Linux these are enums so we can't test for them with ifdef. */
#define IPPROTO_EGP IPPROTO_EGP
@ -476,6 +480,7 @@ static struct xlat icmpfilterflags[] = {
};
#endif /* SOL_RAW */
void
printsock(tcp, addr, addrlen)
struct tcb *tcp;
@ -1164,3 +1169,157 @@ struct tcb *tcp;
}
return 0;
}
#if UNIXWARE >= 7
static struct xlat sock_version[] = {
{ __NETLIB_UW211_SVR4, "UW211_SVR4" },
{ __NETLIB_UW211_XPG4, "UW211_XPG4" },
{ __NETLIB_GEMINI_SVR4, "GEMINI_SVR4" },
{ __NETLIB_GEMINI_XPG4, "GEMINI_XPG4" },
{ __NETLIB_FP1_SVR4, "FP1_SVR4" },
{ __NETLIB_FP1_XPG4, "FP1_XPG4" },
{ 0, NULL },
};
int
netlib_call(tcp, func)
struct tcb *tcp;
int (*func) ();
{
if (entering(tcp)) {
int i;
printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
tprintf(", ");
--tcp->u_nargs;
for (i = 0; i < tcp->u_nargs; i++)
tcp->u_arg[i] = tcp->u_arg[i + 1];
return func (tcp);
}
return func (tcp);
}
int
sys_xsocket(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_socket);
}
int
sys_xsocketpair(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_socketpair);
}
int
sys_xbind(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_bind);
}
int
sys_xconnect(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_connect);
}
int
sys_xlisten(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_listen);
}
int
sys_xaccept(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_accept);
}
int
sys_xsendmsg(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_sendmsg);
}
int
sys_xrecvmsg(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_recvmsg);
}
int
sys_xgetsockaddr(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
printxval (sock_version, tcp->u_arg[0], "__NETLIB_???");
tprintf(", ");
if (tcp->u_arg[1] == 0) {
tprintf ("LOCALNAME, ");
}
else if (tcp->u_arg[1] == 1) {
tprintf ("REMOTENAME, ");
}
else {
tprintf ("%ld, ", tcp->u_arg [1]);
}
tprintf ("%ld, ", tcp->u_arg [2]);
}
else {
if (tcp->u_arg[3] == 0 || syserror(tcp)) {
tprintf("%#lx", tcp->u_arg[3]);
} else {
printsock(tcp, tcp->u_arg[3], tcp->u_arg[4]);
}
tprintf(", ");
printnum(tcp, tcp->u_arg[4], "%lu");
}
return 0;
}
#if 0
int
sys_xsetsockaddr(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_setsockaddr);
}
#endif
int
sys_xgetsockopt(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_getsockopt);
}
int
sys_xsetsockopt(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_setsockopt);
}
int
sys_xshutdown(tcp)
struct tcb *tcp;
{
return netlib_call (tcp, sys_shutdown);
}
#endif

View File

@ -665,6 +665,7 @@ struct tcb *tcp;
{
if (entering(tcp)) {
printsignal(tcp->u_arg[0]);
tprintf(", ");
switch (tcp->u_arg[1]) {
case (int) SIG_ERR:
tprintf("SIG_ERR");
@ -690,6 +691,29 @@ struct tcb *tcp;
#endif /* !SVR4 */
tprintf("%#lx", tcp->u_arg[1]);
}
return 0;
}
else {
switch (tcp->u_rval) {
case (int) SIG_ERR:
tcp->auxstr = "SIG_ERR"; break;
case (int) SIG_DFL:
tcp->auxstr = "SIG_DFL"; break;
case (int) SIG_IGN:
tcp->auxstr = "SIG_IGN"; break;
default:
tcp->auxstr = NULL;
}
return RVAL_HEX | RVAL_STR;
}
}
int
sys_sighold(tcp)
struct tcb *tcp;
{
if (entering(tcp)) {
printsignal(tcp->u_arg[0]);
}
return 0;
}
@ -1020,8 +1044,10 @@ struct tcb *tcp;
{
ucontext_t uc;
if (entering(tcp)) {
if (!tcp->u_arg[0])
if (exiting(tcp)) {
if (tcp->u_error)
tprintf("%#lx", tcp->u_arg[0]);
else if (!tcp->u_arg[0])
tprintf("NULL");
else if (umove(tcp, tcp->u_arg[0], &uc) < 0)
tprintf("{...}");

View File

@ -660,7 +660,7 @@ int attaching;
}
}
/* Stop the process so that we own the stop. */
if (IOCTL(tcp->pfd, PIOCSTOP, NULL) < 0) {
if (IOCTL(tcp->pfd, PIOCSTOP, (char *)NULL) < 0) {
perror("strace: PIOCSTOP");
return -1;
}

View File

@ -125,12 +125,6 @@
#define sys_timer_settime printargs
#define sys_timer_gettime printargs
#define sys_timer_getoverrun printargs
#define sys_signal printargs
#define sys_sigset printargs
#define sys_sighold printargs
#define sys_sigrelse printargs
#define sys_sigignore printargs
#define sys_sigpause printargs
#define sys_msgctl printargs
#define sys_msgget printargs
#define sys_msgrcv printargs
@ -148,6 +142,7 @@
#define sys_sysfs1 printargs
#define sys_sysfs2 printargs
#define sys_sysfs3 printargs
#define sys_xsetsockaddr printargs
/* like another call */
#define sys_lchown sys_chown
@ -165,6 +160,10 @@
#define sys_BSDgetpgrp sys_getpgrp
#define sys_BSDsetpgrp sys_setpgrp
#define sys_waitsys sys_waitid
#define sys_sigset sys_signal
#define sys_sigrelse sys_sighold
#define sys_sigignore sys_sighold
#define sys_sigpause sys_sighold
/* printargs does the right thing */
#define sys_sync printargs

View File

@ -301,6 +301,27 @@ extern int sys_aclipc();
#ifdef HAVE_SYS_DOOR_H
extern int sys_door();
#endif
#if UNIXWARE >= 2
extern int sys_truncate();
extern int sys_ftruncate();
extern int sys_getksym ();
#endif
#if UNIXWARE >= 7
extern int sys_lseek64 ();
extern int sys_xsocket ();
extern int sys_xsocketpair ();
extern int sys_xbind ();
extern int sys_xconnect ();
extern int sys_xlisten ();
extern int sys_xaccept ();
extern int sys_xrecvmsg ();
extern int sys_xsendmsg ();
extern int sys_xgetsockaddr ();
extern int sys_xsetsockaddr ();
extern int sys_xgetsockopt ();
extern int sys_xsetsockopt ();
extern int sys_xshutdown ();
#endif
#endif /* !MIPS */
#ifdef MIPS

View File

@ -409,10 +409,10 @@
{ -1, 0, printargs, "unblock" }, /* 186 */
{ -1, 0, printargs, "cancelblock" }, /* 187 */
{ -1, 0, printargs, "SYS_188" }, /* 188 */
{ -1, 0, sys_pread, "pread" }, /* 189 */
{ -1, 0, sys_pwrite, "pwrite" }, /* 190 */
{ -1, 0, printargs, "truncate" }, /* 191 */
{ -1, 0, printargs, "ftruncate" }, /* 192 */
{ -1, TF, sys_pread, "pread" }, /* 189 */
{ -1, TF, sys_pwrite, "pwrite" }, /* 190 */
{ -1, TF, sys_truncate, "truncate" }, /* 191 */
{ -1, TF, sys_ftruncate, "ftruncate" }, /* 192 */
{ -1, 0, printargs, "lwpkill" }, /* 193 */
{ -1, 0, printargs, "sigwait" }, /* 194 */
{ -1, 0, printargs, "fork1" }, /* 195 */
@ -422,7 +422,7 @@
{ -1, 0, printargs, "modpath" }, /* 199 */
{ -1, 0, printargs, "modstat" }, /* 200 */
{ -1, 0, printargs, "modadm" }, /* 201 */
{ -1, 0, printargs, "getksym" }, /* 202 */
{ -1, 0, sys_getksym, "getksym" }, /* 202 */
{ -1, 0, printargs, "lwpsuspend" }, /* 203 */
{ -1, 0, printargs, "lwpcontinue" }, /* 204 */
{ -1, 0, printargs, "priocntllst" }, /* 205 */
@ -519,6 +519,41 @@
{ -1, 0, printargs, "SYS_213" }, /* 213 */
{ -1, 0, printargs, "SYS_214" }, /* 214 */
{ -1, 0, printargs, "SYS_215" }, /* 215 */
#if UNIXWARE >= 7
{ -1, 0, printargs, "fstatvfs64" }, /* 216 */
{ -1, 0, printargs, "statvfs64" }, /* 217 */
{ -1, 0, printargs, "ftruncate64" }, /* 218 */
{ -1, 0, printargs, "truncate64" }, /* 219 */
{ -1, 0, printargs, "getrlimit64" }, /* 220 */
{ -1, 0, printargs, "setrlimit64" }, /* 221 */
{ -1, TF, sys_lseek64, "lseek64" }, /* 222 */
{ -1, 0, printargs, "mmap64" }, /* 223 */
{ -1, 0, printargs, "pread64" }, /* 224 */
{ -1, 0, printargs, "pwrite64" }, /* 225 */
{ -1, 0, printargs, "creat64" }, /* 226 */
{ -1, 0, printargs, "dshmsys" }, /* 227 */
{ -1, 0, printargs, "invlpg" }, /* 228 */
{ -1, 0, printargs, "rfork1" }, /* 229 */
{ -1, 0, printargs, "rforkall" }, /* 230 */
{ -1, 0, printargs, "rexecve" }, /* 231 */
{ -1, 0, printargs, "migrate" }, /* 232 */
{ -1, 0, printargs, "kill3" }, /* 233 */
{ -1, 0, printargs, "ssisys" }, /* 234 */
{ -1, TN, sys_xaccept, "xaccept" }, /* 235 */
{ -1, TN, sys_xbind, "xbind" }, /* 236 */
{ -1, TN, sys_xbind, "xbindresport" }, /* 237 */
{ -1, TN, sys_xconnect, "xconnect" }, /* 238 */
{ -1, TN, sys_xgetsockaddr, "xgetsockaddr" }, /* 239 */
{ -1, TN, sys_xgetsockopt, "xgetsockopt" }, /* 240 */
{ -1, TN, sys_xlisten, "xlisten" }, /* 241 */
{ -1, TN, sys_xrecvmsg, "xrecvmsg" }, /* 242 */
{ -1, TN, sys_xsendmsg, "xsendmsg" }, /* 243 */
{ -1, TN, sys_xsetsockaddr, "xsetsockaddr" }, /* 244 */
{ -1, TN, sys_xsetsockopt, "xsetsockopt" }, /* 245 */
{ -1, TN, sys_xshutdown, "xshutdown" }, /* 246 */
{ -1, TN, sys_xsocket, "xsocket" }, /* 247 */
{ -1, TN, sys_xsocketpair, "xsocketpair" }, /* 248 */
#else
{ -1, 0, printargs, "SYS_216" }, /* 216 */
{ -1, 0, printargs, "SYS_217" }, /* 217 */
{ -1, 0, printargs, "SYS_218" }, /* 218 */
@ -552,6 +587,7 @@
{ -1, 0, printargs, "SYS_246" }, /* 246 */
{ -1, 0, printargs, "SYS_247" }, /* 247 */
{ -1, 0, printargs, "SYS_248" }, /* 248 */
#endif
{ -1, 0, printargs, "SYS_249" }, /* 249 */
{ -1, 0, printargs, "SYS_250" }, /* 250 */
#endif /* !MIPS */

View File

@ -464,11 +464,10 @@ int nsubcalls;
enum subcall_style style;
{
int i, addr, mask, arg;
if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= nsubcalls)
return;
switch (style) {
case shift_style:
if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= nsubcalls)
return;
tcp->scno = subcall + tcp->u_arg[0];
if (sysent[tcp->scno].nargs != -1)
tcp->u_nargs = sysent[tcp->scno].nargs;
@ -478,6 +477,8 @@ enum subcall_style style;
tcp->u_arg[i] = tcp->u_arg[i + 1];
break;
case deref_style:
if (tcp->u_arg[0] < 0 || tcp->u_arg[0] >= nsubcalls)
return;
tcp->scno = subcall + tcp->u_arg[0];
addr = tcp->u_arg[1];
for (i = 0; i < sysent[tcp->scno].nargs; i++) {
@ -490,9 +491,11 @@ enum subcall_style style;
break;
case mask_style:
mask = (tcp->u_arg[0] >> 8) & 0xff;
tcp->u_arg[0] &= 0xff;
for (i = 0; mask; i++)
mask >>= 1;
if (i >= nsubcalls)
return;
tcp->u_arg[0] &= 0xff;
tcp->scno = subcall + i;
if (sysent[tcp->scno].nargs != -1)
tcp->u_nargs = sysent[tcp->scno].nargs;
@ -500,7 +503,10 @@ enum subcall_style style;
case door_style:
/*
* Oh, yuck. The call code is the *sixth* argument.
* (don't you mean the *last* argument? - JH)
*/
if (tcp->u_arg[5] < 0 || tcp->u_arg[5] >= nsubcalls)
return;
tcp->scno = subcall + tcp->u_arg[5];
if (sysent[tcp->scno].nargs != -1)
tcp->u_nargs = sysent[tcp->scno].nargs;
@ -1029,6 +1035,11 @@ struct tcb *tcp;
}
else {
tcp->u_rval = tcp->status.PR_REG[EAX];
#ifdef HAVE_LONG_LONG
tcp->u_lrval =
((unsigned long long) tcp->status.PR_REG[EDX] << 32) +
tcp->status.PR_REG[EAX];
#endif
u_error = 0;
}
#endif /* I386 */
@ -1337,6 +1348,12 @@ struct tcb *tcp;
case RVAL_DECIMAL:
tprintf("= %ld", tcp->u_rval);
break;
#ifdef HAVE_LONG_LONG
case RVAL_LDECIMAL:
tprintf ("= %lld", tcp->u_lrval);
break;
/* LHEX, LOCTAL, LUDECIMAL... */
#endif
default:
fprintf(stderr,
"invalid rval format\n");

View File

@ -1903,3 +1903,48 @@ struct tcb *tcp;
}
#endif
#if UNIXWARE >= 2
#include <sys/ksym.h>
#include <sys/elf.h>
static struct xlat ksym_flags[] = {
{ STT_NOTYPE, "STT_NOTYPE" },
{ STT_FUNC, "STT_FUNC" },
{ STT_OBJECT, "STT_OBJECT" },
{ 0, NULL },
};
int
sys_getksym(tcp)
struct tcb *tcp;
{
if (entering (tcp)) {
printstr(tcp, tcp->u_arg[0], -1);
tprintf(", ");
}
else {
if (syserror(tcp)) {
tprintf("%#lx, %#lx",
tcp->u_arg[1], tcp->u_arg[2]);
}
else {
int val;
printnum (tcp, tcp->u_arg[1], "%#lx");
tprintf(", ");
if (umove(tcp, tcp->u_arg[2], &val) < 0) {
tprintf("%#lx", tcp->u_arg[2]);
}
else {
tprintf("[");
printxval (ksym_flags, val, "STT_???");
tprintf("]");
}
}
}
return 0;
}
#endif

View File

@ -10,7 +10,7 @@ int
main()
{
char stack[4096];
if (clone(child, stack+4000, CLONE_VM|CLONE_FS|CLONE_FILES, NULL) == 0)
if (clone(child, stack+4000, CLONE_VM|CLONE_FS|CLONE_FILES, NULL) != 0)
write(1, "original\n", 9);
exit(0);
}