From dcbfa74cd351c06f2b9434bcd68b934ca5a3f700 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fredrik=20H=C3=BCbinette=20=28Hubbe=29?= <hubbe@hubbe.net>
Date: Fri, 7 May 1999 17:37:38 -0700
Subject: [PATCH] more debug

Rev: src/interpret.c:1.123
Rev: src/interpreter.h:1.6
---
 src/interpret.c   | 13 ++++++++++++-
 src/interpreter.h |  7 ++++++-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/interpret.c b/src/interpret.c
index 2d9fa132df..097d7d691c 100644
--- a/src/interpret.c
+++ b/src/interpret.c
@@ -5,7 +5,7 @@
 \*/
 /**/
 #include "global.h"
-RCSID("$Id: interpret.c,v 1.122 1999/05/02 08:11:43 hubbe Exp $");
+RCSID("$Id: interpret.c,v 1.123 1999/05/08 00:33:18 hubbe Exp $");
 #include "interpret.h"
 #include "object.h"
 #include "program.h"
@@ -649,6 +649,17 @@ void mega_apply2(enum apply_type type, INT32 args, void *arg1, void *arg2)
 #endif
 #endif
 
+#if defined(PIKE_DEBUG) && defined(_REENTRANT)
+  if(d_flag)
+    {
+      if( thread_id && !th_equal( OBJ2THREAD(thread_id)->id, th_self()) )
+	fatal("Current thread is wrong.\n");
+	
+      if(thread_for_id(th_self()) != thread_id)
+	fatal("thread_for_id() (or thread_id) failed in mega_apply! %p != %p\n",thread_for_id(th_self()),thread_id);
+      }
+#endif
+
   switch(type)
   {
   case APPLY_STACK:
diff --git a/src/interpreter.h b/src/interpreter.h
index 566d522fd4..69cbc29b18 100644
--- a/src/interpreter.h
+++ b/src/interpreter.h
@@ -31,10 +31,15 @@ static int eval_instruction(unsigned char *pc)
 #ifdef PIKE_DEBUG
     if(d_flag)
     {
-#if defined(_REENTRANT) && !defined(__NT__)
+#ifdef _REENTRANT
+#ifndef __NT__
       if(!mt_trylock(& interpreter_lock))
 	fatal("Interpreter running unlocked!\n");
 #endif
+      if(d_flag>1 && thread_for_id(th_self()) != thread_id)
+        fatal("thread_for_id() (or thread_id) failed in interpreter.h! %p != %p\n",thread_for_id(th_self()),thread_id);
+#endif
+
       sp[0].type=99; /* an invalid type */
       sp[1].type=99;
       sp[2].type=99;
-- 
GitLab