[llvmonly] Implement support for stack walks if _Unwind_Backtrace () is available.
authorZoltan Varga <vargaz@gmail.com>
Wed, 3 Feb 2016 00:35:01 +0000 (19:35 -0500)
committerZoltan Varga <vargaz@gmail.com>
Wed, 3 Feb 2016 00:35:26 +0000 (19:35 -0500)
mono/mini/mini-exceptions.c
mono/utils/mono-stack-unwinding.h

index 8cb3fc61b6f819ad26130e211c9f2c47b2938705..9388dc8f9ffbb752babbee5fe3386fe55561472e 100644 (file)
@@ -895,6 +895,36 @@ mono_walk_stack_full (MonoJitStackWalk func, MonoContext *start_ctx, MonoDomain
        gboolean get_reg_locations = unwind_options & MONO_UNWIND_REG_LOCATIONS;
        gboolean async = mono_thread_info_is_async_context ();
 
+       if (mono_llvm_only) {
+               GSList *l, *ips;
+
+               if (async)
+                       return;
+
+               ips = get_unwind_backtrace ();
+               for (l = ips; l; l = l->next) {
+                       guint8 *ip = (guint8*)l->data;
+                       memset (&frame, 0, sizeof (StackFrameInfo));
+                       frame.ji = mini_jit_info_table_find (domain, (char*)ip, &frame.domain);
+                       if (!frame.ji || frame.ji->is_trampoline)
+                               continue;
+                       frame.type = FRAME_TYPE_MANAGED;
+                       frame.method = jinfo_get_method (frame.ji);
+                       // FIXME: Cannot lookup the actual method
+                       frame.actual_method = frame.method;
+                       if (frame.type == FRAME_TYPE_MANAGED) {
+                               if (!frame.method->wrapper_type || frame.method->wrapper_type == MONO_WRAPPER_DYNAMIC_METHOD)
+                                       frame.managed = TRUE;
+                       }
+                       frame.native_offset = ip - (guint8*)frame.ji->code_start;
+                       frame.il_offset = -1;
+
+                       if (func (&frame, NULL, user_data))
+                               break;
+               }
+               g_free (ips);
+       }
+
        g_assert (start_ctx);
        g_assert (domain);
        g_assert (jit_tls);
index 35f7bd0141136dee83f41562195dcc9c88753485..456cb31bb3e7b3aba28590476cafd407483fe949 100644 (file)
@@ -58,6 +58,7 @@ typedef struct {
        MonoMethod *actual_method;
        /* The domain containing the code executed by this frame */
        MonoDomain *domain;
+       /* Whenever method is a user level method */
        gboolean managed;
        /*
         * Whenever this frame was loaded in async context.