public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
To: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	systemtap-ml <systemtap@sources.redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [RFC][PATCH -tip 7/9] tracing: kprobe-tracer plugin supports arguments
Date: Fri, 20 Mar 2009 13:49:14 +0530	[thread overview]
Message-ID: <20090320081914.GD6398@in.ibm.com> (raw)
In-Reply-To: <49C2B4D0.8030904@redhat.com>

On Thu, Mar 19, 2009 at 05:10:40PM -0400, Masami Hiramatsu wrote:

> +#if defined(__i386__)
> +#define REGPARMS 3
> +static unsigned long fetch_argument(struct pt_regs *regs, void *data)
> +{
> +	unsigned long n = (unsigned long)data;
> +	if (n > REGPARMS) {
> +		/*
> +		 * The typical case: arg n is on the stack.
> +		 * stack[0] = return address
> +		 */
> +		return fetch_stack(regs, (void *)(n - REGPARMS));
> +	} else {
> +		switch (n) {
> +		case 1: return regs->ax;
> +		case 2: return regs->dx;
> +		case 3: return regs->cx;
> +		}
> +		return 0;
> +	}
> +}
> +#elif define(__x86_64__)

#elif defined(__x86_64__)

> +#define REGPARMS 6
> +static unsigned long fetch_argument(struct pt_regs *regs, void *data)
> +{
> +	unsigned long n = (unsigned long)data;
> +	if (n > REGPARMS) {
> +		/*
> +		 * The typical case: arg n is on the stack.
> +		 * stack[0] = return address
> +		 */
> +		return fetch_stack(regs, (void *)(n - REGPARMS));
> +	} else {
> +		switch (n) {
> +		case 1: return regs->di;
> +		case 2: return regs->si;
> +		case 3: return regs->dx;
> +		case 4: return regs->cx;
> +		case 5: return regs->r8;
> +		case 6: return regs->r9;
> +		}
> +		return 0;
> +	}
> +}
> +#else
> +static unsigned long fetch_argument(struct pt_regs *regs, void *data)
> +{
> +	return fetch_stack(regs, data);
> +}
> +#endif

As mentioned in another email, if we can generalize something similar to
syscall_get_arguments, this can be made to work for many !x86 archs.
AFAICS the calling conventions mandated by the ABI are followed at
syscall time, isn't it?

Ananth

  parent reply	other threads:[~2009-03-20  8:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-19 21:10 [RFC][PATCH -tip 7/9] tracing: kprobe-tracer plugin supports arguments Masami Hiramatsu
2009-03-20  0:51 ` Frederic Weisbecker
2009-03-20  3:40   ` Masami Hiramatsu
2009-03-20  4:41     ` Ananth N Mavinakayanahalli
2009-03-20 19:30       ` Roland McGrath
2009-03-20  8:19 ` Ananth N Mavinakayanahalli [this message]
2009-03-20 11:29   ` 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=20090320081914.GD6398@in.ibm.com \
    --to=ananth@in.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    --cc=systemtap@sources.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