Skip to content

Commit b3bc854

Browse files
committed
tracing: Have TRACE_DEFINE_ENUM affect trace event types as well
The macro TRACE_DEFINE_ENUM is used to convert enums in the kernel to their actual value when they are exported to user space via the trace event format file. Currently only the enums in the "print fmt" (TP_printk in the TRACE_EVENT macro) have the enums converted. But the enums can be used to denote array size: field:unsigned int fc_ineligible_rc[EXT4_FC_REASON_MAX]; offset:12; size:36; signed:0; The EXT4_FC_REASON_MAX has no meaning to userspace but it needs to know that information to know how to parse the array. Have the array indexes also be parsed as well. Link: https://lore.kernel.org/all/cover.1646922487.git.riteshh@linux.ibm.com/ Reported-by: Ritesh Harjani <riteshh@linux.ibm.com> Tested-by: Ritesh Harjani <riteshh@linux.ibm.com> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 9f438d4 commit b3bc854

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

kernel/trace/trace_events.c

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,6 +2633,33 @@ static void update_event_printk(struct trace_event_call *call,
26332633
}
26342634
}
26352635

2636+
static void update_event_fields(struct trace_event_call *call,
2637+
struct trace_eval_map *map)
2638+
{
2639+
struct ftrace_event_field *field;
2640+
struct list_head *head;
2641+
char *ptr;
2642+
int len = strlen(map->eval_string);
2643+
2644+
head = trace_get_fields(call);
2645+
list_for_each_entry(field, head, link) {
2646+
ptr = strchr(field->type, '[');
2647+
if (!ptr)
2648+
continue;
2649+
ptr++;
2650+
2651+
if (!isalpha(*ptr) && *ptr != '_')
2652+
continue;
2653+
2654+
if (strncmp(map->eval_string, ptr, len) != 0)
2655+
continue;
2656+
2657+
ptr = eval_replace(ptr, map, len);
2658+
/* enum/sizeof string smaller than value */
2659+
WARN_ON_ONCE(!ptr);
2660+
}
2661+
}
2662+
26362663
void trace_event_eval_update(struct trace_eval_map **map, int len)
26372664
{
26382665
struct trace_event_call *call, *p;
@@ -2668,6 +2695,7 @@ void trace_event_eval_update(struct trace_eval_map **map, int len)
26682695
first = false;
26692696
}
26702697
update_event_printk(call, map[i]);
2698+
update_event_fields(call, map[i]);
26712699
}
26722700
}
26732701
}

0 commit comments

Comments
 (0)