Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349988
b: refs/heads/master
c: e23c1a5
h: refs/heads/master
v: v3
  • Loading branch information
Jiri Olsa authored and Arnaldo Carvalho de Melo committed Jan 25, 2013
1 parent f17d6a3 commit 4621a58
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: a2d28d0c198b65fac28ea6212f5f8edc77b29c27
refs/heads/master: e23c1a5578cf32ed3a7ac9dde59a2de0a52ff812
39 changes: 37 additions & 2 deletions trunk/tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,34 @@ static int field_is_long(struct format_field *field)
return 0;
}

static unsigned int type_size(const char *name)
{
/* This covers all FIELD_IS_STRING types. */
static struct {
const char *type;
unsigned int size;
} table[] = {
{ "u8", 1 },
{ "u16", 2 },
{ "u32", 4 },
{ "u64", 8 },
{ "s8", 1 },
{ "s16", 2 },
{ "s32", 4 },
{ "s64", 8 },
{ "char", 1 },
{ },
};
int i;

for (i = 0; table[i].type; i++) {
if (!strcmp(table[i].type, name))
return table[i].size;
}

return 0;
}

static int event_read_fields(struct event_format *event, struct format_field **fields)
{
struct format_field *field = NULL;
Expand All @@ -1232,6 +1260,8 @@ static int event_read_fields(struct event_format *event, struct format_field **f
int count = 0;

do {
unsigned int size_dynamic = 0;

type = read_token(&token);
if (type == EVENT_NEWLINE) {
free_token(token);
Expand Down Expand Up @@ -1390,6 +1420,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f
field->type = new_type;
strcat(field->type, " ");
strcat(field->type, field->name);
size_dynamic = type_size(field->name);
free_token(field->name);
strcat(field->type, brackets);
field->name = token;
Expand Down Expand Up @@ -1478,10 +1509,14 @@ static int event_read_fields(struct event_format *event, struct format_field **f
if (field->flags & FIELD_IS_ARRAY) {
if (field->arraylen)
field->elementsize = field->size / field->arraylen;
else if (field->flags & FIELD_IS_DYNAMIC)
field->elementsize = size_dynamic;
else if (field->flags & FIELD_IS_STRING)
field->elementsize = 1;
else
field->elementsize = event->pevent->long_size;
else if (field->flags & FIELD_IS_LONG)
field->elementsize = event->pevent ?
event->pevent->long_size :
sizeof(long);
} else
field->elementsize = field->size;

Expand Down

0 comments on commit 4621a58

Please sign in to comment.