Skip to content

Commit 3dd3aae

Browse files
mhiramatrostedt
authored andcommitted
tracing/uprobes: Support perf-style return probe
Support perf-style return probe ("SYMBOL%return") for uprobe events as same as kprobe events does. Link: https://lkml.kernel.org/r/159972814601.428528.7641183316212425445.stgit@devnote2 Signed-off-by: Masami Hiramatsu <mhiramat@kernel.org> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
1 parent 4725cd8 commit 3dd3aae

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎kernel/trace/trace.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5125,7 +5125,7 @@ static const char readme_msg[] =
51255125
"place (kretprobe): [<module>:]<symbol>[+<offset>]%return|<memaddr>\n"
51265126
#endif
51275127
#ifdef CONFIG_UPROBE_EVENTS
5128-
" place (uprobe): <path>:<offset>[(ref_ctr_offset)]\n"
5128+
" place (uprobe): <path>:<offset>[%return][(ref_ctr_offset)]\n"
51295129
#endif
51305130
"\t args: <name>=fetcharg[:type]\n"
51315131
"\t fetcharg: %<register>, @<address>, @<symbol>[+|-<offset>],\n"

‎kernel/trace/trace_uprobe.c‎

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -528,7 +528,7 @@ static int register_trace_uprobe(struct trace_uprobe *tu)
528528

529529
/*
530530
* Argument syntax:
531-
* - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET [FETCHARGS]
531+
* - Add uprobe: p|r[:[GRP/]EVENT] PATH:OFFSET[%return][(REF)] [FETCHARGS]
532532
*/
533533
static int trace_uprobe_create(int argc, const char **argv)
534534
{
@@ -617,6 +617,19 @@ static int trace_uprobe_create(int argc, const char **argv)
617617
}
618618
}
619619

620+
/* Check if there is %return suffix */
621+
tmp = strchr(arg, '%');
622+
if (tmp) {
623+
if (!strcmp(tmp, "%return")) {
624+
*tmp = '\0';
625+
is_return = true;
626+
} else {
627+
trace_probe_log_err(tmp - filename, BAD_ADDR_SUFFIX);
628+
ret = -EINVAL;
629+
goto fail_address_parse;
630+
}
631+
}
632+
620633
/* Parse uprobe offset. */
621634
ret = kstrtoul(arg, 0, &offset);
622635
if (ret) {

0 commit comments

Comments
 (0)