Skip to contentSkip to conversation

perf: Fix dynamic field detection

PATCH In review Frederic Weisbecker 2 participants 2 messages Apr 14, 2010 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf: Fix dynamic field detection

From: Thomas Gleixner <[email protected]>

Checking if a tracing field is an array with a dynamic length requires to check the field type and seek the "__data_loc" string that prepends the actual type, as can be found in a trace event format file:

	field:__data_loc char[] name;	offset:16;	size:4;	signed:1;

But we actually use strcmp() to check if the field type fully matches "__data_loc", which may fail as we trip over the rest of the type.

To fix this, use strncmp to only check if it starts with "__data_loc".

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Tom Zanussi <[email protected]>
Cc Steven Rostedt <[email protected]>
---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/trace-event-parse.c +1 -1
index 17d6d66..d6ef414 100644
@@ -761,7 +761,7 @@ static int field_is_string(struct format_field *field)
 
 static int field_is_dynamic(struct format_field *field)
 {
-	if (!strcmp(field->type, "__data_loc"))
+	if (!strncmp(field->type, "__data_loc", 10))
 		return 1;
 
 	return 0;
Signature · 1 line
1.6.2.3
#1 lore raw
Commit-ID:  a1e2f60e3efc812bf66a2be0d8530ee175003f6d
Gitweb:     http://git.kernel.org/tip/a1e2f60e3efc812bf66a2be0d8530ee175003f6d
Author:     Thomas Gleixner <[email protected]>
AuthorDate: Wed, 14 Apr 2010 23:58:03 +0200
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 15 Apr 2010 01:34:46 +0200

perf: Fix dynamic field detection

Checking if a tracing field is an array with a dynamic length requires to check the field type and seek the "__data_loc" string that prepends the actual type, as can be found in a trace event format file:

	field:__data_loc char[] name;	offset:16;	size:4;	signed:1;

But we actually use strcmp() to check if the field type fully matches "__data_loc", which may fail as we trip over the rest of the type.

To fix this, use strncmp to only check if it starts with "__data_loc".

Cc Arnaldo Carvalho de Melo <[email protected]>
Cc Peter Zijlstra <[email protected]>
Cc Paul Mackerras <[email protected]>
Cc Tom Zanussi <[email protected]>
Cc Steven Rostedt <[email protected]>

LKML-Reference: <[email protected]>

---
 tools/perf/util/trace-event-parse.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
tools/perf/util/trace-event-parse.c +1 -1
index 17d6d66..d6ef414 100644
@@ -761,7 +761,7 @@ static int field_is_string(struct format_field *field)
 
 static int field_is_dynamic(struct format_field *field)
 {
-	if (!strcmp(field->type, "__data_loc"))
+	if (!strncmp(field->type, "__data_loc", 10))
 		return 1;
 
 	return 0;