[PATCH] Use PTRACE_GETREGS on i386

Denys Vlasenko dvlasenk at redhat.com
Fri Aug 26 18:26:57 UTC 2011


On Fri, 2011-08-26 at 21:57 +0400, Dmitry V. Levin wrote:
> > > strace is not going to call PTRACE_GETREGS with different regs structures,
> > > so is there any use to include the architecture name to the structure
> > > name?
> > 
> > There *is* a reason to name it i386_regs: it makes it possible
> > to easily find its uses.
> 
> It is called just "regs" three times in this file already: on ARM, AVR32,
> SPARC and SPARC64:
> $ grep -Fn 'static struct pt_regs' syscall.c
> 730:static struct pt_regs regs;
> 735:static struct pt_regs regs;
> 737:static struct pt_regs regs;

Which makes it much harder to find all uses of regs in, say, AVR32
build.

> Of course pt_regs field names may differ, but why should we introduce a
> difference in naming if there are no differences in use?
> Or am I missing something?

When I was preparing change f20bff6a7397cae272b8bee76a31c4163d8a8a43,
more precisely, its part which moved Blackfin's

       if (upeek(tcp, PT_R0, &r0) < 0)
               return -1;

from syscall_fixup_on_sysexit to get_syscall_result,
I had to examine all code to ensure that old r0 is not used
anywhere between get_syscall_result and syscall_fixup_on_sysexit.

My job was harder than it had to be because of Alpha's and SH's
variable with the same name. I had to look at every found r0 usage
and filter out those which are not on Blackfin.

I wish the variable be named bfin_r0.


> > For example,  Alpha, Blackfin and SH all have "static long r0". How can
> > I quickly find only Alpha's usages of r0? There is no easy way to do it.
> > I'd rather have them named alpha_r0, bfin_r0, sh_r0.
> 
> I'd rather kick them out in favour of pt_regs, so it would be regs.r0 instead.
> Or would you like to call them alpha_regs.r0, bfin_regs.r0 and sh_regs.r0?

Yes, <arch>_regs is better, for the reason explained above.

-- 
vda





More information about the Strace-devel mailing list