Version 0.3.25

* Finally added powerpc support (Anton Blanchard <anton@samba.org>)
diff --git a/README b/README
index 51a58c3..e6d8c07 100644
--- a/README
+++ b/README
@@ -27,7 +27,7 @@
 * Morten Eriksen <mortene@sim.no> (misc fixes)
 * Silvio Cesare <silvio@big.net.au> (ELF hacking)
 * Timothy Fesig <slate@us.ibm.com> (S390 port)
-* Anton Blanchard <anton@linuxcare.com.au> (Powerpc port)
+* Anton Blanchard <anton@samba.org> (Powerpc port)
 
 1. Introduction
 ---------------
diff --git a/breakpoints.c b/breakpoints.c
index cc564c5..2d18222 100644
--- a/breakpoints.c
+++ b/breakpoints.c
@@ -34,7 +34,7 @@
 static void dict_init(void);
 static void dict_clear(void);
 static struct breakpoint * dict_enter(struct process * proc, void * brkaddr);
-static struct breakpoint * dict_find_entry(struct process * proc, void * brkaddr);
+struct breakpoint * dict_find_entry(struct process * proc, void * brkaddr);
 static void dict_apply_to_all(void (* func)(struct process *, struct breakpoint *, void * data), void * data);
 
 
@@ -88,7 +88,7 @@
 	return &(newentry->brk);
 }
 
