Hi,

the current upstream version of ltrace shows an ugly testsuite result on ppc64:

# of expected passes            23
# of unexpected failures        74

Taking a closer look, I noticed ltrace is unable to track mostly of the library 
calls on PowerPC 64-bit. This seems to be happening due to a failure in a 
PTRACE_PEEKTEXT call in the function sym2addr(), which returns -1 ('No such 
process', according to perror()) that is saved as a valid address for a 
breakpoint. The following patch ignores this error and sets addr = 0, which 
means this address will be checked again in the future. This patch fixes mostly 
of the failures in the testsuite on ppc64:

# of expected passes            88
# of unexpected failures        9

Please let me know if you have any comments or concerns.

Thanks!
-- 
Edjunior Barbosa Machado
IBM Linux Technology Center

diff --git a/sysdeps/linux-gnu/ppc/plt.c b/sysdeps/linux-gnu/ppc/plt.c
index 668f63d..9308678 100644
--- a/sysdeps/linux-gnu/ppc/plt.c
+++ b/sysdeps/linux-gnu/ppc/plt.c
@@ -1,5 +1,6 @@
 #include <gelf.h>
 #include <sys/ptrace.h>
+#include <errno.h>
 #include "common.h"
 
 GElf_Addr
@@ -42,7 +43,15 @@ sym2addr(Process *proc, struct library_symbol *sym) {
        // non-secure case, the PLT is executable code and we can put the
        // break-point right in the PLT.
 
-       pt_ret = ptrace(PTRACE_PEEKTEXT, proc->pid, addr, 0);
+       if ((pt_ret = ptrace(PTRACE_PEEKTEXT, proc->pid, addr, 0)) == -1) {
+               // ptrace might return -1 (No such process) on PowerPC-64 when
+               // the process is not initialized yet. Return 0 for now and the
+               // address will be collected again in the future.
+               if (errno == ESRCH) 
+                       return 0;
+               else 
+                       perror("PTRACE_PEEKTEXT");
+       }
 
 #if SIZEOF_LONG == 8
        if (proc->mask_32bit) {


_______________________________________________
Ltrace-devel mailing list
[email protected]
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/ltrace-devel

Reply via email to