public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Steven Rostedt <srostedt@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, acme@redhat.com, hpa@zytor.com,
	mingo@redhat.com, peterz@infradead.org, fweisbec@gmail.com,
	srostedt@redhat.com, tglx@linutronix.de, mingo@elte.hu
Subject: [tip:perf/core] perf tools: Handle the case with and without the "signed" trace field
Date: Thu, 15 Oct 2009 08:49:39 GMT	[thread overview]
Message-ID: <tip-13999e59343b042b0807be2df6ae5895d29782a0@git.kernel.org> (raw)
In-Reply-To: <20091014194358.888239553@goodmis.org>

Commit-ID:  13999e59343b042b0807be2df6ae5895d29782a0
Gitweb:     http://git.kernel.org/tip/13999e59343b042b0807be2df6ae5895d29782a0
Author:     Steven Rostedt <srostedt@redhat.com>
AuthorDate: Wed, 14 Oct 2009 15:43:38 -0400
Committer:  Ingo Molnar <mingo@elte.hu>
CommitDate: Thu, 15 Oct 2009 10:42:37 +0200

perf tools: Handle the case with and without the "signed" trace field

The trace format files now have a "signed" field. But we should
still be able to handle the kernels that do not have this field.

Signed-off-by: Steven Rostedt <srostedt@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <20091014194358.888239553@goodmis.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 tools/perf/util/trace-event-parse.c |   81 ++++++++++++++++++++++------------
 1 files changed, 52 insertions(+), 29 deletions(-)

diff --git a/tools/perf/util/trace-event-parse.c b/tools/perf/util/trace-event-parse.c
index 59e4e4d..0739b12 100644
--- a/tools/perf/util/trace-event-parse.c
+++ b/tools/perf/util/trace-event-parse.c
@@ -924,23 +924,30 @@ static int event_read_fields(struct event *event, struct format_field **fields)
 		if (read_expected(EVENT_OP, (char *)";") < 0)
 			goto fail_expect;
 
-		if (read_expected(EVENT_ITEM, (char *)"signed") < 0)
-			goto fail_expect;
+		type = read_token(&token);
+		if (type != EVENT_NEWLINE) {
+			/* newer versions of the kernel have a "signed" type */
+			if (test_type_token(type, token, EVENT_ITEM, (char *)"signed"))
+				goto fail;
 
-		if (read_expected(EVENT_OP, (char *)":") < 0)
-			goto fail_expect;
+			free_token(token);
 
-		if (read_expect_type(EVENT_ITEM, &token))
-			goto fail;
-		if (strtoul(token, NULL, 0))
-			field->flags |= FIELD_IS_SIGNED;
-		free_token(token);
+			if (read_expected(EVENT_OP, (char *)":") < 0)
+				goto fail_expect;
 
-		if (read_expected(EVENT_OP, (char *)";") < 0)
-			goto fail_expect;
+			if (read_expect_type(EVENT_ITEM, &token))
+				goto fail;
+
+			/* add signed type */
+
+			free_token(token);
+			if (read_expected(EVENT_OP, (char *)";") < 0)
+				goto fail_expect;
+
+			if (read_expect_type(EVENT_NEWLINE, &token))
+				goto fail;
+		}
 
-		if (read_expect_type(EVENT_NEWLINE, &token) < 0)
-			goto fail;
 		free_token(token);
 
 		*fields = field;
@@ -2949,21 +2956,23 @@ static void print_args(struct print_arg *args)
 	}
 }
 
