From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752793AbbICJPN (ORCPT ); Thu, 3 Sep 2015 05:15:13 -0400 Received: from mga09.intel.com ([134.134.136.24]:49641 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752389AbbICJPL (ORCPT ); Thu, 3 Sep 2015 05:15:11 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,461,1437462000"; d="scan'208";a="796913107" Subject: Re: [PATCH v2 3/4] perf tests: stop reading if objdump output crossed sections To: Jan Stancek References: <9d1ea95e5f9884fdff1be6f761a2feabef37412c.1441181335.git.jstancek@redhat.com> Cc: linux-kernel@vger.kernel.org, acme@kernel.org, jolsa@kernel.org, dsahern@gmail.com, cjashfor@linux.vnet.ibm.com, fweisbec@gmail.com, mingo@kernel.org, namhyung@kernel.org, paulus@samba.org, a.p.zijlstra@chello.nl From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <55E80EF6.9060008@intel.com> Date: Thu, 3 Sep 2015 12:12:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <9d1ea95e5f9884fdff1be6f761a2feabef37412c.1441181335.git.jstancek@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 02/09/15 11:19, Jan Stancek wrote: > 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 address starts going backwards, > assuming we crossed sections. > > Signed-off-by: Jan Stancek > Cc: Arnaldo Carvalho de Melo > Cc: Jiri Olsa > Cc: Adrian Hunter > Cc: David Ahern > Cc: Corey Ashford > Cc: Frederic Weisbecker > Cc: Ingo Molnar > Cc: Namhyung Kim > Cc: Paul Mackerras > Cc: Peter Zijlstra Acked-by: Adrian Hunter > --- > 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 */ >