[profiler] log profiler: limit method instrumentation to selected methods (#5517)
authorUri Simchoni <urisimchoni@users.noreply.github.com>
Mon, 2 Oct 2017 14:29:49 +0000 (17:29 +0300)
committerZoltan Varga <vargaz@gmail.com>
Mon, 2 Oct 2017 14:29:49 +0000 (16:29 +0200)
commitbfc76bafbf72f8e10c4d2cc7b12e779715c527fa
tree6f45a10c8b5fb003d287bc71a3545286f288ede2
parent30cddad5fb4c3d290906a6e6c33ecd8b07d8b48c
[profiler] log profiler: limit method instrumentation to selected methods (#5517)

* [trace] remove code that has no effect

* [trace] move program assembly out of MonoTraceSpec

The assembly member represents the program assembly. It's
information the trace spec is matched against, not part of
the trace spec per-se (if two trace specs exist for two purposes
we would still have one program assembly)

* [trace] remove side effects from get_string()

On the way towards supporting multiple trace specs,
remove side effects from get_string() function.

* [trace] remove side effects from get_token()

Remove side effects from get_token() to allow handling
multiple trace specs.

* [trace] fix handling of double exclusion and disabled

When encountering "disabled", do not add an entry to
the trace spec

Fix error handling around double "-" - get_spec()
never returns TOKEN_EXCLUDE and the recursion can
be easily avoided.

* [trace] remove side effects from get_spec()

Another step in making the trace options reusable.

* [trace] rename mono_trace_parse_options() to mono_trace_set_options()

This routine actually sets the tracing options, not just parses an
option string, so set_ is more suitable. This frees up the
mono_trace_parse_options() name for pure parsing, when we later
reuse the parsing code.

* [trace] make tracing options API reusable

Add APIs that parse tracing options and evaluate a method
against the parsed options. The tracing functionality now uses
this API, but other components can use this to apply an operation
to a method based on policy (e.g. profiling)

* [trace] rename MonoTraceSpec to MonoCallSpec

In preparation for reusing call specification beyond the
tracer, rename the data structure - it now only specifies
a set of calls, without indication what should be done with
them.

* [trace] rename mono_trace_set_assembly to mono_callspec_set_assembly

As it becoming a reuse candidate, we remove the "trace" component
from the name.

* [trace-metadata] move callspec code into its own module

Introduce callspec.c/h which encapsulate the call specification
functionality.

* [profiler] add "callspec" option to log profiler

The callspec option define which methods get instrumented
at JIT time with entry/exit calls to the profiler. The
syntax is same as the tracer (--trace=) syntax. To
distinguish between profiler options and callspec, wrap the
callspec with double quotes, as in:
--profile=log:callspec="all-mscorlib",calls

Since this typically runs from a shell, the double quotes have to be
escaped or wrapped in single quotes, as in:
mono '--profile=log:callspec="all-mscorlib",calls' prog.exe

* [metadata] add an error return string to callspec parsing

Instead of printing parsing error messages to standard error,
return an error string. That allows the client to do the right thing
with the error.
12 files changed:
mono/metadata/Makefile.am
mono/metadata/callspec.c [new file with mode: 0644]
mono/metadata/callspec.h [new file with mode: 0644]
mono/mini/driver.c
mono/mini/mini.c
mono/mini/mini.h
mono/mini/trace.c
mono/mini/trace.h
mono/profiler/log-args.c
mono/profiler/log.c
mono/profiler/log.h
msvc/libmonoruntime.vcxproj