Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: David Mosberger-Tang <davidm@AZStarNet.com>
Subject: more strace patches
Date: Mon, 20 May 1996 00:27:24 -0700	[thread overview]
Message-ID: <199605200727.AAA17614@koala.azstarnet.com> (raw)

Here are a few more trivial fixes.  I didn't mean to work on strace,
but I wanted to get it to work with glibc and while working on that,
fixed some other things as well.  I verified that the current sources
still build fine with the regular Linux/Alpha libc.

Oh, the patch regarding HAVE_POLL is basically wrong.  The problem is
that glibc has a poll() call, but it doesn't have any of the STREAMS
related stuff.  Seems to me it's a bad idea to use the presence of
poll() to test for the presence of STREAMS.  It would require some
configure.in hacking to fix this properly, which I didn't want to do
right now.

	--david

--
diff -urN strace-3.0.11/defs.h strace-3.0.11axp/defs.h
--- strace-3.0.11/defs.h	Fri May 17 18:20:07 1996
+++ strace-3.0.11axp/defs.h	Sun May 19 18:38:57 1996
@@ -76,7 +76,7 @@
 #undef ptrace
 #ifdef __STDC__
 #ifdef LINUX
-extern int ptrace(int, int, char *, int);
+extern long ptrace(int, int, char *, long);
 #else /* !LINUX */
 extern int ptrace(int, int, char *, int, ...);
 #endif /* !LINUX */
diff -urN strace-3.0.11/desc.c strace-3.0.11axp/desc.c
--- strace-3.0.11/desc.c	Thu May 16 21:39:44 1996
+++ strace-3.0.11axp/desc.c	Sun May 19 20:59:28 1996
@@ -264,8 +264,8 @@
 	struct timeval tv;
 	static char outstr[1024];
 	char *sep;
