aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-trace.c
diff options
context:
space:
mode:
authorChang Hyun Park <heartinpiece@gmail.com>2014-09-26 08:54:01 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2014-09-29 14:25:36 -0400
commit2c82c3ad56921c47f28af9eb8ed96b6d99b47623 (patch)
tree3e99e9e83e01476bb2c7caa4a50222999a99e2fc /tools/perf/builtin-trace.c
parent46441bdc76fee08e297ebcf17e4ca91013b1ee9e (diff)
perf trace: Fix mmap return address truncation to 32-bit
Using 'perf trace' for mmap is truncating return values by stripping the top 32 bits, actually printing only the lower 32 bits. This was because the ret value was of an 'int' type and not a 'long' type. The Problem: 991258501.244 ( 0.004 ms): mmap(len: 40001536, prot: READ|WRITE, flags: PRIVATE|ANONYMOUS, fd: -1) = 0x56691000 991258501.257 ( 0.000 ms): minfault [_int_malloc+0x1038] => //anon@0x7fa056691008 //(d.) The first line shows an mmap, which succeeds and returns 0x56691000. However the next line shows a memory access to that virtual memory area, specifically to 0x7fa056691008. The upper 32 bit is lost due to the problem mentioned above, and thus mmap's return value didn't have the upper 0x7fa0. Tested on 3.17-rc5 from the linus's tree, and the HEAD of tip/master Signed-off-by: Chang Hyun Park <heartinpiece@gmail.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Ingo Molnar <mingo@redhat.com> Cc: Thomas Gleixner <tglx@linutronix.de> Link: http://lkml.kernel.org/r/1411736041-8017-1-git-send-email-heartinpiece@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-trace.c')
-rw-r--r--tools/perf/builtin-trace.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c
index c70e69ea1c5d..09bcf2393910 100644
--- a/tools/perf/builtin-trace.c
+++ b/tools/perf/builtin-trace.c
@@ -1695,7 +1695,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
1695 union perf_event *event __maybe_unused, 1695 union perf_event *event __maybe_unused,
1696 struct perf_sample *sample) 1696 struct perf_sample *sample)
1697{ 1697{
1698 int ret; 1698 long ret;
1699 u64 duration = 0; 1699 u64 duration = 0;
1700 struct thread *thread; 1700 struct thread *thread;
1701 int id = perf_evsel__sc_tp_uint(evsel, id, sample); 1701 int id = perf_evsel__sc_tp_uint(evsel, id, sample);
@@ -1748,7 +1748,7 @@ static int trace__sys_exit(struct trace *trace, struct perf_evsel *evsel,
1748 1748
1749 if (sc->fmt == NULL) { 1749 if (sc->fmt == NULL) {
1750signed_print: 1750signed_print:
1751 fprintf(trace->output, ") = %d", ret); 1751 fprintf(trace->output, ") = %ld", ret);
1752 } else if (ret < 0 && sc->fmt->errmsg) { 1752 } else if (ret < 0 && sc->fmt->errmsg) {
1753 char bf[STRERR_BUFSIZE]; 1753 char bf[STRERR_BUFSIZE];
1754 const char *emsg = strerror_r(-ret, bf, sizeof(bf)), 1754 const char *emsg = strerror_r(-ret, bf, sizeof(bf)),
@@ -1758,7 +1758,7 @@ signed_print:
1758 } else if (ret == 0 && sc->fmt->timeout) 1758 } else if (ret == 0 && sc->fmt->timeout)
1759 fprintf(trace->output, ") = 0 Timeout"); 1759 fprintf(trace->output, ") = 0 Timeout");
1760 else if (sc->fmt->hexret) 1760 else if (sc->fmt->hexret)
1761 fprintf(trace->output, ") = %#x", ret); 1761 fprintf(trace->output, ") = %#lx", ret);
1762 else 1762 else
1763 goto signed_print; 1763 goto signed_print;
1764 1764