aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Rostedt <srostedt@redhat.com>2010-03-25 22:24:29 -0400
committerSteven Rostedt <rostedt@goodmis.org>2010-03-25 22:24:29 -0400
commit8d248f782dd45ab0512be2a9ccb22a15b7288459 (patch)
tree342b469b04b6489661c890a49255d3f8a1bf54af
parentb8981da8e693107bb9142f7629dab8f1253529d5 (diff)
parse-events: Print raw fields of type long in hex
When raw fields are printing, check if the field is of type long. Since longs usually store pointers, it makes more sense to print out a hex number for a field declared as long than decimal. Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--parse-events.c28
-rw-r--r--parse-events.h1
2 files changed, 26 insertions, 3 deletions
diff --git a/parse-events.c b/parse-events.c
index c1415db..e9f122a 100644
--- a/parse-events.c
+++ b/parse-events.c
@@ -1146,6 +1146,15 @@ static int field_is_dynamic(struct format_field *field)
1146 return 0; 1146 return 0;
1147} 1147}
1148 1148
1149static int field_is_long(struct format_field *field)
1150{
1151 /* includes long long */
1152 if (strstr(field->type, "long"))
1153 return 1;
1154
1155 return 0;
1156}
1157
1149static int event_read_fields(struct event_format *event, struct format_field **fields) 1158static int event_read_fields(struct event_format *event, struct format_field **fields)
1150{ 1159{
1151 struct format_field *field = NULL; 1160 struct format_field *field = NULL;
@@ -1297,6 +1306,8 @@ static int event_read_fields(struct event_format *event, struct format_field **f
1297 field->flags |= FIELD_IS_STRING; 1306 field->flags |= FIELD_IS_STRING;
1298 if (field_is_dynamic(field)) 1307 if (field_is_dynamic(field))
1299 field->flags |= FIELD_IS_DYNAMIC; 1308 field->flags |= FIELD_IS_DYNAMIC;
1309 if (field_is_long(field))
1310 field->flags |= FIELD_IS_LONG;
1300 1311
1301 if (test_type_token(type, token, EVENT_OP, ";")) 1312 if (test_type_token(type, token, EVENT_OP, ";"))
1302 goto fail; 1313 goto fail;
@@ -3415,7 +3426,14 @@ static void print_event_fields(struct trace_seq *s, void *data, int size,
3415 } else if (field->flags & FIELD_IS_SIGNED) { 3426 } else if (field->flags & FIELD_IS_SIGNED) {
3416 switch (field->size) { 3427 switch (field->size) {
3417 case 4: 3428 case 4:
3418 trace_seq_printf(s, "%d", (int)val); 3429 /*
3430 * If field is long then print it in hex.
3431 * A long usually stores pointers.
3432 */
3433 if (field->flags & FIELD_IS_LONG)
3434 trace_seq_printf(s, "0x%x", (int)val);
3435 else
3436 trace_seq_printf(s, "%d", (int)val);
3419 break; 3437 break;
3420 case 2: 3438 case 2:
3421 trace_seq_printf(s, "%2d", (short)val); 3439 trace_seq_printf(s, "%2d", (short)val);
@@ -3426,8 +3444,12 @@ static void print_event_fields(struct trace_seq *s, void *data, int size,
3426 default: 3444 default:
3427 trace_seq_printf(s, "%lld", val); 3445 trace_seq_printf(s, "%lld", val);
3428 } 3446 }
3429 } else 3447 } else {
3430 trace_seq_printf(s, "%llu", val); 3448 if (field->flags & FIELD_IS_LONG)
3449 trace_seq_printf(s, "0x%llx", val);
3450 else
3451 trace_seq_printf(s, "%llu", val);
3452 }
3431 } 3453 }
3432 field = field->next; 3454 field = field->next;
3433 } 3455 }
diff --git a/parse-events.h b/parse-events.h
index ba4ef73..03b382e 100644
--- a/parse-events.h
+++ b/parse-events.h
@@ -107,6 +107,7 @@ enum format_flags {
107 FIELD_IS_SIGNED = 4, 107 FIELD_IS_SIGNED = 4,
108 FIELD_IS_STRING = 8, 108 FIELD_IS_STRING = 8,
109 FIELD_IS_DYNAMIC = 16, 109 FIELD_IS_DYNAMIC = 16,
110 FIELD_IS_LONG = 32,
110}; 111};
111 112
112struct format_field { 113struct format_field {