[PATCH] Decode dynamic posix clocks.

Stefan Sørensen stefan.sorensen at spectralink.com
Fri Jan 31 11:01:03 UTC 2014


* time.c (printclockname): New function that decodes posix clock
names, including dynamic fd encoded clocks. Replace clock name
printing with call to this.

Signed-off-by: Stefan Sørensen <stefan.sorensen at spectralink.com>
---
 time.c | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/time.c b/time.c
index 78f9b78..eb66d27 100644
--- a/time.c
+++ b/time.c
@@ -668,11 +668,23 @@ static const struct xlat clocknames[] = {
 	{ 0,				NULL }
 };
 
+
+static void
+printclockname(int clockid)
+{
+#ifdef CLOCKID_TO_FD
+	if(clockid < 0)
+		tprintf("CLOCKFD(%d)", CLOCKID_TO_FD(clockid));
+	else
+#endif
+		printxval(clocknames, clockid, "CLOCK_???");
+}
+
 int
 sys_clock_settime(struct tcb *tcp)
 {
 	if (entering(tcp)) {
-		printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
+		printclockname(tcp->u_arg[0]);
 		tprints(", ");
 		printtv(tcp, tcp->u_arg[1]);
 	}
@@ -683,7 +695,7 @@ int
 sys_clock_gettime(struct tcb *tcp)
 {
 	if (entering(tcp)) {
-		printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
+		printclockname(tcp->u_arg[0]);
 		tprints(", ");
 	} else {
 		if (syserror(tcp))
@@ -698,7 +710,7 @@ int
 sys_clock_nanosleep(struct tcb *tcp)
 {
 	if (entering(tcp)) {
-		printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
+		printclockname(tcp->u_arg[0]);
 		tprints(", ");
 		printflags(clockflags, tcp->u_arg[1], "TIMER_???");
 		tprints(", ");
@@ -718,7 +730,7 @@ sys_clock_adjtime(struct tcb *tcp)
 {
 	if (exiting(tcp))
 		return do_adjtimex(tcp, tcp->u_arg[1]);
-	printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
+	printclockname(tcp->u_arg[0]);
 	tprints(", ");
 	return 0;
 }
@@ -820,7 +832,7 @@ int
 sys_timer_create(struct tcb *tcp)
 {
 	if (entering(tcp)) {
-		printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
+		printclockname(tcp->u_arg[0]);
 		tprints(", ");
 		printsigevent(tcp, tcp->u_arg[1]);
 		tprints(", ");
@@ -968,7 +980,7 @@ sys_timerfd(struct tcb *tcp)
 	if (entering(tcp)) {
 		/* It does not matter that the kernel uses itimerspec.  */
 		tprintf("%ld, ", tcp->u_arg[0]);
-		printxval(clocknames, tcp->u_arg[1], "CLOCK_???");
+		printclockname(tcp->u_arg[0]);
 		tprints(", ");
 		printflags(timerfdflags, tcp->u_arg[2], "TFD_???");
 		tprints(", ");
@@ -981,7 +993,7 @@ int
 sys_timerfd_create(struct tcb *tcp)
 {
 	if (entering(tcp)) {
-		printxval(clocknames, tcp->u_arg[0], "CLOCK_???");
+		printclockname(tcp->u_arg[0]);
 		tprints(", ");
 		printflags(timerfdflags, tcp->u_arg[1], "TFD_???");
 	}
-- 
1.8.5.3





More information about the Strace-devel mailing list