In general, the random bytes is not number or letter, print
as hex array is clear, use 0x%02x format print it, easy to
konw each element is one byte, so 0 will print 0x00.

* getrandom.c:
* tests/getrandom.c: Update print buffer.
* tests/getrandom.test: Update.
---
 getrandom.c          | 16 ++++++++++++----
 tests/getrandom.c    |  6 +++---
 tests/getrandom.test |  2 +-
 3 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/getrandom.c b/getrandom.c
index 0a353ad..695133a 100644
--- a/getrandom.c
+++ b/getrandom.c
@@ -1,13 +1,21 @@
 #include "defs.h"
 #include "xlat/getrandom_flags.h"
 
+static bool
+print_buf(struct tcb *tcp, void *elem_buf, size_t elem_size, void *opaque_data)
+{
+       tprintf("0x%02x", *(unsigned char *) elem_buf);
+
+       return true;
+}
+
 SYS_FUNC(getrandom)
 {
        if (exiting(tcp)) {
-               if (syserror(tcp))
-                       printaddr(tcp->u_arg[0]);
-               else
-                       printstrn(tcp, tcp->u_arg[0], tcp->u_rval);
+               char buf;
+
+               print_array(tcp, tcp->u_arg[0], tcp->u_arg[1], &buf, 
sizeof(buf),
+                               umoven_or_printaddr, print_buf, 0);
                tprintf(", %" PRI_klu ", ", tcp->u_arg[1]);
                printflags(getrandom_flags, tcp->u_arg[2], "GRND_???");
        }
diff --git a/tests/getrandom.c b/tests/getrandom.c
index de1a087..bfdadf4 100644
--- a/tests/getrandom.c
+++ b/tests/getrandom.c
@@ -40,13 +40,13 @@ main(void)
 
        if (syscall(__NR_getrandom, buf, sizeof(buf) - 1, 0) != sizeof(buf) - 1)
                perror_msg_and_skip("getrandom");
-       printf("getrandom(\"\\x%02x\\x%02x\\x%02x\", 3, 0) = 3\n",
+       printf("getrandom([0x%02x, 0x%02x, 0x%02x], 3, 0) = 3\n",
               (int) buf[0], (int) buf[1], (int) buf[2]);
 
        if (syscall(__NR_getrandom, buf, sizeof(buf), 1) != sizeof(buf))
                perror_msg_and_skip("getrandom");
-       printf("getrandom(\"\\x%02x\\x%02x\\x%02x\"..., 4, GRND_NONBLOCK) = 
4\n",
-              (int) buf[0], (int) buf[1], (int) buf[2]);
+       printf("getrandom([0x%02x, 0x%02x, 0x%02x, 0x%02x], 4, GRND_NONBLOCK) = 
4\n",
+              (int) buf[0], (int) buf[1], (int) buf[2], (int) buf[3]);
 
        if (syscall(__NR_getrandom, buf, sizeof(buf), 0x3003) != -1)
                perror_msg_and_skip("getrandom");
diff --git a/tests/getrandom.test b/tests/getrandom.test
index e06367c..f22d2d8 100755
--- a/tests/getrandom.test
+++ b/tests/getrandom.test
@@ -3,4 +3,4 @@
 # Check getrandom syscall decoding.
 
 . "${srcdir=.}/init.sh"
-run_strace_match_diff -a32 -xx -s3
+run_strace_match_diff -a35
-- 
2.7.4


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel

Reply via email to