-	int arg;
-#ifdef LINUX
+	long arg;
+#if defined(LINUX) && !defined(ALPHA)
 	long args[5];
 	if (umoven(tcp, tcp->u_arg[0], sizeof args, (char *) args) < 0) {
 		tprintf("[...]");
@@ -285,7 +285,7 @@
 				continue;
 			}
 			if (!verbose(tcp)) {
-				tprintf(", %#x", arg);
+				tprintf(", %#lx", arg);
 				continue;
 			}
 			if (umove(tcp, arg, &fds) < 0) {
diff -urN strace-3.0.11/file.c strace-3.0.11axp/file.c
--- strace-3.0.11/file.c	Fri May 17 18:20:08 1996
+++ strace-3.0.11axp/file.c	Sun May 19 17:32:53 1996
@@ -31,7 +31,7 @@
 
 #include "defs.h"
 
-#include <sys/dirent.h>
+#include <dirent.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 
diff -urN strace-3.0.11/ioctl.c strace-3.0.11axp/ioctl.c
--- strace-3.0.11/ioctl.c	Thu May 16 19:38:18 1996
+++ strace-3.0.11axp/ioctl.c	Sun May 19 18:03:55 1996
@@ -95,6 +95,9 @@
 	case 'q':
 		return proc_ioctl(tcp, code, arg);
 #endif /* SVR4 */
+#ifdef LINUX
+# undef HAVE_POLL
+#endif
 #ifdef HAVE_POLL
 	case 'S':
 		return stream_ioctl(tcp, code, arg);
diff -urN strace-3.0.11/signal.c strace-3.0.11axp/signal.c
--- strace-3.0.11/signal.c	Fri May 17 18:20:08 1996
+++ strace-3.0.11axp/signal.c	Sun May 19 21:09:22 1996
@@ -40,9 +40,53 @@
 #endif /* SVR4 */
 
 #ifdef LINUX
-#ifdef ALPHA
-#include <asm/sigcontext.h>
-#endif /* ALPHA */
+# if __GNU_LIBRARY__ < 5
+#  ifdef ALPHA
+#   include <asm/sigcontext.h>
+#  endif /* ALPHA */
+#  ifdef I386
+struct sigcontext {
+	unsigned short gs, __gsh;
+	unsigned short fs, __fsh;
+	unsigned short es, __esh;
+	unsigned short ds, __dsh;
+	unsigned long edi;
+	unsigned long esi;
+	unsigned long ebp;
+	unsigned long esp;
+	unsigned long ebx;
+	unsigned long edx;
+	unsigned long ecx;
+	unsigned long eax;
+	unsigned long trapno;
+	unsigned long err;
+	unsigned long eip;
+	unsigned short cs, __csh;
+	unsigned long eflags;
+	unsigned long esp_at_signal;
+	unsigned short ss, __ssh;
+	unsigned long i387;
+	unsigned long oldmask;
+	unsigned long cr2;
+};
+#  endif /* I386 */
+#  ifdef M68K
+struct sigcontext
+{
+	unsigned long sc_mask;
+	unsigned long sc_usp;
+	unsigned long sc_d0;
+	unsigned long sc_d1;
+	unsigned long sc_a0;
+	unsigned long sc_a1;
+	unsigned short sc_sr;
+	unsigned long sc_pc;
+	unsigned short sc_formatvec;
+};
+#  endif /* M68K */
+# else
+#  include <sigcontext.h>
+# endif
 #endif /* LINUX */
 
 char *signalent[] = {
@@ -275,49 +319,6 @@
 
 #endif /* HAVE_SIGACTION */
 
-#ifdef LINUX
-#ifdef I386
-struct sigcontext_struct {
-	unsigned short gs, __gsh;
-	unsigned short fs, __fsh;
-	unsigned short es, __esh;
-	unsigned short ds, __dsh;
-	unsigned long edi;
-	unsigned long esi;
-	unsigned long ebp;
-	unsigned long esp;
-	unsigned long ebx;
-	unsigned long edx;
-	unsigned long ecx;
-	unsigned long eax;
-	unsigned long trapno;
-	unsigned long err;
-	unsigned long eip;
-	unsigned short cs, __csh;
-	unsigned long eflags;
-	unsigned long esp_at_signal;
-	unsigned short ss, __ssh;
-	unsigned long i387;
-	unsigned long oldmask;
-	unsigned long cr2;
-};
-#else /* !I386 */
-#ifdef M68K
-struct sigcontext
-{
-	unsigned long sc_mask;
-	unsigned long sc_usp;
-	unsigned long sc_d0;
-	unsigned long sc_d1;
-	unsigned long sc_a0;
-	unsigned long sc_a1;
-	unsigned short sc_sr;
-	unsigned long sc_pc;
-	unsigned short sc_formatvec;
-};
-#endif /* M68K */
-#endif /* !I386 */
-#endif /* LINUX */
 
 static char *
 sprintsigmask(s, mask)
@@ -705,7 +706,7 @@
 {
 #ifdef I386
 	long esp;
-	struct sigcontext_struct sc;
+	struct sigcontext sc;
 
 	if (entering(tcp)) {
 		tcp->u_arg[0] = 0;
@@ -749,7 +750,11 @@
 #else /* !M68K */
 #ifdef ALPHA
 	long fp;
-	struct sigcontext_struct sc;
+#if __GNU_LIBRARY__ < 5
+	struct sigcontext_struct sc;	/* for backwards compatibility */
+#else
+	struct sigcontext sc;
+#endif
 
 	if (entering(tcp)) {
 		tcp->u_arg[0] = 0;
@@ -917,6 +922,9 @@
 		else
 #endif /* SVR4 */
 		printxval(sigprocmaskcmds, tcp->u_arg[0], "SIG_???");
+#ifdef ALPHA
+		tprintf(", %#lx, ", tcp->u_arg[1]);
+#else /* !ALPHA */
 		tprintf(", ");
 		if (!tcp->u_arg[1])
 			tprintf("NULL, ");
@@ -926,6 +934,7 @@
 			printsigmask(sigset);
 			tprintf(", ");
 		}
+#endif /* !ALPHA */
 	}
 	else {
 		if (!tcp->u_arg[2])
diff -urN strace-3.0.11/stream.c strace-3.0.11axp/stream.c
--- strace-3.0.11/stream.c	Thu May 16 20:43:46 1996
+++ strace-3.0.11axp/stream.c	Sun May 19 18:03:09 1996
@@ -29,6 +29,11 @@
 
 #include "defs.h"
 
+#ifdef LINUX
+  /* glibc supports poll() but it doesn't mean that streams exist... */
+# undef HAVE_POLL
+#endif
+
 #ifdef HAVE_POLL
 
 #include <stropts.h>
diff -urN strace-3.0.11/term.c strace-3.0.11axp/term.c
--- strace-3.0.11/term.c	Thu May 16 19:38:20 1996
+++ strace-3.0.11axp/term.c	Sun May 19 18:06:27 1996
@@ -29,12 +29,24 @@
 
 #include "defs.h"
 
-#if !defined(LINUX) || !defined(ALPHA)
-#include <termio.h>
+#if !(defined(LINUX) && defined(ALPHA))
+# include <termio.h>
+#endif
+#ifdef LINUX
+# define __KERNEL_NEED_TERMIO
+# include <linux/termios.h>
 #endif
 #include <termios.h>
+
 #ifndef LINUX
-#include <sys/filio.h>
+# include <sys/filio.h>
+#endif
+
+#ifndef __TERMIO_VMIN
+# define __TERMIO_VMIN	VMIN
+#endif
+#ifndef __TERMIO_VTIME
+# define __TERMIO_VTIME	VTIME
 #endif
 
 static struct xlat tcxonc_options[] = {
@@ -198,7 +210,8 @@
 		tprintf("c_line=%u, ", tio.c_line);
 		if (!(tio.c_lflag & ICANON))
 			tprintf("c_cc[VMIN]=%d, c_cc[VTIME]=%d, ",
-				tio.c_cc[VMIN], tio.c_cc[VTIME]);
+				tio.c_cc[__TERMIO_VMIN],
+				tio.c_cc[__TERMIO_VTIME]);
 		tprintf("c_cc=\"");
 		for (i = 0; i < NCC; i++)
 			tprintf("\\x%02x", tio.c_cc[i]);
diff -urN strace-3.0.11/util.c strace-3.0.11axp/util.c
--- strace-3.0.11/util.c	Fri May 17 18:20:09 1996
+++ strace-3.0.11axp/util.c	Sun May 19 21:25:31 1996
@@ -491,22 +491,32 @@
 	int pid = tcp->pid;
 	int n, m;
 	union {
-		int val;
-		char x[4];
+		long val;
+		char x[sizeof(long)];
 	} u;
 
-	if (addr & 3) {
-		/* addr not a multiple of 4 */
-		n = addr - (addr & -4); /* residue */
-		addr &= -4; /* residue */
+	if (addr & (sizeof(long) - 1)) {
+		/* addr not a multiple of sizeof(long) */
+		n = addr - (addr & -sizeof(long)); /* residue */
+		addr &= -sizeof(long); /* residue */
+		errno = 0;
 		u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
-		memcpy(laddr, &u.x[n], m = MIN(4 - n, len));
-		addr += 4, laddr += m, len -= m;
+		if (errno) {
+			perror("ptrace: umoven");
+			return -1;
+		}
+		memcpy(laddr, &u.x[n], m = MIN(sizeof(long) - n, len));
+		addr += sizeof(long), laddr += m, len -= m;
 	}
 	while (len) {
+		errno = 0;
 		u.val = ptrace(PTRACE_PEEKDATA, pid, (char *) addr, 0);
-		memcpy(laddr, u.x, m = MIN(4, len));
-		addr += 4, laddr += m, len -= m;
+		if (errno) {
+			perror("ptrace: umoven");
+			return -1;
+		}
+		memcpy(laddr, u.x, m = MIN(sizeof(long), len));
+		addr += sizeof(long), laddr += m, len -= m;
 	}
 #endif
 #endif /* LINUX */
@@ -516,7 +526,7 @@
 #if 0
 	int n, m;
 	union {
-		int val;
+		long val;
 		char x[4];
 	} u;
 
@@ -660,8 +670,8 @@
 	int peek, poke;
 	int n, m;
 	union {
-		int val;
-		char x[4];
+		long val;
+		char x[sizeof(long)];
 	} u;
 
 	if (cmd == PTRACE_WRITETEXT) {
@@ -672,27 +682,32 @@
 		peek = PTRACE_PEEKDATA;
 		poke = PTRACE_POKEDATA;
 	}
-	if (addr & 3) {
-		/* addr not a multiple of 4 */
-		n = addr - (addr & -4); /* residue */
-		addr &= -4;
+	if (addr & (sizeof(long) - 1)) {
+		/* addr not a multiple of sizeof(long) */
+		n = addr - (addr & -sizeof(long)); /* residue */
+		addr &= -sizeof(long);
+		errno = 0;
 		u.val = ptrace(peek, pid, (char *) addr, 0);
-		memcpy(&u.x[n], laddr, m = MIN(4 - n, len));
+		if (errno) {
+			perror("uload: POKE");
+			return -1;
+		}
+		memcpy(&u.x[n], laddr, m = MIN(sizeof(long) - n, len));
 		if (ptrace(poke, pid, (char *)addr, u.val) < 0) {
 			perror("uload: POKE");
 			return -1;
 		}
-		addr += 4, laddr += m, len -= m;
+		addr += sizeof(long), laddr += m, len -= m;
 	}
 	while (len) {
-		if (len < 4)
+		if (len < sizeof(long))
 			u.val = ptrace(peek, pid, (char *) addr, 0);
-		memcpy(u.x, laddr, m = MIN(4, len));
+		memcpy(u.x, laddr, m = MIN(sizeof(long), len));
 		if (ptrace(poke, pid, (char *) addr, u.val) < 0) {
 			perror("uload: POKE");
 			return -1;
 		}
-		addr += 4, laddr += m, len -= m;
+		addr += sizeof(long), laddr += m, len -= m;
 	}
 #endif
 	return 0;
@@ -723,7 +738,7 @@
 long off;
 long *res;
 {
-	int val;
+	long val;
 
 #ifdef SUNOS4_KERNEL_ARCH_KLUDGE
 	{

                 reply	other threads:[~1996-05-20  7:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox