All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Ingo Molnar <mingo@elte.hu>, lkml <linux-kernel@vger.kernel.org>,
	systemtap <systemtap@sources.redhat.com>,
	kvm <kvm@vger.kernel.org>,
	DLE <dle-develop@lists.sourceforge.net>,
	Christoph Hellwig <hch@infradead.org>,
	Ananth N Mavinakayanahalli <ananth@in.ibm.com>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Tom Zanussi <tzanussi@gmail.com>
Subject: Re: [PATCH -tip v8 7/7] tracing: add kprobe-based event tracer
Date: Sat, 30 May 2009 09:15:45 -0400	[thread overview]
Message-ID: <4A213181.5080201@redhat.com> (raw)
In-Reply-To: <alpine.DEB.2.00.0905300009230.14994@gandalf.stny.rr.com>

Steven Rostedt wrote:
> 
> 
> On Thu, 28 May 2009, Masami Hiramatsu wrote:
> 
>> +#undef SHOW_FIELD
>> +#define SHOW_FIELD(type, item, name)					\
>> +	do {								\
>> +		ret = trace_seq_printf(s, "\tfield: " #type " %s;\t"	\
>> +				"offset:%u;tsize:%u;\n", name,		\
>> +				(unsigned)offsetof(typeof(field), item),\
>> +				(unsigned)sizeof(type));		\
>> +		if (!ret)						\
>> +			return 0;					\
>> +	} while (0)
>> +
>> +static int __probe_event_show_format(struct ftrace_event_call *event_call,
>> +				     struct trace_seq *s, const char *fmt,
>> +				     const char *arg)
>> +{
>> +	struct kprobe_trace_entry field __attribute__((unused));
> 
> You use kprobe_trace_entry for both kprobe and kretprobe.

Ah, right. I'll fix that.

Thank you for reviewing!

> 
>> +	int ret, i;
>> +	char buf[MAX_ARGSTR_LEN + 1];
>> +	struct trace_probe *tp = container_of(event_call,
>> +					      struct trace_probe, call);
>> +
>> +	/* Show fields */
>> +	for (i = 0; i < tp->nr_args; i++) {
>> +		sprintf(buf, "arg%d", i);
>> +		SHOW_FIELD(unsigned long, args[i], buf);
>> +	}
>> +	trace_seq_puts(s, "\n");
>> +
>> +	/* Show aliases */
>> +	for (i = 0; i < tp->nr_args; i++) {
>> +		if (trace_arg_string(buf, MAX_ARGSTR_LEN, &tp->args[i]))
>> +			return 0;
>> +		if (!trace_seq_printf(s, "\talias: %s;\toriginal: arg%d;\n",
>> +				      buf, i))
>> +			return 0;
>> +	}
>> +	/* Show format */
>> +	if (!trace_seq_printf(s, "\nprint fmt: \"%s", fmt))
>> +		return 0;
>> +
>> +	for (i = 0; i < tp->nr_args; i++)
>> +		if (!trace_seq_puts(s, " 0x%lx"))
>> +			return 0;
>> +
>> +	if (!trace_seq_printf(s, "\", %s", arg))
>> +		return 0;
>> +
>> +	for (i = 0; i < tp->nr_args; i++)
>> +		if (!trace_seq_printf(s, ", arg%d", i))
>> +			return 0;
>> +
>> +	return trace_seq_puts(s, "\n");
>> +}
>> +
>> +static int kprobe_event_show_format(struct ftrace_event_call *call,
>> +				    struct trace_seq *s)
>> +{
>> +	struct kprobe_trace_entry field __attribute__((unused));
>> +	int ret;
>> +
>> +	SHOW_FIELD(unsigned long, ip, "ip");
>> +	SHOW_FIELD(int, nargs, "nargs");
>> +
>> +	return __probe_event_show_format(call, s, "%lx:", "ip");
>> +}
>> +
>> +static int kretprobe_event_show_format(struct ftrace_event_call *call,
>> +				       struct trace_seq *s)
>> +{
>> +	struct kretprobe_trace_entry field __attribute__((unused));
>> +	int ret;
>> +
>> +	SHOW_FIELD(unsigned long, func, "func");
>> +	SHOW_FIELD(unsigned long, ret_ip, "ret_ip");
>> +	SHOW_FIELD(int, nargs, "nargs");
>> +
>> +	return __probe_event_show_format(call, s, "%lx <- %lx:",
>> +					  "func, ret_ip");
>> +}
> 
> Thus we end up with:
> 
> format:
> 	field:unsigned short common_type;	offset:0;	size:2;
> 	field:unsigned char common_flags;	offset:2;	size:1;
> 	field:unsigned char common_preempt_count;	offset:3;	
> size:1;
> 	field:int common_pid;	offset:4;	size:4;
> 	field:int common_tgid;	offset:8;	size:4;
> 
> 	field: unsigned long func;	offset:16;tsize:8;
> 	field: unsigned long ret_ip;	offset:24;tsize:8;
> 	field: int nargs;	offset:32;tsize:4;
> 	field: unsigned long arg0;	offset:32;tsize:8;
> 	field: unsigned long arg1;	offset:40;tsize:8;
> 	field: unsigned long arg2;	offset:48;tsize:8;
> 	field: unsigned long arg3;	offset:56;tsize:8;
> 
> Notice that nargs and arg0 are both at offest 32.
> 
> -- Steve
> 

-- 
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America) Inc.
Software Solutions Division

e-mail: mhiramat@redhat.com


  reply	other threads:[~2009-05-30 13:15 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-29  0:03 [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder Masami Hiramatsu
2009-05-29  0:03 ` Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 1/7] x86: instruction decoder API Masami Hiramatsu
2009-05-29  0:03   ` Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 2/7] x86: x86 instruction decoder build-time selftest Masami Hiramatsu
2009-05-29  0:03   ` Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 3/7] kprobes: checks probe address is instruction boudary on x86 Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 4/7] kprobes: cleanup fix_riprel() using insn decoder " Masami Hiramatsu
2009-05-29  0:03 ` [PATCH -tip v8 5/7] x86: add pt_regs register and stack access APIs Masami Hiramatsu
2009-05-30  8:13   ` Christoph Hellwig
2009-05-30 14:48     ` Masami Hiramatsu
2009-06-01 23:40     ` Ingo Molnar
2009-05-29  0:03 ` [PATCH -tip v8 6/7] tracing: ftrace dynamic ftrace_event_call support Masami Hiramatsu
2009-05-30  3:23   ` Steven Rostedt
2009-05-29  0:03 ` [PATCH -tip v8 7/7] tracing: add kprobe-based event tracer Masami Hiramatsu
2009-05-29  0:03   ` Masami Hiramatsu
2009-05-30  3:29   ` Steven Rostedt
2009-05-30  4:11   ` Steven Rostedt
2009-05-30 13:15     ` Masami Hiramatsu [this message]
2009-05-30  8:15   ` Christoph Hellwig
2009-05-30 14:38     ` Masami Hiramatsu
2009-05-30  8:05 ` [PATCH -tip v8 0/7] tracing: kprobe-based event tracer and x86 instruction decoder Christoph Hellwig
2009-05-31 13:43   ` Masami Hiramatsu
2009-05-31 13:43     ` Masami Hiramatsu

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=4A213181.5080201@redhat.com \
    --to=mhiramat@redhat.com \
    --cc=ananth@in.ibm.com \
    --cc=dle-develop@lists.sourceforge.net \
    --cc=fweisbec@gmail.com \
    --cc=hch@infradead.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=systemtap@sources.redhat.com \
    --cc=tzanussi@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.