From cc2641ca63d6ef9b3c226cd49ec096ea3b2f4861 Mon Sep 17 00:00:00 2001 From: Rodrigo Kumpera Date: Fri, 20 Jul 2012 13:20:16 -0300 Subject: [PATCH] Add Mono.Runtime::GetNativeStackTrace method to make the new backtracing facility available to managed land. --- mcs/class/corlib/Mono/Runtime.cs | 4 ++++ mono/metadata/exception.c | 13 +++++++++++++ mono/metadata/icall-def.h | 1 + mono/metadata/object-internals.h | 3 +++ 4 files changed, 21 insertions(+) diff --git a/mcs/class/corlib/Mono/Runtime.cs b/mcs/class/corlib/Mono/Runtime.cs index 9636fb1bda3..b036daba679 100644 --- a/mcs/class/corlib/Mono/Runtime.cs +++ b/mcs/class/corlib/Mono/Runtime.cs @@ -47,6 +47,10 @@ namespace Mono { // Format is undefined only for use as a string for reporting [MethodImplAttribute (MethodImplOptions.InternalCall)] internal static extern string GetDisplayName (); + + [MethodImplAttribute (MethodImplOptions.InternalCall)] + public static extern string GetNativeStackTrace (Exception exception); + } } diff --git a/mono/metadata/exception.c b/mono/metadata/exception.c index e3ba90d69d7..f120041e2d2 100644 --- a/mono/metadata/exception.c +++ b/mono/metadata/exception.c @@ -803,3 +803,16 @@ mono_exception_get_native_backtrace (MonoException *exc) #endif } +MonoString * +ves_icall_Mono_Runtime_GetNativeStackTrace (MonoException *exc) +{ + char *trace; + MonoString *res; + if (!exc) + mono_raise_exception (mono_get_exception_argument_null ("exception")); + + trace = mono_exception_get_native_backtrace (exc); + res = mono_string_new (mono_domain_get (), trace); + g_free (trace); + return res; +} diff --git a/mono/metadata/icall-def.h b/mono/metadata/icall-def.h index 3939a9a2f25..b4667d71f46 100644 --- a/mono/metadata/icall-def.h +++ b/mono/metadata/icall-def.h @@ -47,6 +47,7 @@ ICALL(COMPROX_2, "FindProxy", ves_icall_Mono_Interop_ComInteropProxy_FindProxy) ICALL_TYPE(RUNTIME, "Mono.Runtime", RUNTIME_1) ICALL(RUNTIME_1, "GetDisplayName", ves_icall_Mono_Runtime_GetDisplayName) +ICALL(RUNTIME_12, "GetNativeStackTrace", ves_icall_Mono_Runtime_GetNativeStackTrace) #ifndef PLATFORM_RO_FS ICALL_TYPE(KPAIR, "Mono.Security.Cryptography.KeyPairPersistence", KPAIR_1) diff --git a/mono/metadata/object-internals.h b/mono/metadata/object-internals.h index 0f8981c8c79..3a455158cd5 100644 --- a/mono/metadata/object-internals.h +++ b/mono/metadata/object-internals.h @@ -1577,6 +1577,9 @@ mono_monitor_is_il_fastpath_wrapper (MonoMethod *method) MONO_INTERNAL; char * mono_exception_get_native_backtrace (MonoException *exc) MONO_INTERNAL; +MonoString * +ves_icall_Mono_Runtime_GetNativeStackTrace (MonoException *exc) MONO_INTERNAL; + #endif /* __MONO_OBJECT_INTERNALS_H__ */ -- 2.25.1