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


Groups > linux.kernel > #1217407 > unrolled thread

[PATCH v2 1/4] perf tests: take into account address of each objdump line

Started byJan Stancek <jstancek@redhat.com>
First post2015-09-02 10:20 +0200
Last post2015-09-03 13:40 +0200
Articles 6 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [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

#1217407 — [PATCH v2 1/4] perf tests: take into account address of each objdump line

FromJan Stancek <jstancek@redhat.com>
Date2015-09-02 10:20 +0200
Subject[PATCH v2 1/4] perf tests: take into account address of each objdump line
Message-ID<q4bqV-7Rc-17@gated-at.bofh.it>
objdump output can contain repeated bytes. At the moment test reads
all output sequentially, assuming each address is represented in
output only once:

  ffffffff8164efb3 <retint_swapgs+0x9>:
  ffffffff8164efb3:  c1 5d 00 eb        rcrl   $0xeb,0x0(%rbp)
  ffffffff8164efb7:  00 4c 8b 5c        add    %cl,0x5c(%rbx,%rcx,4)

  ffffffff8164efb8 <restore_c_regs_and_iret>:
  ffffffff8164efb8:  4c 8b 5c 24 30     mov    0x30(%rsp),%r11
  ffffffff8164efbd:  4c 8b 54 24 38     mov    0x38(%rsp),%r10

Store objdump output to buffer according to offset calculated
from address on each line.

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 | 51 ++++++++++++++++++++++++++++++-----------
 1 file changed, 38 insertions(+), 13 deletions(-)

Changes in v2:
  patch split into series

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 39c784a100a9..38ee90bc2228 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -33,20 +33,20 @@ static unsigned int hex(char c)
 	return c - 'A' + 10;
 }
 
