[PATCH] fix strace -s N handling

Denys Vlasenko dvlasenk at redhat.com
Wed Nov 5 14:16:52 UTC 2008


Hi,

Before this patch, -s N shows N+1 chars in strings.
More annoyingly, it shows this for shorter strings:

write(1, "hi\n"..., 3) = 3

After patch:

write(1, "hi\n", 3) = 3

Patch author is Jeff Bastian jbastian at redhat.com

Patch is below. Please apply.
--
vda

--- strace-4.5.18.ORIG/util.c	2008-10-20 18:26:25.000000000 -0400
+++ strace-4.5.18/util.c	2008-10-20 18:33:01.000000000 -0400
@@ -556,14 +556,14 @@ printstr(struct tcb *tcp, long addr, int
 		}
 	}
 	else {
-		size = MIN(len, max_strlen + 1);
+		size = MIN(len, max_strlen);
 		if (umoven(tcp, addr, size, str) < 0) {
 			tprintf("%#lx", addr);
 			return;
 		}
 	}
 
-	if (string_quote(str, outstr, len, size))
+	if (string_quote(str, outstr, len, size) && (len > max_strlen))
 		strcat(outstr, "...");
 
 	tprintf("%s", outstr);






More information about the Strace-devel mailing list