[runtime] Include seqpoints, mvid and aotid on runtime generated stack traces.
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 17 Nov 2016 00:07:21 +0000 (16:07 -0800)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 19 Dec 2016 17:56:30 +0000 (15:56 -0200)
mono/metadata/exception-internals.h
mono/metadata/mono-debug.c

index a0f4c783fa14e47ff5a49488fb543101598877f0..e36e5ef9e76a2de9ea91a20b9e4bd59a6b1472ce 100644 (file)
@@ -26,4 +26,10 @@ mono_exception_from_token_two_strings_checked (MonoImage *image, uint32_t token,
                                               MonoString *a1, MonoString *a2,
                                               MonoError *error);
 
+
+typedef int (*MonoGetSeqPointFunc) (MonoDomain *domain, MonoMethod *method, gint32 native_offset);
+
+void
+mono_install_get_seq_point (MonoGetSeqPointFunc func);
+
 #endif
index b139ce9f3e6ef944249972c2acff47bc8d3bf4c7..4d81eefb8d1edac18babde7a684dfb89878da7e5 100644 (file)
@@ -22,6 +22,8 @@
 #include <mono/metadata/gc-internals.h>
 #include <mono/metadata/mempool.h>
 #include <mono/metadata/debug-mono-ppdb.h>
+#include <mono/metadata/exception-internals.h>
+#include <mono/metadata/runtime.h>
 #include <string.h>
 
 #define ALIGN_TO(val,align) ((((guint64)val) + ((align) - 1)) & ~((align) - 1))
@@ -861,6 +863,14 @@ mono_debug_free_source_location (MonoDebugSourceLocation *location)
        }
 }
 
+static int (*get_seq_point) (MonoDomain *domain, MonoMethod *method, gint32 native_offset);
+
+void
+mono_install_get_seq_point (MonoGetSeqPointFunc func)
+{
+       get_seq_point = func;
+}
+
 /**
  * mono_debug_print_stack_frame:
  * @native_offset: Native offset within the @method's machine code.
@@ -891,10 +901,22 @@ mono_debug_print_stack_frame (MonoMethod *method, guint32 native_offset, MonoDom
                        offset = -1;
                }
 
+               if (offset < 0 && get_seq_point)
+                       offset = get_seq_point (domain, method, native_offset);
+
                if (offset < 0)
                        res = g_strdup_printf ("at %s <0x%05x>", fname, native_offset);
-               else
-                       res = g_strdup_printf ("at %s <IL 0x%05x, 0x%05x>", fname, offset, native_offset);
+               else {
+                       char *mvid = mono_guid_to_string_minimal ((uint8_t*)method->klass->image->heap_guid.data);
+                       char *aotid = mono_runtime_get_aotid ();
+                       if (aotid)
+                               res = g_strdup_printf ("at %s [0x%05x] in <%s#%s>:0" , fname, offset, mvid, aotid);
+                       else
+                               res = g_strdup_printf ("at %s [0x%05x] in <%s>:0" , fname, offset, mvid);
+
+                       g_free (aotid);
+                       g_free (mvid);
+               }
                g_free (fname);
                return res;
        }