aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/tests/code-reading.c
diff options
context:
space:
mode:
authorJan Stancek <jstancek@redhat.com>2015-09-02 04:19:16 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2015-09-14 11:50:12 -0400
commitedfdb7eab0fe5f98f2951598dc679b71bdb3e16b (patch)
tree507d05df90b975d8f5de8e0f692d1deb610bc7a5 /tools/perf/tests/code-reading.c
parent06f679c18fcf414cc8462938466f8361315f18cb (diff)
perf tests: Stop reading if objdump output crossed sections
objdump output can span across multiple sections: Disassembly of section .text: 0000000000000008 <crc32c+0x8>: 8: 48 89 e5 mov %rsp,%rbp b: 53 push %rbx c: 8b 01 mov (%rcx),%eax <snip> 6b: 90 nop Disassembly of section .init.text: 0000000000000008 <init_module+0x8>: 8: 00 00 add %al,(%rax) a: 00 00 add %al,(%rax) c: 48 89 e5 Stop further reading if an address starts going backwards, assuming we crossed sections. Signed-off-by: Jan Stancek <jstancek@redhat.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <a.p.zijlstra@chello.nl> Link: http://lkml.kernel.org/r/9d1ea95e5f9884fdff1be6f761a2feabef37412c.1441181335.git.jstancek@redhat.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/tests/code-reading.c')
-rw-r--r--tools/perf/tests/code-reading.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index c409409d7765..8145c67fb43a 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -79,7 +79,7 @@ static int read_objdump_output(FILE *f, void *buf, size_t *len, u64 start_addr)
79 size_t line_len, off_last = 0; 79 size_t line_len, off_last = 0;
80 ssize_t ret; 80 ssize_t ret;
81 int err = 0; 81 int err = 0;
82 u64 addr; 82 u64 addr, last_addr = start_addr;
83 83
84 while (off_last < *len) { 84 while (off_last < *len) {
85 size_t off, read_bytes, written_bytes; 85 size_t off, read_bytes, written_bytes;
@@ -101,6 +101,11 @@ static int read_objdump_output(FILE *f, void *buf, size_t *len, u64 start_addr)
101 101
102 if (sscanf(line, "%"PRIx64, &addr) != 1) 102 if (sscanf(line, "%"PRIx64, &addr) != 1)
103 continue; 103 continue;
104 if (addr < last_addr) {
105 pr_debug("addr going backwards, read beyond section?\n");
106 break;
107 }
108 last_addr = addr;
104 109
105 /* copy it from temporary buffer to 'buf' according 110 /* copy it from temporary buffer to 'buf' according
106 * to address on current objdump line */ 111 * to address on current objdump line */