Skip to contentSkip to conversation

tools lib traceevent: Add direct access to dynamic arrays

PATCH In review Steven Rostedt 3 participants 3 messages Nov 11, 2013 – Nov 12, 2013

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools lib traceevent: Add direct access to dynamic arrays

Jiri Olsa was writing a plugin for the cfg80211_tx_mlme_mgmt trace event, and was not able to get the implemented function working. The event's print fmt looks like:

"netdev:%s(%d), ftype:0x%.2x", REC->name, REC->ifindex,

            __le16_to_cpup((__le16 *)__get_dynamic_array(frame))

As there's no helper function for __le16_to_cpup(), Jiri was creating one with a plugin. But unfortunately, it would not work even though he set up the plugin correctly.

The problem is that the function parameters do not handle the helper function "__get_dynamic_array()", and that passes in a NULL pointer.

Adding PRINT_DYNAMIC_ARRAY direct support to eval_num_arg() allows the use of __get_dynamic_array() in function parameters.

---
 tools/lib/traceevent/event-parse.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/lib/traceevent/event-parse.c +13 -0
index 8f450ad..0362d57 100644
@@ -3435,6 +3435,19 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
 			goto out_warning_op;
 		}
 		break;
+	case PRINT_DYNAMIC_ARRAY:
+		/* Without [], we pass the address to the dynamic data */
+		offset = pevent_read_number(pevent,
+					    data + arg->dynarray.field->offset,
+					    arg->dynarray.field->size);
+		/*
+		 * The actual length of the dynamic array is stored
+		 * in the top half of the field, and the offset
+		 * is in the bottom half of the 32 bit field.
+		 */
+		offset &= 0xffff;
+		val = (unsigned long long)(data + offset);
+		break;
 	default: /* not sure what to do there */
 		return 0;
 	}
Signature · 1 line
1.8.4.rc3
Tested-by on v1 1/1
#1 lore raw
Quoted 12 lines · Steven Rostedt

Jiri Olsa was writing a plugin for the cfg80211_tx_mlme_mgmt trace event, and was not able to get the implemented function working. The event's print fmt looks like:

   "netdev:%s(%d), ftype:0x%.2x", REC->name, REC->ifindex,
            __le16_to_cpup((__le16 *)__get_dynamic_array(frame))

As there's no helper function for __le16_to_cpup(), Jiri was creating one with a plugin. But unfortunately, it would not work even though he set up the plugin correctly.

Quoted 8 lines

The problem is that the function parameters do not handle the helper function "__get_dynamic_array()", and that passes in a NULL pointer.

Adding PRINT_DYNAMIC_ARRAY direct support to eval_num_arg() allows the use of __get_dynamic_array() in function parameters.

cool, thanks

jirka

#2 lore raw
In reply to Steven Rostedt
tools lib traceevent: Add direct access to dynamic arrays
Commit-ID:  0497a9ebaf7ae4d573497b3e053ad4c3d5c9921d
Gitweb:     http://git.kernel.org/tip/0497a9ebaf7ae4d573497b3e053ad4c3d5c9921d
Author:     Steven Rostedt <[email protected]>
AuthorDate: Mon, 11 Nov 2013 16:08:10 -0500
Committer:  Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Tue, 12 Nov 2013 17:23:44 -0300

tools lib traceevent: Add direct access to dynamic arrays

Jiri Olsa was writing a plugin for the cfg80211_tx_mlme_mgmt trace event, and was not able to get the implemented function working. The event's print fmt looks like:

"netdev:%s(%d), ftype:0x%.2x", REC->name, REC->ifindex,

            __le16_to_cpup((__le16 *)__get_dynamic_array(frame))

As there's no helper function for __le16_to_cpup(), Jiri was creating one with a plugin. But unfortunately, it would not work even though he set up the plugin correctly.

The problem is that the function parameters do not handle the helper function "__get_dynamic_array()", and that passes in a NULL pointer.

Adding PRINT_DYNAMIC_ARRAY direct support to eval_num_arg() allows the use of __get_dynamic_array() in function parameters.

---
 tools/lib/traceevent/event-parse.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)
tools/lib/traceevent/event-parse.c +13 -0
index 8f450ad..0362d57 100644
@@ -3435,6 +3435,19 @@ eval_num_arg(void *data, int size, struct event_format *event, struct print_arg
 			goto out_warning_op;
 		}
 		break;
+	case PRINT_DYNAMIC_ARRAY:
+		/* Without [], we pass the address to the dynamic data */
+		offset = pevent_read_number(pevent,
+					    data + arg->dynarray.field->offset,
+					    arg->dynarray.field->size);
+		/*
+		 * The actual length of the dynamic array is stored
+		 * in the top half of the field, and the offset
+		 * is in the bottom half of the 32 bit field.
+		 */
+		offset &= 0xffff;
+		val = (unsigned long long)(data + offset);
+		break;
 	default: /* not sure what to do there */
 		return 0;
 	}