Skip to contentSkip to conversation

perf-probe bugfixes

PATCH In review Masami Hiramatsu 1 participant 9 messages Apr 2, 2010 perf events

lore
Share & tools
lore
#0 lore raw

cover perf-probe bugfixes

Hi Ingo,

Before introducing new patches, I'd like to push some bugfixes. (I'll update previous series and post again.)

Thank you,

---

Masami Hiramatsu (4):
[BUGFIX][RESEND] perf probe: Fix to close dwarf when failing to analyze it [BUGFIX] perf probe: Correct error message for non-structure type [BUGFIX] perf probe: Fix not to return non-matched file [BUGFIX] perf probe: Fix --line syntax help and document

 tools/perf/Documentation/perf-probe.txt |    2 +-
 tools/perf/builtin-probe.c              |    2 +-
 tools/perf/util/probe-finder.c          |   20 ++++++++++++++------
 3 files changed, 16 insertions(+), 8 deletions(-)
Signature · 2 lines
Masami Hiramatsu
e-mail: [email protected]
#1 lore raw

PATCH 1/4 perf probe: Fix --line syntax help and document

Just fix typos. --line option accepts ':START-END' syntax, not ':START:END'.

Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>

---

 tools/perf/Documentation/perf-probe.txt |    2 +-
 tools/perf/builtin-probe.c              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-probe.txt +1 -1
index 0f944b3..bb671b3 100644
@@ -85,7 +85,7 @@ LINE SYNTAX
 -----------
 Line range is descripted by following syntax.
 
- "FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]"
+ "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]"
 
 FUNC specifies the function name of showing lines. 'RLN' is the start line
 number from function entry line, and 'RLN2' is the end line number. As same as
tools/perf/builtin-probe.c +1 -1
index cf2ffa5..b3ba25a 100644
@@ -167,7 +167,7 @@ static const struct option options[] = {
 		    " with existing name"),
 #ifdef DWARF_SUPPORT
 	OPT_CALLBACK('L', "line", NULL,
-		     "FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]",
+		     "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]",
 		     "Show source code lines.", opt_show_lines),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
 		   "file", "vmlinux pathname"),
Signature · 2 lines
Masami Hiramatsu
e-mail: [email protected]
#2 lore raw

[tip:perf/core] perf probe: Fix --line syntax help and document

Commit-ID:  085ea739adf107b5a5d131f3625e517ff4a5181e
Gitweb:     http://git.kernel.org/tip/085ea739adf107b5a5d131f3625e517ff4a5181e
Author:     Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 2 Apr 2010 12:50:39 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 2 Apr 2010 19:35:42 +0200

perf probe: Fix --line syntax help and document

Just fix typos. --line option accepts ':START-END' syntax, not ':START:END'.

Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc systemtap <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/Documentation/perf-probe.txt |    2 +-
 tools/perf/builtin-probe.c              |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tools/perf/Documentation/perf-probe.txt +1 -1
index 0f944b3..bb671b3 100644
@@ -85,7 +85,7 @@ LINE SYNTAX
 -----------
 Line range is descripted by following syntax.
 
- "FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]"
+ "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]"
 
 FUNC specifies the function name of showing lines. 'RLN' is the start line
 number from function entry line, and 'RLN2' is the end line number. As same as
tools/perf/builtin-probe.c +1 -1
index cf2ffa5..b3ba25a 100644
@@ -167,7 +167,7 @@ static const struct option options[] = {
 		    " with existing name"),
 #ifdef DWARF_SUPPORT
 	OPT_CALLBACK('L', "line", NULL,
-		     "FUNC[:RLN[+NUM|:RLN2]]|SRC:ALN[+NUM|:ALN2]",
+		     "FUNC[:RLN[+NUM|-RLN2]]|SRC:ALN[+NUM|-ALN2]",
 		     "Show source code lines.", opt_show_lines),
 	OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
 		   "file", "vmlinux pathname"),
#3 lore raw

PATCH 2/4 perf probe: Fix not to return non-matched file

In reply to Masami Hiramatsu

Fix cu_find_realpath() not to return the last file path if that is not matched to input pattern.

Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>

---

 tools/perf/util/probe-finder.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/probe-finder.c +2 -0