-static void read_objdump_line(const char *line, size_t line_len, void **buf,
-			      size_t *len)
+static size_t read_objdump_line(const char *line, size_t line_len, void *buf,
+			      size_t len)
 {
 	const char *p;
-	size_t i;
+	size_t i, j = 0;
 
 	/* Skip to a colon */
 	p = strchr(line, ':');
 	if (!p)
-		return;
+		return 0;
 	i = p + 1 - line;
 
 	/* Read bytes */
-	while (*len) {
+	while (j < len) {
 		char c1, c2;
 
 		/* Skip spaces */
@@ -65,20 +65,26 @@ static void read_objdump_line(const char *line, size_t line_len, void **buf,
 		if (i < line_len && line[i] && !isspace(line[i]))
 			break;
 		/* Store byte */
-		*(unsigned char *)*buf = (hex(c1) << 4) | hex(c2);
-		*buf += 1;
-		*len -= 1;
+		*(unsigned char *)buf = (hex(c1) << 4) | hex(c2);
+		buf += 1;
+		j++;
 	}
+	/* return number of successfully read bytes */
+	return j;
 }
 
-static int read_objdump_output(FILE *f, void **buf, size_t *len)
+static int read_objdump_output(FILE *f, void *buf, size_t *len, u64 start_addr)
 {
 	char *line = NULL;
-	size_t line_len;
+	size_t line_len, off_last = 0;
 	ssize_t ret;
 	int err = 0;
+	u64 addr;
+
+	while (off_last < *len) {
+		size_t off, read_bytes, written_bytes;
+		unsigned char tmp[BUFSZ];
 
-	while (1) {
 		ret = getline(&line, &line_len, f);
 		if (feof(f))
 			break;
@@ -87,9 +93,28 @@ static int read_objdump_output(FILE *f, void **buf, size_t *len)
 			err = -1;
 			break;
 		}
-		read_objdump_line(line, ret, buf, len);
+
+		/* read objdump data into temporary buffer */
+		read_bytes = read_objdump_line(line, ret, tmp, sizeof(tmp));
+		if (!read_bytes)
+			continue;
+
+		if (sscanf(line, "%"PRIx64, &addr) != 1)
+			continue;
+
+		/* copy it from temporary buffer to 'buf' according
+		 * to address on current objdump line */
+		off = addr - start_addr;
+		if (off >= *len)
+			break;
+		written_bytes = MIN(read_bytes, *len - off);
+		memcpy(buf + off, tmp, written_bytes);
+		off_last = off + written_bytes;
 	}
 
+	/* len returns number of bytes that could not be read */
+	*len -= off_last;
+
 	free(line);
 
 	return err;
@@ -120,7 +145,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
 		return -1;
 	}
 
-	ret = read_objdump_output(f, &buf, &len);
+	ret = read_objdump_output(f, buf, &len, addr);
 	if (len) {
 		pr_debug("objdump read too few bytes\n");
 		if (!ret)
-- 
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/

[toc] | [next] | [standalone]


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

FromJan Stancek <jstancek@redhat.com>
Date2015-09-02 10:30 +0200
Subject[PATCH v2 3/4] perf tests: stop reading if objdump output crossed sections
Message-ID<q4bAB-82i-5@gated-at.bofh.it>
In reply to#1217407
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/

[toc] | [prev] | [next] | [standalone]


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

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-03 11:20 +0200
SubjectRe: [PATCH v2 3/4] perf tests: stop reading if objdump output crossed sections
Message-ID<q4yQy-7Gl-11@gated-at.bofh.it>
In reply to#1217409
On 02/09/15 11:19, Jan Stancek wrote:
> 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>


Acked-by: Adrian Hunter <adrian.hunter@intel.com>


> ---
>  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 */
> 

--
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/

[toc] | [prev] | [next] | [standalone]


#1218115 — Re: [PATCH v2 1/4] perf tests: take into account address of each objdump line

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-03 11:20 +0200
SubjectRe: [PATCH v2 1/4] perf tests: take into account address of each objdump line
Message-ID<q4yQy-7Gl-23@gated-at.bofh.it>
In reply to#1217407
On 02/09/15 11:19, Jan Stancek wrote:
> objdump output can contain repeated bytes. At the moment test reads
> all output sequentially, assuming each address is represented in
> output only once:
> 
>   ffffffff8164efb3 <retint_swapgs+0x9>:
>   ffffffff8164efb3:  c1 5d 00 eb        rcrl   $0xeb,0x0(%rbp)
>   ffffffff8164efb7:  00 4c 8b 5c        add    %cl,0x5c(%rbx,%rcx,4)
> 
>   ffffffff8164efb8 <restore_c_regs_and_iret>:
>   ffffffff8164efb8:  4c 8b 5c 24 30     mov    0x30(%rsp),%r11
>   ffffffff8164efbd:  4c 8b 54 24 38     mov    0x38(%rsp),%r10
> 
> Store objdump output to buffer according to offset calculated
> from address on each line.
> 
> 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>

Apart from a couple of nitpicks below:

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/code-reading.c | 51 ++++++++++++++++++++++++++++++-----------
>  1 file changed, 38 insertions(+), 13 deletions(-)
> 
> Changes in v2:
>   patch split into series
> 
> diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
> index 39c784a100a9..38ee90bc2228 100644
> --- a/tools/perf/tests/code-reading.c
> +++ b/tools/perf/tests/code-reading.c
> @@ -33,20 +33,20 @@ static unsigned int hex(char c)
>  	return c - 'A' + 10;
>  }
>  
> -static void read_objdump_line(const char *line, size_t line_len, void **buf,
> -			      size_t *len)
> +static size_t read_objdump_line(const char *line, size_t line_len, void *buf,
> +			      size_t len)

Some (e.g. checkpatch) suggest that alignment should match open parenthesis

>  {
>  	const char *p;
> -	size_t i;
> +	size_t i, j = 0;
>  
>  	/* Skip to a colon */
>  	p = strchr(line, ':');
>  	if (!p)
> -		return;
> +		return 0;
>  	i = p + 1 - line;
>  
>  	/* Read bytes */
> -	while (*len) {
> +	while (j < len) {
>  		char c1, c2;
>  
>  		/* Skip spaces */
> @@ -65,20 +65,26 @@ static void read_objdump_line(const char *line, size_t line_len, void **buf,
>  		if (i < line_len && line[i] && !isspace(line[i]))
>  			break;
>  		/* Store byte */
> -		*(unsigned char *)*buf = (hex(c1) << 4) | hex(c2);
> -		*buf += 1;
> -		*len -= 1;
> +		*(unsigned char *)buf = (hex(c1) << 4) | hex(c2);
> +		buf += 1;
> +		j++;
>  	}
> +	/* return number of successfully read bytes */
> +	return j;
>  }
>  
> -static int read_objdump_output(FILE *f, void **buf, size_t *len)
> +static int read_objdump_output(FILE *f, void *buf, size_t *len, u64 start_addr)
>  {
>  	char *line = NULL;
> -	size_t line_len;
> +	size_t line_len, off_last = 0;
>  	ssize_t ret;
>  	int err = 0;
> +	u64 addr;
> +
> +	while (off_last < *len) {
> +		size_t off, read_bytes, written_bytes;
> +		unsigned char tmp[BUFSZ];
>  
> -	while (1) {
>  		ret = getline(&line, &line_len, f);
>  		if (feof(f))
>  			break;
> @@ -87,9 +93,28 @@ static int read_objdump_output(FILE *f, void **buf, size_t *len)
>  			err = -1;
>  			break;
>  		}
> -		read_objdump_line(line, ret, buf, len);
> +
> +		/* read objdump data into temporary buffer */
> +		read_bytes = read_objdump_line(line, ret, tmp, sizeof(tmp));
> +		if (!read_bytes)
> +			continue;
> +
> +		if (sscanf(line, "%"PRIx64, &addr) != 1)
> +			continue;
> +
> +		/* copy it from temporary buffer to 'buf' according
> +		 * to address on current objdump line */

The preferred style for long (multi-line) comments is:

		/*
		 * Copy it from temporary buffer to 'buf' according
		 * to address on current objdump line.
		 */

> +		off = addr - start_addr;
> +		if (off >= *len)
> +			break;
> +		written_bytes = MIN(read_bytes, *len - off);

We don't use MIN.  Use min() instead.

> +		memcpy(buf + off, tmp, written_bytes);
> +		off_last = off + written_bytes;
>  	}
>  
> +	/* len returns number of bytes that could not be read */
> +	*len -= off_last;
> +
>  	free(line);
>  
>  	return err;
> @@ -120,7 +145,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
>  		return -1;
>  	}
>  
> -	ret = read_objdump_output(f, &buf, &len);
> +	ret = read_objdump_output(f, buf, &len, addr);
>  	if (len) {
>  		pr_debug("objdump read too few bytes\n");
>  		if (!ret)
> 

--
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/

[toc] | [prev] | [next] | [standalone]


#1218176 — [PATCH v3 1/4] perf tests: take into account address of each objdump line

FromJan Stancek <jstancek@redhat.com>
Date2015-09-03 13:30 +0200
Subject[PATCH v3 1/4] perf tests: take into account address of each objdump line
Message-ID<q4ASm-28C-25@gated-at.bofh.it>
In reply to#1218115
objdump output can contain repeated bytes. At the moment test reads
all output sequentially, assuming each address is represented in
output only once:

  ffffffff8164efb3 <retint_swapgs+0x9>:
  ffffffff8164efb3:  c1 5d 00 eb        rcrl   $0xeb,0x0(%rbp)
  ffffffff8164efb7:  00 4c 8b 5c        add    %cl,0x5c(%rbx,%rcx,4)

  ffffffff8164efb8 <restore_c_regs_and_iret>:
  ffffffff8164efb8:  4c 8b 5c 24 30     mov    0x30(%rsp),%r11
  ffffffff8164efbd:  4c 8b 54 24 38     mov    0x38(%rsp),%r10

Store objdump output to buffer according to offset calculated
from address on each line.

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 | 53 +++++++++++++++++++++++++++++++----------
 1 file changed, 40 insertions(+), 13 deletions(-)

Changes in v3:
  align read_objdump_line parameters on 2nd line
  fix multiline comment
  replace MIN with min

diff --git a/tools/perf/tests/code-reading.c b/tools/perf/tests/code-reading.c
index 39c784a100a9..7fd7ebc0b692 100644
--- a/tools/perf/tests/code-reading.c
+++ b/tools/perf/tests/code-reading.c
@@ -33,20 +33,20 @@ static unsigned int hex(char c)
 	return c - 'A' + 10;
 }
 
-static void read_objdump_line(const char *line, size_t line_len, void **buf,
-			      size_t *len)
+static size_t read_objdump_line(const char *line, size_t line_len, void *buf,
+				size_t len)
 {
 	const char *p;
-	size_t i;
+	size_t i, j = 0;
 
 	/* Skip to a colon */
 	p = strchr(line, ':');
 	if (!p)
-		return;
+		return 0;
 	i = p + 1 - line;
 
 	/* Read bytes */
-	while (*len) {
+	while (j < len) {
 		char c1, c2;
 
 		/* Skip spaces */
@@ -65,20 +65,26 @@ static void read_objdump_line(const char *line, size_t line_len, void **buf,
 		if (i < line_len && line[i] && !isspace(line[i]))
 			break;
 		/* Store byte */
-		*(unsigned char *)*buf = (hex(c1) << 4) | hex(c2);
-		*buf += 1;
-		*len -= 1;
+		*(unsigned char *)buf = (hex(c1) << 4) | hex(c2);
+		buf += 1;
+		j++;
 	}
+	/* return number of successfully read bytes */
+	return j;
 }
 
-static int read_objdump_output(FILE *f, void **buf, size_t *len)
+static int read_objdump_output(FILE *f, void *buf, size_t *len, u64 start_addr)
 {
 	char *line = NULL;
-	size_t line_len;
+	size_t line_len, off_last = 0;
 	ssize_t ret;
 	int err = 0;
+	u64 addr;
+
+	while (off_last < *len) {
+		size_t off, read_bytes, written_bytes;
+		unsigned char tmp[BUFSZ];
 
-	while (1) {
 		ret = getline(&line, &line_len, f);
 		if (feof(f))
 			break;
@@ -87,9 +93,30 @@ static int read_objdump_output(FILE *f, void **buf, size_t *len)
 			err = -1;
 			break;
 		}
-		read_objdump_line(line, ret, buf, len);
+
+		/* read objdump data into temporary buffer */
+		read_bytes = read_objdump_line(line, ret, tmp, sizeof(tmp));
+		if (!read_bytes)
+			continue;
+
+		if (sscanf(line, "%"PRIx64, &addr) != 1)
+			continue;
+
+		/*
+		 * Copy it from temporary buffer to 'buf' according
+		 * to address on current objdump line.
+		 */
+		off = addr - start_addr;
+		if (off >= *len)
+			break;
+		written_bytes = min(read_bytes, *len - off);
+		memcpy(buf + off, tmp, written_bytes);
+		off_last = off + written_bytes;
 	}
 
+	/* len returns number of bytes that could not be read */
+	*len -= off_last;
+
 	free(line);
 
 	return err;
@@ -120,7 +147,7 @@ static int read_via_objdump(const char *filename, u64 addr, void *buf,
 		return -1;
 	}
 
-	ret = read_objdump_output(f, &buf, &len);
+	ret = read_objdump_output(f, buf, &len, addr);
 	if (len) {
 		pr_debug("objdump read too few bytes\n");
 		if (!ret)
-- 
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/

[toc] | [prev] | [next] | [standalone]


#1218181 — Re: [PATCH v3 1/4] perf tests: take into account address of each objdump line

FromAdrian Hunter <adrian.hunter@intel.com>
Date2015-09-03 13:40 +0200
SubjectRe: [PATCH v3 1/4] perf tests: take into account address of each objdump line
Message-ID<q4B23-2jJ-31@gated-at.bofh.it>
In reply to#1218176
On 03/09/15 14:23, Jan Stancek wrote:
> objdump output can contain repeated bytes. At the moment test reads
> all output sequentially, assuming each address is represented in
> output only once:
> 
>   ffffffff8164efb3 <retint_swapgs+0x9>:
>   ffffffff8164efb3:  c1 5d 00 eb        rcrl   $0xeb,0x0(%rbp)
>   ffffffff8164efb7:  00 4c 8b 5c        add    %cl,0x5c(%rbx,%rcx,4)
> 
>   ffffffff8164efb8 <restore_c_regs_and_iret>:
>   ffffffff8164efb8:  4c 8b 5c 24 30     mov    0x30(%rsp),%r11
>   ffffffff8164efbd:  4c 8b 54 24 38     mov    0x38(%rsp),%r10
> 
> Store objdump output to buffer according to offset calculated
> from address on each line.
> 
> 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 | 53 +++++++++++++++++++++++++++++++----------
>  1 file changed, 40 insertions(+), 13 deletions(-)
> 
> Changes in v3:
>   align read_objdump_line parameters on 2nd line
>   fix multiline comment
>   replace MIN with min
> 

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

--
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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web