Re: [PATCH 01/16] perf: Unified API to record selective sets of archregisters

From: Frederic Weisbecker
Date: Thu Jun 07 2012 - 05:46:33 EST


On Thu, May 24, 2012 at 11:43:56AM +0200, Peter Zijlstra wrote:
> On Wed, 2012-05-23 at 21:32 +0200, Jiri Olsa wrote:
> > +static inline u64 perf_reg_value(struct pt_regs *regs, int idx)
> > +{
> > + switch (idx) {
> > + case PERF_X86_32_REG_EAX:
> > + return regs->ax;
> > + case PERF_X86_32_REG_EBX:
> > + return regs->bx;
> > + case PERF_X86_32_REG_ECX:
> > + return regs->cx;
> > + case PERF_X86_32_REG_EDX:
> > + return regs->dx;
> > + case PERF_X86_32_REG_ESI:
> > + return regs->si;
> > + case PERF_X86_32_REG_EDI:
> > + return regs->di;
> > + case PERF_X86_32_REG_EBP:
> > + return regs->bp;
> > + case PERF_X86_32_REG_ESP:
> > + return regs->sp;
> > + case PERF_X86_32_REG_EIP:
> > + return regs->ip;
> > + case PERF_X86_32_REG_FLAGS:
> > + return regs->flags;
> > + case PERF_X86_32_REG_CS:
> > + return regs->cs;
> > + case PERF_X86_32_REG_DS:
> > + return regs->ds;
> > + case PERF_X86_32_REG_ES:
> > + return regs->es;
> > + case PERF_X86_32_REG_FS:
> > + return regs->fs;
> > + case PERF_X86_32_REG_GS:
> > + return regs->gs;
> > + }
> > +
> > + return 0;
> > +}
>
> This is just sad... is there really no saner way to write this? I
> suppose you're going to iterate your sample_regs bitmap and call this
> function for every bit. GCC isn't known to generate particularly sane
> code for switches :/
>

Do you think that compat regs are always a subset of native regs in all
archs as in x86? Sounds logic but I'm asking just in case. If so then yeah
this should work.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/