Skip to content

Commit f04dec9

Browse files
committed
tracing/eprobes: Fix reading of string fields
Currently when an event probe (eprobe) hooks to a string field, it does not display it as a string, but instead as a number. This makes the field rather useless. Handle the different kinds of strings, dynamic, static, relational/dynamic etc. Now when a string field is used, the ":string" type can be used to display it: echo "e:sw sched/sched_switch comm=$next_comm:string" > dynamic_events Link: https://lkml.kernel.org/r/20220820134400.959640191@goodmis.org Cc: stable@vger.kernel.org Cc: Ingo Molnar <mingo@kernel.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Tzvetomir Stoyanov <tz.stoyanov@gmail.com> Cc: Tom Zanussi <zanussi@kernel.org> Fixes: 7491e2c ("tracing: Add a probe that attaches to trace events") Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent 02333de commit f04dec9

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

kernel/trace/trace_eprobe.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,27 @@ static unsigned long get_event_field(struct fetch_insn *code, void *rec)
311311

312312
addr = rec + field->offset;
313313

314+
if (is_string_field(field)) {
315+
switch (field->filter_type) {
316+
case FILTER_DYN_STRING:
317+
val = (unsigned long)(rec + (*(unsigned int *)addr & 0xffff));
318+
break;
319+
case FILTER_RDYN_STRING:
320+
val = (unsigned long)(addr + (*(unsigned int *)addr & 0xffff));
321+
break;
322+
case FILTER_STATIC_STRING:
323+
val = (unsigned long)addr;
324+
break;
325+
case FILTER_PTR_STRING:
326+
val = (unsigned long)(*(char *)addr);
327+
break;
328+
default:
329+
WARN_ON_ONCE(1);
330+
return 0;
331+
}
332+
return val;
333+
}
334+
314335
switch (field->size) {
315336
case 1:
316337
if (field->is_signed)

0 commit comments

Comments
 (0)