From: Shankara Pailoor Date: Sun, 13 Jan 2019 19:37:49 +0000 (-0800) Subject: move_pages: honor xlat styles X-Git-Tag: v5.0~52 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1f66239842d756efc21876fb0c245bc99dde85bf;p=strace move_pages: honor xlat styles * numa.c (print_status): Add xlat_style support for status argument. * tests/move_pages-Xabbrev.c: New file. * tests/move_pages-Xraw.c: Likewise. * tests/move_pages-Xverbose.c: Likewise. * tests/move_pages.c: Handle XLAT_RAW, XLAT_ABBREV, and XLAT_VERBOSE macros. * tests/gen_tests.in (move_pages-Xabbrev, move_pages-Xraw, move_pages-Xverbose): New tests. * tests/pure_executables.list: Add move_pages-Xabbrev, move_pages-Xraw, and move_pages-Xverbose. * tests/.gitignore: Likewise. --- diff --git a/numa.c b/numa.c index 8eba75f4..2b7ac3d5 100644 --- a/numa.c +++ b/numa.c @@ -121,12 +121,22 @@ static bool print_status(struct tcb *tcp, void *elem_buf, size_t elem_size, void *data) { const int status = *(int *) elem_buf; + bool is_errno = (status < 0) && ((unsigned) -status < nerrnos); - if (status < 0 && (unsigned) -status < nerrnos) - tprintf("-%s", errnoent[-status]); - else + if (!is_errno || xlat_verbose(xlat_verbosity) != XLAT_STYLE_ABBREV) tprintf("%d", status); + if (!is_errno || xlat_verbose(xlat_verbosity) == XLAT_STYLE_RAW) + return true; + + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) + tprints(" /* "); + + tprintf("-%s", errnoent[-status]); + + if (xlat_verbose(xlat_verbosity) == XLAT_STYLE_VERBOSE) + tprints(" */"); + return true; } diff --git a/tests/.gitignore b/tests/.gitignore index 5fd5c0a9..aecdf432 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -258,6 +258,9 @@ mount-Xabbrev mount-Xraw mount-Xverbose move_pages +move_pages-Xabbrev +move_pages-Xraw +move_pages-Xverbose mq mq_sendrecv mq_sendrecv-read diff --git a/tests/gen_tests.in b/tests/gen_tests.in index b9886565..3b35a67b 100644 --- a/tests/gen_tests.in +++ b/tests/gen_tests.in @@ -218,6 +218,9 @@ mount-Xabbrev -a33 -e trace=mount -Xabbrev mount-Xraw -a33 -e trace=mount -Xraw mount-Xverbose -a33 -e trace=mount -Xverbose move_pages -s3 +move_pages-Xabbrev -s3 -e trace=move_pages -Xabbrev +move_pages-Xraw -s3 -a36 -e trace=move_pages -Xraw +move_pages-Xverbose -s3 -e trace=move_pages -Xverbose mq -a32 -e trace=mq_getsetattr,mq_open,mq_unlink mq_sendrecv -a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink mq_sendrecv-read -eread=0 -a14 -e trace=mq_open,mq_notify,mq_timedsend,mq_timedreceive,mq_unlink diff --git a/tests/move_pages-Xabbrev.c b/tests/move_pages-Xabbrev.c new file mode 100644 index 00000000..d0949884 --- /dev/null +++ b/tests/move_pages-Xabbrev.c @@ -0,0 +1 @@ +#include "move_pages.c" diff --git a/tests/move_pages-Xraw.c b/tests/move_pages-Xraw.c new file mode 100644 index 00000000..e9a6cc08 --- /dev/null +++ b/tests/move_pages-Xraw.c @@ -0,0 +1,2 @@ +#define XLAT_RAW 1 +#include "move_pages.c" diff --git a/tests/move_pages-Xverbose.c b/tests/move_pages-Xverbose.c new file mode 100644 index 00000000..71fcdee6 --- /dev/null +++ b/tests/move_pages-Xverbose.c @@ -0,0 +1,2 @@ +#define XLAT_VERBOSE 1 +#include "move_pages.c" diff --git a/tests/move_pages.c b/tests/move_pages.c index 90d05535..2f88f792 100644 --- a/tests/move_pages.c +++ b/tests/move_pages.c @@ -106,8 +106,16 @@ print_status_array(const int *const status, const unsigned long count) if (status[i] >= 0) { printf("%d", status[i]); } else { +#if !XLAT_RAW errno = -status[i]; +#endif +#if XLAT_RAW + printf("%d", status[i]); +#elif XLAT_VERBOSE + printf("%d /* -%s */", status[i], errno2name()); +#else printf("-%s", errno2name()); +#endif } } printf("]"); @@ -133,7 +141,13 @@ print_stat_pages(const unsigned long pid, const unsigned long count, } else { print_status_array(status, count); } +#if XLAT_RAW + printf(", 0x2) = %s\n", errstr); +#elif XLAT_VERBOSE + printf(", 0x2 /* MPOL_MF_MOVE */) = %s\n", errstr); +#else /* XLAT_ABBREV */ printf(", MPOL_MF_MOVE) = %s\n", errstr); +#endif } static void @@ -159,7 +173,13 @@ print_move_pages(const unsigned long pid, printf("%p", status); else printf("[]"); +#if XLAT_RAW + printf(", 0x4) = %s\n", errstr); +#elif XLAT_VERBOSE + printf(", 0x4 /* MPOL_MF_MOVE_ALL */) = %s\n", errstr); +#else /* XLAT_ABBREV */ printf(", MPOL_MF_MOVE_ALL) = %s\n", errstr); +#endif } int diff --git a/tests/pure_executables.list b/tests/pure_executables.list index 616ee9ed..af99bda6 100755 --- a/tests/pure_executables.list +++ b/tests/pure_executables.list @@ -217,6 +217,9 @@ mount-Xabbrev mount-Xraw mount-Xverbose move_pages +move_pages-Xabbrev +move_pages-Xraw +move_pages-Xverbose mq mq_sendrecv mq_sendrecv-read