Hi,
This is a patchset which attempts to sync what we have on trace-cmd
into libtraceevent. Although some patch introduced new call-sites of
die() or malloc_or_die(), it'll be removed eventually (or later work)
and this helps marking the every locations that we need to track.
Thanks,
Namhyung
Namhyung Kim (15):
lib/traceevent: Fix printk_cmp()
lib/traceevent: Introduce extend_token()
lib/traceevent: Handle strdup failure cases
lib/traceevent: Fix a possible memory leak
lib/traceevent: Handle realloc() failure path
lib/traceevent: Fix a possibly wrong memory dereference
lib/traceevent: Fix freeing arg on process_dynamic_array()
lib/traceevent: Use proper function parameter type
lib/traceevent: Pass string type argument to args
lib/traceevent: Do not call add_event() again if allocation failed
lib/traceevent: Fix some comments
lib/traceevent: Check result of malloc() during reading token
lib/traceevent: Fix signature of create_arg_item()
lib/traceevent: Check return value of arg_to_str()
lib/traceevent: Cleanup realloc use
Peter Huewe (1):
lib/traceevent: Add missing break in make_bprint_args
Stefan Hajnoczi (1):
lib/traceevent: Allow expressions in __print_symbolic() fields
Steven Rostedt (4):
lib/traceevent: Let filtering numbers by string use function names
lib/traceevent: Add support for "%.*s" in bprintk events
lib/traceevent: Add support to show migrate disable counter
lib/traceevent: Fix %pM print format arg handling
Wolfgang Mauerer (1):
lib/traceevent: Fix trace_printk for long integers
tools/lib/traceevent/event-parse.c | 309 ++++++++++++++++++++++++-----------
tools/lib/traceevent/parse-filter.c | 91 +++++++----
2 files changed, 271 insertions(+), 129 deletions(-)
--
1.7.10.1
From: Steven Rostedt <[email protected]>
When %pM is used, the arg value must be a 6 byte character that
will be printed as a 6 byte MAC address. But the code does a break
over the main code which updates the current processing arg to point
to the next arg. If there are other print arguments after a %pM,
they will be off by one. The next arg will still be processing the
%pM arg.
Reported-by: Johannes Berg <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/event-parse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 4dc0313b4a50..9216aef78394 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3761,6 +3761,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
} else if (*(ptr+1) == 'M' || *(ptr+1) == 'm') {
print_mac_arg(s, *(ptr+1), data, size, event, arg);
ptr++;
+ arg = arg->next;
break;
}
--
1.7.10.1
If set_op_prio() failed, the token will be freed at out_free,
then arg->op.op would turn out to be a dangle pointer. After
returning EVENT_ERROR from process_op(), free_arg() will be
called and then it will finally see the dangling pointer.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 6a8e3169ac68..865d0f268274 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1747,6 +1747,8 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
if (set_op_prio(arg) == -1) {
event->flags |= EVENT_FL_FAILED;
+ /* arg->op.op (= token) will be freed at out_free */
+ arg->op.op = NULL;
goto out_free;
}
--
1.7.10.1
From: Peter Huewe <[email protected]>
In the current code we asign vsize=8 and then fall through to the
default and asign vsize=1. -> probably the break is missing here,
otherwise we can remove the case.
Signed-off-by: Peter Huewe <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/event-parse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index f62f76658d51..f02890530425 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3523,6 +3523,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
break;
case 2:
vsize = 8;
+ break;
default:
vsize = ls; /* ? */
break;
--
1.7.10.1
The @type should be a type of enum event_type not enum
filter_arg_type. This fixes following warning:
$ make
COMPILE FPIC parse-events.o
COMPILE FPIC parse-filter.o
/home/namhyung/project/trace-cmd/parse-filter.c: In function ‘create_arg_item’:
/home/namhyung/project/trace-cmd/parse-filter.c:343:9: warning: comparison between ‘enum filter_arg_type’ and ‘enum event_type’ [-Wenum-compare]
/home/namhyung/project/trace-cmd/parse-filter.c:339:2: warning: case value ‘8’ not in enumerated type ‘enum filter_arg_type’ [-Wswitch]
BUILD STATIC LIB libparsevent.a
BUILD STATIC LIB libtracecmd.a
BUILD trace-cmd
/usr/bin/make -C /home/namhyung/project/trace-cmd/Documentation all
make[1]: Nothing to be done for `all'.
Note: to build the gui, type "make gui"
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/parse-filter.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 901f2de5bd67..a224938e1728 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -325,9 +325,8 @@ static void free_events(struct event_list *events)
}
static struct filter_arg *
-create_arg_item(struct event_format *event,
- const char *token, enum filter_arg_type type,
- char **error_str)
+create_arg_item(struct event_format *event, const char *token,
+ enum event_type type, char **error_str)
{
struct format_field *field;
struct filter_arg *arg;
--
1.7.10.1
The arg_to_str() can fail so we should handle that case properly.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/parse-filter.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index a224938e1728..05a1eeffa776 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -2026,11 +2026,13 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg)
char *lstr;
char *rstr;
char *op;
- char *str;
+ char *str = NULL;
int len;
lstr = arg_to_str(filter, arg->exp.left);
rstr = arg_to_str(filter, arg->exp.right);
+ if (!lstr || !rstr)
+ goto out;
switch (arg->exp.type) {
case FILTER_EXP_ADD:
@@ -2070,6 +2072,7 @@ static char *exp_to_str(struct event_filter *filter, struct filter_arg *arg)
len = strlen(op) + strlen(lstr) + strlen(rstr) + 4;
str = malloc_or_die(len);
snprintf(str, len, "%s %s %s", lstr, op, rstr);
+out:
free(lstr);
free(rstr);
@@ -2086,6 +2089,8 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg)
lstr = arg_to_str(filter, arg->num.left);
rstr = arg_to_str(filter, arg->num.right);
+ if (!lstr || !rstr)
+ goto out;
switch (arg->num.type) {
case FILTER_CMP_EQ:
@@ -2122,6 +2127,7 @@ static char *num_to_str(struct event_filter *filter, struct filter_arg *arg)
break;
}
+out:
free(lstr);
free(rstr);
return str;
@@ -2272,7 +2278,12 @@ int pevent_filter_compare(struct event_filter *filter1, struct event_filter *fil
/* The best way to compare complex filters is with strings */
str1 = arg_to_str(filter1, filter_type1->filter);
str2 = arg_to_str(filter2, filter_type2->filter);
- result = strcmp(str1, str2) != 0;
+ if (str1 && str2)
+ result = strcmp(str1, str2) != 0;
+ else
+ /* bail out if allocation fails */
+ result = 1;
+
free(str1);
free(str2);
if (result)
--
1.7.10.1
There were some places didn't check return value of the strdup
and had unneeded/duplicated checks. Fix it.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 29 +++++++++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index bdfc29607b49..760e7831390a 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -467,8 +467,10 @@ int pevent_register_function(struct pevent *pevent, char *func,
item->mod = NULL;
item->addr = addr;
- pevent->funclist = item;
+ if (!item->func || (mod && !item->mod))
+ die("malloc func");
+ pevent->funclist = item;
pevent->func_count++;
return 0;
@@ -583,10 +585,13 @@ int pevent_register_print_string(struct pevent *pevent, char *fmt,
item = malloc_or_die(sizeof(*item));
item->next = pevent->printklist;
- pevent->printklist = item;
item->printk = strdup(fmt);
item->addr = addr;
+ if (!item->printk)
+ die("malloc fmt");
+
+ pevent->printklist = item;
pevent->printk_count++;
return 0;
@@ -2139,6 +2144,8 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
if (value == NULL)
goto out_free;
field->value = strdup(value);
+ if (field->value == NULL)
+ goto out_free;
free_arg(arg);
arg = alloc_arg();
@@ -2152,6 +2159,8 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
if (value == NULL)
goto out_free;
field->str = strdup(value);
+ if (field->str == NULL)
+ goto out_free;
free_arg(arg);
arg = NULL;
@@ -3356,6 +3365,9 @@ process_defined_func(struct trace_seq *s, void *data, int size,
string = malloc_or_die(sizeof(*string));
string->next = strings;
string->str = strdup(str.buffer);
+ if (!string->str)
+ die("malloc str");
+
strings = string;
trace_seq_destroy(&str);
break;
@@ -3493,6 +3505,8 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
arg->next = NULL;
arg->type = PRINT_BSTRING;
arg->string.string = strdup(bptr);
+ if (!arg->string.string)
+ break;
bptr += strlen(bptr) + 1;
*next = arg;
next = &arg->next;
@@ -4569,6 +4583,8 @@ int pevent_parse_event(struct pevent *pevent,
die("failed to read event id");
event->system = strdup(sys);
+ if (!event->system)
+ die("failed to allocate system");
/* Add pevent to event so that it can be referenced */
event->pevent = pevent;
@@ -4610,6 +4626,10 @@ int pevent_parse_event(struct pevent *pevent,
list = &arg->next;
arg->type = PRINT_FIELD;
arg->field.name = strdup(field->name);
+ if (!arg->field.name) {
+ do_warning("failed to allocate field name");
+ goto event_failed;
+ }
arg->field.field = field;
}
return 0;
@@ -4953,6 +4973,11 @@ int pevent_register_event_handler(struct pevent *pevent,
if (sys_name)
handle->sys_name = strdup(sys_name);
+ if ((event_name && !handle->event_name) ||
+ (sys_name && !handle->sys_name)) {
+ die("Failed to allocate event/sys name");
+ }
+
handle->func = func;
handle->next = pevent->handlers;
pevent->handlers = handle;
--
1.7.10.1
The realloc can fail so that we should handle it properly.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 76 ++++++++++++++++++++++++++++--------
1 file changed, 60 insertions(+), 16 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 0fa09c62a14a..6a8e3169ac68 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1258,9 +1258,15 @@ static int event_read_fields(struct event_format *event, struct format_field **f
field->flags |= FIELD_IS_POINTER;
if (field->type) {
- field->type = realloc(field->type,
- strlen(field->type) +
- strlen(last_token) + 2);
+ char *new_type;
+ new_type = realloc(field->type,
+ strlen(field->type) +
+ strlen(last_token) + 2);
+ if (!new_type) {
+ free(last_token);
+ goto fail;
+ }
+ field->type = new_type;
strcat(field->type, " ");
strcat(field->type, last_token);
free(last_token);
@@ -1285,6 +1291,7 @@ static int event_read_fields(struct event_format *event, struct format_field **f
if (strcmp(token, "[") == 0) {
enum event_type last_type = type;
char *brackets = token;
+ char *new_brackets;
int len;
field->flags |= FIELD_IS_ARRAY;
@@ -1304,9 +1311,14 @@ static int event_read_fields(struct event_format *event, struct format_field **f
len = 1;
last_type = type;
- brackets = realloc(brackets,
- strlen(brackets) +
- strlen(token) + len);
+ new_brackets = realloc(brackets,
+ strlen(brackets) +
+ strlen(token) + len);
+ if (!new_brackets) {
+ free(brackets);
+ goto fail;
+ }
+ brackets = new_brackets;
if (len == 2)
strcat(brackets, " ");
strcat(brackets, token);
@@ -1322,7 +1334,12 @@ static int event_read_fields(struct event_format *event, struct format_field **f
free_token(token);
- brackets = realloc(brackets, strlen(brackets) + 2);
+ new_brackets = realloc(brackets, strlen(brackets) + 2);
+ if (!new_brackets) {
+ free(brackets);
+ goto fail;
+ }
+ brackets = new_brackets;
strcat(brackets, "]");
/* add brackets to type */
@@ -1333,10 +1350,16 @@ static int event_read_fields(struct event_format *event, struct format_field **f
* the format: type [] item;
*/
if (type == EVENT_ITEM) {
- field->type = realloc(field->type,
- strlen(field->type) +
- strlen(field->name) +
- strlen(brackets) + 2);
+ char *new_type;
+ new_type = realloc(field->type,
+ strlen(field->type) +
+ strlen(field->name) +
+ strlen(brackets) + 2);
+ if (!new_type) {
+ free(brackets);
+ goto fail;
+ }
+ field->type = new_type;
strcat(field->type, " ");
strcat(field->type, field->name);
free_token(field->name);
@@ -1344,9 +1367,15 @@ static int event_read_fields(struct event_format *event, struct format_field **f
field->name = token;
type = read_token(&token);
} else {
- field->type = realloc(field->type,
- strlen(field->type) +
- strlen(brackets) + 1);
+ char *new_type;
+ new_type = realloc(field->type,
+ strlen(field->type) +
+ strlen(brackets) + 1);
+ if (!new_type) {
+ free(brackets);
+ goto fail;
+ }
+ field->type = new_type;
strcat(field->type, brackets);
}
free(brackets);
@@ -1727,10 +1756,16 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
/* could just be a type pointer */
if ((strcmp(arg->op.op, "*") == 0) &&
type == EVENT_DELIM && (strcmp(token, ")") == 0)) {
+ char *new_atom;
+
if (left->type != PRINT_ATOM)
die("bad pointer type");
- left->atom.atom = realloc(left->atom.atom,
+ new_atom = realloc(left->atom.atom,
strlen(left->atom.atom) + 3);
+ if (!new_atom)
+ goto out_free;
+
+ left->atom.atom = new_atom;
strcat(left->atom.atom, " *");
free(arg->op.op);
*arg = *left;
@@ -2545,7 +2580,16 @@ process_arg_token(struct event_format *event, struct print_arg *arg,
}
/* atoms can be more than one token long */
while (type == EVENT_ITEM) {
- atom = realloc(atom, strlen(atom) + strlen(token) + 2);
+ char *new_atom;
+ new_atom = realloc(atom,
+ strlen(atom) + strlen(token) + 2);
+ if (!new_atom) {
+ free(atom);
+ *tok = NULL;
+ free_token(token);
+ return EVENT_ERROR;
+ }
+ atom = new_atom;
strcat(atom, " ");
strcat(atom, token);
free_token(token);
--
1.7.10.1
If event_read_fields failed in the middle, each member of
struct format_field should be freed also.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 760e7831390a..0fa09c62a14a 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1437,8 +1437,11 @@ static int event_read_fields(struct event_format *event, struct format_field **f
fail:
free_token(token);
fail_expect:
- if (field)
+ if (field) {
+ free(field->type);
+ free(field->name);
free(field);
+ }
return -1;
}
--
1.7.10.1
The @arg paremeter should not be freed inside of process_XXX(),
because it'd be freed from the caller of process_arg(). We can
free it only after it was reused for local usage.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 865d0f268274..eb9babbf8e55 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2342,17 +2342,18 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char **
arg = alloc_arg();
type = process_arg(event, arg, &token);
if (type == EVENT_ERROR)
- goto out_free;
+ goto out_free_arg;
if (!test_type_token(type, token, EVENT_OP, "]"))
- goto out_free;
+ goto out_free_arg;
free_token(token);
type = read_token_item(tok);
return type;
+ out_free_arg:
+ free_arg(arg);
out_free:
- free(arg);
free_token(token);
*tok = NULL;
return EVENT_ERROR;
--
1.7.10.1
The if branch is completely unnecessary since 'realloc' can
handle NULL pointers for the first parameter.
This patch is just an adoption of Ulrich Drepper's recent
patch on perf tools.
Link: http://lkml.kernel.org/r/[email protected]
Cc: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ulrich Drepper <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 8 ++------
tools/lib/traceevent/parse-filter.c | 24 ++++++++----------------
2 files changed, 10 insertions(+), 22 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index f02890530425..c471075e4974 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -631,12 +631,8 @@ static void add_event(struct pevent *pevent, struct event_format *event)
{
int i;
- if (!pevent->events)
- pevent->events = malloc_or_die(sizeof(event));
- else
- pevent->events =
- realloc(pevent->events, sizeof(event) *
- (pevent->nr_events + 1));
+ pevent->events = realloc(pevent->events, sizeof(event) *
+ (pevent->nr_events + 1));
if (!pevent->events)
die("Can not allocate events");
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 05a1eeffa776..c262e069c635 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -148,17 +148,11 @@ add_filter_type(struct event_filter *filter, int id)
if (filter_type)
return filter_type;
- if (!filter->filters)
- filter->event_filters =
- malloc_or_die(sizeof(*filter->event_filters));
- else {
- filter->event_filters =
- realloc(filter->event_filters,
- sizeof(*filter->event_filters) *
- (filter->filters + 1));
- if (!filter->event_filters)
- die("Could not allocate filter");
- }
+ filter->event_filters = realloc(filter->event_filters,
+ sizeof(*filter->event_filters) *
+ (filter->filters + 1));
+ if (!filter->event_filters)
+ die("Could not allocate filter");
for (i = 0; i < filter->filters; i++) {
if (filter->event_filters[i].event_id > id)
@@ -1480,7 +1474,7 @@ void pevent_filter_clear_trivial(struct event_filter *filter,
{
struct filter_type *filter_type;
int count = 0;
- int *ids;
+ int *ids = NULL;
int i;
if (!filter->filters)
@@ -1504,10 +1498,8 @@ void pevent_filter_clear_trivial(struct event_filter *filter,
default:
break;
}
- if (count)
- ids = realloc(ids, sizeof(*ids) * (count + 1));
- else
- ids = malloc(sizeof(*ids));
+
+ ids = realloc(ids, sizeof(*ids) * (count + 1));
if (!ids)
die("Can't allocate ids");
ids[count++] = filter_type->event_id;
--
1.7.10.1
The param needs to be updated when setting args up so that
the loop in process_defined_func() can see the correct
param->type for the farg.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index eb9babbf8e55..4ffcb33697cd 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3430,6 +3430,7 @@ process_defined_func(struct trace_seq *s, void *data, int size,
break;
}
farg = farg->next;
+ param = param->next;
}
ret = (*func_handle->func)(s, args);
--
1.7.10.1
The malloc can fail so the return value should be checked.
For now, just use malloc_or_die().
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/parse-filter.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 466579f4b02f..901f2de5bd67 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -96,7 +96,7 @@ static enum event_type read_token(char **tok)
(strcmp(token, "=") == 0 || strcmp(token, "!") == 0) &&
pevent_peek_char() == '~') {
/* append it */
- *tok = malloc(3);
+ *tok = malloc_or_die(3);
sprintf(*tok, "%c%c", *token, '~');
free_token(token);
/* Now remove the '~' from the buffer */
--
1.7.10.1
Update and add missing argument descriptions and fix some typo
on function comments.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index cb36a964b053..f62f76658d51 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3954,8 +3954,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
* pevent_data_lat_fmt - parse the data for the latency format
* @pevent: a handle to the pevent
* @s: the trace_seq to write to
- * @data: the raw data to read from
- * @size: currently unused.
+ * @record: the record to read from
*
* This parses out the Latency format (interrupts disabled,
* need rescheduling, in hard/soft interrupt, preempt count
@@ -4090,10 +4089,7 @@ const char *pevent_data_comm_from_pid(struct pevent *pevent, int pid)
* pevent_data_comm_from_pid - parse the data into the print format
* @s: the trace_seq to write to
* @event: the handle to the event
- * @cpu: the cpu the event was recorded on
- * @data: the raw data
- * @size: the size of the raw data
- * @nsecs: the timestamp of the event
+ * @record: the record to read from
*
* This parses the raw @data using the given @event information and
* writes the print format into the trace_seq.
@@ -4854,7 +4850,7 @@ int pevent_get_any_field_val(struct trace_seq *s, struct event_format *event,
* @record: The record with the field name.
* @err: print default error if failed.
*
- * Returns: 0 on success, -1 field not fould, or 1 if buffer is full.
+ * Returns: 0 on success, -1 field not found, or 1 if buffer is full.
*/
int pevent_print_num_field(struct trace_seq *s, const char *fmt,
struct event_format *event, const char *name,
@@ -4896,11 +4892,12 @@ static void free_func_handle(struct pevent_function_handler *func)
* pevent_register_print_function - register a helper function
* @pevent: the handle to the pevent
* @func: the function to process the helper function
+ * @ret_type: the return type of the helper function
* @name: the name of the helper function
* @parameters: A list of enum pevent_func_arg_type
*
* Some events may have helper functions in the print format arguments.
- * This allows a plugin to dynmically create a way to process one
+ * This allows a plugin to dynamically create a way to process one
* of these functions.
*
* The @parameters is a variable list of pevent_func_arg_type enums that
@@ -4971,12 +4968,13 @@ int pevent_register_print_function(struct pevent *pevent,
}
/**
- * pevent_register_event_handle - register a way to parse an event
+ * pevent_register_event_handler - register a way to parse an event
* @pevent: the handle to the pevent
* @id: the id of the event to register
* @sys_name: the system name the event belongs to
* @event_name: the name of the event
* @func: the function to call to parse the event information
+ * @context: the data to be passed to @func
*
* This function allows a developer to override the parsing of
* a given event. If for some reason the default print format
--
1.7.10.1
When memory allocation for the field name is failed, do not
goto event_failed since we added the event already.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 67ecb0d2a09a..cb36a964b053 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -4680,7 +4680,8 @@ int pevent_parse_event(struct pevent *pevent,
arg->field.name = strdup(field->name);
if (!arg->field.name) {
do_warning("failed to allocate field name");
- goto event_failed;
+ event->flags |= EVENT_FL_FAILED;
+ return -1;
}
arg->field.field = field;
}
--
1.7.10.1
It seems PEVENT_FUNC_ARG_STRING missed passing the allocated
string to the args array. Fix it.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 4ffcb33697cd..67ecb0d2a09a 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3418,6 +3418,7 @@ process_defined_func(struct trace_seq *s, void *data, int size,
if (!string->str)
die("malloc str");
+ args[i] = (unsigned long long)string->str;
strings = string;
trace_seq_destroy(&str);
break;
--
1.7.10.1
The printk_cmp function should use printk_map instead of func_map.
Also rename the variables for consistency.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 8282523f489d..58fa6eb6aa59 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -511,12 +511,12 @@ struct printk_list {
static int printk_cmp(const void *a, const void *b)
{
- const struct func_map *fa = a;
- const struct func_map *fb = b;
+ const struct printk_map *pa = a;
+ const struct printk_map *pb = b;
- if (fa->addr < fb->addr)
+ if (pa->addr < pb->addr)
return -1;
- if (fa->addr > fb->addr)
+ if (pa->addr > pb->addr)
return 1;
return 0;
--
1.7.10.1
The __read_token() function has some duplicated code to handle
internal buffer overflow. Factor them out to new extend_token().
According to the man pages of realloc/free(3), they can handle
NULL pointer input so that it can be ended up to compact the code.
Also handle error path correctly.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
[ added some extra whitespace ]
Signed-off-by: Steven Rostedt <[email protected]>
---
tools/lib/traceevent/event-parse.c | 50 +++++++++++++++++-------------------
1 file changed, 24 insertions(+), 26 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 58fa6eb6aa59..bdfc29607b49 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -775,6 +775,25 @@ int pevent_peek_char(void)
return __peek_char();
}
+static int extend_token(char **tok, char *buf, int size)
+{
+ char *newtok = realloc(*tok, size);
+
+ if (!newtok) {
+ free(*tok);
+ *tok = NULL;
+ return -1;
+ }
+
+ if (!*tok)
+ strcpy(newtok, buf);
+ else
+ strcat(newtok, buf);
+ *tok = newtok;
+
+ return 0;
+}
+
static enum event_type force_token(const char *str, char **tok);
static enum event_type __read_token(char **tok)
@@ -859,17 +878,10 @@ static enum event_type __read_token(char **tok)
do {
if (i == (BUFSIZ - 1)) {
buf[i] = 0;
- if (*tok) {
- *tok = realloc(*tok, tok_size + BUFSIZ);
- if (!*tok)
- return EVENT_NONE;
- strcat(*tok, buf);
- } else
- *tok = strdup(buf);
+ tok_size += BUFSIZ;
- if (!*tok)
+ if (extend_token(tok, buf, tok_size) < 0)
return EVENT_NONE;
- tok_size += BUFSIZ;
i = 0;
}
last_ch = ch;
@@ -908,17 +920,10 @@ static enum event_type __read_token(char **tok)
while (get_type(__peek_char()) == type) {
if (i == (BUFSIZ - 1)) {
buf[i] = 0;
- if (*tok) {
- *tok = realloc(*tok, tok_size + BUFSIZ);
- if (!*tok)
- return EVENT_NONE;
- strcat(*tok, buf);
- } else
- *tok = strdup(buf);
+ tok_size += BUFSIZ;
- if (!*tok)
+ if (extend_token(tok, buf, tok_size) < 0)
return EVENT_NONE;
- tok_size += BUFSIZ;
i = 0;
}
ch = __read_char();
@@ -927,14 +932,7 @@ static enum event_type __read_token(char **tok)
out:
buf[i] = 0;
- if (*tok) {
- *tok = realloc(*tok, tok_size + i);
- if (!*tok)
- return EVENT_NONE;
- strcat(*tok, buf);
- } else
- *tok = strdup(buf);
- if (!*tok)
+ if (extend_token(tok, buf, tok_size + i + 1) < 0)
return EVENT_NONE;
if (type == EVENT_ITEM) {
--
1.7.10.1
From: Stefan Hajnoczi <[email protected]>
The __print_symbolic() function takes a sequence of key-value pairs for
pretty-printing a constant. The new kvm:kvm_exit print fmt uses the
expression:
__print_symbolic(..., { 0x040 + 1, "DB excp" }, ...)
Currently only atoms are supported and this print fmt fails to parse.
This patch adds support for expressions instead of just atoms so that
0x040 + 1 is parsed successfully.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Stefan Hajnoczi <[email protected]>
Cc: Avi Kivity <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/event-parse.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 9216aef78394..59534e299590 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2124,6 +2124,13 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
free_token(token);
type = process_arg(event, arg, &token);
+
+ if (type == EVENT_OP)
+ type = process_op(event, arg, &token);
+
+ if (type == EVENT_ERROR)
+ goto out_free;
+
if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free;
--
1.7.10.1
From: Wolfgang Mauerer <[email protected]>
On 32 bit systems, a conversion of the trace_printk format string
"%lu" -> "%llu" is intended (similar for %lx etc.) when a
trace was taken on a machine with 64 bit long integers. However,
the current code computes the bogus transformation "%lu" -> "%u".
Fix this.
Besides that, the transformation is only required on systems
that don't use 64 bits for long integers natively.
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Wolfgang Mauerer <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/event-parse.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 59534e299590..8282523f489d 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3805,14 +3805,15 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
break;
}
}
- if (pevent->long_size == 8 && ls) {
+ if (pevent->long_size == 8 && ls &&
+ sizeof(long) != 8) {
char *p;
ls = 2;
/* make %l into %ll */
p = strchr(format, 'l');
if (p)
- memmove(p, p+1, strlen(p)+1);
+ memmove(p+1, p, strlen(p)+1);
else if (strcmp(format, "%p") == 0)
strcpy(format, "0x%llx");
}
--
1.7.10.1
From: Steven Rostedt <[email protected]>
As a pointer can be converted into a function name, let the filters
work with the function name as well as with the pointer number.
If the comparison expects a string, then convert numbers into functions,
but only when the number is the same size as a long.
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/parse-filter.c | 45 +++++++++++++++++++++++++++--------
1 file changed, 35 insertions(+), 10 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 2d40c5ed81d6..466579f4b02f 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -1711,18 +1711,43 @@ static int test_num(struct event_format *event,
static const char *get_field_str(struct filter_arg *arg, struct pevent_record *record)
{
- const char *val = record->data + arg->str.field->offset;
+ struct event_format *event;
+ struct pevent *pevent;
+ unsigned long long addr;
+ const char *val = NULL;
+ char hex[64];
- /*
- * We need to copy the data since we can't be sure the field
- * is null terminated.
- */
- if (*(val + arg->str.field->size - 1)) {
- /* copy it */
- memcpy(arg->str.buffer, val, arg->str.field->size);
- /* the buffer is already NULL terminated */
- val = arg->str.buffer;
+ /* If the field is not a string convert it */
+ if (arg->str.field->flags & FIELD_IS_STRING) {
+ val = record->data + arg->str.field->offset;
+
+ /*
+ * We need to copy the data since we can't be sure the field
+ * is null terminated.
+ */
+ if (*(val + arg->str.field->size - 1)) {
+ /* copy it */
+ memcpy(arg->str.buffer, val, arg->str.field->size);
+ /* the buffer is already NULL terminated */
+ val = arg->str.buffer;
+ }
+
+ } else {
+ event = arg->str.field->event;
+ pevent = event->pevent;
+ addr = get_value(event, arg->str.field, record);
+
+ if (arg->str.field->flags & (FIELD_IS_POINTER | FIELD_IS_LONG))
+ /* convert to a kernel symbol */
+ val = pevent_find_function(pevent, addr);
+
+ if (val == NULL) {
+ /* just use the hex of the string name */
+ snprintf(hex, 64, "0x%llx", addr);
+ val = hex;
+ }
}
+
return val;
}
--
1.7.10.1
From: Steven Rostedt <[email protected]>
The RT kernel added a migrate disable counter in all events. Add support
to show this in the latency format.
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/event-parse.c | 57 ++++++++++++++++++++++++------------
1 file changed, 38 insertions(+), 19 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index a2f4c22c8c4f..4dc0313b4a50 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2822,7 +2822,7 @@ static int get_common_info(struct pevent *pevent,
event = pevent->events[0];
field = pevent_find_common_field(event, type);
if (!field)
- die("field '%s' not found", type);
+ return -1;
*offset = field->offset;
*size = field->size;
@@ -2873,15 +2873,16 @@ static int parse_common_flags(struct pevent *pevent, void *data)
static int parse_common_lock_depth(struct pevent *pevent, void *data)
{
- int ret;
-
- ret = __parse_common(pevent, data,
- &pevent->ld_size, &pevent->ld_offset,
- "common_lock_depth");
- if (ret < 0)
- return -1;
+ return __parse_common(pevent, data,
+ &pevent->ld_size, &pevent->ld_offset,
+ "common_lock_depth");
+}
- return ret;
+static int parse_common_migrate_disable(struct pevent *pevent, void *data)
+{
+ return __parse_common(pevent, data,
+ &pevent->ld_size, &pevent->ld_offset,
+ "common_migrate_disable");
}
static int events_id_cmp(const void *a, const void *b);
@@ -3891,10 +3892,13 @@ void pevent_data_lat_fmt(struct pevent *pevent,
struct trace_seq *s, struct pevent_record *record)
{
static int check_lock_depth = 1;
+ static int check_migrate_disable = 1;
static int lock_depth_exists;
+ static int migrate_disable_exists;
unsigned int lat_flags;
unsigned int pc;
int lock_depth;
+ int migrate_disable;
int hardirq;
int softirq;
void *data = record->data;
@@ -3902,18 +3906,26 @@ void pevent_data_lat_fmt(struct pevent *pevent,
lat_flags = parse_common_flags(pevent, data);
pc = parse_common_pc(pevent, data);
/* lock_depth may not always exist */
- if (check_lock_depth) {
- struct format_field *field;
- struct event_format *event;
-
- check_lock_depth = 0;
- event = pevent->events[0];
- field = pevent_find_common_field(event, "common_lock_depth");
- if (field)
- lock_depth_exists = 1;
- }
if (lock_depth_exists)
lock_depth = parse_common_lock_depth(pevent, data);
+ else if (check_lock_depth) {
+ lock_depth = parse_common_lock_depth(pevent, data);
+ if (lock_depth < 0)
+ check_lock_depth = 0;
+ else
+ lock_depth_exists = 1;
+ }
+
+ /* migrate_disable may not always exist */
+ if (migrate_disable_exists)
+ migrate_disable = parse_common_migrate_disable(pevent, data);
+ else if (check_migrate_disable) {
+ migrate_disable = parse_common_migrate_disable(pevent, data);
+ if (migrate_disable < 0)
+ check_migrate_disable = 0;
+ else
+ migrate_disable_exists = 1;
+ }
hardirq = lat_flags & TRACE_FLAG_HARDIRQ;
softirq = lat_flags & TRACE_FLAG_SOFTIRQ;
@@ -3932,6 +3944,13 @@ void pevent_data_lat_fmt(struct pevent *pevent,
else
trace_seq_putc(s, '.');
+ if (migrate_disable_exists) {
+ if (migrate_disable < 0)
+ trace_seq_putc(s, '.');
+ else
+ trace_seq_printf(s, "%d", migrate_disable);
+ }
+
if (lock_depth_exists) {
if (lock_depth < 0)
trace_seq_putc(s, '.');
--
1.7.10.1
From: Steven Rostedt <[email protected]>
The arg notation of '*' in bprintks is not handled by the parser.
Implement it so that they show up properly in the output and do not
kill the tracer from reporting events.
Reported-by: Johannes Berg <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
---
tools/lib/traceevent/event-parse.c | 34 +++++++++++++++++++++++++---------
1 file changed, 25 insertions(+), 9 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 998534992197..a2f4c22c8c4f 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3286,7 +3286,7 @@ static void print_str_arg(struct trace_seq *s, void *data, int size,
break;
}
case PRINT_BSTRING:
- trace_seq_printf(s, format, arg->string.string);
+ print_str_to_seq(s, format, len_arg, arg->string.string);
break;
case PRINT_OP:
/*
@@ -3386,6 +3386,7 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
unsigned long long ip, val;
char *ptr;
void *bptr;
+ int vsize;
field = pevent->bprint_buf_field;
ip_field = pevent->bprint_ip_field;
@@ -3434,6 +3435,8 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
goto process_again;
case '0' ... '9':
goto process_again;
+ case '.':
+ goto process_again;
case 'p':
ls = 1;
/* fall through */
@@ -3441,23 +3444,29 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
case 'u':
case 'x':
case 'i':
- /* the pointers are always 4 bytes aligned */
- bptr = (void *)(((unsigned long)bptr + 3) &
- ~3);
switch (ls) {
case 0:
- ls = 4;
+ vsize = 4;
break;
case 1:
- ls = pevent->long_size;
+ vsize = pevent->long_size;
break;
case 2:
- ls = 8;
+ vsize = 8;
default:
+ vsize = ls; /* ? */
break;
}
- val = pevent_read_number(pevent, bptr, ls);
- bptr += ls;
+ /* fall through */
+ case '*':
+ if (*ptr == '*')
+ vsize = 4;
+
+ /* the pointers are always 4 bytes aligned */
+ bptr = (void *)(((unsigned long)bptr + 3) &
+ ~3);
+ val = pevent_read_number(pevent, bptr, vsize);
+ bptr += vsize;
arg = alloc_arg();
arg->next = NULL;
arg->type = PRINT_ATOM;
@@ -3465,6 +3474,13 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
sprintf(arg->atom.atom, "%lld", val);
*next = arg;
next = &arg->next;
+ /*
+ * The '*' case means that an arg is used as the length.
+ * We need to continue to figure out for what.
+ */
+ if (*ptr == '*')
+ goto process_again;
+
break;
case 's':
arg = alloc_arg();
--
1.7.10.1
On Wed, 2012-05-23 at 11:36 +0900, Namhyung Kim wrote:
> Hi,
>
> This is a patchset which attempts to sync what we have on trace-cmd
> into libtraceevent. Although some patch introduced new call-sites of
> die() or malloc_or_die(), it'll be removed eventually (or later work)
> and this helps marking the every locations that we need to track.
Thanks Namhyung!
I would recommend that this patch set be queued for 3.6, with the
following being cherry-picked for 3.5:
patch 5, 10, 12, 13, 14, 15, 19, and 21
Some of the other patches have fixes for failed allocation. As these
bugs have been around in current perf since forever, they can probably
wait another release before being added. It's not like it will cause the
kernel to crash ;-)
-- Steve
Commit-ID: 00b9da7219cd027a1c51c3ef576aadbbd9fe38fe
Gitweb: http://git.kernel.org/tip/00b9da7219cd027a1c51c3ef576aadbbd9fe38fe
Author: Stefan Hajnoczi <[email protected]>
AuthorDate: Wed, 23 May 2012 11:36:42 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 May 2012 11:29:25 -0300
tools lib traceevent: Allow expressions in __print_symbolic() fields
The __print_symbolic() function takes a sequence of key-value pairs for
pretty-printing a constant. The new kvm:kvm_exit print fmt uses the
expression:
__print_symbolic(..., { 0x040 + 1, "DB excp" }, ...)
Currently only atoms are supported and this print fmt fails to parse.
This patch adds support for expressions instead of just atoms so that
0x040 + 1 is parsed successfully.
Cc: Avi Kivity <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Stefan Hajnoczi <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/event-parse.c | 7 +++++++
1 files changed, 7 insertions(+), 0 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 9985349..33450c9 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2124,6 +2124,13 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
free_token(token);
type = process_arg(event, arg, &token);
+
+ if (type == EVENT_OP)
+ type = process_op(event, arg, &token);
+
+ if (type == EVENT_ERROR)
+ goto out_free;
+
if (test_type_token(type, token, EVENT_DELIM, ","))
goto out_free;
Commit-ID: 57d34dc5568f6ac700ef7e5c67f2bd6a8c7c4659
Gitweb: http://git.kernel.org/tip/57d34dc5568f6ac700ef7e5c67f2bd6a8c7c4659
Author: Namhyung Kim <[email protected]>
AuthorDate: Wed, 23 May 2012 11:36:47 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 May 2012 11:32:10 -0300
tools lib traceevent: Fix a possible memory leak
If event_read_fields failed in the middle, each member of
struct format_field should be freed also.
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/event-parse.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 33450c9..d598b37 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1434,8 +1434,11 @@ static int event_read_fields(struct event_format *event, struct format_field **f
fail:
free_token(token);
fail_expect:
- if (field)
+ if (field) {
+ free(field->type);
+ free(field->name);
free(field);
+ }
return -1;
}
Commit-ID: d1de10870909a27ce2ac380d0671feb308826491
Gitweb: http://git.kernel.org/tip/d1de10870909a27ce2ac380d0671feb308826491
Author: Namhyung Kim <[email protected]>
AuthorDate: Wed, 23 May 2012 11:36:49 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 May 2012 11:33:34 -0300
tools lib traceevent: Fix a possibly wrong memory dereference
If set_op_prio() failed, the token will be freed at out_free,
then arg->op.op would turn out to be a dangle pointer. After
returning EVENT_ERROR from process_op(), free_arg() will be
called and then it will finally see the dangling pointer.
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/event-parse.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index d598b37..445a43a 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -1715,6 +1715,8 @@ process_op(struct event_format *event, struct print_arg *arg, char **tok)
if (set_op_prio(arg) == -1) {
event->flags |= EVENT_FL_FAILED;
+ /* arg->op.op (= token) will be freed at out_free */
+ arg->op.op = NULL;
goto out_free;
}
Commit-ID: b3511d0530c7a2b4fa64d1f5218c5f073ae7b543
Gitweb: http://git.kernel.org/tip/b3511d0530c7a2b4fa64d1f5218c5f073ae7b543
Author: Namhyung Kim <[email protected]>
AuthorDate: Wed, 23 May 2012 11:36:50 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 May 2012 11:33:53 -0300
tools lib traceevent: Fix freeing arg on process_dynamic_array()
The @arg paremeter should not be freed inside of process_XXX(),
because it'd be freed from the caller of process_arg(). We can
free it only after it was reused for local usage.
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/event-parse.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 445a43a..3559027 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2300,17 +2300,18 @@ process_dynamic_array(struct event_format *event, struct print_arg *arg, char **
arg = alloc_arg();
type = process_arg(event, arg, &token);
if (type == EVENT_ERROR)
- goto out_free;
+ goto out_free_arg;
if (!test_type_token(type, token, EVENT_OP, "]"))
- goto out_free;
+ goto out_free_arg;
free_token(token);
type = read_token_item(tok);
return type;
+ out_free_arg:
+ free_arg(arg);
out_free:
- free(arg);
free_token(token);
*tok = NULL;
return EVENT_ERROR;
Commit-ID: 21c69e721d03e15ac97d01620d4311eaa1c18a46
Gitweb: http://git.kernel.org/tip/21c69e721d03e15ac97d01620d4311eaa1c18a46
Author: Namhyung Kim <[email protected]>
AuthorDate: Wed, 23 May 2012 11:36:51 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 May 2012 11:34:12 -0300
tools lib traceevent: Use proper function parameter type
The param needs to be updated when setting args up so that
the loop in process_defined_func() can see the correct
param->type for the farg.
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/event-parse.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 3559027..5548282 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3375,6 +3375,7 @@ process_defined_func(struct trace_seq *s, void *data, int size,
break;
}
farg = farg->next;
+ param = param->next;
}
ret = (*func_handle->func)(s, args);
Commit-ID: eaec12d7f526694f24d581a4ad23de6ce0315cd2
Gitweb: http://git.kernel.org/tip/eaec12d7f526694f24d581a4ad23de6ce0315cd2
Author: Namhyung Kim <[email protected]>
AuthorDate: Wed, 23 May 2012 11:36:56 +0900
Committer: Arnaldo Carvalho de Melo <[email protected]>
CommitDate: Thu, 24 May 2012 11:36:05 -0300
tools lib traceevent: Fix signature of create_arg_item()
The @type should be a type of enum event_type not enum filter_arg_type.
This fixes following warning:
$ make
COMPILE FPIC parse-events.o
COMPILE FPIC parse-filter.o
/home/namhyung/project/trace-cmd/parse-filter.c: In function ‘create_arg_item’:
/home/namhyung/project/trace-cmd/parse-filter.c:343:9: warning: comparison between ‘enum filter_arg_type’ and ‘enum event_type’ [-Wenum-compare]
/home/namhyung/project/trace-cmd/parse-filter.c:339:2: warning: case value ‘8’ not in enumerated type ‘enum filter_arg_type’ [-Wswitch]
BUILD STATIC LIB libparsevent.a
BUILD STATIC LIB libtracecmd.a
BUILD trace-cmd
/usr/bin/make -C /home/namhyung/project/trace-cmd/Documentation all
make[1]: Nothing to be done for `all'.
Note: to build the gui, type "make gui"
Cc: Borislav Petkov <[email protected]>
Cc: David Ahern <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Namhyung Kim <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Namhyung Kim <[email protected]>
Signed-off-by: Steven Rostedt <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/lib/traceevent/parse-filter.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/parse-filter.c b/tools/lib/traceevent/parse-filter.c
index 2d40c5e..e08d21f 100644
--- a/tools/lib/traceevent/parse-filter.c
+++ b/tools/lib/traceevent/parse-filter.c
@@ -325,9 +325,8 @@ static void free_events(struct event_list *events)
}
static struct filter_arg *
-create_arg_item(struct event_format *event,
- const char *token, enum filter_arg_type type,
- char **error_str)
+create_arg_item(struct event_format *event, const char *token,
+ enum event_type type, char **error_str)
{
struct format_field *field;
struct filter_arg *arg;
Hi, Arnaldo
It'd be great if you set up a branch for this so that I can continue to
work on it until fully-merged.
Thanks,
Namhyung
Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
> Hi, Arnaldo
>
> It'd be great if you set up a branch for this so that I can continue to
> work on it until fully-merged.
Have you had luck obtaining a git.kernel.org account? It would be better
if you used git and maintained such branch :-\
- Arnaldo
On Thu, 2012-05-31 at 11:52 -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
> > Hi, Arnaldo
> >
> > It'd be great if you set up a branch for this so that I can continue to
> > work on it until fully-merged.
>
> Have you had luck obtaining a git.kernel.org account? It would be better
> if you used git and maintained such branch :-\
>
Darn it! I wish I signed his key when I had the chance :-p
-- Steve
Em Thu, May 31, 2012 at 11:09:46AM -0400, Steven Rostedt escreveu:
> On Thu, 2012-05-31 at 11:52 -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
> > > Hi, Arnaldo
> > >
> > > It'd be great if you set up a branch for this so that I can continue to
> > > work on it until fully-merged.
> >
> > Have you had luck obtaining a git.kernel.org account? It would be better
> > if you used git and maintained such branch :-\
> >
>
> Darn it! I wish I signed his key when I had the chance :-p
I did it, Fr?d?ric too, so he should have no problem getting an account,
I think,
- Arnaldo
On Thu, May 31, 2012 at 12:13:56PM -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 31, 2012 at 11:09:46AM -0400, Steven Rostedt escreveu:
> > On Thu, 2012-05-31 at 11:52 -0300, Arnaldo Carvalho de Melo wrote:
> > > Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
> > > > Hi, Arnaldo
> > > >
> > > > It'd be great if you set up a branch for this so that I can continue to
> > > > work on it until fully-merged.
> > >
> > > Have you had luck obtaining a git.kernel.org account? It would be better
> > > if you used git and maintained such branch :-\
> > >
> >
> > Darn it! I wish I signed his key when I had the chance :-p
>
> I did it, Fr?d?ric too, so he should have no problem getting an account,
> I think,
Except I haven't yet managed to get my korg account back and only Namhyung has
signed my key. So I'm not going to be very helpful in this regard ;)
Em Thu, May 31, 2012 at 05:22:45PM +0200, Frederic Weisbecker escreveu:
> On Thu, May 31, 2012 at 12:13:56PM -0300, Arnaldo Carvalho de Melo wrote:
> > Em Thu, May 31, 2012 at 11:09:46AM -0400, Steven Rostedt escreveu:
> > > On Thu, 2012-05-31 at 11:52 -0300, Arnaldo Carvalho de Melo wrote:
> > > > Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
> > > > > It'd be great if you set up a branch for this so that I can continue to
> > > > > work on it until fully-merged.
> > > > Have you had luck obtaining a git.kernel.org account? It would be better
> > > > if you used git and maintained such branch :-\
> > > Darn it! I wish I signed his key when I had the chance :-p
> > I did it, Fr?d?ric too, so he should have no problem getting an account,
> > I think,
>
> Except I haven't yet managed to get my korg account back and only Namhyung has
> signed my key. So I'm not going to be very helpful in this regard ;)
I just checked, he got other sigs, so your chain also should be good to
go ;-)
- Arnaldo
Hi, all
On Thu, 31 May 2012 12:31:53 -0300, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 31, 2012 at 05:22:45PM +0200, Frederic Weisbecker escreveu:
>> On Thu, May 31, 2012 at 12:13:56PM -0300, Arnaldo Carvalho de Melo wrote:
>> > Em Thu, May 31, 2012 at 11:09:46AM -0400, Steven Rostedt escreveu:
>> > > On Thu, 2012-05-31 at 11:52 -0300, Arnaldo Carvalho de Melo wrote:
>> > > > Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
>> > > > > It'd be great if you set up a branch for this so that I can continue to
>> > > > > work on it until fully-merged.
>
>> > > > Have you had luck obtaining a git.kernel.org account? It would be better
>> > > > if you used git and maintained such branch :-\
>
>> > > Darn it! I wish I signed his key when I had the chance :-p
>
>> > I did it, Frédéric too, so he should have no problem getting an account,
>> > I think,
>>
>> Except I haven't yet managed to get my korg account back and only Namhyung has
>> signed my key. So I'm not going to be very helpful in this regard ;)
>
> I just checked, he got other sigs, so your chain also should be good to
> go ;-)
>
After asking the account John said my key is outside of the trust path,
so I haven't had the luck. As I got additional sigs from Kukjin and
Tejun today, I think I'm inside now.
John, could you please process my account request?
Thanks,
Namhyung
Hi, all
2012-06-01 12:31 AM, Arnaldo Carvalho de Melo wrote:
> Em Thu, May 31, 2012 at 05:22:45PM +0200, Frederic Weisbecker escreveu:
>> On Thu, May 31, 2012 at 12:13:56PM -0300, Arnaldo Carvalho de Melo wrote:
>>> Em Thu, May 31, 2012 at 11:09:46AM -0400, Steven Rostedt escreveu:
>>>> On Thu, 2012-05-31 at 11:52 -0300, Arnaldo Carvalho de Melo wrote:
>>>>> Em Thu, May 31, 2012 at 03:07:26PM +0900, Namhyung Kim escreveu:
>>>>>> It'd be great if you set up a branch for this so that I can continue to
>>>>>> work on it until fully-merged.
>
>>>>> Have you had luck obtaining a git.kernel.org account? It would be better
>>>>> if you used git and maintained such branch :-\
>
>>>> Darn it! I wish I signed his key when I had the chance :-p
>
>>> I did it, Frédéric too, so he should have no problem getting an account,
>>> I think,
>>
>> Except I haven't yet managed to get my korg account back and only Namhyung has
>> signed my key. So I'm not going to be very helpful in this regard ;)
>
> I just checked, he got other sigs, so your chain also should be good to
> go ;-)
>
Now I got an account and setup a tree at
/pub/scm/linux/kernel/git/namhyung/linux-perf.git. I'll work on further
libtraceevent improvement on libtraceeevnt/next branch.
Thanks to all you guys to help me setting this up. :)
Em Mon, Jun 11, 2012 at 11:47:10AM +0900, Namhyung Kim escreveu:
> Now I got an account and setup a tree at
> /pub/scm/linux/kernel/git/namhyung/linux-perf.git. I'll work on
> further libtraceevent improvement on libtraceeevnt/next branch.
>
> Thanks to all you guys to help me setting this up. :)
Yay! Look forward from pulling from your repository!
Please try to add that Link: thing, for patches that you write you can
use:
echo Link: http://lkml.kernel.org/n/tip-`ranpwd -l 24`@git.kernel.org
While for patches you collect from other people you should use the
message-id:
Link: http://lkml.kernel.org/r/$MESSAGE_ID
- Arnaldo
Hi, Arnaldo
On Mon, 11 Jun 2012 11:17:13 -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jun 11, 2012 at 11:47:10AM +0900, Namhyung Kim escreveu:
>> Now I got an account and setup a tree at
>> /pub/scm/linux/kernel/git/namhyung/linux-perf.git. I'll work on
>> further libtraceevent improvement on libtraceeevnt/next branch.
>>
>> Thanks to all you guys to help me setting this up. :)
>
> Yay! Look forward from pulling from your repository!
>
> Please try to add that Link: thing, for patches that you write you can
> use:
>
> echo Link: http://lkml.kernel.org/n/tip-`ranpwd -l 24`@git.kernel.org
>
> While for patches you collect from other people you should use the
> message-id:
>
> Link: http://lkml.kernel.org/r/$MESSAGE_ID
>
Thanks, I'll do that.
Namhyung
Hi, Arnaldo
Just a question..
On Mon, 11 Jun 2012 11:17:13 -0300, Arnaldo Carvalho de Melo wrote:
> Em Mon, Jun 11, 2012 at 11:47:10AM +0900, Namhyung Kim escreveu:
>> Now I got an account and setup a tree at
>> /pub/scm/linux/kernel/git/namhyung/linux-perf.git. I'll work on
>> further libtraceevent improvement on libtraceeevnt/next branch.
>>
>> Thanks to all you guys to help me setting this up. :)
>
> Yay! Look forward from pulling from your repository!
>
> Please try to add that Link: thing, for patches that you write you can
> use:
>
> echo Link: http://lkml.kernel.org/n/tip-`ranpwd -l 24`@git.kernel.org
>
It's for my own patch not posted to lkml? When I send a patch to lkml,
I can get a message-id and use it for /r/$MESSAGE_ID form? Just out of
curiousity.
Thanks,
Namhyung
> While for patches you collect from other people you should use the
> message-id:
>
> Link: http://lkml.kernel.org/r/$MESSAGE_ID
>
> - Arnaldo