From owner-freebsd-emulation Fri Sep 10 9:27:47 1999 Delivered-To: freebsd-emulation@freebsd.org Received: from blaubaer.kn-bremen.de (blaubaer.kn-bremen.de [195.37.179.254]) by hub.freebsd.org (Postfix) with ESMTP id 1E9EC15CCD for ; Fri, 10 Sep 1999 09:27:08 -0700 (PDT) (envelope-from nox@saturn.kn-bremen.de) Received: from saturn.kn-bremen.de (uucp@localhost) by blaubaer.kn-bremen.de (8.9.1/8.9.1) with UUCP id SAA22563; Fri, 10 Sep 1999 18:21:08 +0200 Received: (from nox@localhost) by saturn.kn-bremen.de (8.9.3/8.8.5) id SAA25808; Fri, 10 Sep 1999 18:02:26 +0200 (MET DST) From: Juergen Lock Date: Fri, 10 Sep 1999 18:02:26 +0200 To: Bruce Evans Cc: Juergen Lock , Luoqi Chen , marcus@jet.franken.de, FreeBSD-emulation@FreeBSD.ORG, wine-devel@winehq.com Subject: Re: debugger, stepi, c(ontinue) from breakpoint... Message-ID: <19990910180225.A22248@saturn.kn-bremen.de> References: <19990908225333.C1394@saturn.kn-bremen.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.7i In-Reply-To: Sender: owner-freebsd-emulation@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org On Thu, Sep 09, 1999 at 03:36:50PM +1000, Bruce Evans wrote: > On Wed, 8 Sep 1999, Juergen Lock wrote: > > > On Wed, Sep 08, 1999 at 02:33:57PM -0400, Luoqi Chen wrote: > > > > > > > > - if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) { > > > > + if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM) && > > > > + *callp->sy_call != sigreturn && *callp->sy_call != linux_sigreturn) { > > > > /* Traced syscall. */ > > > > frame.tf_eflags &= ~PSL_T; > > > > + /* tell the signal handler this is a trace trap */ > > > > + frame.tf_trapno = T_TRCTRAP; > > > > trapsignal(p, SIGTRAP, 0); > > This should probably be trapsignal(p, SIGTRAP, T_TRCTRAP). Signal handlers > should examine the signal code (the 3rd arg to trapsignal()) before examining > tf_trapno. It may be a bug to even look at tf_trapno. The signal code is > supposed to be a properly translated version of tf_trapno. Hmm, currently code is often 0, for example in SIGTRAP... (for both trap and breakpoint.) > > I think the purpose of (original version of the) above code is only to > make a traced syscall stop on return from the syscall and not one > instruction later. Yep. > However, this is wrong if the trace flag was set > by sigreturn(). Your changes seem to fix this case but break the case > where sigreturn() is being traced but is not responsible for setting the > trace flag. True... > This can probably be fixed by calling trapsignal() if the > trace flag was set on entry to syscall(), not if it set on exit from > syscall(). Indeed! If i do that, Index: i386/i386/trap.c =================================================================== RCS file: /home/cvs/cvs/src/sys/i386/i386/trap.c,v retrieving revision 1.133.2.1 diff -u -u -r1.133.2.1 trap.c --- trap.c 1999/08/29 16:05:56 1.133.2.1 +++ trap.c 1999/09/10 14:42:21 @@ -1041,6 +1084,7 @@ int error; int args[8]; u_int code; + int tracedsyscall = ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)); #ifdef DIAGNOSTIC if (ISPL(frame.tf_cs) != SEL_UPL) @@ -1135,10 +1179,12 @@ break; } - if ((frame.tf_eflags & PSL_T) && !(frame.tf_eflags & PSL_VM)) { + if (tracedsyscall) { /* Traced syscall. */ frame.tf_eflags &= ~PSL_T; - trapsignal(p, SIGTRAP, 0); + /* tell the signal handler this is a trace trap */ + frame.tf_trapno = T_TRCTRAP; + trapsignal(p, SIGTRAP, T_TRCTRAP); } userret(p, &frame, sticks); I can single-step in wine's debugger and single-step over the sigreturn syscall from gdb like it should be. (at least in a simple test program, i first tried to test this on wine itself but there i got strange signals when i tried to set breakpoints at the end of its signal handlers. this may have to do something with the fact that wine uses sigaltstack, i don't know...) > > > > > } > > > > > > > > (so wine must be the first program that handles SIGTAP for itself and > > > > sets the trace bit from a signal handler? :) I Cc'd this to -emulation, > > Quite possibly. Heh. Regards, -- Juergen Lock (remove dot foo from address to reply) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-emulation" in the body of the message