X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Ftrace.c;h=b81fe604ed3aef345b7eef2ca52c01e4630172d7;hb=770ea9329202d7dad0f6abb92dcadd84a899b0d5;hp=0b0a15ad9b6f7b820991f7dd1451506c4118fd1c;hpb=44f4429237816e808e42136783c6fb885e13a5dd;p=mono.git diff --git a/mono/mini/trace.c b/mono/mini/trace.c index 0b0a15ad9b6..b81fe604ed3 100644 --- a/mono/mini/trace.c +++ b/mono/mini/trace.c @@ -1,5 +1,6 @@ -/* - * trace.c: Tracing facilities for the Mono Runtime. +/** + * \file + * Tracing facilities for the Mono Runtime. * * Author: * Paolo Molaro (lupus@ximian.com) @@ -7,6 +8,7 @@ * * (C) 2002 Ximian, Inc. * Copyright 2011 Xamarin, Inc (http://www.xamarin.com) + * Licensed under the MIT license. See LICENSE file in the project root for full license information. */ #include @@ -24,32 +26,13 @@ #include #include "trace.h" -#if defined (PLATFORM_ANDROID) || (defined (TARGET_IOS) && defined (TARGET_IOS)) +#if defined (HOST_ANDROID) || (defined (TARGET_IOS) && defined (TARGET_IOS)) # undef printf # define printf(...) g_log("mono", G_LOG_LEVEL_MESSAGE, __VA_ARGS__) # undef fprintf # define fprintf(__ignore, ...) g_log ("mono-gc", G_LOG_LEVEL_MESSAGE, __VA_ARGS__) #endif -#ifdef __GNUC__ - -#define RETURN_ADDRESS_N(N) (__builtin_extract_return_addr (__builtin_return_address (N))) -#define RETURN_ADDRESS() RETURN_ADDRESS_N(0) - -#elif defined(_MSC_VER) - -#include -#pragma intrinsic(_ReturnAddress) - -#define RETURN_ADDRESS() _ReturnAddress() -#define RETURN_ADDRESS_N(N) NULL - -#else - -#error "Missing return address intrinsics implementation" - -#endif - static MonoTraceSpec trace_spec; static volatile gint32 output_lock = 0; @@ -100,17 +83,21 @@ mono_trace_eval (MonoMethod *method) switch (op->op){ case MONO_TRACEOP_ALL: - inc = 1; break; + inc = 1; + break; case MONO_TRACEOP_PROGRAM: if (trace_spec.assembly && (method->klass->image == mono_assembly_get_image (trace_spec.assembly))) - inc = 1; break; + inc = 1; + break; case MONO_TRACEOP_WRAPPER: if ((method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) || (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE)) - inc = 1; break; + inc = 1; + break; case MONO_TRACEOP_METHOD: if (mono_method_desc_full_match ((MonoMethodDesc *) op->data, method)) - inc = 1; break; + inc = 1; + break; case MONO_TRACEOP_CLASS: if (strcmp (method->klass->name_space, op->data) == 0) if (strcmp (method->klass->name, op->data2) == 0) @@ -118,18 +105,21 @@ mono_trace_eval (MonoMethod *method) break; case MONO_TRACEOP_ASSEMBLY: if (strcmp (mono_image_get_name (method->klass->image), op->data) == 0) - inc = 1; break; + inc = 1; + break; case MONO_TRACEOP_NAMESPACE: if (strcmp (method->klass->name_space, op->data) == 0) inc = 1; + break; case MONO_TRACEOP_EXCEPTION: break; } - if (op->exclude){ + if (op->exclude) { if (inc) include = 0; - } else if (inc) + } else if (inc) { include = 1; + } } return include; } @@ -158,9 +148,10 @@ static void get_string (void) } if (value != NULL) g_free (value); - value = g_malloc (input - start + 1); - strncpy (value, start, input-start); - value [input-start] = 0; + size_t len = input - start; + value = (char *)g_malloc (len + 1); + memcpy (value, start, len); + value [len] = 0; } enum Token { @@ -431,11 +422,11 @@ mono_trace_enter_method (MonoMethod *method, char *ebp) sig = mono_method_signature (method); - arg_info = alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1)); + arg_info = (MonoJitArgumentInfo *)alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1)); if (method->is_inflated) { /* FIXME: Might be better to pass the ji itself */ - MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), RETURN_ADDRESS (), NULL); + MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (char *)RETURN_ADDRESS (), NULL); if (ji) { gsctx = mono_jit_info_get_generic_sharing_context (ji); if (gsctx && gsctx->is_gsharedvt) { @@ -455,11 +446,11 @@ mono_trace_enter_method (MonoMethod *method, char *ebp) } if (mono_method_signature (method)->hasthis) { - gpointer *this = (gpointer *)(ebp + arg_info [0].offset); + gpointer *this_obj = (gpointer *)(ebp + arg_info [0].offset); if (method->klass->valuetype) { - printf ("value:%p, ", *arg_in_stack_slot(this, gpointer *)); + printf ("value:%p, ", *arg_in_stack_slot(this_obj, gpointer *)); } else { - o = *arg_in_stack_slot(this, MonoObject *); + o = *arg_in_stack_slot(this_obj, MonoObject *); if (o) { klass = o->vtable->klass; @@ -533,7 +524,7 @@ mono_trace_enter_method (MonoMethod *method, char *ebp) g_free (as); } else if (klass == mono_defaults.int32_class) { printf ("[INT32:%p:%d], ", o, *(gint32 *)((char *)o + sizeof (MonoObject))); - } else if (klass == mono_defaults.monotype_class) { + } else if (klass == mono_defaults.runtimetype_class) { printf ("[TYPE:%s], ", mono_type_full_name (((MonoReflectionType*)o)->type)); } else printf ("[%s.%s:%p], ", klass->name_space, klass->name, o); @@ -599,7 +590,7 @@ mono_trace_leave_method (MonoMethod *method, ...) if (method->is_inflated) { /* FIXME: Might be better to pass the ji itself */ - MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), RETURN_ADDRESS (), NULL); + MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), (char *)RETURN_ADDRESS (), NULL); if (ji) { gsctx = mono_jit_info_get_generic_sharing_context (ji); if (gsctx && gsctx->is_gsharedvt) { @@ -694,7 +685,7 @@ mono_trace_leave_method (MonoMethod *method, ...) break; } case MONO_TYPE_VALUETYPE: { - guint8 *p = va_arg (ap, gpointer); + guint8 *p = (guint8 *)va_arg (ap, gpointer); int j, size, align; size = mono_type_size (type, &align); printf ("[");