[PATCH 1/4] Introduce is_restart_error(), implement nanosleep decoder

Dmitry V. Levin ldv at altlinux.org
Wed Jul 23 21:57:41 UTC 2008


2008-04-19  Dmitry V. Levin <ldv at altlinux.org>

	* syscall.c (is_restart_error): New function.
	* defs.h (is_restart_error): Declare it.

	* linux/dummy.h (sys_nanosleep): Uncouple from sys_adjtime.
	* time.c (sys_nanosleep): New function, based on is_restart_error.
---
 strace/defs.h        |    1 +
 strace/linux/dummy.h |    1 -
 strace/syscall.c     |   19 +++++++++++++++++++
 strace/time.c        |   15 +++++++++++++++
 4 files changed, 35 insertions(+), 1 deletions(-)

--- a/strace/defs.h
+++ b/strace/defs.h
@@ -503,6 +503,7 @@ extern void tabto P((int));
 extern void call_summary P((FILE *));
 extern void tprint_iov P((struct tcb *, unsigned long, unsigned long));
 extern void tprint_open_modes P((struct tcb *, mode_t));
+extern int is_restart_error P((struct tcb *));
 
 #ifdef LINUX
 extern int internal_clone P((struct tcb *));
--- a/strace/linux/dummy.h
+++ b/strace/linux/dummy.h
@@ -58,7 +58,6 @@
 #define	sys_fchdir		sys_close
 #define	sys_setfsuid		sys_setuid
 #define	sys_setfsgid		sys_setgid
-#define sys_nanosleep		sys_adjtime
 #define	sys_acct		sys_chdir
 #define sys_fdatasync		sys_close
 #define sys_mlock		sys_munmap
--- a/strace/syscall.c
+++ b/strace/syscall.c
@@ -2640,3 +2640,22 @@ struct tcb *tcp;
 	return 0;
 }
 #endif /* SUNOS4 */
+
+int
+is_restart_error(struct tcb *tcp)
+{
+#ifdef LINUX
+	if (!syserror(tcp))
+		return 0;
+	switch (tcp->u_error) {
+		case ERESTARTSYS:
+		case ERESTARTNOINTR:
+		case ERESTARTNOHAND:
+		case ERESTART_RESTARTBLOCK:
+			return 1;
+		default:
+			break;
+	}
+#endif /* LINUX */
+	return 0;
+}
--- a/strace/time.c
+++ b/strace/time.c
@@ -329,6 +329,21 @@ struct tcb *tcp;
 	return 0;
 }
 
+int
+sys_nanosleep(struct tcb *tcp)
+{
+	if (entering(tcp)) {
+		print_timespec(tcp, tcp->u_arg[0]);
+		tprintf(", ");
+	} else {
+		if (!tcp->u_arg[1] || is_restart_error(tcp))
+			print_timespec(tcp, tcp->u_arg[1]);
+		else
+			tprintf("%#lx", tcp->u_arg[1]);
+	}
+	return 0;
+}
+
 static const struct xlat which[] = {
 	{ ITIMER_REAL,	"ITIMER_REAL"	},
 	{ ITIMER_VIRTUAL,"ITIMER_VIRTUAL"},

-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20080724/accc68b6/attachment.bin>


More information about the Strace-devel mailing list