Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: strace completion (Re: grouping/joining _values)

On Sun, Jun 15, 2008 at 01:49:59PM +0100, Stephane Chazelas wrote:
> On Sun, Jun 15, 2008 at 09:37:12AM +0100, Stephane Chazelas wrote:
> [...]
> > how disapointing. Could you please send me your binary of strace
> > so that I can try and understand how this can happen?
> > 
> > I was quite confident it would work as it worked on old RHEL
> > x86, new debian x86 and old Solaris sparc (with truss).
> [...]
> You must be on x86_64? I observe the same on
> td152.testdrive.hp.com (debian)
> Anyway, I also found that if it's built without optimisation or
> older gccs, it fails early because strcmp is then called and
> strace fails before it have a chance to compare the system
> call names.

I found a way to work around those problems.

Bart's problem was due (I think) to "prelink" (which
short-circuits dynamic name resolution) and can be worked around
by undoing the prelink with prelink -u. The second can be worked
around by replacing strcmp with rename (a syscall so something
that strace can trace), make sure the first renames don't fail
by touching the relevant files and then use strace to trace the
other renames and get the syscall from there.

Of course, it's probably still precarious. I've tested it on
Linux on i386, x86_64 and ia64, redhat and debian.

list_strace_syscalls() {
 rm -f -- "$tmp"
 (umask 077 && exec mkdir -- "$tmp") || return
   cd -P -- "$tmp" || return
   zmodload -i zsh/mapfile || return
   print -rn -- "${mapfile[/usr/bin/strace]//strcmp/rename}" > strace || return
   chmod +x strace
   PATH=$PATH:/usr/sbin:/sbin:/usr/local/sbin prelink -u strace 2> /dev/null
   touch time all none
   /usr/bin/strace -e rename ./strace -e xxx |&
   awk -F\" '/xxx/{print $4}' | sort -u
 local ret="$?"
 rm -rf "$tmp"
 return "$ret"


Messages sorted by: Reverse Date, Date, Thread, Author