mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Namhyung Kim <namhyung@kernel.org>
To: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Paul Mackerras <paulus@samba.org>, Ingo Molnar <mingo@kernel.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Steven Rostedt <srostedt@redhat.com>
Subject: [PATCH 02/16] tools lib traceevent: Add support for "%.*s" in bprintk events
Date: Wed,  4 Jul 2012 14:35:16 +0900	[thread overview]
Message-ID: <1341380130-23863-2-git-send-email-namhyung@kernel.org> (raw)
In-Reply-To: <1341380130-23863-1-git-send-email-namhyung@kernel.org>

From: Steven Rostedt <srostedt@redhat.com>

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 <johannes.berg@intel.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/n/tip-t0ctq7t1xz3ud6wv4v886jou@git.kernel.org
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
---
 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 83f0a8add177..0644c2a23ad6 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -3370,7 +3370,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:
 		/*
@@ -3471,6 +3471,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;
@@ -3519,6 +3520,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 */
@@ -3526,23 +3529,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;
@@ -3550,6 +3559,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.4


  reply	other threads:[~2012-07-04  5:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-04  5:34 [GIT PULL 00/16] tools lib traceevent: Pending backports of libparseevent Namhyung Kim
2012-07-04  5:35 ` [PATCH 01/16] tools lib traceevent: Let filtering numbers by string use function names Namhyung Kim
2012-07-04  5:35   ` Namhyung Kim [this message]
2012-07-04  5:35   ` [PATCH 03/16] tools lib traceevent: Add support to show migrate disable counter Namhyung Kim
2012-07-04  5:35   ` [PATCH 04/16] tools lib traceevent: Fix %pM print format arg handling Namhyung Kim
2012-07-04  5:35   ` [PATCH 05/16] tools lib traceevent: Fix trace_printk for long integers Namhyung Kim
2012-07-04  5:35   ` [PATCH 06/16] tools lib traceevent: Fix printk_cmp() Namhyung Kim
2012-07-04  5:35   ` [PATCH 07/16] tools lib traceevent: Introduce extend_token() Namhyung Kim
2012-07-04  5:35   ` [PATCH 08/16] tools lib traceevent: Handle strdup failure cases Namhyung Kim
2012-07-04  5:35   ` [PATCH 09/16] tools lib traceevent: Handle realloc() failure path Namhyung Kim
2012-07-04  5:35   ` [PATCH 10/16] tools lib traceevent: Pass string type argument to args Namhyung Kim
2012-07-04  5:35   ` [PATCH 11/16] tools lib traceevent: Do not call add_event() again if allocation failed Namhyung Kim
2012-07-04  5:35   ` [PATCH 12/16] tools lib traceevent: Fix some comments Namhyung Kim
2012-07-04  5:35   ` [PATCH 13/16] tools lib traceevent: Check result of malloc() during reading token Namhyung Kim
2012-07-04  5:35   ` [PATCH 14/16] tools lib traceevent: Check return value of arg_to_str() Namhyung Kim
2012-07-04  5:35   ` [PATCH 15/16] tools lib traceevent: Add missing break in make_bprint_args Namhyung Kim
2012-07-04  5:35   ` [PATCH 16/16] tools lib traceevent: Cleanup realloc use Namhyung Kim
2012-07-05 15:27 ` [GIT PULL 00/16] tools lib traceevent: Pending backports of libparseevent 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=1341380130-23863-2-git-send-email-namhyung@kernel.org \
    --to=namhyung@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.org \
    --cc=rostedt@goodmis.org \
    --cc=srostedt@redhat.com \
    /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

all inboxes | Powered by JetHome®