fffe0fb
Index: output.c
fffe0fb
===================================================================
fffe0fb
--- output.c	(revision 45)
fffe0fb
+++ output.c	(working copy)
fffe0fb
@@ -170,7 +170,6 @@ void output_left(enum tof type, struct p
fffe0fb
 	}
fffe0fb
 	if (current_proc) {
fffe0fb
 		fprintf(output, " <unfinished ...>\n");
fffe0fb
-		current_proc = 0;
fffe0fb
 		current_column = 0;
fffe0fb
 	}
fffe0fb
 	current_proc = proc;
fffe0fb
Index: elf.c
fffe0fb
===================================================================
fffe0fb
--- elf.c	(revision 45)
fffe0fb
+++ elf.c	(working copy)
fffe0fb
@@ -403,7 +403,7 @@ struct library_symbol *read_elf(struct p
fffe0fb
 			add_library_symbol(addr, name, &library_symbols,
fffe0fb
 					   (PLTS_ARE_EXECUTABLE(lte)
fffe0fb
 					   ?  LS_TOPLT_EXEC : LS_TOPLT_POINT),
fffe0fb
-					   ELF64_ST_BIND(sym.st_info) != 0);
fffe0fb
+					   ELF64_ST_BIND(sym.st_info) == STB_WEAK);
fffe0fb
 			if (!lib_tail)
fffe0fb
 				lib_tail = &(library_symbols->next);
fffe0fb
 		}
fffe0fb
@@ -415,7 +415,7 @@ struct library_symbol *read_elf(struct p
fffe0fb
                    already there. */
fffe0fb
 		main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t));
fffe0fb
 		if (main_cheat == NULL)
fffe0fb
-			error(EXIT_FAILURE, 0, "Couldn allocate memory");
fffe0fb
+			error(EXIT_FAILURE, 0, "Couldn't allocate memory");
fffe0fb
 		main_cheat->next = opt_x;
fffe0fb
 		main_cheat->found = 0;
fffe0fb
 		main_cheat->name = PLTs_initialized_by_here;
