[Ltrace-devel] r75 - in ltrace/trunk: . sysdeps/linux-gnu
Petr Machata
pmachata-guest at alioth.debian.org
Thu Jan 25 18:05:45 CET 2007
Author: pmachata-guest
Date: 2007-01-25 18:05:44 +0100 (Thu, 25 Jan 2007)
New Revision: 75
Modified:
ltrace/trunk/ChangeLog
ltrace/trunk/breakpoints.c
ltrace/trunk/proc.c
ltrace/trunk/sysdeps/linux-gnu/trace.c
Log:
- fix -p behavior: wait for process to stop after PTRACE_ATTACH
- fix -L behavior: always initialize the breakpoint dictionary,
and thus aviod NULL dereference.
Modified: ltrace/trunk/ChangeLog
===================================================================
--- ltrace/trunk/ChangeLog 2006-12-28 15:16:56 UTC (rev 74)
+++ ltrace/trunk/ChangeLog 2007-01-25 17:05:44 UTC (rev 75)
@@ -1,3 +1,13 @@
+2007-01-19 Petr Machata <pmachata at redhat.com>
+
+ * sysdeps/linux-gnu/trace.c (trace_pid): wait for child to stop,
+ as indicated by ptrace documentation.
+ * proc.c (open_pid): start the traced child again, it will have
+ been stopped after trace_pid. Fixes tracing with -p.
+ * breakpoints.c: initialize proc->breakpoints always, don't wait
+ untill it might be needed. This renders a check in insert_breakpoint
+ superfluous. Fixes a sigsegvs experienced with -L.
+
2006-12-28 Eric Vaitl <evaitl at cisco.com>
* sysdeps/linux-gnu/mipsel/* Added mipsel support
Modified: ltrace/trunk/breakpoints.c
===================================================================
--- ltrace/trunk/breakpoints.c 2006-12-28 15:16:56 UTC (rev 74)
+++ ltrace/trunk/breakpoints.c 2007-01-25 17:05:44 UTC (rev 75)
@@ -30,12 +30,6 @@
struct breakpoint *sbp;
debug(1, "symbol=%s, addr=%p", libsym?libsym->name:"(nil)", addr);
- if (!proc->breakpoints) {
- proc->breakpoints =
- dict_init(dict_key2hash_int, dict_key_cmp_int);
- /* atexit(brk_dict_clear); *//* why bother to do this on exit? */
- }
-
if (!addr)
return;
@@ -169,6 +163,7 @@
dict_clear(proc->breakpoints);
proc->breakpoints = NULL;
}
+ proc->breakpoints = dict_init(dict_key2hash_int, dict_key_cmp_int);
if (opt_L && proc->filename) {
proc->list_of_symbols = read_elf(proc);
Modified: ltrace/trunk/proc.c
===================================================================
--- ltrace/trunk/proc.c 2006-12-28 15:16:56 UTC (rev 74)
+++ ltrace/trunk/proc.c 2007-01-25 17:05:44 UTC (rev 75)
@@ -56,5 +56,6 @@
#endif
proc = open_program(filename, pid);
+ continue_process (pid);
proc->breakpoints_enabled = 1;
}
Modified: ltrace/trunk/sysdeps/linux-gnu/trace.c
===================================================================
--- ltrace/trunk/sysdeps/linux-gnu/trace.c 2006-12-28 15:16:56 UTC (rev 74)
+++ ltrace/trunk/sysdeps/linux-gnu/trace.c 2007-01-25 17:05:44 UTC (rev 75)
@@ -4,6 +4,7 @@
#include <errno.h>
#include <unistd.h>
#include <sys/types.h>
+#include <sys/wait.h>
#include "ptrace.h"
#include <asm/unistd.h>
@@ -87,6 +88,16 @@
if (ptrace(PTRACE_ATTACH, pid, 1, 0) < 0) {
return -1;
}
+
+ /* man ptrace: PTRACE_ATTACH attaches to the process specified
+ in pid. The child is sent a SIGSTOP, but will not
+ necessarily have stopped by the completion of this call;
+ use wait() to wait for the child to stop. */
+ if (waitpid (pid, NULL, 0) != pid) {
+ perror ("trace_pid: waitpid");
+ exit (1);
+ }
+
return 0;
}
More information about the Ltrace-devel
mailing list