Skip to contentSkip to conversation

perf probe: Allow of casting an array of char to string

PATCH In review Hyeoncheol Lee 2 participants 2 messages Sep 20, 2012 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf probe: Allow of casting an array of char to string

Before casting a type of a variable to string, convert_variable_type() confirms that the type is a pointer or an array. if it is a pointer to char, it is casted to string. but in case of an array of char, it isn't

Cc Masami Hiramatsu <[email protected]>
Cc Srikar Dronamraju <[email protected]>
---
 tools/perf/util/probe-finder.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/probe-finder.c +5 -5
index 1daf5c1..be03293 100644
@@ -413,12 +413,12 @@ static int convert_variable_type(Dwarf_Die *vr_die,
 				   dwarf_diename(vr_die), dwarf_diename(&type));
 			return -EINVAL;
 		}
+		if (die_get_real_type(&type, &type) == NULL) {
+			pr_warning("Failed to get a type"
+				   " information.\n");
+			return -ENOENT;
+		}
 		if (ret == DW_TAG_pointer_type) {
-			if (die_get_real_type(&type, &type) == NULL) {
-				pr_warning("Failed to get a type"
-					   " information.\n");
-				return -ENOENT;
-			}
 			while (*ref_ptr)
 				ref_ptr = &(*ref_ptr)->next;
 			/* Add new reference with offset +0 */
Signature · 1 line
1.7.10.4
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · Hyeoncheol Lee

Before casting a type of a variable to string, convert_variable_type() confirms that the type is a pointer or an array. if it is a pointer to char, it is casted to string. but in case of an array of char, it isn't

Oops, right! I missed the array case. This must be fixed.

Thank you!

Quoted 31 lines
Cc Masami Hiramatsu <[email protected]>
Cc Srikar Dronamraju <[email protected]>
---
 tools/perf/util/probe-finder.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
tools/perf/util/probe-finder.c +5 -5
index 1daf5c1..be03293 100644
@@ -413,12 +413,12 @@ static int convert_variable_type(Dwarf_Die *vr_die,
 				   dwarf_diename(vr_die), dwarf_diename(&type));
 			return -EINVAL;
 		}
+		if (die_get_real_type(&type, &type) == NULL) {
+			pr_warning("Failed to get a type"
+				   " information.\n");
+			return -ENOENT;
+		}
 		if (ret == DW_TAG_pointer_type) {
-			if (die_get_real_type(&type, &type) == NULL) {
-				pr_warning("Failed to get a type"
-					   " information.\n");
-				return -ENOENT;
-			}
 			while (*ref_ptr)
 				ref_ptr = &(*ref_ptr)->next;
 			/* Add new reference with offset +0 */
Signature · 4 lines
Masami HIRAMATSU
Software Platform Research Dept. Linux Technology Center
Hitachi, Ltd., Yokohama Research Laboratory
E-mail: [email protected]