From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752525AbbIOG6v (ORCPT ); Tue, 15 Sep 2015 02:58:51 -0400 Received: from terminus.zytor.com ([198.137.202.10]:49964 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752429AbbIOG6s (ORCPT ); Tue, 15 Sep 2015 02:58:48 -0400 Date: Mon, 14 Sep 2015 23:58:23 -0700 From: tip-bot for Jan Stancek Message-ID: Cc: linux-kernel@vger.kernel.org, adrian.hunter@intel.com, paulus@samba.org, hpa@zytor.com, fweisbec@gmail.com, tglx@linutronix.de, cjashfor@linux.vnet.ibm.com, a.p.zijlstra@chello.nl, acme@redhat.com, dsahern@gmail.com, mingo@kernel.org, jolsa@kernel.org, jstancek@redhat.com, namhyung@kernel.org Reply-To: jolsa@kernel.org, dsahern@gmail.com, mingo@kernel.org, a.p.zijlstra@chello.nl, acme@redhat.com, namhyung@kernel.org, jstancek@redhat.com, adrian.hunter@intel.com, linux-kernel@vger.kernel.org, cjashfor@linux.vnet.ibm.com, tglx@linutronix.de, hpa@zytor.com, fweisbec@gmail.com, paulus@samba.org In-Reply-To: <9d1ea95e5f9884fdff1be6f761a2feabef37412c.1441181335.git.jstancek@redhat.com> References: <9d1ea95e5f9884fdff1be6f761a2feabef37412c.1441181335.git.jstancek@redhat.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tests: Stop reading if objdump output crossed sections Git-Commit-ID: edfdb7eab0fe5f98f2951598dc679b71bdb3e16b X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: edfdb7eab0fe5f98f2951598dc679b71bdb3e16b Gitweb: http://git.kernel.org/tip/edfdb7eab0fe5f98f2951598dc679b71bdb3e16b Author: Jan Stancek AuthorDate: Wed, 2 Sep 2015 10:19:16 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 14 Sep 2015 12:50:12 -0300 perf tests: Stop reading if objdump output crossed sections objdump output can span across multiple sections: Disassembly of section .text: 0000000000000008 : 8: 48 89 e5 mov %rsp,%rbp b: 53 push %rbx c: 8b 01 mov (%rcx),%eax 6b: 90 nop Disassembly of section .init.text: 0000000000000008 : 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 Acked-by: Adrian Hunter Cc: Corey Ashford Cc: David Ahern Cc: Frederic Weisbecker Cc: Jiri Olsa Cc: Namhyung Kim Cc: Paul Mackerras Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/9d1ea95e5f9884fdff1be6f761a2feabef37412c.1441181335.git.jstancek@redhat.com Signed-off-by: Arnaldo Carvalho de Melo --- 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 c409409..8145c67 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 */