Merge pull request #822 from carlosmn/asp-pc
[mono.git] / mono / mini / trace.c
1 /*
2  * trace.c: Tracing facilities for the Mono Runtime.
3  *
4  * Author:
5  *   Paolo Molaro (lupus@ximian.com)
6  *   Dietmar Maurer (dietmar@ximian.com)
7  *
8  * (C) 2002 Ximian, Inc.
9  * Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
10  */
11
12 #include <config.h>
13 #include <signal.h>
14 #ifdef HAVE_ALLOCA_H
15 #include <alloca.h>
16 #endif
17 #ifdef HAVE_UNISTD_H
18 #include <unistd.h>
19 #endif
20 #include <string.h>
21 #include "mini.h"
22 #include <mono/metadata/debug-helpers.h>
23 #include <mono/metadata/assembly.h>
24 #include <mono/utils/mono-time.h>
25 #include "trace.h"
26
27 #if defined (PLATFORM_ANDROID) || (defined (TARGET_IOS) && defined (TARGET_IOS))
28 #  undef printf
29 #  define printf(...) g_log("mono", G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
30 #  undef fprintf
31 #  define fprintf(__ignore, ...) g_log ("mono-gc", G_LOG_LEVEL_MESSAGE, __VA_ARGS__)
32 #endif
33
34 #define RETURN_ADDRESS(N) (__builtin_extract_return_addr (__builtin_return_address (N)))
35
36 static MonoTraceSpec trace_spec;
37
38 gboolean
39 mono_trace_eval_exception (MonoClass *klass)
40 {
41         int include = 0;
42         int i;
43
44         if (!klass)
45                 return FALSE;
46
47         for (i = 0; i < trace_spec.len; i++) {
48                 MonoTraceOperation *op = &trace_spec.ops [i];
49                 int inc = 0;
50                 
51                 switch (op->op){
52                 case MONO_TRACEOP_EXCEPTION:
53                         if (strcmp ("", op->data) == 0 && strcmp ("all", op->data2) == 0)
54                                 inc = 1;
55                         else if (strcmp ("", op->data) == 0 || strcmp (klass->name_space, op->data) == 0)
56                                 if (strcmp (klass->name, op->data2) == 0)
57                                         inc = 1;
58                         break;
59                 default:
60                         break;
61                 }
62                 if (op->exclude){
63                         if (inc)
64                                 include = 0;
65                 } else if (inc)
66                         include = 1;
67         }
68
69         return include;
70 }
71
72 gboolean
73 mono_trace_eval (MonoMethod *method)
74 {
75         int include = 0;
76         int i;
77
78         for (i = 0; i < trace_spec.len; i++){
79                 MonoTraceOperation *op = &trace_spec.ops [i];
80                 int inc = 0;
81                 
82                 switch (op->op){
83                 case MONO_TRACEOP_ALL:
84                         inc = 1; break;
85                 case MONO_TRACEOP_PROGRAM:
86                         if (trace_spec.assembly && (method->klass->image == mono_assembly_get_image (trace_spec.assembly)))
87                                 inc = 1; break;
88                 case MONO_TRACEOP_WRAPPER:
89                         if ((method->wrapper_type == MONO_WRAPPER_NATIVE_TO_MANAGED) ||
90                                 (method->wrapper_type == MONO_WRAPPER_MANAGED_TO_NATIVE))
91                                 inc = 1; break;
92                 case MONO_TRACEOP_METHOD:
93                         if (mono_method_desc_full_match ((MonoMethodDesc *) op->data, method))
94                                 inc = 1; break;
95                 case MONO_TRACEOP_CLASS:
96                         if (strcmp (method->klass->name_space, op->data) == 0)
97                                 if (strcmp (method->klass->name, op->data2) == 0)
98                                         inc = 1;
99                         break;
100                 case MONO_TRACEOP_ASSEMBLY:
101                         if (strcmp (mono_image_get_name (method->klass->image), op->data) == 0)
102                                 inc = 1; break;
103                 case MONO_TRACEOP_NAMESPACE:
104                         if (strcmp (method->klass->name_space, op->data) == 0)
105                                 inc = 1;
106                 case MONO_TRACEOP_EXCEPTION:
107                         break;
108                 }
109                 if (op->exclude){
110                         if (inc)
111                                 include = 0;
112                 } else if (inc)
113                         include = 1;
114         }
115         return include;
116 }
117
118 static int is_filenamechar (char p)
119 {
120         if (p >= 'A' && p <= 'Z')
121                 return TRUE;
122         if (p >= 'a' && p <= 'z')
123                 return TRUE;
124         if (p >= '0' && p <= '9')
125                 return TRUE;
126         if (p == '.' || p == ':' || p == '_' || p == '-')
127                 return TRUE;
128         return FALSE;
129 }
130
131 static char *input;
132 static char *value;
133
134 static void get_string (void)
135 {
136         char *start = input;
137         while (is_filenamechar (*input)){
138                 input++;
139         }
140         if (value != NULL)
141                 g_free (value);
142         value = g_malloc (input - start + 1);
143         strncpy (value, start, input-start);
144         value [input-start] = 0;
145 }
146
147 enum Token {
148         TOKEN_METHOD,
149         TOKEN_CLASS,
150         TOKEN_ALL,
151         TOKEN_PROGRAM,
152         TOKEN_EXCEPTION,
153         TOKEN_NAMESPACE,
154         TOKEN_WRAPPER,
155         TOKEN_STRING,
156         TOKEN_EXCLUDE,
157         TOKEN_DISABLED,
158         TOKEN_SEPARATOR,
159         TOKEN_END,
160         TOKEN_ERROR
161 };
162
163 static int
164 get_token (void)
165 {
166         while (input [0] == '+')
167                 input++;
168
169         if (input [0] == '\0') {
170                 return TOKEN_END;
171         }
172         if (input [0] == 'M' && input [1] == ':'){
173                 input += 2;
174                 get_string ();
175                 return TOKEN_METHOD;
176         }
177         if (input [0] == 'N' && input [1] == ':'){
178                 input += 2;
179                 get_string ();
180                 return TOKEN_NAMESPACE;
181         }
182         if (input [0] == 'T' && input [1] == ':'){
183                 input += 2;
184                 get_string ();
185                 return TOKEN_CLASS;
186         }
187         if (input [0] == 'E' && input [1] == ':'){
188                 input += 2;
189                 get_string ();
190                 return TOKEN_EXCEPTION;
191         }
192         if (*input == '-'){
193                 input++;
194                 return TOKEN_EXCLUDE;
195         }
196         if (is_filenamechar (*input)){
197                 get_string ();
198                 if (strcmp (value, "all") == 0)
199                         return TOKEN_ALL;
200                 if (strcmp (value, "program") == 0)
201                         return TOKEN_PROGRAM;
202                 if (strcmp (value, "wrapper") == 0)
203                         return TOKEN_WRAPPER;
204                 if (strcmp (value, "disabled") == 0)
205                         return TOKEN_DISABLED;
206                 return TOKEN_STRING;
207         }
208         if (*input == ','){
209                 input++;
210                 return TOKEN_SEPARATOR;
211         }
212
213         fprintf (stderr, "Syntax error at or around '%s'\n", input);    
214         return TOKEN_ERROR;
215 }
216
217 static void
218 cleanup (void)
219 {
220         if (value != NULL)
221                 g_free (value);
222 }
223
224 static int
225 get_spec (int *last)
226 {
227         int token = get_token ();
228         if (token == TOKEN_EXCLUDE){
229                 token = get_spec (last);
230                 if (token == TOKEN_EXCLUDE){
231                         fprintf (stderr, "Expecting an expression");
232                         return TOKEN_ERROR;
233                 }
234                 if (token == TOKEN_ERROR)
235                         return token;
236                 trace_spec.ops [(*last)-1].exclude = 1;
237                 return TOKEN_SEPARATOR;
238         }
239         if (token == TOKEN_END || token == TOKEN_SEPARATOR || token == TOKEN_ERROR)
240                 return token;
241         
242         if (token == TOKEN_METHOD){
243                 MonoMethodDesc *desc = mono_method_desc_new (value, TRUE);
244                 if (desc == NULL){
245                         fprintf (stderr, "Invalid method name: %s\n", value);
246                         return TOKEN_ERROR;
247                 }
248                 trace_spec.ops [*last].op = MONO_TRACEOP_METHOD;
249                 trace_spec.ops [*last].data = desc;
250         } else if (token == TOKEN_ALL)
251                 trace_spec.ops [*last].op = MONO_TRACEOP_ALL;
252         else if (token == TOKEN_PROGRAM)
253                 trace_spec.ops [*last].op = MONO_TRACEOP_PROGRAM;
254         else if (token == TOKEN_WRAPPER)
255                 trace_spec.ops [*last].op = MONO_TRACEOP_WRAPPER;
256         else if (token == TOKEN_NAMESPACE){
257                 trace_spec.ops [*last].op = MONO_TRACEOP_NAMESPACE;
258                 trace_spec.ops [*last].data = g_strdup (value);
259         } else if (token == TOKEN_CLASS || token == TOKEN_EXCEPTION){
260                 char *p = strrchr (value, '.');
261                 if (p) {
262                         *p++ = 0;
263                         trace_spec.ops [*last].data = g_strdup (value);
264                         trace_spec.ops [*last].data2 = g_strdup (p);
265                 }
266                 else {
267                         trace_spec.ops [*last].data = g_strdup ("");
268                         trace_spec.ops [*last].data2 = g_strdup (value);
269                 }
270                 trace_spec.ops [*last].op = token == TOKEN_CLASS ? MONO_TRACEOP_CLASS : MONO_TRACEOP_EXCEPTION;
271         } else if (token == TOKEN_STRING){
272                 trace_spec.ops [*last].op = MONO_TRACEOP_ASSEMBLY;
273                 trace_spec.ops [*last].data = g_strdup (value);
274         } else if (token == TOKEN_DISABLED) {
275                 trace_spec.enabled = FALSE;
276         } else {
277                 fprintf (stderr, "Syntax error in trace option specification\n");
278                 return TOKEN_ERROR;
279         }
280         (*last)++;
281         return TOKEN_SEPARATOR;
282 }
283
284 MonoTraceSpec *
285 mono_trace_parse_options (const char *options)
286 {
287         char *p = (char*)options;
288         int size = 1;
289         int last_used;
290         int token;
291
292         trace_spec.enabled = TRUE;
293         if (*p == 0){
294                 trace_spec.len = 1;
295                 trace_spec.ops = g_new0 (MonoTraceOperation, 1);
296                 trace_spec.ops [0].op = MONO_TRACEOP_ALL;
297                 return &trace_spec;
298         }
299                 
300         for (p = (char*)options; *p != 0; p++)
301                 if (*p == ',')
302                         size++;
303         
304         trace_spec.ops = g_new0 (MonoTraceOperation, size);
305
306         input = (char*)options;
307         last_used = 0;
308         
309         while ((token = (get_spec (&last_used))) != TOKEN_END){
310                 if (token == TOKEN_ERROR)
311                         return NULL;
312                 if (token == TOKEN_SEPARATOR)
313                         continue;
314         }
315         trace_spec.len = last_used;
316         cleanup ();
317         return &trace_spec;
318 }
319
320 void
321 mono_trace_set_assembly (MonoAssembly *assembly)
322 {
323         trace_spec.assembly = assembly;
324 }
325
326 static
327 #ifdef HAVE_KW_THREAD
328 __thread 
329 #endif
330 int indent_level = 0;
331 static guint64 start_time = 0;
332
333 static double seconds_since_start (void)
334 {
335         guint64 diff = mono_100ns_ticks () - start_time;
336         return diff/10000000.0;
337 }
338
339 static void indent (int diff) {
340         if (diff < 0)
341                 indent_level += diff;
342         if (start_time == 0)
343                 start_time = mono_100ns_ticks ();
344         printf ("[%p: %.5f %d] ", (void*)GetCurrentThreadId (), seconds_since_start (), indent_level);
345         if (diff > 0)
346                 indent_level += diff;
347 }
348
349 static char *
350 string_to_utf8 (MonoString *s)
351 {
352         char *as;
353         GError *error = NULL;
354
355         g_assert (s);
356
357         if (!s->length)
358                 return g_strdup ("");
359
360         as = g_utf16_to_utf8 (mono_string_chars (s), s->length, NULL, NULL, &error);
361         if (error) {
362                 /* Happens with StringBuilders */
363                 g_error_free (error);
364                 return g_strdup ("<INVALID UTF8>");
365         }
366         else
367                 return as;
368 }
369
370 /*
371  * cpos (ebp + arg_info[n].offset) points to the beginning of the
372  * stack slot for this argument.  On little-endian systems, we can
373  * simply dereference it. On big-endian systems, we need to adjust
374  * cpos upward first if the datatype we're referencing is smaller than
375  * a stack slot. Also - one can't assume that gpointer is also the
376  * size of a stack slot - use SIZEOF_REGISTER instead. The following
377  * helper macro tries to keep down the mess of all the pointer
378  * calculations.
379  */
380 #if (G_BYTE_ORDER == G_LITTLE_ENDIAN)
381 #define arg_in_stack_slot(cpos, type) ((type *)(cpos))
382 #else
383 #define arg_in_stack_slot(cpos, type) ((type *)((sizeof(type) < SIZEOF_REGISTER) ? (((gssize)(cpos)) + SIZEOF_REGISTER - sizeof(type)) : (gssize)(cpos)))
384 #endif
385
386 void
387 mono_trace_enter_method (MonoMethod *method, char *ebp)
388 {
389         int i, j;
390         MonoClass *class;
391         MonoObject *o;
392         MonoJitArgumentInfo *arg_info;
393         MonoMethodSignature *sig;
394         char *fname;
395         MonoGenericSharingContext *gsctx = NULL;
396
397         if (!trace_spec.enabled)
398                 return;
399
400         fname = mono_method_full_name (method, TRUE);
401         indent (1);
402         printf ("ENTER: %s(", fname);
403         g_free (fname);
404
405         if (!ebp) {
406                 printf (") ip: %p\n", RETURN_ADDRESS (1));
407                 return;
408         }       
409
410         sig = mono_method_signature (method);
411
412         arg_info = alloca (sizeof (MonoJitArgumentInfo) * (sig->param_count + 1));
413
414         if (method->is_inflated) {
415                 /* FIXME: Might be better to pass the ji itself */
416                 MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), RETURN_ADDRESS (0), NULL);
417                 if (ji) {
418                         gsctx = mono_jit_info_get_generic_sharing_context (ji);
419                         if (gsctx && (gsctx->var_is_vt || gsctx->mvar_is_vt)) {
420                                 /* Needs a ctx to get precise method */
421                                 printf (") <gsharedvt>\n");
422                                 return;
423                         }
424                 }
425         }
426
427         mono_arch_get_argument_info (gsctx, sig, sig->param_count, arg_info);
428
429         if (MONO_TYPE_ISSTRUCT (mono_method_signature (method)->ret)) {
430                 g_assert (!mono_method_signature (method)->ret->byref);
431
432                 printf ("VALUERET:%p, ", *((gpointer *)(ebp + 8)));
433         }
434
435         if (mono_method_signature (method)->hasthis) {
436                 gpointer *this = (gpointer *)(ebp + arg_info [0].offset);
437                 if (method->klass->valuetype) {
438                         printf ("value:%p, ", *arg_in_stack_slot(this, gpointer *));
439                 } else {
440                         o = *arg_in_stack_slot(this, MonoObject *);
441
442                         if (o) {
443                                 class = o->vtable->klass;
444
445                                 if (class == mono_defaults.string_class) {
446                                         MonoString *s = (MonoString*)o;
447                                         char *as = string_to_utf8 (s);
448
449                                         printf ("this:[STRING:%p:%s], ", o, as);
450                                         g_free (as);
451                                 } else {
452                                         printf ("this:%p[%s.%s %s], ", o, class->name_space, class->name, o->vtable->domain->friendly_name);
453                                 }
454                         } else 
455                                 printf ("this:NULL, ");
456                 }
457         }
458
459         for (i = 0; i < mono_method_signature (method)->param_count; ++i) {
460                 gpointer *cpos = (gpointer *)(ebp + arg_info [i + 1].offset);
461                 int size = arg_info [i + 1].size;
462
463                 MonoType *type = mono_method_signature (method)->params [i];
464                 
465                 if (type->byref) {
466                         printf ("[BYREF:%p], ", *arg_in_stack_slot(cpos, gpointer *));
467                 } else switch (mono_type_get_underlying_type (type)->type) {
468                         
469                 case MONO_TYPE_I:
470                 case MONO_TYPE_U:
471                         printf ("%p, ", *arg_in_stack_slot(cpos, gpointer *));
472                         break;
473                 case MONO_TYPE_BOOLEAN:
474                 case MONO_TYPE_CHAR:
475                 case MONO_TYPE_I1:
476                 case MONO_TYPE_U1:
477                         printf ("%d, ", *arg_in_stack_slot(cpos, gint8));
478                         break;
479                 case MONO_TYPE_I2:
480                 case MONO_TYPE_U2:
481                         printf ("%d, ", *arg_in_stack_slot(cpos, gint16));
482                         break;
483                 case MONO_TYPE_I4:
484                 case MONO_TYPE_U4:
485                         printf ("%d, ", *arg_in_stack_slot(cpos, int));
486                         break;
487                 case MONO_TYPE_STRING: {
488                         MonoString *s = *arg_in_stack_slot(cpos, MonoString *);
489                         if (s) {
490                                 char *as;
491
492                                 g_assert (((MonoObject *)s)->vtable->klass == mono_defaults.string_class);
493                                 as = string_to_utf8 (s);
494
495                                 printf ("[STRING:%p:%s], ", s, as);
496                                 g_free (as);
497                         } else 
498                                 printf ("[STRING:null], ");
499                         break;
500                 }
501                 case MONO_TYPE_CLASS:
502                 case MONO_TYPE_OBJECT: {
503                         o = *arg_in_stack_slot(cpos, MonoObject *);
504                         if (o) {
505                                 class = o->vtable->klass;
506                     
507                                 if (class == mono_defaults.string_class) {
508                                         char *as = string_to_utf8 ((MonoString*)o);
509
510                                         printf ("[STRING:%p:%s], ", o, as);
511                                         g_free (as);
512                                 } else if (class == mono_defaults.int32_class) {
513                                         printf ("[INT32:%p:%d], ", o, *(gint32 *)((char *)o + sizeof (MonoObject)));
514                                 } else if (class == mono_defaults.monotype_class) {
515                                         printf ("[TYPE:%s], ", mono_type_full_name (((MonoReflectionType*)o)->type));
516                                 } else
517                                         printf ("[%s.%s:%p], ", class->name_space, class->name, o);
518                         } else {
519                                 printf ("%p, ", *arg_in_stack_slot(cpos, gpointer));
520                         }
521                         break;
522                 }
523                 case MONO_TYPE_PTR:
524                 case MONO_TYPE_FNPTR:
525                 case MONO_TYPE_ARRAY:
526                 case MONO_TYPE_SZARRAY:
527                         printf ("%p, ", *arg_in_stack_slot(cpos, gpointer));
528                         break;
529                 case MONO_TYPE_I8:
530                 case MONO_TYPE_U8:
531                         printf ("0x%016llx, ", (long long)*arg_in_stack_slot(cpos, gint64));
532                         break;
533                 case MONO_TYPE_R4:
534                         printf ("%f, ", *arg_in_stack_slot(cpos, float));
535                         break;
536                 case MONO_TYPE_R8:
537                         printf ("%f, ", *arg_in_stack_slot(cpos, double));
538                         break;
539                 case MONO_TYPE_VALUETYPE: 
540                         printf ("[");
541                         for (j = 0; j < size; j++)
542                                 printf ("%02x,", *((guint8*)cpos +j));
543                         printf ("], ");
544                         break;
545                 default:
546                         printf ("XX, ");
547                 }
548         }
549
550         printf (")\n");
551         fflush (stdout);
552 }
553
554 void
555 mono_trace_leave_method (MonoMethod *method, ...)
556 {
557         MonoType *type;
558         char *fname;
559         va_list ap;
560         MonoGenericSharingContext *gsctx;
561
562         if (!trace_spec.enabled)
563                 return;
564
565         va_start(ap, method);
566
567         fname = mono_method_full_name (method, TRUE);
568         indent (-1);
569         printf ("LEAVE: %s", fname);
570         g_free (fname);
571
572         if (method->is_inflated) {
573                 /* FIXME: Might be better to pass the ji itself */
574                 MonoJitInfo *ji = mini_jit_info_table_find (mono_domain_get (), RETURN_ADDRESS (0), NULL);
575                 if (ji) {
576                         gsctx = mono_jit_info_get_generic_sharing_context (ji);
577                         if (gsctx && (gsctx->var_is_vt || gsctx->mvar_is_vt)) {
578                                 /* Needs a ctx to get precise method */
579                                 printf (") <gsharedvt>\n");
580                                 return;
581                         }
582                 }
583         }
584
585         type = mono_method_signature (method)->ret;
586
587 handle_enum:
588         switch (type->type) {
589         case MONO_TYPE_VOID:
590                 break;
591         case MONO_TYPE_BOOLEAN: {
592                 int eax = va_arg (ap, int);
593                 if (eax)
594                         printf ("TRUE:%d", eax);
595                 else 
596                         printf ("FALSE");
597                         
598                 break;
599         }
600         case MONO_TYPE_CHAR:
601         case MONO_TYPE_I1:
602         case MONO_TYPE_U1:
603         case MONO_TYPE_I2:
604         case MONO_TYPE_U2:
605         case MONO_TYPE_I4:
606         case MONO_TYPE_U4:
607         case MONO_TYPE_I:
608         case MONO_TYPE_U: {
609                 int eax = va_arg (ap, int);
610                 printf ("result=%d", eax);
611                 break;
612         }
613         case MONO_TYPE_STRING: {
614                 MonoString *s = va_arg (ap, MonoString *);
615 ;
616                 if (s) {
617                         char *as;
618
619                         g_assert (((MonoObject *)s)->vtable->klass == mono_defaults.string_class);
620                         as = string_to_utf8 (s);
621                         printf ("[STRING:%p:%s]", s, as);
622                         g_free (as);
623                 } else 
624                         printf ("[STRING:null], ");
625                 break;
626         }
627         case MONO_TYPE_CLASS: 
628         case MONO_TYPE_OBJECT: {
629                 MonoObject *o = va_arg (ap, MonoObject *);
630
631                 if (o) {
632                         if (o->vtable->klass == mono_defaults.boolean_class) {
633                                 printf ("[BOOLEAN:%p:%d]", o, *((guint8 *)o + sizeof (MonoObject)));            
634                         } else if  (o->vtable->klass == mono_defaults.int32_class) {
635                                 printf ("[INT32:%p:%d]", o, *((gint32 *)((char *)o + sizeof (MonoObject))));    
636                         } else if  (o->vtable->klass == mono_defaults.int64_class) {
637                                 printf ("[INT64:%p:%lld]", o, (long long)*((gint64 *)((char *)o + sizeof (MonoObject))));       
638                         } else
639                                 printf ("[%s.%s:%p]", o->vtable->klass->name_space, o->vtable->klass->name, o);
640                 } else
641                         printf ("[OBJECT:%p]", o);
642                
643                 break;
644         }
645         case MONO_TYPE_PTR:
646         case MONO_TYPE_FNPTR:
647         case MONO_TYPE_ARRAY:
648         case MONO_TYPE_SZARRAY: {
649                 gpointer p = va_arg (ap, gpointer);
650                 printf ("result=%p", p);
651                 break;
652         }
653         case MONO_TYPE_I8: {
654                 gint64 l =  va_arg (ap, gint64);
655                 printf ("lresult=0x%16llx", (long long)l);
656                 break;
657         }
658         case MONO_TYPE_U8: {
659                 gint64 l =  va_arg (ap, gint64);
660                 printf ("lresult=0x%16llx", (long long)l);
661                 break;
662         }
663         case MONO_TYPE_R4:
664         case MONO_TYPE_R8: {
665                 double f = va_arg (ap, double);
666                 printf ("FP=%f", f);
667                 break;
668         }
669         case MONO_TYPE_VALUETYPE: 
670                 if (type->data.klass->enumtype) {
671                         type = mono_class_enum_basetype (type->data.klass);
672                         goto handle_enum;
673                 } else {
674                         guint8 *p = va_arg (ap, gpointer);
675                         int j, size, align;
676                         size = mono_type_size (type, &align);
677                         printf ("[");
678                         for (j = 0; p && j < size; j++)
679                                 printf ("%02x,", p [j]);
680                         printf ("]");
681                 }
682                 break;
683         default:
684                 printf ("(unknown return type %x)", mono_method_signature (method)->ret->type);
685         }
686
687         //printf (" ip: %p\n", RETURN_ADDRESS (1));
688         printf ("\n");
689         fflush (stdout);
690 }
691
692 void
693 mono_trace_enable (gboolean enable)
694 {
695         trace_spec.enabled = enable;
696 }
697
698 gboolean
699 mono_trace_is_enabled ()
700 {
701         return trace_spec.enabled;
702 }