Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1217409

[PATCH v2 3/4] perf tests: stop reading if objdump output crossed sections

From Jan Stancek <jstancek@redhat.com>
Newsgroups linux.kernel
Subject [PATCH v2 3/4] perf tests: stop reading if objdump output crossed sections
Date 2015-09-02 10:30 +0200
Message-ID <q4bAB-82i-5@gated-at.bofh.it> (permalink)
References <q4bqV-7Rc-17@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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 address starts going backwards,
assuming we crossed sections.

Signed-off-by: Jan Stancek <jstancek@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
---
 tools/perf/tests/code-reading.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 375ba30e4ed0..e6bf47ff7e91 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)
 	size_t line_len, off_last = 0;
 	ssize_t ret;
 	int err = 0;
-	u64 addr;
+	u64 addr, last_addr = start_addr;
 
 	while (off_last < *len) {
 		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)
 
 		if (sscanf(line, "%"PRIx64, &addr) != 1)
 			continue;
+		if (addr < last_addr) {
+			pr_debug("addr going backwards, read beyond section?\n");
+			break;
+		}
+		last_addr = addr;
 
 		/* copy it from temporary buffer to 'buf' according
 		 * to address on current objdump line */
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH v2 1/4] perf tests: take into account address of each objdump line Jan Stancek <jstancek@redhat.com> - 2015-09-02 10:20 +0200
  [PATCH v2 3/4] perf tests: stop reading if objdump output crossed sections Jan Stancek <jstancek@redhat.com> - 2015-09-02 10:30 +0200
    Re: [PATCH v2 3/4] perf tests: stop reading if objdump output crossed  sections Adrian Hunter <adrian.hunter@intel.com> - 2015-09-03 11:20 +0200
  Re: [PATCH v2 1/4] perf tests: take into account address of each  objdump line Adrian Hunter <adrian.hunter@intel.com> - 2015-09-03 11:20 +0200
    [PATCH v3 1/4] perf tests: take into account address of each objdump line Jan Stancek <jstancek@redhat.com> - 2015-09-03 13:30 +0200
      Re: [PATCH v3 1/4] perf tests: take into account address of each  objdump line Adrian Hunter <adrian.hunter@intel.com> - 2015-09-03 13:40 +0200

csiph-web