From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org,
Steven Rostedt <rostedt@goodmis.org>,
Namhyung Kim <namhyung@kernel.org>,
Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 06/11] lib tools traceevent: Add back pevent assignment in __pevent_parse_format()
Date: Wed, 17 Oct 2012 14:19:42 -0300 [thread overview]
Message-ID: <1350494387-10987-7-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1350494387-10987-1-git-send-email-acme@infradead.org>
From: Steven Rostedt <rostedt@goodmis.org>
Even though with the change of commit commit 2b29175 "tools lib
traceevent: Carve out events format parsing routine", allowed
__pevent_parse_format() to parse an event without the need of a pevent
handler, the event still needs to assign the pevent handed to it.
There's no problem with assigning it if the pevent is NULL, as the
event->pevent would be NULL without the assignment. But function parsing
handlers may be assigned to the pevent handler to help in parsing the
event. If there's no pevent then there would not be any function
handlers, but if the pevent isn't assigned first before parsing the
event, it wont honor the function handlers that were assigned.
Worse yet, the current code crashes if an event has a function that it
tries to parse. For example:
# perf record -e scsi:scsi_dispatch_cmd_timeout
Segmentation fault (core dumped)
This happens because the scsi_dispatch_cmd_timeout event format has the following:
scsi_trace_parse_cdb(p, __get_dynamic_array(cmnd), REC->cmd_len)
which hasn't been defined by the pevent code.
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: http://lkml.kernel.org/r/1349136831.22822.133.camel@gandalf.local.home
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/lib/traceevent/event-parse.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 47264b4..f2989c5 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2602,6 +2602,9 @@ find_func_handler(struct pevent *pevent, char *func_name)
{
struct pevent_function_handler *func;
+ if (!pevent)
+ return NULL;
+
for (func = pevent->func_handlers; func; func = func->next) {
if (strcmp(func->name, func_name) == 0)
break;
@@ -4938,6 +4941,9 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
goto event_alloc_failed;
}
+ /* Add pevent to event so that it can be referenced */
+ event->pevent = pevent;
+
ret = event_read_format(event);
if (ret < 0) {
ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
@@ -5041,9 +5047,6 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
if (event == NULL)
return ret;
- /* Add pevent to event so that it can be referenced */
- event->pevent = pevent;
-
if (add_event(pevent, event)) {
ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
goto event_add_failed;
--
1.7.1
next prev parent reply other threads:[~2012-10-17 17:22 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-17 17:19 [GIT PULL 00/11] perf/urgent fixes Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 01/11] perf tool: Precise mode requires exclude_guest Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 02/11] perf: Require exclude_guest to use PEBS - kernel side enforcement Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 03/11] perf tools: Fix segfault when using srcline sort key Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 04/11] perf tools: Remove warnings on JIT samples for " Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 05/11] perf hists browser: Fix off-by-two bug on the first column Arnaldo Carvalho de Melo
2012-10-17 17:19 ` Arnaldo Carvalho de Melo [this message]
2012-10-17 17:19 ` [PATCH 07/11] tools lib traceevent: Fix missed freeing of subargs in free_arg() in filter Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 08/11] perf python: Initialize 'page_size' variable Arnaldo Carvalho de Melo
2012-10-18 1:31 ` Namhyung Kim
2012-10-18 13:58 ` Arnaldo Carvalho de Melo
2012-10-17 17:19 ` [PATCH 09/11] perf python: Link with libtraceevent Arnaldo Carvalho de Melo
2012-10-18 1:38 ` Namhyung Kim
2012-10-18 14:00 ` Arnaldo Carvalho de Melo
2012-10-18 14:38 ` Arnaldo Carvalho de Melo
2012-10-18 15:40 ` Namhyung Kim
2012-10-20 0:35 ` Ingo Molnar
2012-10-20 15:04 ` Arnaldo Carvalho de Melo
2012-10-21 13:33 ` Ingo Molnar
2012-10-17 17:19 ` [PATCH 10/11] perf tools: Fix build on sparc Arnaldo Carvalho de Melo
2012-10-18 1:39 ` Namhyung Kim
2012-10-18 2:15 ` David Miller
2012-10-17 17:19 ` [PATCH 11/11] perf hists browser: Add back callchain folding symbol Arnaldo Carvalho de Melo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1350494387-10987-7-git-send-email-acme@infradead.org \
--to=acme@infradead.org \
--cc=acme@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=namhyung@kernel.org \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).