semop()/semtimedop() sembuf argument printing in strace

Jakub Bogusz qboosh at pld-linux.org
Wed Sep 30 15:59:07 UTC 2009


Hello,

the attached patch adds pretty printing of sembuf argument and flags to
semop() and semtimedop() syscalls.


Regards,

-- 
Jakub Bogusz    http://qboosh.pl/
-------------- next part --------------
--- strace-4.5.18/ipc.c.orig	2007-01-15 21:25:52.000000000 +0100
+++ strace-4.5.18/ipc.c	2009-09-30 17:48:38.080610937 +0200
@@ -152,6 +152,12 @@
 	{ 0,		NULL		},
 };
 
+static const struct xlat semop_flags[] = {
+	{ SEM_UNDO,	"SEM_UNDO"	},
+	{ IPC_NOWAIT,	"IPC_NOWAIT"	},
+	{ 0,		NULL		},
+};
+
 int sys_msgget(tcp)
 struct tcb *tcp;
 {
@@ -273,14 +279,34 @@
 int sys_semop(tcp)
 struct tcb *tcp;
 {
+	int i;
+
 	if (entering(tcp)) {
 		tprintf("%lu", tcp->u_arg[0]);
 		if (indirect_ipccall(tcp)) {
-			tprintf(", %#lx", tcp->u_arg[3]);
-			tprintf(", %lu", tcp->u_arg[1]);
+			tprintf(", %#lx {", tcp->u_arg[3]);
+			for(i = 0; i < tcp->u_arg[1]; i++) {
+				struct sembuf sb;
+				umove(tcp, tcp->u_arg[3]+i*sizeof(struct sembuf), &sb);
+				if(i != 0)
+					tprintf(", ");
+				tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
+				printflags(semop_flags, sb.sem_flg, "SEM_???");
+				tprintf("}");
+			}
+			tprintf("}, %lu", tcp->u_arg[1]);
 		} else {
-			tprintf(", %#lx", tcp->u_arg[1]);
-			tprintf(", %lu", tcp->u_arg[2]);
+			tprintf(", %#lx {", tcp->u_arg[1]);
+			for(i = 0; i < tcp->u_arg[2]; i++) {
+				struct sembuf sb;
+				umove(tcp, tcp->u_arg[1]+i*sizeof(struct sembuf), &sb);
+				if(i != 0)
+					tprintf(", ");
+				tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
+				printflags(semop_flags, sb.sem_flg, "SEM_???");
+				tprintf("}");
+			}
+			tprintf("}, %lu", tcp->u_arg[2]);
 		}
 	}
 	return 0;
@@ -290,15 +316,35 @@
 int sys_semtimedop(tcp)
 struct tcb *tcp;
 {
+	int i;
+
 	if (entering(tcp)) {
 		tprintf("%lu", tcp->u_arg[0]);
 		if (indirect_ipccall(tcp)) {
-			tprintf(", %#lx", tcp->u_arg[3]);
-			tprintf(", %lu, ", tcp->u_arg[1]);
+			tprintf(", %#lx {", tcp->u_arg[3]);
+			for(i = 0; i < tcp->u_arg[1]; i++) {
+				struct sembuf sb;
+				umove(tcp, tcp->u_arg[3]+i*sizeof(struct sembuf), &sb);
+				if(i != 0)
+					tprintf(", ");
+				tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
+				printflags(semop_flags, sb.sem_flg, "SEM_???");
+				tprintf("}");
+			}
+			tprintf("}, %lu, ", tcp->u_arg[1]);
 			printtv(tcp, tcp->u_arg[5]);
 		} else {
-			tprintf(", %#lx", tcp->u_arg[1]);
-			tprintf(", %lu, ", tcp->u_arg[2]);
+			tprintf(", %#lx {", tcp->u_arg[1]);
+			for(i = 0; i < tcp->u_arg[2]; i++) {
+				struct sembuf sb;
+				umove(tcp, tcp->u_arg[1]+i*sizeof(struct sembuf), &sb);
+				if(i != 0)
+					tprintf(", ");
+				tprintf("{%u, %d, ", sb.sem_num, sb.sem_op);
+				printflags(semop_flags, sb.sem_flg, "SEM_???");
+				tprintf("}");
+			}
+			tprintf("}, %lu, ", tcp->u_arg[2]);
 			printtv(tcp, tcp->u_arg[3]);
 		}
 	}


More information about the Strace-devel mailing list