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/[email protected] Cc: [email protected] Cc: Ingo Molnar <[email protected]> Cc: Andrew Morton <[email protected]> Cc: Tzvetomir Stoyanov <[email protected]> Cc: Tom Zanussi <[email protected]> Fixes: 7491e2c ("tracing: Add a probe that attaches to trace events") Acked-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 02333de commit f04dec9

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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)