All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf-probe: fix perf-probe(1)'s report
@ 2010-12-23 15:04 Franck Bui-Huu
  2010-12-26 14:30 ` Masami Hiramatsu
  2011-01-04  8:20 ` [tip:perf/core] perf probe: Fix short file name probe location reporting tip-bot for Franck Bui-Huu
  0 siblings, 2 replies; 3+ messages in thread
From: Franck Bui-Huu @ 2010-12-23 15:04 UTC (permalink / raw)
  To: Masami Hiramatsu; +Cc: Arnaldo Carvalho de Melo, linux-kernel

From: Franck Bui-Huu <fbuihuu@gmail.com>

After adding probes, perf-probe(1) reports the probes locations which
include filenames for certain cases.

But for short file names (whose length < 32), perf-probe didn't display
the name correctly. It actually skipped the first character.

Here's an example where 'icmp.c' was screwed:

   $ perf probe -n -a "icmp.c;sk=*"
   Add new events:
     probe:icmp_push_reply (on @cmp.c)
     probe:icmp_reply     (on @cmp.c)
     probe:icmp_reply_1   (on @cmp.c)
     probe:icmp_send      (on @cmp.c)
     probe:icmp_send_1    (on @cmp.c)
     probe:icmp_error     (on @cmp.c)
     probe:icmp_error_1   (on @cmp.c)
     probe:icmp_error_2   (on @cmp.c)
     probe:icmp_error_3   (on @cmp.c)

This patch fixes this bug in synthesize_perf_probe_point().

Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
---
 tools/perf/util/probe-event.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 10ad1ad..adc2620 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1077,13 +1077,13 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
 			goto error;
 	}
 	if (pp->file) {
-		len = strlen(pp->file) - 31;
-		if (len < 0)
-			len = 0;
-		tmp = strchr(pp->file + len, '/');
-		if (!tmp)
-			tmp = pp->file + len;
-		ret = e_snprintf(file, 32, "@%s", tmp + 1);
+		tmp = pp->file;
+		len = strlen(tmp);
+		if (len > 30) {
+			tmp = strchr(pp->file + len - 30, '/');
+			tmp = tmp ? tmp + 1 : pp->file + len - 30;
+		}
+		ret = e_snprintf(file, 32, "@%s", tmp);
 		if (ret <= 0)
 			goto error;
 	}
@@ -1099,7 +1099,7 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
 
 	return buf;
 error:
-	pr_debug("Failed to synthesize perf probe point: %s",
+	pr_debug("Failed to synthesize perf probe point: %s\n",
 		 strerror(-ret));
 	if (buf)
 		free(buf);
-- 
1.7.3.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] perf-probe: fix perf-probe(1)'s report
  2010-12-23 15:04 [PATCH] perf-probe: fix perf-probe(1)'s report Franck Bui-Huu
@ 2010-12-26 14:30 ` Masami Hiramatsu
  2011-01-04  8:20 ` [tip:perf/core] perf probe: Fix short file name probe location reporting tip-bot for Franck Bui-Huu
  1 sibling, 0 replies; 3+ messages in thread
From: Masami Hiramatsu @ 2010-12-26 14:30 UTC (permalink / raw)
  To: Franck Bui-Huu; +Cc: Arnaldo Carvalho de Melo, linux-kernel, 2nddept-manager

(2010/12/24 0:04), Franck Bui-Huu wrote:
> From: Franck Bui-Huu <fbuihuu@gmail.com>
> 
> After adding probes, perf-probe(1) reports the probes locations which
> include filenames for certain cases.
> 
> But for short file names (whose length < 32), perf-probe didn't display
> the name correctly. It actually skipped the first character.
> 
> Here's an example where 'icmp.c' was screwed:
> 
>    $ perf probe -n -a "icmp.c;sk=*"
>    Add new events:
>      probe:icmp_push_reply (on @cmp.c)
>      probe:icmp_reply     (on @cmp.c)
>      probe:icmp_reply_1   (on @cmp.c)
>      probe:icmp_send      (on @cmp.c)
>      probe:icmp_send_1    (on @cmp.c)
>      probe:icmp_error     (on @cmp.c)
>      probe:icmp_error_1   (on @cmp.c)
>      probe:icmp_error_2   (on @cmp.c)
>      probe:icmp_error_3   (on @cmp.c)
> 
> This patch fixes this bug in synthesize_perf_probe_point().

Oops, I've missed that.
Thanks! that's really good catch!

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>

