Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > media > main-src > by-pkgid > b3bd92884018251b87f9099340c300c3 > files > 32

ltrace-0.5-13.45svn.el5_7.12.src.rpm

diff -Naurp ltrace-0.5/process_event.c ltrace-0.5-mod/process_event.c
--- ltrace-0.5/process_event.c	2006-09-26 08:41:49.000000000 -0500
+++ ltrace-0.5-mod/process_event.c	2006-09-26 08:41:20.000000000 -0500
@@ -238,19 +238,6 @@ static void process_sysret(struct event 
 		output_right(LT_TOF_SYSCALLR, event->proc,
 			     sysname(event->proc, event->e_un.sysnum));
 	}
-	if (exec_p(event->proc, event->e_un.sysnum)) {
-			pid_t saved_pid;
-			event->proc->mask_32bit = 0;
-			event->proc->personality = 0;
-			/* FIXME: Leak, should have arch_dep_free.
-			   But we are leaking here much more than that.  */
-			event->proc->arch_ptr = NULL;
-			event->proc->filename = pid2name(event->proc->pid);
-			saved_pid = event->proc->pid;
-			event->proc->pid = 0;
-			breakpoints_init(event->proc);
-			event->proc->pid = saved_pid;
-	}
 	continue_process(event->proc->pid);
 }
 
diff -Naurp ltrace-0.5/wait_for_something.c ltrace-0.5-mod/wait_for_something.c
--- ltrace-0.5/wait_for_something.c	2006-02-20 15:48:07.000000000 -0600
+++ ltrace-0.5-mod/wait_for_something.c	2006-09-26 08:41:20.000000000 -0500
@@ -92,6 +92,29 @@ struct event *wait_for_something(void)
 		event.e_un.signum = WSTOPSIG(status);
 		return &event;
 	}
+	if (WSTOPSIG(status) == SIGTRAP){
+	/* Check whether this SIGTRAP is received just after execve is called for this process */
+		struct callstack_element *elem;
+		elem = &event.proc->callstack[event.proc->callstack_depth - 1];
+		if( elem && elem->is_syscall &&  exec_p(event.proc, elem->c_un.syscall)){
+			pid_t saved_pid;
+
+			event.thing = LT_EV_NONE;
+			event.e_un.signum = WSTOPSIG(status);
+			debug(1,"Placing breakpoints for the new program");
+			event.proc->mask_32bit = 0;
+			event.proc->personality = 0;
+			event.proc->arch_ptr = NULL;
+			event.proc->filename = pid2name(event.proc->pid);
+			saved_pid = event.proc->pid;
+			event.proc->pid = 0;
+			breakpoints_init(event.proc);
+			event.proc->pid = saved_pid;
+			continue_process(event.proc->pid);
+			return &event;
+		}
+	}
+
 	event.thing = LT_EV_BREAKPOINT;
 	if (!event.proc->instruction_pointer) {
 		event.proc->instruction_pointer =
diff -urp ltrace-0.5/sysdeps/linux-gnu/trace.c ltrace-0.5-pm/sysdeps/linux-gnu/trace.c
--- ltrace-0.5/sysdeps/linux-gnu/trace.c	2009-02-24 19:49:30.000000000 +0100
+++ ltrace-0.5-pm/sysdeps/linux-gnu/trace.c	2009-02-24 19:49:11.000000000 +0100
@@ -104,13 +104,16 @@ void trace_set_options(struct process *p
 #ifndef PTRACE_O_TRACEFORK
 #define PTRACE_O_TRACEFORK 0x00000002
 #endif
+#ifndef PTRACE_O_TRACEEXEC
+#define PTRACE_O_TRACEEXEC 0x00000010
+#endif
       
 	ulong setoptions = 0;
 
 	if (proc->tracesysgood & 0x80)
 		return;
  
-	setoptions |= PTRACE_O_TRACESYSGOOD;
+	setoptions |= PTRACE_O_TRACESYSGOOD | PTRACE_O_TRACEEXEC;
 	if (TRACE_FORK == option){
 		setoptions |= PTRACE_O_TRACEFORK;
 	}