[debug-ltrace] Add latest version.
author"Yann E. MORIN" <yann.morin.1998@anciens.enib.fr>
Sun Aug 02 23:33:36 2009 +0200 (2009-08-02)
changeset 1437b37804bfeba6
parent 1436 3cfa075e88b3
child 1438 023fdab7a819
[debug-ltrace] Add latest version.

Add ltrace 0.5.2, propagate patchset from 0.5.1 and from Debian.
config/debug/ltrace.in
patches/ltrace/0.5.2/100-allow-cross-compile.patch
patches/ltrace/0.5.2/110-alpha-support.patch
patches/ltrace/0.5.2/120-debian-ltrace-0.5.2-2.patch
     1.1 --- a/config/debug/ltrace.in	Sun Aug 02 23:33:36 2009 +0200
     1.2 +++ b/config/debug/ltrace.in	Sun Aug 02 23:33:36 2009 +0200
     1.3 @@ -25,6 +25,10 @@
     1.4      prompt "0.5.1  (EXPERIMENTAL)"
     1.5      depends on EXPERIMENTAL
     1.6  
     1.7 +config LTRACE_V_0_5_2
     1.8 +    bool
     1.9 +    prompt "0.5.2"
    1.10 +
    1.11  # CT_INSERT_VERSION_ABOVE
    1.12  # Don't remove above line!
    1.13  endchoice
    1.14 @@ -34,5 +38,6 @@
    1.15      default "0.4" if LTRACE_V_0_4
    1.16      default "0.5" if LTRACE_V_0_5
    1.17      default "0.5.1" if LTRACE_V_0_5_1
    1.18 +    default "0.5.2" if LTRACE_V_0_5_2
    1.19  # CT_INSERT_VERSION_STRING_ABOVE
    1.20  # # Don't remove above line!
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/patches/ltrace/0.5.2/100-allow-cross-compile.patch	Sun Aug 02 23:33:36 2009 +0200
     2.3 @@ -0,0 +1,77 @@
     2.4 +diff -durN ltrace-0.5.2.orig/Makefile.in ltrace-0.5.2/Makefile.in
     2.5 +--- ltrace-0.5.2.orig/Makefile.in	2009-05-21 19:14:54.000000000 +0200
     2.6 ++++ ltrace-0.5.2/Makefile.in	2009-06-27 15:30:34.000000000 +0200
     2.7 +@@ -2,8 +2,14 @@
     2.8 + # ltrace's Makefile.in
     2.9 + #
    2.10 + 
    2.11 +-#OS		:= $(shell uname -s)
    2.12 + OS		:= @HOST_OS@
    2.13 ++ARCH		:= $(shell echo "@HOST_ARCH@" |sed -e s/i.86/i386/      \
    2.14 ++						   -e s/sun4u/sparc64/  \
    2.15 ++						   -e s/arm.*/arm/      \
    2.16 ++						   -e s/sa110/arm/      \
    2.17 ++						   -e s/ppc64/ppc/      \
    2.18 ++						   -e s/s390x/s390/)
    2.19 ++export ARCH
    2.20 + 
    2.21 + TOPDIR		= $(shell pwd)
    2.22 + 
    2.23 +diff -durN ltrace-0.5.2.orig/configure ltrace-0.5.2/configure
    2.24 +--- ltrace-0.5.2.orig/configure	2009-05-21 19:14:57.000000000 +0200
    2.25 ++++ ltrace-0.5.2/configure	2009-06-27 15:30:34.000000000 +0200
    2.26 +@@ -660,6 +660,7 @@
    2.27 + host_cpu
    2.28 + host_vendor
    2.29 + host_os
    2.30 ++HOST_ARCH
    2.31 + HOST_OS
    2.32 + CC
    2.33 + CFLAGS
    2.34 +@@ -1823,6 +1824,7 @@
    2.35 + case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
    2.36 + 
    2.37 + 
    2.38 ++HOST_ARCH="$host_cpu"
    2.39 + case "$host_os" in
    2.40 +   linux-gnu*) host_os=linux-gnu
    2.41 + esac
    2.42 +@@ -5406,6 +5408,7 @@
    2.43 + host_cpu!$host_cpu$ac_delim
    2.44 + host_vendor!$host_vendor$ac_delim
    2.45 + host_os!$host_os$ac_delim
    2.46 ++HOST_ARCH!$HOST_ARCH$ac_delim
    2.47 + HOST_OS!$HOST_OS$ac_delim
    2.48 + CC!$CC$ac_delim
    2.49 + CFLAGS!$CFLAGS$ac_delim
    2.50 +@@ -5426,7 +5429,7 @@
    2.51 + LTLIBOBJS!$LTLIBOBJS$ac_delim
    2.52 + _ACEOF
    2.53 + 
    2.54 +-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 63; then
    2.55 ++  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 64; then
    2.56 +     break
    2.57 +   elif $ac_last_try; then
    2.58 +     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
    2.59 +diff -durN ltrace-0.5.2.orig/configure.ac ltrace-0.5.2/configure.ac
    2.60 +--- ltrace-0.5.2.orig/configure.ac	2009-05-21 19:14:54.000000000 +0200
    2.61 ++++ ltrace-0.5.2/configure.ac	2009-06-27 15:30:34.000000000 +0200
    2.62 +@@ -11,6 +11,8 @@
    2.63 + esac
    2.64 + HOST_OS="$host_os"
    2.65 + AC_SUBST(HOST_OS)
    2.66 ++HOST_ARCH="$host_cpu"
    2.67 ++AC_SUBST(HOST_ARCH)
    2.68 + 
    2.69 + dnl Checks for programs.
    2.70 + AC_PROG_CC
    2.71 +diff -durN ltrace-0.5.2.orig/sysdeps/linux-gnu/Makefile ltrace-0.5.2/sysdeps/linux-gnu/Makefile
    2.72 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/Makefile	2009-05-21 19:14:54.000000000 +0200
    2.73 ++++ ltrace-0.5.2/sysdeps/linux-gnu/Makefile	2009-06-27 15:30:34.000000000 +0200
    2.74 +@@ -1,6 +1,3 @@
    2.75 +-ARCH		:=	$(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
    2.76 +-			-e s/arm.*/arm/ -e s/sa110/arm/ -e s/ppc64/ppc/ -e s/s390x/s390/)
    2.77 +-
    2.78 + CPPFLAGS	+=	-I$(TOPDIR)/sysdeps/linux-gnu/$(ARCH)
    2.79 + 
    2.80 + OBJ		=	events.o trace.o proc.o breakpoint.o
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/patches/ltrace/0.5.2/110-alpha-support.patch	Sun Aug 02 23:33:36 2009 +0200
     3.3 @@ -0,0 +1,11 @@
     3.4 +diff -durN ltrace-0.5.2.orig/Makefile.in ltrace-0.5.2/Makefile.in
     3.5 +--- ltrace-0.5.2.orig/Makefile.in	2009-06-27 15:34:04.000000000 +0200
     3.6 ++++ ltrace-0.5.2/Makefile.in	2009-06-27 15:34:27.000000000 +0200
     3.7 +@@ -5,6 +5,7 @@
     3.8 + OS		:= @HOST_OS@
     3.9 + ARCH		:= $(shell echo "@HOST_ARCH@" |sed -e s/i.86/i386/      \
    3.10 + 						   -e s/sun4u/sparc64/  \
    3.11 ++						   -e s/alpha.*/alpha/  \
    3.12 + 						   -e s/arm.*/arm/      \
    3.13 + 						   -e s/sa110/arm/      \
    3.14 + 						   -e s/ppc64/ppc/      \
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/patches/ltrace/0.5.2/120-debian-ltrace-0.5.2-2.patch	Sun Aug 02 23:33:36 2009 +0200
     4.3 @@ -0,0 +1,240 @@
     4.4 +--- ltrace-0.5.2.orig/TODO
     4.5 ++++ ltrace-0.5.2/TODO
     4.6 +@@ -37,3 +37,4 @@
     4.7 + * debug: change "-d" option to be something like "-d elf,events", or "-d breakpoints"
     4.8 + * Find out if a process is sharing memory with its parent?
     4.9 + * When using -p, find out if that process is sharing memory with other procs
    4.10 ++* After a clone(), syscalls may be seen as sysrets in s390 (see trace.c:syscall_p())
    4.11 +--- ltrace-0.5.2.orig/process_event.c
    4.12 ++++ ltrace-0.5.2/process_event.c
    4.13 +@@ -170,7 +170,7 @@
    4.14 + 			enable_breakpoint(proc->pid, proc->breakpoint_being_enabled);
    4.15 + 			proc->breakpoint_being_enabled = NULL;
    4.16 + 		}
    4.17 +-		if (proc->parent->state == STATE_ATTACHED && options.follow) {
    4.18 ++		if (options.follow) {
    4.19 + 			proc->state = STATE_ATTACHED;
    4.20 + 		} else {
    4.21 + 			proc->state = STATE_IGNORED;
    4.22 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/ppc/trace.c
    4.23 ++++ ltrace-0.5.2/sysdeps/linux-gnu/ppc/trace.c
    4.24 +@@ -50,9 +50,9 @@
    4.25 + 			*sysnum =
    4.26 + 			    (int)ptrace(PTRACE_PEEKUSER, proc->pid,
    4.27 + 					sizeof(long) * PT_R0, 0);
    4.28 +-			if (proc->callstack_depth > 0
    4.29 +-			    && proc->callstack[proc->callstack_depth -
    4.30 +-					       1].is_syscall) {
    4.31 ++			if (proc->callstack_depth > 0 &&
    4.32 ++					proc->callstack[proc->callstack_depth - 1].is_syscall &&
    4.33 ++					proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
    4.34 + 				return 2;
    4.35 + 			}
    4.36 + 			return 1;
    4.37 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/i386/trace.c
    4.38 ++++ ltrace-0.5.2/sysdeps/linux-gnu/i386/trace.c
    4.39 +@@ -32,7 +32,8 @@
    4.40 + 		*sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4 * ORIG_EAX, 0);
    4.41 + 
    4.42 + 		if (proc->callstack_depth > 0 &&
    4.43 +-		    proc->callstack[proc->callstack_depth - 1].is_syscall) {
    4.44 ++				proc->callstack[proc->callstack_depth - 1].is_syscall &&
    4.45 ++				proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
    4.46 + 			return 2;
    4.47 + 		}
    4.48 + 
    4.49 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/ia64/trace.c
    4.50 ++++ ltrace-0.5.2/sysdeps/linux-gnu/ia64/trace.c
    4.51 +@@ -106,8 +106,8 @@
    4.52 + 		if (insn == 0x1000000000 || insn == 0x1ffffffffff) {
    4.53 + 			*sysnum = r15;
    4.54 + 			if (proc->callstack_depth > 0 &&
    4.55 +-			    proc->callstack[proc->callstack_depth -
    4.56 +-					    1].is_syscall) {
    4.57 ++				proc->callstack[proc->callstack_depth - 1].is_syscall &&
    4.58 ++				proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
    4.59 + 				return 2;
    4.60 + 			}
    4.61 + 			return 1;
    4.62 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/m68k/trace.c
    4.63 ++++ ltrace-0.5.2/sysdeps/linux-gnu/m68k/trace.c
    4.64 +@@ -36,9 +36,8 @@
    4.65 + 		if (*sysnum >= 0) {
    4.66 + 			depth = proc->callstack_depth;
    4.67 + 			if (depth > 0 &&
    4.68 +-			    proc->callstack[depth - 1].is_syscall &&
    4.69 +-			    proc->callstack[depth - 1].c_un.syscall ==
    4.70 +-			    *sysnum) {
    4.71 ++					proc->callstack[depth - 1].is_syscall &&
    4.72 ++					proc->callstack[depth - 1].c_un.syscall == *sysnum) {
    4.73 + 				return 2;
    4.74 + 			} else {
    4.75 + 				return 1;
    4.76 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/alpha/trace.c
    4.77 ++++ ltrace-0.5.2/sysdeps/linux-gnu/alpha/trace.c
    4.78 +@@ -36,8 +36,9 @@
    4.79 + 			return 0;
    4.80 + 		*sysnum =
    4.81 + 		    ptrace(PTRACE_PEEKUSER, proc->pid, 0 /* REG_R0 */ , 0);
    4.82 +-		if (proc->callstack_depth > 0
    4.83 +-		    && proc->callstack[proc->callstack_depth - 1].is_syscall) {
    4.84 ++		if (proc->callstack_depth > 0 &&
    4.85 ++		    proc->callstack[proc->callstack_depth - 1].is_syscall &&
    4.86 ++			proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
    4.87 + 			return 2;
    4.88 + 		}
    4.89 + 		if (*sysnum >= 0 && *sysnum < 500) {
    4.90 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/sparc/trace.c
    4.91 ++++ ltrace-0.5.2/sysdeps/linux-gnu/sparc/trace.c
    4.92 +@@ -33,9 +33,9 @@
    4.93 + 		insn = ptrace(PTRACE_PEEKTEXT, proc->pid, ip, 0);
    4.94 + 		if ((insn & 0xc1f8007f) == 0x81d00010) {
    4.95 + 			*sysnum = ((proc_archdep *) proc->arch_ptr)->regs.r_g1;
    4.96 +-			if ((proc->callstack_depth > 0)
    4.97 +-			    && proc->callstack[proc->callstack_depth -
    4.98 +-					       1].is_syscall) {
    4.99 ++			if (proc->callstack_depth > 0 &&
   4.100 ++					proc->callstack[proc->callstack_depth - 1].is_syscall &&
   4.101 ++					proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
   4.102 + 				return 2;
   4.103 + 			} else if (*sysnum >= 0) {
   4.104 + 				return 1;
   4.105 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/mipsel/trace.c
   4.106 ++++ ltrace-0.5.2/sysdeps/linux-gnu/mipsel/trace.c
   4.107 +@@ -60,33 +60,34 @@
   4.108 + int
   4.109 + syscall_p(Process *proc, int status, int *sysnum) {
   4.110 + 	if (WIFSTOPPED(status)
   4.111 +-	    && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
   4.112 +-       /* get the user's pc (plus 8) */
   4.113 +-       long pc = (long)get_instruction_pointer(proc);
   4.114 +-       /* fetch the SWI instruction */
   4.115 +-       int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
   4.116 +-       int num = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 8, 0);
   4.117 +-       
   4.118 +-/*
   4.119 +-  On a mipsel,  syscall looks like:
   4.120 +-  24040fa1    li v0, 0x0fa1   # 4001 --> _exit syscall
   4.121 +-  0000000c    syscall
   4.122 +- */
   4.123 +-      if(insn!=0x0000000c){
   4.124 +-          return 0;
   4.125 +-      }
   4.126 +-
   4.127 +-      *sysnum = (num & 0xFFFF) - 4000;
   4.128 +-      /* if it is a syscall, return 1 or 2 */
   4.129 +-      if (proc->callstack_depth > 0 &&
   4.130 +-          proc->callstack[proc->callstack_depth - 1].is_syscall) {
   4.131 +-          return 2;
   4.132 +-      }
   4.133 +-      
   4.134 +-      if (*sysnum >= 0) {
   4.135 +-          return 1;
   4.136 +-      }
   4.137 +-   }
   4.138 ++			&& WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
   4.139 ++		/* get the user's pc (plus 8) */
   4.140 ++		long pc = (long)get_instruction_pointer(proc);
   4.141 ++		/* fetch the SWI instruction */
   4.142 ++		int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
   4.143 ++		int num = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 8, 0);
   4.144 ++
   4.145 ++		/*
   4.146 ++		   On a mipsel,  syscall looks like:
   4.147 ++		   24040fa1    li v0, 0x0fa1   # 4001 --> _exit syscall
   4.148 ++		   0000000c    syscall
   4.149 ++		 */
   4.150 ++		if(insn!=0x0000000c){
   4.151 ++			return 0;
   4.152 ++		}
   4.153 ++
   4.154 ++		*sysnum = (num & 0xFFFF) - 4000;
   4.155 ++		/* if it is a syscall, return 1 or 2 */
   4.156 ++		if (proc->callstack_depth > 0 &&
   4.157 ++				proc->callstack[proc->callstack_depth - 1].is_syscall &&
   4.158 ++				proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
   4.159 ++			return 2;
   4.160 ++		}
   4.161 ++
   4.162 ++		if (*sysnum >= 0) {
   4.163 ++			return 1;
   4.164 ++		}
   4.165 ++	}
   4.166 + 	return 0;
   4.167 + }
   4.168 + /**
   4.169 +@@ -119,34 +120,34 @@
   4.170 + */
   4.171 + long
   4.172 + gimme_arg(enum tof type, Process *proc, int arg_num, arg_type_info *info) {
   4.173 +-    long ret;
   4.174 +-    debug(2,"type %d arg %d",type,arg_num);
   4.175 +-    if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL){
   4.176 +-        if(arg_num <4){
   4.177 +-            ret=ptrace(PTRACE_PEEKUSER,proc->pid,off_a0+arg_num,0);
   4.178 +-            debug(2,"ret = %#lx",ret);
   4.179 +-            return ret;
   4.180 +-        } else {
   4.181 +-            // If we need this, I think we can look at [sp+16] for arg_num==4.
   4.182 +-            CP;
   4.183 +-            return 0;
   4.184 +-        }
   4.185 +-    } 
   4.186 +-    if(arg_num>=0){
   4.187 +-       fprintf(stderr,"args on return?");
   4.188 +-    }
   4.189 +-    if(type == LT_TOF_FUNCTIONR) {
   4.190 +-        return  ptrace(PTRACE_PEEKUSER,proc->pid,off_v0,0);
   4.191 +-    }
   4.192 +-    if (type == LT_TOF_SYSCALLR) {
   4.193 +-        unsigned a3=ptrace(PTRACE_PEEKUSER, proc->pid,off_a3,0);
   4.194 +-        unsigned v0=ptrace(PTRACE_PEEKUSER, proc->pid,off_v0,0);
   4.195 +-        if(!a3){
   4.196 +-            return v0;
   4.197 +-        }
   4.198 +-        return -1;
   4.199 +-    }
   4.200 +-    fprintf(stderr, "gimme_arg called with wrong arguments\n");
   4.201 ++	long ret;
   4.202 ++	debug(2,"type %d arg %d",type,arg_num);
   4.203 ++	if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL){
   4.204 ++		if(arg_num <4){
   4.205 ++			ret=ptrace(PTRACE_PEEKUSER,proc->pid,off_a0+arg_num,0);
   4.206 ++			debug(2,"ret = %#lx",ret);
   4.207 ++			return ret;
   4.208 ++		} else {
   4.209 ++			// If we need this, I think we can look at [sp+16] for arg_num==4.
   4.210 ++			CP;
   4.211 ++			return 0;
   4.212 ++		}
   4.213 ++	} 
   4.214 ++	if(arg_num>=0){
   4.215 ++		fprintf(stderr,"args on return?");
   4.216 ++	}
   4.217 ++	if(type == LT_TOF_FUNCTIONR) {
   4.218 ++		return  ptrace(PTRACE_PEEKUSER,proc->pid,off_v0,0);
   4.219 ++	}
   4.220 ++	if (type == LT_TOF_SYSCALLR) {
   4.221 ++		unsigned a3=ptrace(PTRACE_PEEKUSER, proc->pid,off_a3,0);
   4.222 ++		unsigned v0=ptrace(PTRACE_PEEKUSER, proc->pid,off_v0,0);
   4.223 ++		if(!a3){
   4.224 ++			return v0;
   4.225 ++		}
   4.226 ++		return -1;
   4.227 ++	}
   4.228 ++	fprintf(stderr, "gimme_arg called with wrong arguments\n");
   4.229 + 	return 0;
   4.230 + }
   4.231 + 
   4.232 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/x86_64/trace.c
   4.233 ++++ ltrace-0.5.2/sysdeps/linux-gnu/x86_64/trace.c
   4.234 +@@ -41,7 +41,8 @@
   4.235 + 		*sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 8 * ORIG_RAX, 0);
   4.236 + 
   4.237 + 		if (proc->callstack_depth > 0 &&
   4.238 +-		    proc->callstack[proc->callstack_depth - 1].is_syscall) {
   4.239 ++				proc->callstack[proc->callstack_depth - 1].is_syscall &&
   4.240 ++				proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
   4.241 + 			return 2;
   4.242 + 		}
   4.243 +