Skip to content

Commit e34f6ac

Browse files
Leo-Yannamhyung
authored andcommitted
perf probe: Improve log for long event name failure
If a symbol name is longer than the maximum event length (64 bytes), the perf tool reports error: # perf probe -x test_cpp_mangle --add "this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)" snprintf() failed: -7; the event name nbase='this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)' is too long Error: Failed to add events. An information is missed in the log that the symbol name and the event name can be set separately. Especially, this is recommended for adding probe for a long symbol. This commit refines the log for reminding event syntax. After: # perf probe -x test_cpp_mangle --add "this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)" snprintf() failed: -7; the event name 'this_is_a_very_very_long_print_data_abcdefghijklmnopqrstuvwxyz(int)' is too long Hint: Set a shorter event with syntax "EVENT=PROBEDEF" EVENT: Event name (max length: 64 bytes). Error: Failed to add events. Signed-off-by: Leo Yan <leo.yan@arm.com> Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org> Link: https://lore.kernel.org/r/20241012204725.928794-4-leo.yan@arm.com Signed-off-by: Namhyung Kim <namhyung@kernel.org>
1 parent 6768faf commit e34f6ac

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/perf/util/probe-event.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,7 +2760,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
27602760
/* Try no suffix number */
27612761
ret = e_snprintf(buf, len, "%s%s", nbase, ret_event ? "__return" : "");
27622762
if (ret < 0) {
2763-
pr_warning("snprintf() failed: %d; the event name nbase='%s' is too long\n", ret, nbase);
2763+
pr_warning("snprintf() failed: %d; the event name '%s' is too long\n"
2764+
" Hint: Set a shorter event with syntax \"EVENT=PROBEDEF\"\n"
2765+
" EVENT: Event name (max length: %d bytes).\n",
2766+
ret, nbase, MAX_EVENT_NAME_LEN);
27642767
goto out;
27652768
}
27662769
if (!strlist__has_entry(namelist, buf))
@@ -2780,7 +2783,10 @@ static int get_new_event_name(char *buf, size_t len, const char *base,
27802783
for (i = 1; i < MAX_EVENT_INDEX; i++) {
27812784
ret = e_snprintf(buf, len, "%s_%d", nbase, i);
27822785
if (ret < 0) {
2783-
pr_debug("snprintf() failed: %d\n", ret);
2786+
pr_warning("Add suffix failed: %d; the event name '%s' is too long\n"
2787+
" Hint: Set a shorter event with syntax \"EVENT=PROBEDEF\"\n"
2788+
" EVENT: Event name (max length: %d bytes).\n",
2789+
ret, nbase, MAX_EVENT_NAME_LEN);
27842790
goto out;
27852791
}
27862792
if (!strlist__has_entry(namelist, buf))

0 commit comments

Comments
 (0)