[profiler] log profiler: limit method instrumentation to selected methods (#5517)
[mono.git] / mono / profiler / log-args.c
index c0c756070819d1ec727d64a1ffb6c02171aefed1..b20444f31db4fc324d731d8c6a3d15301627bca8 100644 (file)
@@ -20,7 +20,7 @@ static NameAndMask event_list[] = {
        { "gcmove", PROFLOG_GC_MOVE_EVENTS },
        { "gcroot", PROFLOG_GC_ROOT_EVENTS },
        { "gchandle", PROFLOG_GC_HANDLE_EVENTS },
-       { "finalization", PROFLOG_FINALIZATION_EVENTS },
+       { "finalization", PROFLOG_GC_FINALIZATION_EVENTS },
        { "counter", PROFLOG_COUNTER_EVENTS },
        { "jit", PROFLOG_JIT_EVENTS },
 
@@ -67,6 +67,9 @@ parse_arg (const char *arg, ProfilerConfig *config)
                set_hsmode (config, val);
                if (config->hs_mode != MONO_PROFILER_HEAPSHOT_NONE)
                        config->enable_mask |= PROFLOG_HEAPSHOT_ALIAS;
+       } else if (match_option (arg, "heapshot-on-shutdown", NULL)) {
+               config->hs_on_shutdown = TRUE;
+               config->enable_mask |= PROFLOG_HEAPSHOT_ALIAS;
        } else if (match_option (arg, "sample", &val)) {
                set_sample_freq (config, val);
                config->sampling_mode = MONO_PROFILER_SAMPLE_MODE_PROCESS;
@@ -78,6 +81,7 @@ parse_arg (const char *arg, ProfilerConfig *config)
        } else if (match_option (arg, "calls", NULL)) {
                config->enter_leave = TRUE;
        } else if (match_option (arg, "coverage", NULL)) {
+               g_warning ("the log profiler support for code coverage is obsolete, use the \"coverage\" profiler");
                config->collect_coverage = TRUE;
        } else if (match_option (arg, "zip", NULL)) {
                config->use_zip = TRUE;
@@ -100,6 +104,24 @@ parse_arg (const char *arg, ProfilerConfig *config)
        } else if (match_option (arg, "calldepth", &val)) {
                char *end;
                config->max_call_depth = strtoul (val, &end, 10);
+       } else if (match_option (arg, "callspec", &val)) {
+               if (!val)
+                       val = "";
+               if (val[0] == '\"')
+                       ++val;
+               char *spec = g_strdup (val);
+               size_t speclen = strlen (val);
+               if (speclen > 0 && spec[speclen - 1] == '\"')
+                       spec[speclen - 1] = '\0';
+               char *errstr;
+               if (!mono_callspec_parse (spec, &config->callspec, &errstr)) {
+                       mono_profiler_printf_err (
+                           "Could not parse callspec: '%s': %s", spec,
+                           errstr);
+                       g_free (errstr);
+                       mono_callspec_cleanup (&config->callspec);
+               }
+               g_free (spec);
        } else if (match_option (arg, "covfilter-file", &val)) {
                if (config->cov_filter_files == NULL)
                        config->cov_filter_files = g_ptr_array_new ();
@@ -259,12 +281,14 @@ usage (void)
                mono_profiler_printf ("\t                         %s", event_list [i].event_name);
 
        mono_profiler_printf ("\t[no]alloc            enable/disable recording allocation info");
-       mono_profiler_printf ("\t[no]legacy           enable/disable pre mono 5.4 default profiler events");
+       mono_profiler_printf ("\t[no]legacy           enable/disable pre Mono 5.6 default profiler events");
        mono_profiler_printf ("\tsample[-real][=FREQ] enable/disable statistical sampling of threads");
        mono_profiler_printf ("\t                     FREQ in Hz, 100 by default");
        mono_profiler_printf ("\t                     the -real variant uses wall clock time instead of process time");
        mono_profiler_printf ("\theapshot[=MODE]      record heapshot info (by default at each major collection)");
        mono_profiler_printf ("\t                     MODE: every XXms milliseconds, every YYgc collections, ondemand");
+       mono_profiler_printf ("\theapshot-on-shutdown do a heapshot on runtime shutdown");
+       mono_profiler_printf ("\t                     this option is independent of the above option");
        mono_profiler_printf ("\tcalls                enable recording enter/leave method events (very heavy)");
        mono_profiler_printf ("\tcoverage             enable collection of code coverage data");
        mono_profiler_printf ("\tcovfilter=ASSEMBLY   add ASSEMBLY to the code coverage filters");