Skip to content

Commit

Permalink
tools lib traceevent: Handle __attribute__((user)) in field names
Browse files Browse the repository at this point in the history
Commit c61f13e ("gcc-plugins: Add structleak for more stack
initialization") added "__attribute__((user))" to the user when
stackleak detector is enabled. This now appears in the field format of
system call trace events for system calls that have user buffers. The
"__attribute__((user))" breaks the parsing in libtraceevent. That needs
to be handled.

Signed-off-by: Steven Rostedt (VMware) <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Jaewon Kim <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kees Kook <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: [email protected]
Cc: [email protected]
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
rostedt authored and acmel committed Jun 18, 2020
1 parent 27d4d33 commit 74621d9
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1444,6 +1444,7 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field **
enum tep_event_type type;
char *token;
char *last_token;
char *delim = " ";
int count = 0;
int ret;

Expand Down Expand Up @@ -1504,13 +1505,49 @@ static int event_read_fields(struct tep_event *event, struct tep_format_field **
field->flags |= TEP_FIELD_IS_POINTER;

if (field->type) {
ret = append(&field->type, " ", last_token);
ret = append(&field->type, delim, last_token);
free(last_token);
if (ret < 0)
goto fail;
} else
field->type = last_token;
last_token = token;
delim = " ";
continue;
}

/* Handle __attribute__((user)) */
if ((type == TEP_EVENT_DELIM) &&
strcmp("__attribute__", last_token) == 0 &&
token[0] == '(') {
int depth = 1;
int ret;

ret = append(&field->type, " ", last_token);
ret |= append(&field->type, "", "(");
if (ret < 0)
goto fail;

delim = " ";
while ((type = read_token(&token)) != TEP_EVENT_NONE) {
if (type == TEP_EVENT_DELIM) {
if (token[0] == '(')
depth++;
else if (token[0] == ')')
depth--;
if (!depth)
break;
ret = append(&field->type, "", token);
delim = "";
} else {
ret = append(&field->type, delim, token);
delim = " ";
}
if (ret < 0)
goto fail;
free(last_token);
last_token = token;
}
continue;
}
break;
Expand Down

0 comments on commit 74621d9

Please sign in to comment.