[PATCH -tip 3/4] [BUGFIX] perf probe: Correct error message fornon-structure type

From: Masami Hiramatsu
Date: Fri Apr 02 2010 - 13:04:13 EST


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.

Signed-off-by: Masami Hiramatsu <mhiramat@xxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxx>
Cc: Paul Mackerras <paulus@xxxxxxxxx>
Cc: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Mike Galbraith <efault@xxxxxx>
Cc: Frederic Weisbecker <fweisbec@xxxxxxxxx>
---

tools/perf/util/probe-finder.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index b44132e..59b0115 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -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);


--
Masami Hiramatsu
e-mail: mhiramat@xxxxxxxxxx
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/