+2003-01-16 Dietmar Maurer <dietmar@ximian.com>
+
+ * exception.c (arch_handle_exception): exclude runtime invoke
+ wrapper from the stack trace
+
+ * jit.c (mono_cfg_new): allocate extra space to store esp (used by exceptions)
+ (mono_thread_start_cb): save an additional LMF at thread start
+
2003-01-16 Martin Baulig <martin@ximian.com>
* jit.c (mono_runtime_install_handlers): Use SYS_sigaction() for
frame = MONO_CONTEXT_GET_BP (ctx);
- max_stack = lmf ? lmf : jit_tls->end_of_stack;
+ max_stack = lmf && lmf->method ? lmf : jit_tls->end_of_stack;
*new_ctx = *ctx;
*new_ctx = *ctx;
+ if (!(*lmf)->method)
+ return (gpointer)-1;
+
if (trace)
*trace = g_strdup_printf ("in (unmanaged) %s", mono_method_full_name ((*lmf)->method, TRUE));
ji = mono_arch_find_jit_info (domain, jit_tls, &ctx, &new_ctx, NULL, &lmf, &native_offset, &managed);
g_assert (ji);
-
+
+ if (ji == (gpointer)-1)
+ return;
+
il_offset = mono_debug_il_offset_from_address (ji->method, native_offset);
if (func (ji->method, native_offset, il_offset, managed, user_data))
ji = mono_arch_find_jit_info (domain, jit_tls, &ctx, &new_ctx, NULL, &lmf, native_offset, NULL);
ctx = new_ctx;
- if (!ji || MONO_CONTEXT_GET_BP (&ctx) >= jit_tls->end_of_stack)
+ if (!ji || ji == (gpointer)-1 || MONO_CONTEXT_GET_BP (&ctx) >= jit_tls->end_of_stack)
return FALSE;
if (ji->method->wrapper_type == MONO_WRAPPER_RUNTIME_INVOKE)
ji = mono_arch_find_jit_info (domain, jit_tls, ctx, &new_ctx,
test_only ? &trace : NULL, &lmf, NULL, NULL);
+
if (!ji) {
g_warning ("Exception inside function without unwind info");
g_assert_not_reached ();
}
- if (ji->method != mono_start_method) {
-
- if (test_only) {
+ if (ji != (gpointer)-1) {
+ if (test_only && ji->method->wrapper_type != MONO_WRAPPER_RUNTIME_INVOKE) {
char *tmp, *strace;
trace_ips = g_list_append (trace_ips, MONO_CONTEXT_GET_IP (ctx));
strace = g_strdup ("");
else
strace = mono_string_to_utf8 (((MonoException*)obj)->stack_trace);
-
+
tmp = g_strdup_printf ("%s%s\n", strace, trace);
g_free (strace);
*ctx = new_ctx;
- if (ji->method == mono_start_method || MONO_CONTEXT_GET_BP (ctx) >= jit_tls->end_of_stack) {
+ if ((ji == (gpointer)-1) || MONO_CONTEXT_GET_BP (ctx) >= jit_tls->end_of_stack) {
if (!test_only) {
jit_tls->lmf = lmf;
jit_tls->abort_func (obj);
MonoObject *(*runtime_invoke) (MonoObject *this, void **params, MonoObject **exc);
invoke = mono_marshal_get_runtime_invoke (method);
- runtime_invoke = mono_compile_method (invoke);
+ runtime_invoke = mono_compile_method (invoke);
return runtime_invoke (obj, params, exc);
}
/* reserve space to save LMF */
cfg->locals_size = sizeof (MonoLMF);
+ cfg->locals_size += sizeof (gpointer);
mono_exc_esp_offset = - cfg->locals_size;
+ cfg->locals_size += sizeof (gpointer);
+
/* aligment check */
g_assert (!(cfg->locals_size & 0x7));
#endif
/**
- * mono_compile_method:
+ * mono_jit_compile_method:
* @method: pointer to the method info
*
* JIT compilation of a single method.
mono_jit_stats.native_code_size += ji->code_size;
+ ji->num_clauses = header->num_clauses;
+
if (header->num_clauses) {
int i, start_block, end_block, filter_block;
- ji->num_clauses = header->num_clauses;
ji->clauses = mono_mempool_alloc0 (target_domain->mp,
sizeof (MonoJitExceptionInfo) * header->num_clauses);
mono_thread_start_cb (gpointer stack_start)
{
MonoJitTlsData *jit_tls;
+ MonoLMF *lmf;
jit_tls = g_new0 (MonoJitTlsData, 1);
jit_tls->abort_func = mono_thread_abort;
jit_tls->end_of_stack = stack_start;
+
+ lmf = g_new0 (MonoLMF, 1);
+ lmf->ebp = -1;
+
+ jit_tls->lmf = lmf;
}
void (*mono_thread_attach_aborted_cb ) (MonoObject *obj) = NULL;
mono_thread_attach_cb (gpointer stack_start)
{
MonoJitTlsData *jit_tls;
+ MonoLMF *lmf;
jit_tls = g_new0 (MonoJitTlsData, 1);
jit_tls->abort_func = mono_thread_abort_dummy;
jit_tls->end_of_stack = stack_start;
+
+ lmf = g_new0 (MonoLMF, 1);
+ lmf->ebp = -1;
+
+ jit_tls->lmf = lmf;
}
static CRITICAL_SECTION ms;
return main_args;
}
-MonoMethod *mono_start_method = NULL;
-
/*
* Execute a standard Main() method (argc/argv contains the
* executable name). This method also sets the command line argument value
mono_assembly_set_main (method->klass->image->assembly);
- mono_start_method = mono_marshal_get_runtime_invoke (method);
-
return mono_runtime_exec_main (method, args, exc);
}
{
MonoDomain *domain;
gpointer pa [1];
+ MonoObject *res;
int rval;
g_assert (args);
#define mono_string_chars(s) ((gunichar2*)(s)->chars)
#define mono_string_length(s) ((s)->length)
-extern MonoMethod *mono_start_method;
-
void *
mono_object_allocate (size_t size);
HANDLE thread_handle;
guint32 tid;
+ 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);
+ }
+ return thread;
+ }
+
thread = (MonoThread *)mono_object_new (domain,
mono_defaults.thread_class);