768acb9
diff -Nurp ltrace-0.5-orig/testsuite/ltrace.torture/ia64-sigill.exp ltrace-0.5/testsuite/ltrace.torture/ia64-sigill.exp
768acb9
--- ltrace-0.5-orig/testsuite/ltrace.torture/ia64-sigill.exp	1969-12-31 19:00:00.000000000 -0500
768acb9
+++ ltrace-0.5/testsuite/ltrace.torture/ia64-sigill.exp	2007-05-04 13:29:43.000000000 -0400
768acb9
@@ -0,0 +1,33 @@
768acb9
+# This file was written by Yao Qi <qiyao@cn.ibm.com>.
768acb9
+
768acb9
+set testfile "ia64-sigill"
768acb9
+set srcfile ${testfile}.s
768acb9
+set binfile ${testfile}
768acb9
+
768acb9
+if { [istarget ia64-*] } then {
768acb9
+    verbose "compiling source file now....."
768acb9
+    # Build the shared libraries this test case needs.
768acb9
+    if  { [ ltrace_compile "${srcdir}/${subdir}/${testfile}.s" "${srcdir}/${subdir}/${binfile}" executable {debug} ] != "" } {
768acb9
+	 send_user "Testcase compile failed, so all tests in this file will automatically fail\n."
768acb9
+    }
768acb9
+
768acb9
+    # Run PUT for ltarce.
768acb9
+    set exec_output [ltrace_runtest $srcdir/$subdir $srcdir/$subdir/$binfile]
768acb9
+
768acb9
+    # Check the output of this program.
768acb9
+    verbose "ltrace runtest output: $exec_output\n"
768acb9
+    if [regexp {ELF from incompatible architecture} $exec_output] {
768acb9
+	    fail "32-bit ltrace can not perform on 64-bit PUTs and rebuild ltrace in 64 bit mode!"
768acb9
+	    return
768acb9
+    } elseif [ regexp {Couldn't get .hash data} $exec_output ] {
768acb9
+	    fail "Couldn't get .hash data!"
768acb9
+	    return
768acb9
+    }
768acb9
+
768acb9
+    catch "exec sh -c {grep SIGILL ${srcdir}/${subdir}/${testfile}.ltrace | wc -l ;exit}" output
768acb9
+    if { $output == 0 } then {
768acb9
+	pass "ltrace did interpret SIGILL as breakpoint."
768acb9
+    } else {
768acb9
+	fail "ltrace failed to interpret SIGILL as breakpoint."
768acb9
+    }
768acb9
+}
768acb9
diff -Nurp ltrace-0.5-orig/testsuite/ltrace.torture/ia64-sigill.s ltrace-0.5/testsuite/ltrace.torture/ia64-sigill.s
768acb9
--- ltrace-0.5-orig/testsuite/ltrace.torture/ia64-sigill.s	1969-12-31 19:00:00.000000000 -0500
768acb9
+++ ltrace-0.5/testsuite/ltrace.torture/ia64-sigill.s	2007-05-04 12:51:14.000000000 -0400
768acb9
@@ -0,0 +1,43 @@
768acb9
+	.file	"pokus.c"
768acb9
+	.pred.safe_across_calls p1-p5,p16-p63
768acb9
+	.section	.rodata
768acb9
+	.align 8
768acb9
+.LC0:
768acb9
+	stringz	""
768acb9
+	.text
768acb9
+	.align 16
768acb9
+	.global main#
768acb9
+	.proc main#
768acb9
+main:
768acb9
+	.prologue 14, 32
768acb9
+	.save ar.pfs, r33
768acb9
+	alloc r33 = ar.pfs, 0, 4, 1, 0
768acb9
+	.vframe r34
768acb9
+	mov r34 = r12
768acb9
+	mov r35 = r1
768acb9
+	.save rp, r32
768acb9
+	mov r32 = b0
768acb9
+	.body
768acb9
+	addl r36 = @ltoffx(.LC0), r1
768acb9
+	;;
768acb9
+	ld8.mov r36 = [r36], .LC0
768acb9
+	br.call.sptk.many b0 = printf#
768acb9
+	nop.b 0x0
768acb9
+	nop.b 0x1
768acb9
+	nop.b 0x2
768acb9
+	nop.b 0x0
768acb9
+	nop.b 0x1
768acb9
+	nop.b 0x2
768acb9
+	mov r1 = r35
768acb9
+	addl r14 = 234, r0
768acb9
+	;;
768acb9
+	mov r8 = r14
768acb9
+	mov ar.pfs = r33
768acb9
+	mov b0 = r32
768acb9
+	.restore sp
768acb9
+	mov r12 = r34
768acb9
+	br.ret.sptk.many b0
768acb9
+	;;
768acb9
+	.endp main#
768acb9
+	.section	.note.GNU-stack,"",@progbits
768acb9
+	.ident	"GCC: (GNU) 3.4.6 20060404 (Red Hat 3.4.6-3)"
768acb9
diff -Nurp ltrace-0.5-orig/wait_for_something.c ltrace-0.5/wait_for_something.c
768acb9
--- ltrace-0.5-orig/wait_for_something.c	2007-05-04 12:39:00.000000000 -0400
768acb9
+++ ltrace-0.5/wait_for_something.c	2007-05-04 13:53:30.000000000 -0400
768acb9
@@ -27,6 +27,7 @@ struct event *wait_for_something(void)
768acb9
 	pid_t pid, child_pid;
768acb9
 	int status;
768acb9
 	int tmp;
768acb9
+	int stop_signal;
768acb9
 
768acb9
 	if (!list_of_processes) {
768acb9
 		debug(1, "No more children");
768acb9
@@ -92,15 +93,38 @@ struct event *wait_for_something(void)
768acb9
 		event.thing = LT_EV_UNKNOWN;
768acb9
 		return &event;
768acb9
 	}
768acb9
-	if ((WSTOPSIG(status) != (SIGTRAP | event.proc->tracesysgood)) &&
768acb9
-	    (WSTOPSIG(status) != SIGTRAP)) {
768acb9
+
768acb9
+	stop_signal = WSTOPSIG(status);
768acb9
+	event.thing = LT_EV_NONE;
768acb9
+
768acb9
+	/* On some targets, breakpoints are signalled not using
768acb9
+	   SIGTRAP, but also with SIGILL, SIGSEGV or SIGEMT.  Check
768acb9
+	   for these. */
768acb9
+	if (stop_signal == SIGSEGV
768acb9
+	    || stop_signal == SIGILL
768acb9
+#ifdef SIGEMT
768acb9
+	    || stop_signal == SIGEMT
768acb9
+#endif
768acb9
+	    ) {
768acb9
+		// If we didn't need to know IP so far, get it now.
768acb9
+		void * addr = opt_i
768acb9
+		  ? event.proc->instruction_pointer
768acb9
+		  : (event.proc->instruction_pointer = get_instruction_pointer (event.proc));
768acb9
+
768acb9
+		if (address2bpstruct(event.proc, addr))
768acb9
+			stop_signal = SIGTRAP;
768acb9
+	}
768acb9
+
768acb9
+	if (event.thing == LT_EV_NONE
768acb9
+	    && (stop_signal != (SIGTRAP | event.proc->tracesysgood))
768acb9
+	    && (stop_signal != SIGTRAP)) {
768acb9
 		event.thing = LT_EV_SIGNAL;
768acb9
-		event.e_un.signum = WSTOPSIG(status);
768acb9
+		event.e_un.signum = stop_signal;
768acb9
 		return &event;
768acb9
 	}
768acb9
-        if((WSTOPSIG(status) == SIGTRAP) && (status & FORK_MASK)) {
768acb9
+        if(stop_signal == SIGTRAP && (status & FORK_MASK)) {
768acb9
 		event.thing = LT_EV_NONE;
768acb9
-		event.e_un.signum = WSTOPSIG(status);
768acb9
+		event.e_un.signum = stop_signal;
768acb9
 		child_pid = (pid_t) get_child_pid(event.proc->pid);
768acb9
                 if (child_pid){
768acb9
 			debug (3, "fork: get_child_pid gave us %d", child_pid);
768acb9
@@ -110,7 +134,7 @@ struct event *wait_for_something(void)
768acb9
 		continue_after_signal(event.proc->pid, event.e_un.signum);
768acb9
 		return &event;
768acb9
 	}
768acb9
-	if (WSTOPSIG(status) == SIGTRAP){
768acb9
+	if (stop_signal == SIGTRAP){
768acb9
 	/* Check whether this SIGTRAP is received just after execve is called for this process */
768acb9
 		struct callstack_element *elem;
768acb9
 		elem = &event.proc->callstack[event.proc->callstack_depth - 1];
768acb9
@@ -118,7 +142,7 @@ struct event *wait_for_something(void)
768acb9
 			pid_t saved_pid;
768acb9
 
768acb9
 			event.thing = LT_EV_NONE;
768acb9
-			event.e_un.signum = WSTOPSIG(status);
768acb9
+			event.e_un.signum = stop_signal;
768acb9
 			debug(1,"Placing breakpoints for the new program");
768acb9
 			event.proc->mask_32bit = 0;
768acb9
 			event.proc->personality = 0;