From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <554538b81a21959b94eabef570e8e4de.axp-list@archive.invalid> X-Archive-Original-Message-ID: <199604252206.AAA01736@bigbug.franken.de> Date: Fri, 26 Apr 1996 15:52:20 +0300 (EET DST) From: Linus Torvalds Subject: Re: Linux-1.3.95 - strace for alpha In-Reply-To: <199604252206.AAA01736@bigbug.franken.de> On Fri, 26 Apr 1996, Thomas Bogendoerfer wrote: > > > For the alpha people, it has support for "strace", but no strace binary that > > knows about it yet ;-) Thomas Bogendoerfer has been working on that side, but > > I'm afraid I changed the kernel code a bit, and we'll have to synchronize > > I changed strace, so that it works with the new official interface. > I've tared together my current development tree, and put it on > ftp.franken.de under /pub/people/tsbogend/strace-alpha-0.00.tar.gz. > There are still lots of bugs in this version, especially with > execve (strace dumps core:-( ), because it gets a little bit > confused with the syscall number. I'm now trying to fix the > remaining bugs. After this is done, I will start clean up sources > and talk to the strace maintainer (if there is one; it looks > like nobody maintains strace, because you even can't compile it > on Linux/x86) for inclusion of my patches. I suspect that the 95 kernel still has a bug in strace handling: traced system calls that return errors can (and will) corrupt the $9 and $10 registers that should be safe across system calls. This can result in strange behaviour of traced processes (SIGSEGV's etc, if the corrupted register was being used to have a pointer in it, for example). This smallish patch should fix it (totally untested as usual, but it looks ok) Linus ----- diff -u --recursive --new-file v1.3.95/linux/arch/alpha/kernel/entry.S linux/arch/alpha/kernel/entry.S --- v1.3.95/linux/arch/alpha/kernel/entry.S Wed Apr 24 17:00:33 1996 +++ linux/arch/alpha/kernel/entry.S Fri Apr 26 12:12:34 1996 @@ -541,7 +541,7 @@ jsr $26,($27),syscall_trace bsr $1,undo_switch_stack - /* get the system call number and the argments back.. */ + /* get the system call number and the arguments back.. */ ldq $0,0($30) ldq $16,SP_OFF+24($30) ldq $17,SP_OFF+32($30) @@ -574,9 +574,9 @@ .align 3 strace_error: - ldq $9,0($30) /* old syscall nr (zero if success) */ - beq $9,strace_success - ldq $10,72($30) /* .. and this a3 */ + ldq $19,0($30) /* old syscall nr (zero if success) */ + beq $19,strace_success + ldq $20,72($30) /* .. and this a3 */ subq $31,$0,$0 /* with error in v0 */ addq $31,1,$1 /* set a3 for errno return */ @@ -584,13 +584,15 @@ stq $1,72($30) /* a3 for return */ bsr $1,do_switch_stack + bis $19,$19,$9 /* save old syscall number */ + bis $20,$20,$10 /* save old a3 */ lda $27,syscall_trace jsr $26,($27),syscall_trace + bis $9,$9,$19 + bis $10,$10,$20 bsr $1,undo_switch_stack bis $31,$31,$26 /* tell "ret_from_sys_call" that we can restart */ - bis $9,$9,$19 /* .. old syscall nr */ - bis $10,$10,$20 /* .. old a3 */ br $31,ret_from_sys_call .align 3 -----