Skip to content

Commit 5e58fcf

Browse files
committed
perf trace: Allow allocating sc->arg_fmt even without the syscall tracepoint
At least "clone" doesn't have (enter, exit) entries tracefs/events/syscalls/, but we can provide a syscall_fmt and use it instead, as will be done for "clone" in the next cset. Cc: Adrian Hunter <[email protected]> Cc: David Ahern <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/n/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent d57da8c commit 5e58fcf

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

tools/perf/builtin-trace.c

+21-10
Original file line numberDiff line numberDiff line change
@@ -1165,22 +1165,31 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
11651165
return err;
11661166
}
11671167

1168-
static int syscall__set_arg_fmts(struct syscall *sc)
1168+
static int syscall__alloc_arg_fmts(struct syscall *sc, int nr_args)
11691169
{
1170-
struct format_field *field;
1171-
int idx = 0, len;
1170+
int idx;
11721171

1173-
sc->arg_fmt = calloc(sc->nr_args, sizeof(*sc->arg_fmt));
1172+
sc->arg_fmt = calloc(nr_args, sizeof(*sc->arg_fmt));
11741173
if (sc->arg_fmt == NULL)
11751174
return -1;
11761175

1177-
for (field = sc->args; field; field = field->next, ++idx) {
1178-
if (sc->fmt) {
1176+
for (idx = 0; idx < nr_args; ++idx) {
1177+
if (sc->fmt)
11791178
sc->arg_fmt[idx] = sc->fmt->arg[idx];
1179+
}
11801180

1181-
if (sc->fmt->arg[idx].scnprintf)
1182-
continue;
1183-
}
1181+
sc->nr_args = nr_args;
1182+
return 0;
1183+
}
1184+
1185+
static int syscall__set_arg_fmts(struct syscall *sc)
1186+
{
1187+
struct format_field *field;
1188+
int idx = 0, len;
1189+
1190+
for (field = sc->args; field; field = field->next, ++idx) {
1191+
if (sc->fmt && sc->fmt->arg[idx].scnprintf)
1192+
continue;
11841193

11851194
if (strcmp(field->type, "const char *") == 0 &&
11861195
(strcmp(field->name, "filename") == 0 ||
@@ -1251,11 +1260,13 @@ static int trace__read_syscall_info(struct trace *trace, int id)
12511260
sc->tp_format = trace_event__tp_format("syscalls", tp_name);
12521261
}
12531262

1263+
if (syscall__alloc_arg_fmts(sc, IS_ERR(sc->tp_format) ? 6 : sc->tp_format->format.nr_fields))
1264+
return -1;
1265+
12541266
if (IS_ERR(sc->tp_format))
12551267
return -1;
12561268

12571269
sc->args = sc->tp_format->format.fields;
1258-
sc->nr_args = sc->tp_format->format.nr_fields;
12591270
/*
12601271
* We need to check and discard the first variable '__syscall_nr'
12611272
* or 'nr' that mean the syscall number. It is needless here.

0 commit comments

Comments
 (0)