History

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

Steven Rostedt (Google) committed 4 years ago

Commit f04dec91 parent 02333de1 file · +21 −0Browse files

Showing the changes to kernel (1 of 1 file). Show all

Unified · Split

kernel/trace/trace_eprobe.c+21−0
@@ -311,6 +311,27 @@ static unsigned long get_event_field(struct fetch_insn *code, void *rec) · 310 unmodified lines
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)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t