1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/patches/ltrace/0.5.2/120-debian-ltrace-0.5.2-2.patch Mon Oct 18 16:51:01 2010 +0200
1.3 @@ -0,0 +1,240 @@
1.4 +--- ltrace-0.5.2.orig/TODO
1.5 ++++ ltrace-0.5.2/TODO
1.6 +@@ -37,3 +37,4 @@
1.7 + * debug: change "-d" option to be something like "-d elf,events", or "-d breakpoints"
1.8 + * Find out if a process is sharing memory with its parent?
1.9 + * When using -p, find out if that process is sharing memory with other procs
1.10 ++* After a clone(), syscalls may be seen as sysrets in s390 (see trace.c:syscall_p())
1.11 +--- ltrace-0.5.2.orig/process_event.c
1.12 ++++ ltrace-0.5.2/process_event.c
1.13 +@@ -170,7 +170,7 @@
1.14 + enable_breakpoint(proc->pid, proc->breakpoint_being_enabled);
1.15 + proc->breakpoint_being_enabled = NULL;
1.16 + }
1.17 +- if (proc->parent->state == STATE_ATTACHED && options.follow) {
1.18 ++ if (options.follow) {
1.19 + proc->state = STATE_ATTACHED;
1.20 + } else {
1.21 + proc->state = STATE_IGNORED;
1.22 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/ppc/trace.c
1.23 ++++ ltrace-0.5.2/sysdeps/linux-gnu/ppc/trace.c
1.24 +@@ -50,9 +50,9 @@
1.25 + *sysnum =
1.26 + (int)ptrace(PTRACE_PEEKUSER, proc->pid,
1.27 + sizeof(long) * PT_R0, 0);
1.28 +- if (proc->callstack_depth > 0
1.29 +- && proc->callstack[proc->callstack_depth -
1.30 +- 1].is_syscall) {
1.31 ++ if (proc->callstack_depth > 0 &&
1.32 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.33 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.34 + return 2;
1.35 + }
1.36 + return 1;
1.37 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/i386/trace.c
1.38 ++++ ltrace-0.5.2/sysdeps/linux-gnu/i386/trace.c
1.39 +@@ -32,7 +32,8 @@
1.40 + *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4 * ORIG_EAX, 0);
1.41 +
1.42 + if (proc->callstack_depth > 0 &&
1.43 +- proc->callstack[proc->callstack_depth - 1].is_syscall) {
1.44 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.45 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.46 + return 2;
1.47 + }
1.48 +
1.49 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/ia64/trace.c
1.50 ++++ ltrace-0.5.2/sysdeps/linux-gnu/ia64/trace.c
1.51 +@@ -106,8 +106,8 @@
1.52 + if (insn == 0x1000000000 || insn == 0x1ffffffffff) {
1.53 + *sysnum = r15;
1.54 + if (proc->callstack_depth > 0 &&
1.55 +- proc->callstack[proc->callstack_depth -
1.56 +- 1].is_syscall) {
1.57 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.58 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.59 + return 2;
1.60 + }
1.61 + return 1;
1.62 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/m68k/trace.c
1.63 ++++ ltrace-0.5.2/sysdeps/linux-gnu/m68k/trace.c
1.64 +@@ -36,9 +36,8 @@
1.65 + if (*sysnum >= 0) {
1.66 + depth = proc->callstack_depth;
1.67 + if (depth > 0 &&
1.68 +- proc->callstack[depth - 1].is_syscall &&
1.69 +- proc->callstack[depth - 1].c_un.syscall ==
1.70 +- *sysnum) {
1.71 ++ proc->callstack[depth - 1].is_syscall &&
1.72 ++ proc->callstack[depth - 1].c_un.syscall == *sysnum) {
1.73 + return 2;
1.74 + } else {
1.75 + return 1;
1.76 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/alpha/trace.c
1.77 ++++ ltrace-0.5.2/sysdeps/linux-gnu/alpha/trace.c
1.78 +@@ -36,8 +36,9 @@
1.79 + return 0;
1.80 + *sysnum =
1.81 + ptrace(PTRACE_PEEKUSER, proc->pid, 0 /* REG_R0 */ , 0);
1.82 +- if (proc->callstack_depth > 0
1.83 +- && proc->callstack[proc->callstack_depth - 1].is_syscall) {
1.84 ++ if (proc->callstack_depth > 0 &&
1.85 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.86 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.87 + return 2;
1.88 + }
1.89 + if (*sysnum >= 0 && *sysnum < 500) {
1.90 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/sparc/trace.c
1.91 ++++ ltrace-0.5.2/sysdeps/linux-gnu/sparc/trace.c
1.92 +@@ -33,9 +33,9 @@
1.93 + insn = ptrace(PTRACE_PEEKTEXT, proc->pid, ip, 0);
1.94 + if ((insn & 0xc1f8007f) == 0x81d00010) {
1.95 + *sysnum = ((proc_archdep *) proc->arch_ptr)->regs.r_g1;
1.96 +- if ((proc->callstack_depth > 0)
1.97 +- && proc->callstack[proc->callstack_depth -
1.98 +- 1].is_syscall) {
1.99 ++ if (proc->callstack_depth > 0 &&
1.100 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.101 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.102 + return 2;
1.103 + } else if (*sysnum >= 0) {
1.104 + return 1;
1.105 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/mipsel/trace.c
1.106 ++++ ltrace-0.5.2/sysdeps/linux-gnu/mipsel/trace.c
1.107 +@@ -60,33 +60,34 @@
1.108 + int
1.109 + syscall_p(Process *proc, int status, int *sysnum) {
1.110 + if (WIFSTOPPED(status)
1.111 +- && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
1.112 +- /* get the user's pc (plus 8) */
1.113 +- long pc = (long)get_instruction_pointer(proc);
1.114 +- /* fetch the SWI instruction */
1.115 +- int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
1.116 +- int num = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 8, 0);
1.117 +-
1.118 +-/*
1.119 +- On a mipsel, syscall looks like:
1.120 +- 24040fa1 li v0, 0x0fa1 # 4001 --> _exit syscall
1.121 +- 0000000c syscall
1.122 +- */
1.123 +- if(insn!=0x0000000c){
1.124 +- return 0;
1.125 +- }
1.126 +-
1.127 +- *sysnum = (num & 0xFFFF) - 4000;
1.128 +- /* if it is a syscall, return 1 or 2 */
1.129 +- if (proc->callstack_depth > 0 &&
1.130 +- proc->callstack[proc->callstack_depth - 1].is_syscall) {
1.131 +- return 2;
1.132 +- }
1.133 +-
1.134 +- if (*sysnum >= 0) {
1.135 +- return 1;
1.136 +- }
1.137 +- }
1.138 ++ && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
1.139 ++ /* get the user's pc (plus 8) */
1.140 ++ long pc = (long)get_instruction_pointer(proc);
1.141 ++ /* fetch the SWI instruction */
1.142 ++ int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
1.143 ++ int num = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 8, 0);
1.144 ++
1.145 ++ /*
1.146 ++ On a mipsel, syscall looks like:
1.147 ++ 24040fa1 li v0, 0x0fa1 # 4001 --> _exit syscall
1.148 ++ 0000000c syscall
1.149 ++ */
1.150 ++ if(insn!=0x0000000c){
1.151 ++ return 0;
1.152 ++ }
1.153 ++
1.154 ++ *sysnum = (num & 0xFFFF) - 4000;
1.155 ++ /* if it is a syscall, return 1 or 2 */
1.156 ++ if (proc->callstack_depth > 0 &&
1.157 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.158 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.159 ++ return 2;
1.160 ++ }
1.161 ++
1.162 ++ if (*sysnum >= 0) {
1.163 ++ return 1;
1.164 ++ }
1.165 ++ }
1.166 + return 0;
1.167 + }
1.168 + /**
1.169 +@@ -119,34 +120,34 @@
1.170 + */
1.171 + long
1.172 + gimme_arg(enum tof type, Process *proc, int arg_num, arg_type_info *info) {
1.173 +- long ret;
1.174 +- debug(2,"type %d arg %d",type,arg_num);
1.175 +- if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL){
1.176 +- if(arg_num <4){
1.177 +- ret=ptrace(PTRACE_PEEKUSER,proc->pid,off_a0+arg_num,0);
1.178 +- debug(2,"ret = %#lx",ret);
1.179 +- return ret;
1.180 +- } else {
1.181 +- // If we need this, I think we can look at [sp+16] for arg_num==4.
1.182 +- CP;
1.183 +- return 0;
1.184 +- }
1.185 +- }
1.186 +- if(arg_num>=0){
1.187 +- fprintf(stderr,"args on return?");
1.188 +- }
1.189 +- if(type == LT_TOF_FUNCTIONR) {
1.190 +- return ptrace(PTRACE_PEEKUSER,proc->pid,off_v0,0);
1.191 +- }
1.192 +- if (type == LT_TOF_SYSCALLR) {
1.193 +- unsigned a3=ptrace(PTRACE_PEEKUSER, proc->pid,off_a3,0);
1.194 +- unsigned v0=ptrace(PTRACE_PEEKUSER, proc->pid,off_v0,0);
1.195 +- if(!a3){
1.196 +- return v0;
1.197 +- }
1.198 +- return -1;
1.199 +- }
1.200 +- fprintf(stderr, "gimme_arg called with wrong arguments\n");
1.201 ++ long ret;
1.202 ++ debug(2,"type %d arg %d",type,arg_num);
1.203 ++ if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL){
1.204 ++ if(arg_num <4){
1.205 ++ ret=ptrace(PTRACE_PEEKUSER,proc->pid,off_a0+arg_num,0);
1.206 ++ debug(2,"ret = %#lx",ret);
1.207 ++ return ret;
1.208 ++ } else {
1.209 ++ // If we need this, I think we can look at [sp+16] for arg_num==4.
1.210 ++ CP;
1.211 ++ return 0;
1.212 ++ }
1.213 ++ }
1.214 ++ if(arg_num>=0){
1.215 ++ fprintf(stderr,"args on return?");
1.216 ++ }
1.217 ++ if(type == LT_TOF_FUNCTIONR) {
1.218 ++ return ptrace(PTRACE_PEEKUSER,proc->pid,off_v0,0);
1.219 ++ }
1.220 ++ if (type == LT_TOF_SYSCALLR) {
1.221 ++ unsigned a3=ptrace(PTRACE_PEEKUSER, proc->pid,off_a3,0);
1.222 ++ unsigned v0=ptrace(PTRACE_PEEKUSER, proc->pid,off_v0,0);
1.223 ++ if(!a3){
1.224 ++ return v0;
1.225 ++ }
1.226 ++ return -1;
1.227 ++ }
1.228 ++ fprintf(stderr, "gimme_arg called with wrong arguments\n");
1.229 + return 0;
1.230 + }
1.231 +
1.232 +--- ltrace-0.5.2.orig/sysdeps/linux-gnu/x86_64/trace.c
1.233 ++++ ltrace-0.5.2/sysdeps/linux-gnu/x86_64/trace.c
1.234 +@@ -41,7 +41,8 @@
1.235 + *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 8 * ORIG_RAX, 0);
1.236 +
1.237 + if (proc->callstack_depth > 0 &&
1.238 +- proc->callstack[proc->callstack_depth - 1].is_syscall) {
1.239 ++ proc->callstack[proc->callstack_depth - 1].is_syscall &&
1.240 ++ proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
1.241 + return 2;
1.242 + }
1.243 +