[PATCH/v2] Fix printing clone flags

Wang Chao wang.chao at cn.fujitsu.com
Thu Sep 2 07:08:59 UTC 2010


If we trace clone() syscall with only exit signal as clone
flags, strace will print an unnecessary OR operator.

* process.c (sys_clone): Fix this.

Signed-off-by: Wang Chao <wang.chao at cn.fujitsu.com>
---
 process.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/process.c b/process.c
index f7af196..8af960a 100644
--- a/process.c
+++ b/process.c
@@ -618,6 +618,7 @@ sys_clone(tcp)
 struct tcb *tcp;
 {
 	if (exiting(tcp)) {
+		const char *sep = "|";
 		unsigned long flags = tcp->u_arg[ARG_FLAGS];
 		tprintf("child_stack=%#lx, ", tcp->u_arg[ARG_STACK]);
 # ifdef ARG_STACKSIZE
@@ -626,9 +627,10 @@ struct tcb *tcp;
 				tcp->u_arg[ARG_STACKSIZE]);
 # endif
 		tprintf("flags=");
-		printflags(clone_flags, flags &~ CSIGNAL, NULL);
+		if (!printflags(clone_flags, flags &~ CSIGNAL, NULL))
+			sep = "";
 		if ((flags & CSIGNAL) != 0)
-			tprintf("|%s", signame(flags & CSIGNAL));
+			tprintf("%s%s", sep, signame(flags & CSIGNAL));
 		if ((flags & (CLONE_PARENT_SETTID|CLONE_CHILD_SETTID
 			      |CLONE_CHILD_CLEARTID|CLONE_SETTLS)) == 0)
 			return 0;
-- 
1.6.5.2





More information about the Strace-devel mailing list