#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>
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 */