diff options
author | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-10-25 16:24:45 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2018-10-30 10:46:23 -0400 |
commit | f932184e282f574cfd34afee917a10b782fd3e76 (patch) | |
tree | 5aaf2c7a32040c30c0e82f771bd7fd7f70f9dd27 | |
parent | 73d141adcea66de656d0c8336811f2b0bbd9700c (diff) |
perf trace: Consider syscall aliases too
When trying to trace the 'umount' syscall on x86_64 I noticed that it
was failing:
# trace -e umount umount /mnt
event syntax error: 'umount'
\___ parser error
Run 'perf list' for a list of valid events
Usage: perf trace [<options>] [<command>]
or: perf trace [<options>] -- <command> [<options>]
or: perf trace record [<options>] [<command>]
or: perf trace record [<options>] -- <command> [<options>]
-e, --event <event> event/syscall selector. use 'perf list' to list available events
#
This is because in the x86-64 we have it just as 'umount2':
$ grep umount arch/x86/entry/syscalls/syscall_64.tbl
166 common umount2 __x64_sys_umount
$
So if the syscall name fails, try fallbacking to looking at the aliases
we have in the syscall_fmts table to then re-lookup, now:
# trace -e umount umount -f /mnt
umount: /mnt: not mounted.
1.759 ( 0.004 ms): umount/18365 umount2(name: 0x55fbfcbc4480, flags: 1) = -1 EINVAL Invalid argument
#
Time to beautify the flags arg :-)
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Benjamin Peterson <benjamin@python.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: https://lkml.kernel.org/n/tip-ukweodgzbmjd25lfkgryeft1@git.kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/builtin-trace.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 76c14c0129fc..db8711061ca3 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c | |||
@@ -862,6 +862,18 @@ static struct syscall_fmt *syscall_fmt__find(const char *name) | |||
862 | return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp); | 862 | return bsearch(name, syscall_fmts, nmemb, sizeof(struct syscall_fmt), syscall_fmt__cmp); |
863 | } | 863 | } |
864 | 864 | ||
865 | static struct syscall_fmt *syscall_fmt__find_by_alias(const char *alias) | ||
866 | { | ||
867 | int i, nmemb = ARRAY_SIZE(syscall_fmts); | ||
868 | |||
869 | for (i = 0; i < nmemb; ++i) { | ||
870 | if (syscall_fmts[i].alias && strcmp(syscall_fmts[i].alias, alias) == 0) | ||
871 | return &syscall_fmts[i]; | ||
872 | } | ||
873 | |||
874 | return NULL; | ||
875 | } | ||
876 | |||
865 | /* | 877 | /* |
866 | * is_exit: is this "exit" or "exit_group"? | 878 | * is_exit: is this "exit" or "exit_group"? |
867 | * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter. | 879 | * is_open: is this "open" or "openat"? To associate the fd returned in sys_exit with the pathname in sys_enter. |
@@ -3195,6 +3207,7 @@ static int trace__parse_events_option(const struct option *opt, const char *str, | |||
3195 | int len = strlen(str) + 1, err = -1, list, idx; | 3207 | int len = strlen(str) + 1, err = -1, list, idx; |
3196 | char *strace_groups_dir = system_path(STRACE_GROUPS_DIR); | 3208 | char *strace_groups_dir = system_path(STRACE_GROUPS_DIR); |
3197 | char group_name[PATH_MAX]; | 3209 | char group_name[PATH_MAX]; |
3210 | struct syscall_fmt *fmt; | ||
3198 | 3211 | ||
3199 | if (strace_groups_dir == NULL) | 3212 | if (strace_groups_dir == NULL) |
3200 | return -1; | 3213 | return -1; |
@@ -3212,12 +3225,19 @@ static int trace__parse_events_option(const struct option *opt, const char *str, | |||
3212 | if (syscalltbl__id(trace->sctbl, s) >= 0 || | 3225 | if (syscalltbl__id(trace->sctbl, s) >= 0 || |
3213 | syscalltbl__strglobmatch_first(trace->sctbl, s, &idx) >= 0) { | 3226 | syscalltbl__strglobmatch_first(trace->sctbl, s, &idx) >= 0) { |
3214 | list = 1; | 3227 | list = 1; |
3228 | goto do_concat; | ||
3229 | } | ||
3230 | |||
3231 | fmt = syscall_fmt__find_by_alias(s); | ||
3232 | if (fmt != NULL) { | ||
3233 | list = 1; | ||
3234 | s = fmt->name; | ||
3215 | } else { | 3235 | } else { |
3216 | path__join(group_name, sizeof(group_name), strace_groups_dir, s); | 3236 | path__join(group_name, sizeof(group_name), strace_groups_dir, s); |
3217 | if (access(group_name, R_OK) == 0) | 3237 | if (access(group_name, R_OK) == 0) |
3218 | list = 1; | 3238 | list = 1; |
3219 | } | 3239 | } |
3220 | 3240 | do_concat: | |
3221 | if (lists[list]) { | 3241 | if (lists[list]) { |
3222 | sprintf(lists[list] + strlen(lists[list]), ",%s", s); | 3242 | sprintf(lists[list] + strlen(lists[list]), ",%s", s); |
3223 | } else { | 3243 | } else { |