This commit was manufactured by cvs2svn to create branch 'mono-1-0'.
[mono.git] / mono / metadata / profiler.c
index c01ba80258c05e539e1b440ab58fda13e192e7ac..e31492883f046dd4166a2bfd90a30a75906c197b 100644 (file)
@@ -2,7 +2,8 @@
 #include "mono/metadata/profiler-private.h"
 #include "mono/metadata/debug-helpers.h"
 #include "mono/metadata/mono-debug.h"
-#include "mono/io-layer/critical-sections.h"
+#include "mono/metadata/class-internals.h"
+#include "mono/io-layer/io-layer.h"
 #include <string.h>
 #include <gmodule.h>
 
@@ -954,7 +955,13 @@ simple_allocation (MonoProfiler *prof, MonoObject *obj, MonoClass *klass)
 
        GET_THREAD_PROF (prof);
        if (prof->callers) {
-               if (!(profile_info = g_hash_table_lookup (prof->methods, prof->callers->method)))
+               MonoMethod *caller = prof->callers->method;
+
+               /* Otherwise all allocations are attributed to icall_wrapper_mono_object_new */
+               if (caller->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)
+                       caller = prof->callers->next->method;
+
+               if (!(profile_info = g_hash_table_lookup (prof->methods, caller)))
                        g_assert_not_reached ();
        } else {
                return; /* fine for now */