Date: Fri, 4 Jan 2002 16:19:12 +0100 From: Bernd Walter <ticso@cicely8.cicely.de> To: Daniel Eischen <eischen@pcnet1.pcnet.com> Cc: alpha@FreeBSD.org Subject: Re: {get,set,make,swap}context for alpha Message-ID: <20020104161911.B8703@cicely8.cicely.de> In-Reply-To: <Pine.SUN.3.91.1020104090012.16130A-100000@pcnet1.pcnet.com> References: <20020104143622.A8703@cicely8.cicely.de> <Pine.SUN.3.91.1020104090012.16130A-100000@pcnet1.pcnet.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jan 04, 2002 at 09:14:58AM -0500, Daniel Eischen wrote: > On Fri, 4 Jan 2002, Bernd Walter wrote: > > On Thu, Jan 03, 2002 at 04:05:25PM -0500, Daniel Eischen wrote: > > > I've got *context implemented and working for i386, but need some > > > help getting them to work on the alpha. Anyone here care to give > > > it a try? You can get them from: > > > > > > http://people.freebsd.org/~deischen/ucontext/uc-libc-sys.diffs > > > http://people.freebsd.org/~deischen/ucontext/uc-i386-standalone.tgz > > > http://people.freebsd.org/~deischen/ucontext/uc-alpha-standalone.tgz > > [...] > > > One problem I found is that you defined getcontext to be a LEAF > > function, but actually call others. > > Hmm, lib/libc/alpha/gen/setjmp.S does the same thing and also > makes a call to sigprocmask. I see that it does save and restore > ra though. Yes - you can make this working as long as you take care to make it looks like a LEAF function. It was just my first guess. > So I guess I should use NESTED, or make sure I save and restore ra > and any S register I use? saving s* and ra is expected by every caller anyway. You are calling _sigprocmask yourself and expect it to return with the old s0 value. > It seems weird that ra needs to be restored in order for a branch > instruction to work properly... Actually it's needed to return getcontext. What happens is that getcontext tries to return and falls back to after the call to __sigprocmask because ra says we was called from there. restoring ra and s0 gets getcontext working: Send a few SIGUSR1's to pid 64935 Main: setting context to myself. Main: returned from setcontext. Segmentation fault (core dumped) Exit 139 --- setcontext.S.orig Fri Jan 4 16:12:48 2002 +++ setcontext.S Fri Jan 4 16:12:28 2002 @@ -314,6 +314,8 @@ ldiq a0, 3 /* how: SIG_SETMASK */ CALL(_sigprocmask) /* see what's blocked */ mov s0, a0 /* restore ptr to ucontext */ + ldq s0, ((FRAME_S0 + 3) * 8)(a0) /* restore s0 */ + ldq ra, ((FRAME_RA + 3) * 8)(a0) /* restore ra */ beq v0, Lgc2 /* check for error */ ldiq v0, -1 /* return -1 */ br Lgcend I'm now looking into setcontext function where something similar needs to be done. -- B.Walter COSMO-Project http://www.cosmo-project.de ticso@cicely.de Usergroup info@cosmo-project.de To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-alpha" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20020104161911.B8703>