> 
> Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
> ---
>  tools/perf/util/probe-event.c |   16 ++++++++--------
>  1 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
> index 10ad1ad..adc2620 100644
> --- a/tools/perf/util/probe-event.c
> +++ b/tools/perf/util/probe-event.c
> @@ -1077,13 +1077,13 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
>  			goto error;
>  	}
>  	if (pp->file) {
> -		len = strlen(pp->file) - 31;
> -		if (len < 0)
> -			len = 0;
> -		tmp = strchr(pp->file + len, '/');
> -		if (!tmp)
> -			tmp = pp->file + len;
> -		ret = e_snprintf(file, 32, "@%s", tmp + 1);
> +		tmp = pp->file;
> +		len = strlen(tmp);
> +		if (len > 30) {
> +			tmp = strchr(pp->file + len - 30, '/');
> +			tmp = tmp ? tmp + 1 : pp->file + len - 30;
> +		}
> +		ret = e_snprintf(file, 32, "@%s", tmp);
>  		if (ret <= 0)
>  			goto error;
>  	}
> @@ -1099,7 +1099,7 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
>  
>  	return buf;
>  error:
> -	pr_debug("Failed to synthesize perf probe point: %s",
> +	pr_debug("Failed to synthesize perf probe point: %s\n",
>  		 strerror(-ret));
>  	if (buf)
>  		free(buf);


-- 
Masami HIRAMATSU
2nd Dept. Linux Technology Center
Hitachi, Ltd., Systems Development Laboratory
E-mail: masami.hiramatsu.pt@hitachi.com

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [tip:perf/core] perf probe: Fix short file name probe location reporting
  2010-12-23 15:04 [PATCH] perf-probe: fix perf-probe(1)'s report Franck Bui-Huu
  2010-12-26 14:30 ` Masami Hiramatsu
@ 2011-01-04  8:20 ` tip-bot for Franck Bui-Huu
  1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Franck Bui-Huu @ 2011-01-04  8:20 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: acme, linux-kernel, hpa, mingo, masami.hiramatsu.pt, fbuihuu, tglx

Commit-ID:  32ae2ade462146729580117d9886cc9efd83dfbe
Gitweb:     http://git.kernel.org/tip/32ae2ade462146729580117d9886cc9efd83dfbe
Author:     Franck Bui-Huu <fbuihuu@gmail.com>
AuthorDate: Thu, 23 Dec 2010 16:04:23 +0100
Committer:  Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Mon, 27 Dec 2010 19:48:21 -0200

perf probe: Fix short file name probe location reporting

After adding probes, perf-probe(1) reports the probes locations which include
filenames for certain cases.

But for short file names (whose length < 32), perf-probe didn't display the
name correctly. It actually skipped the first character.

Here's an example where 'icmp.c' was screwed:

   $ perf probe -n -a "icmp.c;sk=*"
   Add new events:
     probe:icmp_push_reply (on @cmp.c)
     probe:icmp_reply     (on @cmp.c)
     probe:icmp_reply_1   (on @cmp.c)
     probe:icmp_send      (on @cmp.c)
     probe:icmp_send_1    (on @cmp.c)
     probe:icmp_error     (on @cmp.c)
     probe:icmp_error_1   (on @cmp.c)
     probe:icmp_error_2   (on @cmp.c)
     probe:icmp_error_3   (on @cmp.c)

This patch fixes this bug in synthesize_perf_probe_point().

Acked-by: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
LKML-Reference: <m31v588r9k.fsf@gmail.com>
Signed-off-by: Franck Bui-Huu <fbuihuu@gmail.com>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/probe-event.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/probe-event.c b/tools/perf/util/probe-event.c
index 4bde988..d3af30d 100644
--- a/tools/perf/util/probe-event.c
+++ b/tools/perf/util/probe-event.c
@@ -1068,13 +1068,13 @@ static char *synthesize_perf_probe_point(struct perf_probe_point *pp)
 			goto error;
 	}
 	if (pp->file) {
-		len = strlen(pp->file) - 31;
-		if (len < 0)
-			len = 0;
-		tmp = strchr(pp->file + len, '/');
-		if (!tmp)
-			tmp = pp->file + len;
-		ret = e_snprintf(file, 32, "@%s", tmp + 1);
+		tmp = pp->file;
+		len = strlen(tmp);
+		if (len > 30) {
+			tmp = strchr(pp->file + len - 30, '/');
+			tmp = tmp ? tmp + 1 : pp->file + len - 30;
+		}
+		ret = e_snprintf(file, 32, "@%s", tmp);
 		if (ret <= 0)
 			goto error;
 	}

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-01-04  8:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-12-23 15:04 [PATCH] perf-probe: fix perf-probe(1)'s report Franck Bui-Huu
2010-12-26 14:30 ` Masami Hiramatsu
2011-01-04  8:20 ` [tip:perf/core] perf probe: Fix short file name probe location reporting tip-bot for Franck Bui-Huu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.