index db52ec2..b44132e 100644
@@ -183,6 +183,8 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname)
 		if (strtailcmp(src, fname) == 0)
 			break;
 	}
+	if (i == nfiles)
+		return NULL;
 	return src;
 }
 
Signature · 2 lines
Masami Hiramatsu
e-mail: [email protected]
#4 lore raw

[tip:perf/core] perf probe: Fix not to return non-matched file

Commit-ID:  c9e385826d4f1ca5a72005ab8503598f791a8dc0
Gitweb:     http://git.kernel.org/tip/c9e385826d4f1ca5a72005ab8503598f791a8dc0
Author:     Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 2 Apr 2010 12:50:45 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 2 Apr 2010 19:35:42 +0200

perf probe: Fix not to return non-matched file

Fix cu_find_realpath() not to return the last file path if that is not matched to input pattern.

Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc systemtap <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/util/probe-finder.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
tools/perf/util/probe-finder.c +2 -0
index db52ec2..b44132e 100644
@@ -183,6 +183,8 @@ static const char *cu_find_realpath(Dwarf_Die *cu_die, const char *fname)
 		if (strtailcmp(src, fname) == 0)
 			break;
 	}
+	if (i == nfiles)
+		return NULL;
 	return src;
 }
 
#5 lore raw

PATCH 3/4 perf probe: Correct error message for non-structure type

In reply to Masami Hiramatsu

perf probe outputs incorrect error message when it called with non-exist field on a non-data structure local variable.

<Before>

 # perf probe vfs_read 'count.hoge'
  Fatal: Structure on a register is not supported yet.
 # perf probe vfs_read 'count->hoge'
  Fatal: Semantic error: hoge must be referred by '.'

This corrects the messsage.

<After>

 # perf probe vfs_read 'count.hoge'
  Fatal: count is not a data structure.
 # perf probe vfs_read 'count->hoge'
  Fatal: count is not a data structure.
Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>

---

 tools/perf/util/probe-finder.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
tools/perf/util/probe-finder.c +8 -4
index b44132e..59b0115 100644
@@ -429,12 +429,20 @@ static void convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
 		if (die_get_real_type(&type, &type) == NULL)
 			die("Failed to get a type information of %s.", varname);
 
+		/* Verify it is a data structure  */
+		if (dwarf_tag(&type) != DW_TAG_structure_type)
+			die("%s is not a data structure.", varname);
+
 		ref = xzalloc(sizeof(struct kprobe_trace_arg_ref));
 		if (*ref_ptr)
 			(*ref_ptr)->next = ref;
 		else
 			*ref_ptr = ref;
 	} else {
+		/* Verify it is a data structure  */
+		if (dwarf_tag(&type) != DW_TAG_structure_type)
+			die("%s is not a data structure.", varname);
+
 		if (field->ref)
 			die("Semantic error: %s must be referred by '.'",
 			    field->name);
@@ -442,10 +450,6 @@ static void convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
 			die("Structure on a register is not supported yet.");
 	}
 
-	/* Verify it is a data structure  */
-	if (dwarf_tag(&type) != DW_TAG_structure_type)
-		die("%s is not a data structure.", varname);
-
 	if (die_find_member(&type, field->name, &member) == NULL)
 		die("%s(tyep:%s) has no member %s.", varname,
 		    dwarf_diename(&type), field->name);
Signature · 2 lines
Masami Hiramatsu
e-mail: [email protected]
#6 lore raw

[tip:perf/core] perf probe: Correct error message for non-structure type

Commit-ID:  12e5a7ae475ccb2733d740ffb95d9ca0a18392da
Gitweb:     http://git.kernel.org/tip/12e5a7ae475ccb2733d740ffb95d9ca0a18392da
Author:     Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 2 Apr 2010 12:50:53 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 2 Apr 2010 19:35:43 +0200

perf probe: Correct error message for non-structure type

perf probe outputs incorrect error message when it is called with non-existent field on a non-data structure local variable.

<Before>

 # perf probe vfs_read 'count.hoge'
  Fatal: Structure on a register is not supported yet.
 # perf probe vfs_read 'count->hoge'
  Fatal: Semantic error: hoge must be referred by '.'

This corrects the messsage.

