diff options
author | Bernhard Urban <bernhard.urban@xamarin.com> | 2017-02-27 19:55:54 +0300 |
---|---|---|
committer | Bernhard Urban <bernhard.urban@xamarin.com> | 2017-03-01 00:59:28 +0300 |
commit | c0eb4ba3744acdc3836870c11622f2687b19b113 (patch) | |
tree | 09ec6b5e8fcf2c3e50a53cbd5db09aefd09e8ef3 | |
parent | a5aa5a1354fc10adc92d0ab12dd4e6e1cc65c807 (diff) |
[interpreter] install stack walking callback
-rw-r--r-- | mono/mini/interpreter/interp.c | 45 | ||||
-rw-r--r-- | mono/mini/interpreter/interp.h | 3 | ||||
-rw-r--r-- | mono/mini/mini-exceptions.c | 9 |
3 files changed, 37 insertions, 20 deletions
diff --git a/mono/mini/interpreter/interp.c b/mono/mini/interpreter/interp.c index 8bc422c7e0e..b1fe4c1584d 100644 --- a/mono/mini/interpreter/interp.c +++ b/mono/mini/interpreter/interp.c @@ -689,35 +689,42 @@ ves_array_element_address (MonoInvocation *frame) frame->retval->data.p = ea; } -static void -interp_walk_stack (MonoStackWalk func, gboolean do_il_offset, gpointer user_data) +void +interp_walk_stack_with_ctx (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data) { - ThreadContext *context = mono_native_tls_get_value (thread_context_id); - MonoInvocation *frame; - int il_offset; - MonoMethodHeader *hd; MonoError error; + ThreadContext *context = mono_native_tls_get_value (thread_context_id); - if (!context) return; - - frame = context->current_frame; + MonoInvocation *frame = context->current_frame; while (frame) { - gboolean managed = FALSE; - MonoMethod *method = frame->runtime_method->method; - if (!method || (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))) - il_offset = -1; - else { - hd = mono_method_get_header_checked (method, &error); + MonoStackFrameInfo fi; + memset (&fi, 0, sizeof (MonoStackFrameInfo)); + + /* TODO: hack to make some asserts happy. */ + fi.ji = (MonoJitInfo *) frame->runtime_method; + + if (frame->runtime_method) + fi.method = fi.actual_method = frame->runtime_method->method; + + if (!fi.method || (fi.method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL) || (fi.method->iflags & (METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL | METHOD_IMPL_ATTRIBUTE_RUNTIME))) { + fi.il_offset = -1; + fi.type = FRAME_TYPE_MANAGED_TO_NATIVE; + } else { + MonoMethodHeader *hd = mono_method_get_header_checked (fi.method, &error); mono_error_cleanup (&error); /* FIXME: don't swallow the error */ - il_offset = frame->ip - (const unsigned short *)hd->code; - if (!method->wrapper_type) - managed = TRUE; + fi.type = FRAME_TYPE_MANAGED; + fi.il_offset = frame->ip - (const unsigned short *) hd->code; + if (!fi.method->wrapper_type) + fi.managed = TRUE; } - if (func (method, -1, il_offset, managed, user_data)) + + if (func (&fi, ctx, user_data)) return; frame = frame->parent; } + + g_assert (0); } static MonoPIFunc mono_interp_enter_icall_trampoline = NULL; diff --git a/mono/mini/interpreter/interp.h b/mono/mini/interpreter/interp.h index ad9ca81c567..59428a882f2 100644 --- a/mono/mini/interpreter/interp.h +++ b/mono/mini/interpreter/interp.h @@ -16,4 +16,7 @@ mono_interp_runtime_invoke (MonoMethod *method, void *obj, void **params, MonoOb void mono_interp_init_delegate (MonoDelegate *del); + +void +interp_walk_stack_with_ctx (MonoInternalStackWalk func, MonoContext *ctx, MonoUnwindOptions options, void *user_data); #endif /* __MONO_MINI_INTERPRETER_H__ */ diff --git a/mono/mini/mini-exceptions.c b/mono/mini/mini-exceptions.c index e130eb59411..de5745a88db 100644 --- a/mono/mini/mini-exceptions.c +++ b/mono/mini/mini-exceptions.c @@ -73,6 +73,7 @@ #include "seq-points.h" #include "llvm-runtime.h" #include "mini-llvm.h" +#include "interpreter/interp.h" #ifdef ENABLE_LLVM #include "mini-llvm-cpp.h" @@ -220,7 +221,13 @@ mono_exceptions_init (void) #ifdef MONO_ARCH_HAVE_EXCEPTIONS_INIT mono_arch_exceptions_init (); #endif - cbs.mono_walk_stack_with_ctx = mono_runtime_walk_stack_with_ctx; +#ifdef ENABLE_INTERPRETER + if (mono_use_interpreter) + cbs.mono_walk_stack_with_ctx = interp_walk_stack_with_ctx; + else +#endif + cbs.mono_walk_stack_with_ctx = mono_runtime_walk_stack_with_ctx; + cbs.mono_walk_stack_with_state = mono_walk_stack_with_state; if (mono_llvm_only) |