-static void parse_header_field(char *type,
+static void parse_header_field(char *field,
 			       int *offset, int *size)
 {
 	char *token;
+	int type;
 
 	if (read_expected(EVENT_ITEM, (char *)"field") < 0)
 		return;
 	if (read_expected(EVENT_OP, (char *)":") < 0)
 		return;
+
 	/* type */
 	if (read_expect_type(EVENT_ITEM, &token) < 0)
-		return;
+		goto fail;
 	free_token(token);
 
-	if (read_expected(EVENT_ITEM, type) < 0)
+	if (read_expected(EVENT_ITEM, field) < 0)
 		return;
 	if (read_expected(EVENT_OP, (char *)";") < 0)
 		return;
@@ -2972,7 +2981,7 @@ static void parse_header_field(char *type,
 	if (read_expected(EVENT_OP, (char *)":") < 0)
 		return;
 	if (read_expect_type(EVENT_ITEM, &token) < 0)
-		return;
+		goto fail;
 	*offset = atoi(token);
 	free_token(token);
 	if (read_expected(EVENT_OP, (char *)";") < 0)
@@ -2982,22 +2991,36 @@ static void parse_header_field(char *type,
 	if (read_expected(EVENT_OP, (char *)":") < 0)
 		return;
 	if (read_expect_type(EVENT_ITEM, &token) < 0)
-		return;
+		goto fail;
 	*size = atoi(token);
 	free_token(token);
 	if (read_expected(EVENT_OP, (char *)";") < 0)
 		return;
-	if (read_expected(EVENT_ITEM, (char *)"signed") < 0)
-		return;
-	if (read_expected(EVENT_OP, (char *)":") < 0)
-		return;
-	if (read_expect_type(EVENT_ITEM, &token) < 0)
-		return;
-	free_token(token);
-	if (read_expected(EVENT_OP, (char *)";") < 0)
-		return;
-	if (read_expect_type(EVENT_NEWLINE, &token) < 0)
-		return;
+	type = read_token(&token);
+	if (type != EVENT_NEWLINE) {
+		/* newer versions of the kernel have a "signed" type */
+		if (type != EVENT_ITEM)
+			goto fail;
+
+		if (strcmp(token, (char *)"signed") != 0)
+			goto fail;
+
+		free_token(token);
+
+		if (read_expected(EVENT_OP, (char *)":") < 0)
+			return;
+
+		if (read_expect_type(EVENT_ITEM, &token))
+			goto fail;
+
+		free_token(token);
+		if (read_expected(EVENT_OP, (char *)";") < 0)
+			return;
+
+		if (read_expect_type(EVENT_NEWLINE, &token))
+			goto fail;
+	}
+ fail:
 	free_token(token);
 }
 

  reply	other threads:[~2009-10-15  8:51 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-14 19:43 [PATCH 00/13] [GIT PULL] perf tools: updates to parsing events Steven Rostedt
2009-10-14 19:43 ` [PATCH 01/13] [PATCH 01/13] perf tools: handle print concatinations in event format file Steven Rostedt
2009-10-15  8:48   ` [tip:perf/core] perf tools: Handle print concatenations " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 02/13] [PATCH 02/13] perf tools: fix backslash processing on trace print formats Steven Rostedt
2009-10-15  8:48   ` [tip:perf/core] perf tools: Fix " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 03/13] [PATCH 03/13] perf tools: handle trace parsing of < and > Steven Rostedt
2009-10-15  8:48   ` [tip:perf/core] perf tools: Handle " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 04/13] [PATCH 04/13] perf tools: handle arrays in print fields for trace parsing Steven Rostedt
2009-10-15  8:48   ` [tip:perf/core] perf tools: Handle " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 05/13] [PATCH 05/13] perf tools: handle * as typecast in " Steven Rostedt
2009-10-15  8:49   ` [tip:perf/core] perf tools: Handle " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 06/13] [PATCH 06/13] perf tools: handle newlines in trace parsing better Steven Rostedt
2009-10-15  8:49   ` [tip:perf/core] perf tools: Handle " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 07/13] [PATCH 07/13] perf tools: handle the case with and without the "signed" trace field Steven Rostedt
2009-10-15  8:49   ` tip-bot for Steven Rostedt [this message]
2009-10-14 19:43 ` [PATCH 08/13] [PATCH 08/13] perf tools: still continue on failed parsing of an event Steven Rostedt
2009-10-15  8:49   ` [tip:perf/core] perf tools: Still " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 09/13] [PATCH 09/13] perf tools: fix bprintk reading in trace output Steven Rostedt
2009-10-15  8:50   ` [tip:perf/core] perf tools: Fix " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 10/13] [PATCH 10/13] perf tools: handle both versions of ftrace output Steven Rostedt
2009-10-15  8:50   ` [tip:perf/core] perf tools: Handle " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 11/13] [PATCH 11/13] perf tools: add latency format to trace output Steven Rostedt
2009-10-15  8:50   ` [tip:perf/core] perf tools: Add " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 12/13] [PATCH 12/13] perf tools: handle - and + in parsing trace print format Steven Rostedt
2009-10-15  6:42   ` Ingo Molnar
2009-10-15  7:05     ` Peter Zijlstra
2009-10-15  9:20       ` Steven Rostedt
2009-10-15  8:50   ` [tip:perf/core] perf tools: Handle " tip-bot for Steven Rostedt
2009-10-14 19:43 ` [PATCH 13/13] [PATCH 13/13] perf tools: remove all char * typecasts and use const in prototype Steven Rostedt
2009-10-14 20:26   ` Frederic Weisbecker
2009-10-15  8:51   ` [tip:perf/core] perf tools: Remove " tip-bot for Steven Rostedt
2009-10-15  8:55 ` [PATCH 00/13] [GIT PULL] perf tools: updates to parsing events Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2009-10-20 23:19 [PATCH 0/2] [GIT PULL] perf tools: trace parse fix and debug compiling Steven Rostedt
2009-10-20 23:19 ` [PATCH 1/2] [PATCH 1/2] perf tools: add make DEBUG=1 to remove the -O6 cflag Steven Rostedt
2009-10-24  1:03   ` [tip:branch?] perf tools: Add 'make DEBUG=1' " tip-bot for Steven Rostedt
2009-10-20 23:19 ` [PATCH 2/2] [PATCH 2/2] perf tools: use strsep over strtok_r for parsing single line Steven Rostedt
2009-10-24  1:03   ` [tip:branch?] perf tools: Use strsep() over strtok_r() " tip-bot for Steven Rostedt

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=tip-13999e59343b042b0807be2df6ae5895d29782a0@git.kernel.org \
    --to=srostedt@redhat.com \
    --cc=acme@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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