This is the mail archive of the
systemtap@sourceware.org
mailing list for the systemtap project.
Re: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs
- From: Masami Hiramatsu <mhiramat at redhat dot com>
- To: Andi Kleen <andi at firstfloor dot org>
- Cc: Ingo Molnar <mingo at elte dot hu>, Steven Rostedt <rostedt at goodmis dot org>, lkml <linux-kernel at vger dot kernel dot org>, systemtap <systemtap at sources dot redhat dot com>, kvm <kvm at vger dot kernel dot org>, DLE <dle-develop at lists dot sourceforge dot net>, Christoph Hellwig <hch at infradead dot org>, Ananth N Mavinakayanahalli <ananth at in dot ibm dot com>, Frederic Weisbecker <fweisbec at gmail dot com>, Roland McGrath <roland at redhat dot com>, Srikar Dronamraju <srikar at linux dot vnet dot ibm dot com>, linux-arch at vger dot kernel dot org
- Date: Mon, 06 Jul 2009 15:28:02 -0400
- Subject: Re: [PATCH -tip -v10 5/7] x86: add pt_regs register and stack access APIs
- References: <20090701010838.32547.62843.stgit@localhost.localdomain> <20090701010911.32547.1313.stgit@localhost.localdomain> <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