Re: [PATCH 57/63] perf beauty mmap: Print PROT_READ before PROT_EXEC to match strace output

From: Namhyung Kim
Date: Wed Dec 19 2018 - 04:15:12 EST


On Tue, Dec 18, 2018 at 07:07:27PM -0300, Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
>
> Helps with comparing 'strace' and 'perf trace' output, for mutual
> regression testing.
>
> Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
> Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
> Cc: Luis ClÃudio GonÃalves <lclaudio@xxxxxxxxxx>
> Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
> Cc: Wang Nan <wangnan0@xxxxxxxxxx>
> Link: https://lkml.kernel.org/n/tip-va0qe95xbhep5hy52aq5qe0v@xxxxxxxxxxxxxx
> Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
> ---
> tools/perf/trace/beauty/mmap.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/perf/trace/beauty/mmap.c b/tools/perf/trace/beauty/mmap.c
> index 138f36a47fb1..eb31089790e3 100644
> --- a/tools/perf/trace/beauty/mmap.c
> +++ b/tools/perf/trace/beauty/mmap.c
> @@ -17,8 +17,8 @@ static size_t syscall_arg__scnprintf_mmap_prot(char *bf, size_t size,
> prot &= ~PROT_##n; \
> }
>
> - P_MMAP_PROT(EXEC);
> P_MMAP_PROT(READ);
> + P_MMAP_PROT(EXEC);
> P_MMAP_PROT(WRITE);

EXEC should be printed after WRITE..

$ cat mmap.c
#include <sys/mman.h>

int main(void)
{
mmap(0, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
return 0;
}

$ strace -e mmap ./a.out
...
mmap(NULL, 4096, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f4c643ec000
+++ exited with 0 +++

Thanks,
Namhyung



> P_MMAP_PROT(SEM);
> P_MMAP_PROT(GROWSDOWN);
> --
> 2.19.2
>