+2003-01-22 Martin Baulig <martin@ximian.com>
+
+ * appdomain.h (MonoThreadStartCB): Added `MonoThread *thread' and
+ `gpointer func' arguments.
+ (MonoThreadAttachCB): New typedef; like the old MonoThreadStartCB,
+ but added `MonoThread *thread' argument.
+ (mono_runtime_init): The last argument is now a MonoThreadAttachCB.
+
+ * threads.c (mono_new_thread_init): Added `gpointer func' argument
+ and pass it to the mono_thread_start_cb callback.
+ (mono_install_thread_callbacks): New public function to install a
+ set of callbacks which are set by the debugger.
+ (mono_thread_init): The last argument is now a MonoThreadAttachCB.
+
2003-01-22 Martin Baulig <martin@ximian.com>
* Makefile.am: Install debug-mono-symfile.h.
#include <mono/utils/mono-hash.h>
#include <mono/io-layer/io-layer.h>
-typedef void (*MonoThreadStartCB) (gpointer stack_start);
+typedef void (*MonoThreadStartCB) (MonoThread *thread, gpointer stack_start, gpointer func);
+typedef void (*MonoThreadAttachCB) (MonoThread *thread, gpointer stack_start);
/* This is a copy of System.AppDomainSetup */
typedef struct {
void
mono_runtime_init (MonoDomain *domain, MonoThreadStartCB start_cb,
- MonoThreadStartCB attach_cb);
+ MonoThreadAttachCB attach_cb);
void
mono_runtime_cleanup (MonoDomain *domain);
static MonoThreadStartCB mono_thread_start_cb = NULL;
/* function called at thread attach */
-static MonoThreadStartCB mono_thread_attach_cb = NULL;
+static MonoThreadAttachCB mono_thread_attach_cb = NULL;
+
+/* function called when a new thread has been created */
+static MonoThreadCallbacks *mono_thread_callbacks = NULL;
/* The TLS key that holds the LocalDataStoreSlot hash in each thread */
static guint32 slothash_key;
mono_profiler_thread_start (tid);
- mono_new_thread_init (start_info->obj, &tid);
+ mono_new_thread_init (start_info->obj, &tid, start_func);
g_free (start_info);
return(0);
}
-void mono_new_thread_init (MonoThread *thread_object, gpointer stack_start)
+void mono_new_thread_init (MonoThread *thread_object, gpointer stack_start, gpointer func)
{
/* FIXME: GC problem here with recorded object
* pointer!
TlsSetValue (current_object_key, thread_object);
if (mono_thread_start_cb) {
- mono_thread_start_cb (stack_start);
+ mono_thread_start_cb (thread_object, stack_start, func);
}
}
if ((thread = mono_thread_current ())) {
g_warning ("mono_thread_attach called for an already attached thread");
if (mono_thread_attach_cb) {
- mono_thread_attach_cb (&tid);
+ mono_thread_attach_cb (thread, &tid);
}
return thread;
}
mono_domain_set (domain);
if (mono_thread_attach_cb) {
- mono_thread_attach_cb (&tid);
+ mono_thread_attach_cb (thread, &tid);
}
return(thread);
#endif
im = mono_get_delegate_invoke (start->vtable->klass);
- start_func = mono_compile_method (im);
+ if (mono_thread_callbacks)
+ start_func = (* mono_thread_callbacks->thread_start_compile_func) (im);
+ else
+ start_func = mono_compile_method (im);
if(start_func==NULL) {
g_warning(G_GNUC_PRETTY_FUNCTION
g_message(G_GNUC_PRETTY_FUNCTION
": Started thread ID %d (handle %p)", tid, thread);
#endif
-
+
return(thread);
}
}
*/
handle_store(this);
+ if (mono_thread_callbacks)
+ (* mono_thread_callbacks->start_resume) (this);
+
ResumeThread(thread);
+
+ if (mono_thread_callbacks)
+ (* mono_thread_callbacks->end_resume) (this);
}
void ves_icall_System_Threading_Thread_Sleep_internal(gint32 ms)
}
}
-void mono_thread_init (MonoDomain *domain, MonoThreadStartCB start_cb,
- MonoThreadStartCB attach_cb)
+void mono_thread_init (MonoDomain *domain, MonoThreadStartCB start_cb, MonoThreadAttachCB attach_cb)
{
/* Build a System.Threading.Thread object instance to return
* for the main line's Thread.CurrentThread property.
GetCurrentProcess ();
}
+void mono_install_thread_callbacks (MonoThreadCallbacks *callbacks)
+{
+ mono_thread_callbacks = callbacks;
+}
+
#ifdef THREAD_DEBUG
static void print_tids (gpointer key, gpointer value, gpointer user)
{
extern int mono_thread_get_abort_signal (void);
extern void mono_thread_init (MonoDomain *domain, MonoThreadStartCB start_cb,
- MonoThreadStartCB attach_cb);
+ MonoThreadAttachCB attach_cb);
extern void mono_thread_cleanup(void);
extern MonoThread *mono_thread_current (void);
+typedef struct {
+ gpointer (* thread_start_compile_func) (MonoMethod *delegate);
+ void (* start_resume) (MonoThread *thread);
+ void (* end_resume) (MonoThread *thread);
+} MonoThreadCallbacks;
+
+extern void mono_install_thread_callbacks (MonoThreadCallbacks *callbacks);
+
extern void mono_new_thread_init (MonoThread *thread_object,
- gpointer stack_start);
+ gpointer stack_start,
+ gpointer func);
extern MonoThread *mono_thread_create (MonoDomain *domain, gpointer func,
gpointer arg);
extern MonoThread *mono_thread_attach (MonoDomain *domain);