<After>

 # perf probe vfs_read 'count.hoge'
  Fatal: count is not a data structure.
 # perf probe vfs_read 'count->hoge'
  Fatal: count is not a data structure.
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc systemtap <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/util/probe-finder.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
tools/perf/util/probe-finder.c +8 -4
index b44132e..59b0115 100644
@@ -429,12 +429,20 @@ static void convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
 		if (die_get_real_type(&type, &type) == NULL)
 			die("Failed to get a type information of %s.", varname);
 
+		/* Verify it is a data structure  */
+		if (dwarf_tag(&type) != DW_TAG_structure_type)
+			die("%s is not a data structure.", varname);
+
 		ref = xzalloc(sizeof(struct kprobe_trace_arg_ref));
 		if (*ref_ptr)
 			(*ref_ptr)->next = ref;
 		else
 			*ref_ptr = ref;
 	} else {
+		/* Verify it is a data structure  */
+		if (dwarf_tag(&type) != DW_TAG_structure_type)
+			die("%s is not a data structure.", varname);
+
 		if (field->ref)
 			die("Semantic error: %s must be referred by '.'",
 			    field->name);
@@ -442,10 +450,6 @@ static void convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
 			die("Structure on a register is not supported yet.");
 	}
 
-	/* Verify it is a data structure  */
-	if (dwarf_tag(&type) != DW_TAG_structure_type)
-		die("%s is not a data structure.", varname);
-
 	if (die_find_member(&type, field->name, &member) == NULL)
 		die("%s(tyep:%s) has no member %s.", varname,
 		    dwarf_diename(&type), field->name);
#7 lore raw

PATCH RESEND 4/4 perf probe: Fix to close dwarf when failing to analyze it

In reply to Masami Hiramatsu

Fix to close libdw routine when failing to analyze it in find_perf_probe_point().

Cc Ingo Molnar <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>

---

 tools/perf/util/probe-finder.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +4 -2
index 59b0115..a851377 100644
@@ -818,8 +818,10 @@ int find_perf_probe_point(int fd, unsigned long addr,
 		return -ENOENT;
 
 	/* Find cu die */
-	if (!dwarf_addrdie(dbg, (Dwarf_Addr)addr, &cudie))
-		return -EINVAL;
+	if (!dwarf_addrdie(dbg, (Dwarf_Addr)addr, &cudie)) {
+		ret = -EINVAL;
+		goto end;
+	}
 
 	/* Find a corresponding line */
 	line = dwarf_getsrc_die(&cudie, (Dwarf_Addr)addr);
Signature · 2 lines
Masami Hiramatsu
e-mail: [email protected]
#8 lore raw

[tip:perf/core] perf probe: Fix to close dwarf when failing to analyze it

Commit-ID:  75ec5a245c7763c397f31ec8964d0a46c54a7386
Gitweb:     http://git.kernel.org/tip/75ec5a245c7763c397f31ec8964d0a46c54a7386
Author:     Masami Hiramatsu <[email protected]>
AuthorDate: Fri, 2 Apr 2010 12:50:59 -0400
Committer:  Ingo Molnar <[email protected]>
CommitDate: Fri, 2 Apr 2010 19:35:44 +0200

perf probe: Fix to close dwarf when failing to analyze it

Fix to close libdw routine when failing to analyze it in find_perf_probe_point().

Cc Paul Mackerras <[email protected]>
Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Mike Galbraith <[email protected]>
Cc Frederic Weisbecker <[email protected]>
Cc systemtap <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/util/probe-finder.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
tools/perf/util/probe-finder.c +4 -2
index 59b0115..a851377 100644
@@ -818,8 +818,10 @@ int find_perf_probe_point(int fd, unsigned long addr,
 		return -ENOENT;
 
 	/* Find cu die */
-	if (!dwarf_addrdie(dbg, (Dwarf_Addr)addr, &cudie))
-		return -EINVAL;
+	if (!dwarf_addrdie(dbg, (Dwarf_Addr)addr, &cudie)) {
+		ret = -EINVAL;
+		goto end;
+	}
 
 	/* Find a corresponding line */
 	line = dwarf_getsrc_die(&cudie, (Dwarf_Addr)addr);