[profiler] log profiler: limit method instrumentation to selected methods (#5517)
[mono.git] / mono / profiler / log-args.c
index 3cfadd1e5138ba73a8edc41cd0d618dceb975a53..b20444f31db4fc324d731d8c6a3d15301627bca8 100644 (file)
@@ -104,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 ();