Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Sep 1999 01:58:56 +0200
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        Marcus Meissner <marcus@jet.franken.de>
Cc:        wine-devel@winehq.com, FreeBSD-emulation@FreeBSD.ORG
Subject:   Re: debugger, stepi, c(ontinue) from breakpoint...
Message-ID:  <19990906015856.A15839@saturn.kn-bremen.de>
In-Reply-To: <19990904130203.A1206@jet.franken.de>
References:  <19990904035542.A20689@saturn.kn-bremen.de> <19990904130203.A1206@jet.franken.de>

next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, Sep 04, 1999 at 01:02:03PM +0200, Marcus Meissner wrote:
> On Sat, Sep 04, 1999 at 03:55:43AM +0200, Juergen Lock wrote:
> > ...still don't work on FreeBSD (they loop endlessly, getting signalled
> > again and again).  Looks like this is another result of the missing
> > TRAP_sig?  If yes i could try to fix it, if someone could point me
> > to a description of those constants in there?  FreeBSD only has
> > sc_trapno which comes straight from the hardware and is defined
> > completely different... (see <machine/trap.h>.)
> 
> Hmm. Not sure about differently, but Linux also uses the one directly
> passed from the x86 hardware.

Your right of course, FreeBSD's sc_trapno constants are the ones that
differ from what the hardware uses, where was i looking...

>  Could you just try to define TRAP_sig()
> accordingly (if the code is passed up through the signal handler)?

 So i made a translation function,

Index: include/sig_context.h
===================================================================
RCS file: /home/wine/wine/include/sig_context.h,v
retrieving revision 1.15
diff -u -u -r1.15 sig_context.h
--- include/sig_context.h	1999/09/05 16:26:12	1.15
+++ include/sig_context.h	1999/09/05 22:41:26
@@ -171,6 +171,8 @@
 #define EFL_sig(context)     ((context)->sc_efl)
 /* FreeBSD, see i386/i386/traps.c::trap_pfault va->err kludge  */
 #define CR2_sig(context)     ((context)->sc_err)
+int xlatebsdtrapno(int t);
+#define TRAP_sig(context)    ((long)xlatebsdtrapno((context)->sc_trapno))
 #endif                      
 
 
Index: dlls/ntdll/exception.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/exception.c,v
retrieving revision 1.11
diff -u -u -r1.11 exception.c
--- dlls/ntdll/exception.c	1999/09/03 12:46:38	1.11
+++ dlls/ntdll/exception.c	1999/09/05 22:41:22
@@ -31,6 +31,34 @@
 # define GET_IP(context) ((LPVOID)0)
 #endif  /* __i386__ */
 
+#ifdef __FreeBSD__
+/* translate BSD's sigcontext sc_trapno for TRAP_sig */
+int xlatebsdtrapno(int t)
+{
+    switch (t)
+    {
+	case T_PRIVINFLT: return 6;
+	case T_BPTFLT:	return 3;
+	case T_ARITHTRAP: return 16;
+	case T_PROTFLT:	return 13;
+	case T_TRCTRAP:	return 1;
+	case T_PAGEFLT:	return 14;
+	case T_ALIGNFLT: return 17;
+	case T_DIVIDE:	return 0;
+	case T_NMI:	return 2;
+	case T_OFLOW:	return 4;
+	case T_BOUND:	return 5;
+	case T_DNA:	return 7;
+	case T_FPOPFLT:	return 9;
+	case T_TSSFLT:	return 10;
+	case T_SEGNPFLT: return 11;
+	case T_STKFLT:	return 12;
+	case T_RESERVED: return 15;
+	default:	return 18;
+    }
+}
+#endif
+
 /* Default hook for built-in debugger */
 static DWORD default_hook( EXCEPTION_RECORD *rec, CONTEXT *ctx, BOOL first )
 {

 but i also had to patch this before it started working,

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/05 01:56:02
@@ -57,6 +57,9 @@
 #include <sys/signalvar.h>
 #include <sys/syscall.h>
 #include <sys/sysent.h>
+#include <sys/sysproto.h>
+#include <i386/linux/linux.h>
+#include <i386/linux/linux_proto.h>
 #include <sys/uio.h>
 #include <sys/vmmeter.h>
 #ifdef KTRACE
@@ -1135,9 +1181,12 @@
 		break;
 	}
 
-	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);
 	}
 
 (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,
are any committers reading or should i also send-pr it?)

 now `si' works but sometimes(!) i still have to disable a breakpoint
before it would step over it, shouldn't the debugger do this itself?
the funny thing is it appears sometimes it does it and sometimes not!
can anyone reproduce this on eg linux?  (wine -debug different programs
and see if `si' steps over the initial breakpoint, for me it depends on
the program i chose if it does or not...)

 Oh and after some hacking i can now also read the taz archive CDs
with wine, there's only one little problem with a scrollbar...

 Regards,
-- 
Juergen Lock <nox.foo@jelal.kn-bremen.de>
(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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?19990906015856.A15839>