1 --- ltrace-0.5.2.orig/TODO
4 * debug: change "-d" option to be something like "-d elf,events", or "-d breakpoints"
5 * Find out if a process is sharing memory with its parent?
6 * When using -p, find out if that process is sharing memory with other procs
7 +* After a clone(), syscalls may be seen as sysrets in s390 (see trace.c:syscall_p())
8 --- ltrace-0.5.2.orig/process_event.c
9 +++ ltrace-0.5.2/process_event.c
11 enable_breakpoint(proc->pid, proc->breakpoint_being_enabled);
12 proc->breakpoint_being_enabled = NULL;
14 - if (proc->parent->state == STATE_ATTACHED && options.follow) {
15 + if (options.follow) {
16 proc->state = STATE_ATTACHED;
18 proc->state = STATE_IGNORED;
19 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/ppc/trace.c
20 +++ ltrace-0.5.2/sysdeps/linux-gnu/ppc/trace.c
23 (int)ptrace(PTRACE_PEEKUSER, proc->pid,
24 sizeof(long) * PT_R0, 0);
25 - if (proc->callstack_depth > 0
26 - && proc->callstack[proc->callstack_depth -
28 + if (proc->callstack_depth > 0 &&
29 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
30 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
34 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/i386/trace.c
35 +++ ltrace-0.5.2/sysdeps/linux-gnu/i386/trace.c
37 *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4 * ORIG_EAX, 0);
39 if (proc->callstack_depth > 0 &&
40 - proc->callstack[proc->callstack_depth - 1].is_syscall) {
41 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
42 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
46 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/ia64/trace.c
47 +++ ltrace-0.5.2/sysdeps/linux-gnu/ia64/trace.c
49 if (insn == 0x1000000000 || insn == 0x1ffffffffff) {
51 if (proc->callstack_depth > 0 &&
52 - proc->callstack[proc->callstack_depth -
54 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
55 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
59 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/m68k/trace.c
60 +++ ltrace-0.5.2/sysdeps/linux-gnu/m68k/trace.c
63 depth = proc->callstack_depth;
65 - proc->callstack[depth - 1].is_syscall &&
66 - proc->callstack[depth - 1].c_un.syscall ==
68 + proc->callstack[depth - 1].is_syscall &&
69 + proc->callstack[depth - 1].c_un.syscall == *sysnum) {
73 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/alpha/trace.c
74 +++ ltrace-0.5.2/sysdeps/linux-gnu/alpha/trace.c
78 ptrace(PTRACE_PEEKUSER, proc->pid, 0 /* REG_R0 */ , 0);
79 - if (proc->callstack_depth > 0
80 - && proc->callstack[proc->callstack_depth - 1].is_syscall) {
81 + if (proc->callstack_depth > 0 &&
82 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
83 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
86 if (*sysnum >= 0 && *sysnum < 500) {
87 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/sparc/trace.c
88 +++ ltrace-0.5.2/sysdeps/linux-gnu/sparc/trace.c
90 insn = ptrace(PTRACE_PEEKTEXT, proc->pid, ip, 0);
91 if ((insn & 0xc1f8007f) == 0x81d00010) {
92 *sysnum = ((proc_archdep *) proc->arch_ptr)->regs.r_g1;
93 - if ((proc->callstack_depth > 0)
94 - && proc->callstack[proc->callstack_depth -
96 + if (proc->callstack_depth > 0 &&
97 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
98 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
100 } else if (*sysnum >= 0) {
102 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/mipsel/trace.c
103 +++ ltrace-0.5.2/sysdeps/linux-gnu/mipsel/trace.c
106 syscall_p(Process *proc, int status, int *sysnum) {
107 if (WIFSTOPPED(status)
108 - && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
109 - /* get the user's pc (plus 8) */
110 - long pc = (long)get_instruction_pointer(proc);
111 - /* fetch the SWI instruction */
112 - int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
113 - int num = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 8, 0);
116 - On a mipsel, syscall looks like:
117 - 24040fa1 li v0, 0x0fa1 # 4001 --> _exit syscall
120 - if(insn!=0x0000000c){
124 - *sysnum = (num & 0xFFFF) - 4000;
125 - /* if it is a syscall, return 1 or 2 */
126 - if (proc->callstack_depth > 0 &&
127 - proc->callstack[proc->callstack_depth - 1].is_syscall) {
131 - if (*sysnum >= 0) {
135 + && WSTOPSIG(status) == (SIGTRAP | proc->tracesysgood)) {
136 + /* get the user's pc (plus 8) */
137 + long pc = (long)get_instruction_pointer(proc);
138 + /* fetch the SWI instruction */
139 + int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
140 + int num = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 8, 0);
143 + On a mipsel, syscall looks like:
144 + 24040fa1 li v0, 0x0fa1 # 4001 --> _exit syscall
147 + if(insn!=0x0000000c){
151 + *sysnum = (num & 0xFFFF) - 4000;
152 + /* if it is a syscall, return 1 or 2 */
153 + if (proc->callstack_depth > 0 &&
154 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
155 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {
159 + if (*sysnum >= 0) {
166 @@ -119,34 +120,34 @@
169 gimme_arg(enum tof type, Process *proc, int arg_num, arg_type_info *info) {
171 - debug(2,"type %d arg %d",type,arg_num);
172 - if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL){
174 - ret=ptrace(PTRACE_PEEKUSER,proc->pid,off_a0+arg_num,0);
175 - debug(2,"ret = %#lx",ret);
178 - // If we need this, I think we can look at [sp+16] for arg_num==4.
184 - fprintf(stderr,"args on return?");
186 - if(type == LT_TOF_FUNCTIONR) {
187 - return ptrace(PTRACE_PEEKUSER,proc->pid,off_v0,0);
189 - if (type == LT_TOF_SYSCALLR) {
190 - unsigned a3=ptrace(PTRACE_PEEKUSER, proc->pid,off_a3,0);
191 - unsigned v0=ptrace(PTRACE_PEEKUSER, proc->pid,off_v0,0);
197 - fprintf(stderr, "gimme_arg called with wrong arguments\n");
199 + debug(2,"type %d arg %d",type,arg_num);
200 + if (type == LT_TOF_FUNCTION || type == LT_TOF_SYSCALL){
202 + ret=ptrace(PTRACE_PEEKUSER,proc->pid,off_a0+arg_num,0);
203 + debug(2,"ret = %#lx",ret);
206 + // If we need this, I think we can look at [sp+16] for arg_num==4.
212 + fprintf(stderr,"args on return?");
214 + if(type == LT_TOF_FUNCTIONR) {
215 + return ptrace(PTRACE_PEEKUSER,proc->pid,off_v0,0);
217 + if (type == LT_TOF_SYSCALLR) {
218 + unsigned a3=ptrace(PTRACE_PEEKUSER, proc->pid,off_a3,0);
219 + unsigned v0=ptrace(PTRACE_PEEKUSER, proc->pid,off_v0,0);
225 + fprintf(stderr, "gimme_arg called with wrong arguments\n");
229 --- ltrace-0.5.2.orig/sysdeps/linux-gnu/x86_64/trace.c
230 +++ ltrace-0.5.2/sysdeps/linux-gnu/x86_64/trace.c
232 *sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 8 * ORIG_RAX, 0);
234 if (proc->callstack_depth > 0 &&
235 - proc->callstack[proc->callstack_depth - 1].is_syscall) {
236 + proc->callstack[proc->callstack_depth - 1].is_syscall &&
237 + proc->callstack[proc->callstack_depth - 1].c_un.syscall == *sysnum) {