-static struct breakpoint *
+struct breakpoint *
 dict_find_entry(struct process * proc, void * brkaddr) {
 	unsigned int bucketpos = ((unsigned long int)brkaddr) % DICTTABLESIZE;
 	struct dict_entry * entry = dict_buckets[bucketpos];
diff --git a/debian/changelog b/debian/changelog
index 3911a90..f231a6a 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,15 @@
+ltrace (0.3.25) unstable; urgency=low
+
+  * Finally added powerpc support (Anton Blanchard <anton@samba.org>)
+
+ -- Juan Cespedes <cespedes@debian.org>  Sun, 31 Mar 2002 19:58:25 +0200
+
 ltrace (0.3.24) unstable; urgency=low
 
   * Fixed 2 minor buffer overflows (closes: Bug#130746)
   * Obey --prefix, --sysconfdir, --mandir options in configure
   * Adding powerpc support (doesn't work yet)
-    (Anton Blanchard <anton@linuxcare.com.au>)
+    (Anton Blanchard <anton@samba.org>)
 
  -- Juan Cespedes <cespedes@debian.org>  Wed, 27 Mar 2002 00:20:57 +0100
 
diff --git a/debian/control b/debian/control
index 0d316a7..1de2c81 100644
--- a/debian/control
+++ b/debian/control
@@ -6,7 +6,7 @@
 Build-Depends: binutils-dev
 
 Package: ltrace
-Architecture: i386 arm m68k s390
+Architecture: i386 arm m68k s390 powerpc
 Depends: ${shlibs:Depends}
 Description: Tracks runtime library calls in dynamically linked programs
  ltrace is a debugging program which runs a specified command until it
diff --git a/debian/copyright b/debian/copyright
index fecf224..1893192 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -11,7 +11,7 @@
 Misc fixes: Copyright (C) 1999 Morten Eriksen <mortene@sim.no>
 s390 port: Copyright (C) 2001 IBM Poughkeepsie, IBM Cororation <slate@us.ibm.com>
 ELF hacking: Copyright (C) 1999 Silvio Cesare <silvio@big.net.au>
-PowerPC port: Copyright (C) 2001 Anton Blanchard <anton@linuxcare.com.au>
+PowerPC port: Copyright (C) 2001-2002 Anton Blanchard <anton@samba.org>
 
 
 Autoconf stuff: Copyright 1992-1996 Free Software Foundation, Inc.
diff --git a/options.c b/options.c
index c4182d1..19c64eb 100644
--- a/options.c
+++ b/options.c
@@ -3,7 +3,7 @@
 #endif
 
 #ifndef VERSION
-# define VERSION "0.3.24"
+# define VERSION "0.3.25"
 #endif
 
 #include <string.h>
diff --git a/process_event.c b/process_event.c
index 0847241..53012f4 100644
--- a/process_event.c
+++ b/process_event.c
@@ -227,6 +227,24 @@
 
 	for(i=event->proc->callstack_depth-1; i>=0; i--) {
 		if (event->e_un.brk_addr == event->proc->callstack[i].return_addr) {
+#ifdef __powerpc__
+                       unsigned long a;
+                       unsigned long addr = event->proc->callstack[i].c_un.libfunc->enter_addr;
+                       struct breakpoint *sbp = dict_find_entry(event->proc, addr);
+                       unsigned char break_insn[] = BREAKPOINT_VALUE;
+
+                       /*
+                        * PPC HACK! (XXX FIXME TODO)
+                        * The PLT gets modified during the first call,
+                        * so be sure to re-enable the breakpoint.
+                        */
+                       a = ptrace(PTRACE_PEEKTEXT, event->proc->pid, addr);
+
+                       if (memcmp(&a, break_insn, 4)) {
+                               sbp->enabled--;
+                               insert_breakpoint(event->proc, addr);
+                       }
+#endif
 			for(j=event->proc->callstack_depth-1; j>=i; j--) {
 				callstack_pop(event->proc);
 			}
diff --git a/sysdeps/linux-gnu/ppc/arch.h b/sysdeps/linux-gnu/ppc/arch.h
index e04fe5b..72fa45f 100644
--- a/sysdeps/linux-gnu/ppc/arch.h
+++ b/sysdeps/linux-gnu/ppc/arch.h
@@ -1,3 +1,3 @@
-#define BREAKPOINT_VALUE { 0xf7, 0xe0, 0x00, 0x08 }
+#define BREAKPOINT_VALUE { 0x7f, 0xe0, 0x00, 0x08 }
 #define BREAKPOINT_LENGTH 4
 #define DECR_PC_AFTER_BREAK 0
diff --git a/sysdeps/linux-gnu/ppc/regs.c b/sysdeps/linux-gnu/ppc/regs.c
index 1eb51e5..193bb75 100644
--- a/sysdeps/linux-gnu/ppc/regs.c
+++ b/sysdeps/linux-gnu/ppc/regs.c
@@ -31,5 +31,5 @@
 
 void *
 get_return_addr(pid_t pid, void * stack_pointer) {
-	return (void *)ptrace(PTRACE_PEEKTEXT, pid, 4*PT_LNK, 0);
+	return (void *)ptrace(PTRACE_PEEKUSER, pid, 4*PT_LNK, 0);
 }
diff --git a/sysdeps/linux-gnu/ppc/syscallent.h b/sysdeps/linux-gnu/ppc/syscallent.h
index 40c8ba1..acbb4bc 100644
--- a/sysdeps/linux-gnu/ppc/syscallent.h
+++ b/sysdeps/linux-gnu/ppc/syscallent.h
@@ -206,3 +206,17 @@
 	"madvise",                         /* 205 */
 	"mincore",                         /* 206 */
 	"gettid",                          /* 207 */
+	"tkill",                           /* 208 */
+	"setxattr",                        /* 209 */
+	"lsetxattr",                       /* 210 */
+	"fsetxattr",                       /* 211 */
+	"getxattr",                        /* 212 */
+	"lgetxattr",                       /* 213 */
+	"fgetxattr",                       /* 214 */
+	"listxattr",                       /* 215 */
+	"llistxattr",                      /* 216 */
+	"flistxattr",                      /* 217 */
+	"removexattr",                     /* 218 */
+	"lremovexattr",                    /* 219 */
+	"fremovexattr",                    /* 220 */
+	"futex",                           /* 221 */
diff --git a/sysdeps/linux-gnu/ppc/trace.c b/sysdeps/linux-gnu/ppc/trace.c
index 8e4135f..9634d1d 100644
--- a/sysdeps/linux-gnu/ppc/trace.c
+++ b/sysdeps/linux-gnu/ppc/trace.c
@@ -28,14 +28,12 @@
 		int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc-4, 0);
 
 		if (insn == SYSCALL_INSN) {
-			*sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_RO, 0);
+			*sysnum = ptrace(PTRACE_PEEKUSER, proc->pid, 4*PT_R0, 0);
 			if (proc->callstack_depth > 0 &&
 					proc->callstack[proc->callstack_depth-1].is_syscall) {
 				return 2;
 			}
-			if (*sysnum >= 0 && *sysnum <= 255) {
-				return 1;
-			}
+			return 1;
 		}
 	}
 	return 0;
@@ -51,7 +49,7 @@
 		if (arg_num < 8) {
 			return ptrace(PTRACE_PEEKUSER, proc->pid, 4*(arg_num+PT_R3), 0);
 		} else {
-			return ptrace(PTRACE_PEEKDATA, proc->pid, proc->stack_pointer+4*(arg_num-8), 0); /* Check */
+			return ptrace(PTRACE_PEEKDATA, proc->pid, proc->stack_pointer+8*(arg_num-8), 0);
 		}
 	} else {
 		fprintf(stderr, "gimme_arg called with wrong arguments\n");