grammar updates
[mono.git] / mono / mini / driver.c
index a2eea0f6ccba17a41ac6e164cdea5e7f1b9aadf5..ab4038f2dd5f1b91f4cfd9f83f4b7a965120509e 100644 (file)
@@ -510,7 +510,7 @@ mini_usage (void)
                "    --ncompile N           Number of times to compile METHOD (default: 1)\n"
                "    --regression           Runs the regression test contained in the assembly\n"
                "    --print-vtable         Print the vtable of all used classes\n"
-               "    --trace                Enable tracing\n"
+               "    --trace[=EXPR]         Enable tracing, use --help-trace for details\n"
                "    --compile-all          Compiles all the methods in the assembly\n"
                "    --breakonex            Inserts a breakpoint on exceptions\n"
                "    --break METHOD         Inserts a breakpoint at METHOD entry\n"
@@ -540,8 +540,28 @@ mini_usage (void)
                fprintf (stderr, "                           %-10s %s\n", opt_names [i].name, opt_names [i].desc);
 }
 
+static void
+mini_trace_usage (void)
+{
+       fprintf (stderr,
+                "Tracing options:\n"
+                "   --trace[=EXPR]        Trace every call, optional EXPR controls the scope\n"
+                "\n"
+                "EXPR is composed of:\n"
+                "    all                  All assemblies\n"
+                "    none                 No assemblies\n"
+                "    program              Entry point assembly\n"
+                "    assembly             Specifies an assembly\n"
+                "    M:Type:Method        Specifies a method\n"
+                "    N:Namespace          Specifies a namespace\n"
+                "    T:Type               Specifies a type\n"
+                "    +EXPR                Includes expression\n"
+                "    -EXPR                Excludes expression\n");
+}
+
 int
-mono_main (int argc, char* argv[]) {
+mono_main (int argc, char* argv[])
+{
        MainThreadArgs main_args;
        MonoAssembly *assembly;
        MonoMethodDesc *desc;
@@ -555,6 +575,7 @@ mono_main (int argc, char* argv[]) {
        guint32 opt, action = DO_EXEC;
        MonoGraphOptions mono_graph_options = 0;
        int mini_verbose = 0;
+       char *trace_options = NULL;
 
        setlocale (LC_ALL, "");
        g_log_set_always_fatal (G_LOG_LEVEL_ERROR);
@@ -575,6 +596,9 @@ mono_main (int argc, char* argv[]) {
                } else if (strcmp (argv [i], "--help") == 0 || strcmp (argv [i], "-h") == 0) {
                        mini_usage ();
                        return 0;
+               } else if (strcmp (argv [i], "--help-trace") == 0){
+                       mini_trace_usage ();
+                       return 0;
                } else if (strncmp (argv [i], "--statfile", 10) == 0) {
                        mini_stats_fd = fopen (argv [++i], "w+");
                } else if (strncmp (argv [i], "--optimize=", 11) == 0) {
@@ -587,7 +611,9 @@ mono_main (int argc, char* argv[]) {
                        count = atoi (argv [++i]);
                        action = DO_BENCH;
                } else if (strcmp (argv [i], "--trace") == 0) {
-                       mono_jit_trace_calls = TRUE;
+                       trace_options = "";
+               } else if (strncmp (argv [i], "--trace=", 8) == 0) {
+                       trace_options = &argv [i][8];
                } else if (strcmp (argv [i], "--breakonex") == 0) {
                        mono_break_on_exc = TRUE;
                } else if (strcmp (argv [i], "--break") == 0) {
@@ -635,7 +661,7 @@ mono_main (int argc, char* argv[]) {
 
        mono_set_defaults (mini_verbose, opt);
        domain = mini_init (argv [i]);
-
+       
        switch (action) {
        case DO_REGRESSION:
                if (mini_regression_list (mini_verbose, argc -i, argv + i)) {
@@ -689,6 +715,12 @@ mono_main (int argc, char* argv[]) {
                return 2;
        }
 
+       if (trace_options != NULL){
+               mono_jit_trace_calls = mono_trace_parse_options (assembly, trace_options);
+               if (mono_jit_trace_calls == NULL)
+                       exit (1);
+       }
+
        if (enable_debugging)
                mono_debug_init_2 (assembly);
 
@@ -797,6 +829,10 @@ mono_main (int argc, char* argv[]) {
                        fprintf (mini_stats_fd, ");\n");
                } else {
                        for (i = 0; i < count; ++i) {
+                               if ((method->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
+                                       (method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
+                                       method = mono_marshal_get_native_wrapper (method);
+
                                cfg = mini_method_compile (method, opt, mono_root_domain, 0);
                                mono_destroy_compile (cfg);
                        }