From: Masami Hiramatsu <mhiramat@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
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>,
Roland McGrath <roland@redhat.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
linux-arch@vger.kernel.org
Subject: Re: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs
Date: Mon, 06 Jul 2009 15:28:02 -0400 [thread overview]
Message-ID: <4A525042.5030702@redhat.com> (raw)
In-Reply-To: <871votop6a.fsf@basil.nowhere.org>
Andi Kleen wrote:
> Masami Hiramatsu <mhiramat@redhat.com> writes:
>
>> Add following APIs for accessing registers and stack entries from pt_regs.
>
> You forgot to state who calls these functions/why are they added?
> Who only has strings for registers?
Oh, yes. This patch is needed for kprobes based event tracer on ftrace.
Some other debugging tools might be able to use it.
> I can see the point of having a function for nth argument though,
> that's useful.
>
>> +static inline unsigned long regs_get_argument_nth(struct pt_regs *regs,
>> + unsigned n)
>> +{
>> + if (n < NR_REGPARMS) {
>> + switch (n) {
>> + case 0:
>> + return regs->ax;
>> + case 1:
>> + return regs->dx;
>> + case 2:
>> + return regs->cx;
>
>
> [....]
>
> That could be done shorter with a offsetof table.
>
>> + if (n < NR_REGPARMS) {
>> + switch (n) {
>> + case 0:
>> + return regs->di;
>> + case 1:
>> + return regs->si;
>> + case 2:
>> + return regs->dx;
>> + case 3:
>> + return regs->cx;
>> + case 4:
>> + return regs->r8;
>> + case 5:
>> + return regs->r9;
>
> and that too.
I'm not so sure about your idea.
Would you mean below code?
int offs_table[NR_REGPARMS] = {
[0] = offsetof(struct pt_regs, di),
...
};
if (n < NR_REGPARMS)
return *((unsigned long *)regs + offs_table[n]);
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
WARNING: multiple messages have this Message-ID (diff)
From: Masami Hiramatsu <mhiramat@redhat.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
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>,
Roland McGrath <roland@redhat.com>,
Srikar Dronamraju <srikar@linux.vnet.ibm.com>,
linux-arch@vger.kernel.org
Subject: Re: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs
Date: Mon, 06 Jul 2009 15:28:02 -0400 [thread overview]
Message-ID: <4A525042.5030702@redhat.com> (raw)
Message-ID: <20090706192802.QVixDKD8ThNE10RSrz26-R7zqJPu1LQAPzVkQ-kLs3c@z> (raw)
In-Reply-To: <871votop6a.fsf@basil.nowhere.org>
Andi Kleen wrote:
> Masami Hiramatsu <mhiramat@redhat.com> writes:
>
>> Add following APIs for accessing registers and stack entries from pt_regs.
>
> You forgot to state who calls these functions/why are they added?
> Who only has strings for registers?
Oh, yes. This patch is needed for kprobes based event tracer on ftrace.
Some other debugging tools might be able to use it.
> I can see the point of having a function for nth argument though,
> that's useful.
>
>> +static inline unsigned long regs_get_argument_nth(struct pt_regs *regs,
>> + unsigned n)
>> +{
>> + if (n < NR_REGPARMS) {
>> + switch (n) {
>> + case 0:
>> + return regs->ax;
>> + case 1:
>> + return regs->dx;
>> + case 2:
>> + return regs->cx;
>
>
> [....]
>
> That could be done shorter with a offsetof table.
>
>> + if (n < NR_REGPARMS) {
>> + switch (n) {
>> + case 0:
>> + return regs->di;
>> + case 1:
>> + return regs->si;
>> + case 2:
>> + return regs->dx;
>> + case 3:
>> + return regs->cx;
>> + case 4:
>> + return regs->r8;
>> + case 5:
>> + return regs->r9;
>
> and that too.
I'm not so sure about your idea.
Would you mean below code?
int offs_table[NR_REGPARMS] = {
[0] = offsetof(struct pt_regs, di),
...
};
if (n < NR_REGPARMS)
return *((unsigned long *)regs + offs_table[n]);
Thank you,
--
Masami Hiramatsu
Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division
e-mail: mhiramat@redhat.com
next prev parent reply other threads:[~2009-07-06 19:28 UTC|newest]
Thread overview: 36+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-01 1:08 [PATCH -tip -v10 0/7] tracing: kprobe-based event tracer and x86 instruction decoder Masami Hiramatsu
2009-07-01 1:08 ` Masami Hiramatsu
2009-07-01 1:08 ` [PATCH -tip -v10 1/7] x86: instruction decoder API Masami Hiramatsu
2009-07-01 1:08 ` Masami Hiramatsu
2009-07-01 1:08 ` [PATCH -tip -v10 2/7] x86: x86 instruction decoder build-time selftest Masami Hiramatsu
2009-07-01 1:08 ` Masami Hiramatsu
2009-07-01 1:09 ` [PATCH -tip -v10 3/7] kprobes: checks probe address is instruction boudary on x86 Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-01 1:09 ` [PATCH -tip -v10 4/7] kprobes: cleanup fix_riprel() using insn decoder " Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-01 1:09 ` [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-06 1:42 ` Frederic Weisbecker
2009-07-06 14:34 ` Andi Kleen
2009-07-06 19:28 ` Masami Hiramatsu [this message]
2009-07-06 19:28 ` Masami Hiramatsu
2009-07-06 20:06 ` Andi Kleen
2009-07-07 0:07 ` Masami Hiramatsu
2009-07-07 0:07 ` Masami Hiramatsu
2009-07-01 1:09 ` [PATCH -tip -v10 6/7] tracing: ftrace dynamic ftrace_event_call support Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-06 1:59 ` Frederic Weisbecker
2009-07-06 1:59 ` Frederic Weisbecker
2009-07-01 1:09 ` [PATCH -tip -v10 7/7] tracing: add kprobe-based event tracer Masami Hiramatsu
2009-07-01 1:09 ` Masami Hiramatsu
2009-07-07 7:31 ` Frederic Weisbecker
2009-07-07 19:55 ` Masami Hiramatsu
2009-07-07 20:20 ` Frederic Weisbecker
2009-07-07 20:42 ` Masami Hiramatsu
2009-07-07 20:58 ` Frederic Weisbecker
2009-07-07 21:31 ` Masami Hiramatsu
2009-07-07 21:34 ` Frederic Weisbecker
2009-07-07 21:42 ` Masami Hiramatsu
2009-07-07 22:00 ` 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=4A525042.5030702@redhat.com \
--to=mhiramat@redhat.com \
--cc=ananth@in.ibm.com \
--cc=andi@firstfloor.org \
--cc=dle-develop@lists.sourceforge.net \
--cc=fweisbec@gmail.com \
--cc=hch@infradead.org \
--cc=kvm@vger.kernel.org \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=roland@redhat.com \
--cc=rostedt@goodmis.org \
--cc=srikar@linux.vnet.ibm.com \
--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 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.