Skip to content

Commit 2f63e5d

Browse files
mhiramatrostedt
authored andcommitted
tracing/eprobe: Show syntax error logs in error_log file
Show the syntax errors for event probes in error_log file as same as other dynamic events, so that user can understand what is the problem. Link: https://lkml.kernel.org/r/165932113556.2850673.3483079297896607612.stgit@devnote2 Signed-off-by: Masami Hiramatsu (Google) <[email protected]> Signed-off-by: Steven Rostedt (Google) <[email protected]>
1 parent 95522f0 commit 2f63e5d

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

kernel/trace/trace_eprobe.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -839,8 +839,11 @@ static int trace_eprobe_tp_update_arg(struct trace_eprobe *ep, const char *argv[
839839
if (ret)
840840
return ret;
841841

842-
if (ep->tp.args[i].code->op == FETCH_OP_TP_ARG)
842+
if (ep->tp.args[i].code->op == FETCH_OP_TP_ARG) {
843843
ret = trace_eprobe_tp_arg_update(ep, i);
844+
if (ret)
845+
trace_probe_log_err(0, BAD_ATTACH_ARG);
846+
}
844847

845848
return ret;
846849
}
@@ -880,8 +883,10 @@ static int __trace_eprobe_create(int argc, const char *argv[])
880883
trace_probe_log_set_index(1);
881884
sys_event = argv[1];
882885
ret = traceprobe_parse_event_name(&sys_event, &sys_name, buf2, 0);
883-
if (!sys_event || !sys_name)
886+
if (!sys_event || !sys_name) {
887+
trace_probe_log_err(0, NO_EVENT_INFO);
884888
goto parse_error;
889+
}
885890

886891
if (!event) {
887892
strscpy(buf1, argv[1], MAX_EVENT_NAME_LEN);
@@ -896,6 +901,8 @@ static int __trace_eprobe_create(int argc, const char *argv[])
896901

897902
if (IS_ERR(ep)) {
898903
ret = PTR_ERR(ep);
904+
if (ret == -ENODEV)
905+
trace_probe_log_err(0, BAD_ATTACH_EVENT);
899906
/* This must return -ENOMEM or missing event, else there is a bug */
900907
WARN_ON_ONCE(ret != -ENOMEM && ret != -ENODEV);
901908
ep = NULL;

kernel/trace/trace_probe.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,10 @@ extern int traceprobe_define_arg_fields(struct trace_event_call *event_call,
442442
C(FAIL_REG_PROBE, "Failed to register probe event"),\
443443
C(DIFF_PROBE_TYPE, "Probe type is different from existing probe"),\
444444
C(DIFF_ARG_TYPE, "Argument type or name is different from existing probe"),\
445-
C(SAME_PROBE, "There is already the exact same probe event"),
445+
C(SAME_PROBE, "There is already the exact same probe event"),\
446+
C(NO_EVENT_INFO, "This requires both group and event name to attach"),\
447+
C(BAD_ATTACH_EVENT, "Attached event does not exist"),\
448+
C(BAD_ATTACH_ARG, "Attached event does not have this field"),
446449

447450
#undef C
448451
#define C(a, b) TP_ERR_##a

0 commit comments

Comments
 (0)