Skip to content
Snippets Groups Projects
Commit db40ab31 authored by Fredrik Hübinette (Hubbe)'s avatar Fredrik Hübinette (Hubbe)
Browse files

error() now works when thread is swapped out (I hope)

Rev: src/error.c:1.33
Rev: src/interpret.h:1.30
Rev: src/threads.h:1.65
parent 50536bf3
No related branches found
No related tags found
No related merge requests found
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
#include "backend.h" #include "backend.h"
#include "operators.h" #include "operators.h"
#include "module_support.h" #include "module_support.h"
#include "threads.h"
RCSID("$Id: error.c,v 1.32 1999/04/02 15:18:05 hubbe Exp $"); RCSID("$Id: error.c,v 1.33 1999/04/15 19:12:49 hubbe Exp $");
#undef ATTRIBUTE #undef ATTRIBUTE
#define ATTRIBUTE(X) #define ATTRIBUTE(X)
...@@ -110,14 +111,25 @@ void push_error(char *description) ...@@ -110,14 +111,25 @@ void push_error(char *description)
struct svalue throw_value = { T_INT }; struct svalue throw_value = { T_INT };
int throw_severity; int throw_severity;
static const char *in_error; static const char *in_error;
void low_error(char *buf)
{
push_error(buf);
free_svalue(& throw_value);
throw_value = *--sp;
throw_severity=THROW_ERROR;
in_error=0;
pike_throw(); /* Hope someone is catching, or we will be out of balls. */
}
/* FIXME: NOTE: This function uses a static buffer. /* FIXME: NOTE: This function uses a static buffer.
* Check sizes of arguments passed! * Check sizes of arguments passed!
*/ */
void va_error(const char *fmt, va_list args) ATTRIBUTE((noreturn)) void va_error(const char *fmt, va_list args) ATTRIBUTE((noreturn))
{ {
char buf[4096]; char buf[4096];
SWAP_IN_THREAD_IF_REQUIRED();
if(in_error) if(in_error)
{ {
const char *tmp=in_error; const char *tmp=in_error;
...@@ -146,13 +158,7 @@ void va_error(const char *fmt, va_list args) ATTRIBUTE((noreturn)) ...@@ -146,13 +158,7 @@ void va_error(const char *fmt, va_list args) ATTRIBUTE((noreturn))
if((long)strlen(buf) >= (long)sizeof(buf)) if((long)strlen(buf) >= (long)sizeof(buf))
fatal("Buffer overflow in error()\n"); fatal("Buffer overflow in error()\n");
push_error(buf); low_error(buf);
free_svalue(& throw_value);
throw_value = *--sp;
throw_severity=THROW_ERROR;
in_error=0;
pike_throw(); /* Hope someone is catching, or we will be out of balls. */
} }
void new_error(const char *name, const char *text, struct svalue *oldsp, void new_error(const char *name, const char *text, struct svalue *oldsp,
...@@ -160,6 +166,8 @@ void new_error(const char *name, const char *text, struct svalue *oldsp, ...@@ -160,6 +166,8 @@ void new_error(const char *name, const char *text, struct svalue *oldsp,
{ {
int i; int i;
ASSERT_THREAD_SWAPPED_IN();
if(in_error) if(in_error)
{ {
const char *tmp=in_error; const char *tmp=in_error;
...@@ -320,8 +328,10 @@ void f_error_backtrace(INT32 args) ...@@ -320,8 +328,10 @@ void f_error_backtrace(INT32 args)
#define INIT_ERROR(FEL)\ #define INIT_ERROR(FEL)\
va_list foo; \ va_list foo; \
struct object *o=low_clone(PIKE_CONCAT(FEL,_error_program)); \ struct object *o; \
va_start(foo,desc); va_start(foo,desc); \
ASSERT_THREAD_SWAPPED_IN(); \
o=low_clone(PIKE_CONCAT(FEL,_error_program));
#define ERROR_DONE(FOO) \ #define ERROR_DONE(FOO) \
PIKE_CONCAT(FOO,_error_va(o,func, \ PIKE_CONCAT(FOO,_error_va(o,func, \
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
\*/ \*/
/* /*
* $Id: interpret.h,v 1.29 1999/04/12 20:00:37 grubba Exp $ * $Id: interpret.h,v 1.30 1999/04/15 19:12:50 hubbe Exp $
*/ */
#ifndef INTERPRET_H #ifndef INTERPRET_H
#define INTERPRET_H #define INTERPRET_H
...@@ -57,7 +57,7 @@ struct pike_frame ...@@ -57,7 +57,7 @@ struct pike_frame
long x_= ((char *)&x_) + STACK_DIRECTION * (X) - stack_top ; \ long x_= ((char *)&x_) + STACK_DIRECTION * (X) - stack_top ; \
x_*=STACK_DIRECTION; \ x_*=STACK_DIRECTION; \
if(x_>0) \ if(x_>0) \
error("C stack overflow.\n"); \ low_error("C stack overflow.\n"); \
}while(0) }while(0)
......
/* /*
* $Id: threads.h,v 1.64 1999/04/07 23:10:12 hubbe Exp $ * $Id: threads.h,v 1.65 1999/04/15 19:12:51 hubbe Exp $
*/ */
#ifndef THREADS_H #ifndef THREADS_H
#define THREADS_H #define THREADS_H
...@@ -490,6 +490,21 @@ struct thread_state { ...@@ -490,6 +490,21 @@ struct thread_state {
} \ } \
} while(0) } while(0)
#define SWAP_IN_THREAD_IF_REQUIRED() do { \
struct thread_state *_tmp=thread_state_for_id(th_self()); \
HIDE_GLOBAL_VARIABLES(); \
THREADS_DISALLOW()
#ifdef PIKE_DEBUG
#define ASSERT_THREAD_SWAPPED_IN() do { \
struct thread_state *_tmp=thread_state_for_id(th_self()); \
if(_tmp->swapped) fatal("Thread is not swapped in!\n"); \
}while(0)
#else
#define ASSERT_THREAD_SWAPPED_IN()
#endif
/* Prototypes begin here */ /* Prototypes begin here */
struct thread_starter; struct thread_starter;
void *new_thread_func(void * data); void *new_thread_func(void * data);
...@@ -550,6 +565,8 @@ void exit_interleave_mutex(IMUTEX_T *im); ...@@ -550,6 +565,8 @@ void exit_interleave_mutex(IMUTEX_T *im);
#define THREADS_DISALLOW_UID() #define THREADS_DISALLOW_UID()
#define HIDE_GLOBAL_VARIABLES() #define HIDE_GLOBAL_VARIABLES()
#define REVEAL_GLOBAL_VARIABLES() #define REVEAL_GLOBAL_VARIABLES()
#define ASSERT_THREAD_SWAPPED_IN()
#define SWAP_IN_THREAD_IF_REQUIRED()
#define th_init() #define th_init()
#define low_th_init() #define low_th_init()
#define th_cleanup() #define th_cleanup()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment