@@ -1165,22 +1165,31 @@ static int trace__symbols_init(struct trace *trace, struct perf_evlist *evlist)
1165
1165
return err ;
1166
1166
}
1167
1167
1168
- static int syscall__set_arg_fmts (struct syscall * sc )
1168
+ static int syscall__alloc_arg_fmts (struct syscall * sc , int nr_args )
1169
1169
{
1170
- struct format_field * field ;
1171
- int idx = 0 , len ;
1170
+ int idx ;
1172
1171
1173
- sc -> arg_fmt = calloc (sc -> nr_args , sizeof (* sc -> arg_fmt ));
1172
+ sc -> arg_fmt = calloc (nr_args , sizeof (* sc -> arg_fmt ));
1174
1173
if (sc -> arg_fmt == NULL )
1175
1174
return -1 ;
1176
1175
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 )
1179
1178
sc -> arg_fmt [idx ] = sc -> fmt -> arg [idx ];
1179
+ }
1180
1180
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 ;
1184
1193
1185
1194
if (strcmp (field -> type , "const char *" ) == 0 &&
1186
1195
(strcmp (field -> name , "filename" ) == 0 ||
@@ -1251,11 +1260,13 @@ static int trace__read_syscall_info(struct trace *trace, int id)
1251
1260
sc -> tp_format = trace_event__tp_format ("syscalls" , tp_name );
1252
1261
}
1253
1262
1263
+ if (syscall__alloc_arg_fmts (sc , IS_ERR (sc -> tp_format ) ? 6 : sc -> tp_format -> format .nr_fields ))
1264
+ return -1 ;
1265
+
1254
1266
if (IS_ERR (sc -> tp_format ))
1255
1267
return -1 ;
1256
1268
1257
1269
sc -> args = sc -> tp_format -> format .fields ;
1258
- sc -> nr_args = sc -> tp_format -> format .nr_fields ;
1259
1270
/*
1260
1271
* We need to check and discard the first variable '__syscall_nr'
1261
1272
* or 'nr' that mean the syscall number. It is needless here.
0 commit comments