fffe0fb
@@ -464,7 +464,7 @@ struct library_symbol *read_elf(struct p
fffe0fb
 			if (strcmp(xptr->name, PLTs_initialized_by_here) == 0) {
fffe0fb
 				if (lte->ehdr.e_entry) {
fffe0fb
 					add_library_symbol (
fffe0fb
-						elf_plt2addr (lte, (void*)(long)
fffe0fb
+						opd2addr (lte, (void*)(long)
fffe0fb
 							lte->ehdr.e_entry),
fffe0fb
 						PLTs_initialized_by_here,
fffe0fb
 						lib_tail, 1, 0);
fffe0fb
Index: sysdeps/linux-gnu/ppc/plt.c
fffe0fb
===================================================================
fffe0fb
--- sysdeps/linux-gnu/ppc/plt.c	(revision 45)
fffe0fb
+++ sysdeps/linux-gnu/ppc/plt.c	(working copy)
fffe0fb
@@ -1,4 +1,5 @@
fffe0fb
 #include <gelf.h>
fffe0fb
+#include <errno.h>
fffe0fb
 #include "ltrace.h"
fffe0fb
 #include "elf.h"
fffe0fb
 #include "debug.h"
fffe0fb
@@ -15,8 +16,7 @@ void *sym2addr(struct process *proc, str
fffe0fb
 	long addr = sym->enter_addr;
fffe0fb
 	long pt_ret;
fffe0fb
 
fffe0fb
-	debug(3, 0);
fffe0fb
-
fffe0fb
+	debug(2, "sym2addr: sym=%s, pid=%d, enter_addr=%p", sym->name, proc->pid, addr);
fffe0fb
 	if (sym->plt_type != LS_TOPLT_POINT) {
fffe0fb
 		return addr;
fffe0fb
 	}
fffe0fb
@@ -46,6 +46,10 @@ void *sym2addr(struct process *proc, str
fffe0fb
 	// break-point right in the PLT.
fffe0fb
 
fffe0fb
 	pt_ret = ptrace(PTRACE_PEEKTEXT, proc->pid, addr, 0);
fffe0fb
+	if (pt_ret == -1 && errno) {
fffe0fb
+		perror ("ptrace");
fffe0fb
+		return 0;
fffe0fb
+	}
fffe0fb
 
fffe0fb
 	if (proc->mask_32bit) {
fffe0fb
 		// Assume big-endian.
fffe0fb
Index: sysdeps/linux-gnu/ppc/regs.c
fffe0fb
===================================================================
fffe0fb
--- sysdeps/linux-gnu/ppc/regs.c	(revision 45)
fffe0fb
+++ sysdeps/linux-gnu/ppc/regs.c	(working copy)
fffe0fb
@@ -5,8 +5,10 @@
fffe0fb
 #include <sys/types.h>
fffe0fb
 #include <sys/ptrace.h>
fffe0fb
 #include <asm/ptrace.h>
fffe0fb
+#include <errno.h>
fffe0fb
 
fffe0fb
 #include "ltrace.h"
fffe0fb
+#include "debug.h"
fffe0fb
 
fffe0fb
 #if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
fffe0fb
 # define PTRACE_PEEKUSER PTRACE_PEEKUSR
fffe0fb
@@ -35,6 +37,11 @@ void *get_stack_pointer(struct process *
fffe0fb
 
fffe0fb
 void *get_return_addr(struct process *proc, void *stack_pointer)
fffe0fb
 {
fffe0fb
-	return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long) * PT_LNK,
fffe0fb
-			      0);
fffe0fb
+	long p = ptrace(PTRACE_PEEKUSER, proc->pid, sizeof(long) * PT_LNK, NULL);
fffe0fb
+	if (p == -1 && errno) {
fffe0fb
+		perror ("ptrace");
fffe0fb
+		return NULL;
fffe0fb
+	}
fffe0fb
+	debug (3, "pid=%d ret=%p", proc->pid, p);
fffe0fb
+	return (void*)p;
fffe0fb
 }
fffe0fb
Index: sysdeps/linux-gnu/ppc/arch.h
fffe0fb
===================================================================
fffe0fb
--- sysdeps/linux-gnu/ppc/arch.h	(revision 45)
fffe0fb
+++ sysdeps/linux-gnu/ppc/arch.h	(working copy)
fffe0fb
@@ -7,6 +7,7 @@
fffe0fb
 #ifdef __powerpc64__ // Says 'ltrace' is 64 bits, says nothing about target.
fffe0fb
 #define LT_ELFCLASS2	ELFCLASS64
fffe0fb
 #define LT_ELF_MACHINE2	EM_PPC64
fffe0fb
+#endif
fffe0fb
 
fffe0fb
 #define PLT_REINITALISATION_BP    "_start"
fffe0fb
 
fffe0fb
@@ -16,6 +17,3 @@
fffe0fb
 #if (PPC_NOP_LENGTH != BREAKPOINT_LENGTH)
fffe0fb
 #error "Length of the breakpoint value not equal to the length of a nop instruction"
fffe0fb
 #endif
fffe0fb
-
fffe0fb
-
fffe0fb
-#endif
fffe0fb
Index: breakpoints.c
fffe0fb
===================================================================
fffe0fb
--- breakpoints.c	(revision 45)
fffe0fb
+++ breakpoints.c	(working copy)
fffe0fb
@@ -28,6 +28,7 @@ insert_breakpoint(struct process *proc, 
fffe0fb
 		  struct library_symbol *libsym)
fffe0fb
 {
fffe0fb
 	struct breakpoint *sbp;
fffe0fb
+	debug(1, "insert_breakpoint(symbol=%s, addr=%p)", libsym?libsym->name:"(nil)", addr);
fffe0fb
 
fffe0fb
 	if (!proc->breakpoints) {
fffe0fb
 		proc->breakpoints =
fffe0fb
@@ -165,11 +166,9 @@ void breakpoints_init(struct process *pr
fffe0fb
 	} else {
fffe0fb
 		proc->list_of_symbols = NULL;
fffe0fb
 	}
fffe0fb
-	sym = proc->list_of_symbols;
fffe0fb
-	while (sym) {
fffe0fb
+	for (sym = proc->list_of_symbols; sym; sym = sym->next) {
fffe0fb
 		/* proc->pid==0 delays enabling. */
fffe0fb
 		insert_breakpoint(proc, sym2addr(proc, sym), sym);
fffe0fb
-		sym = sym->next;
fffe0fb
 	}
fffe0fb
 	proc->callstack_depth = 0;
fffe0fb
 	proc->breakpoints_enabled = -1;