Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUri Simchoni <uri@vfunction.com>2017-08-06 13:20:01 +0300
committerUri Simchoni <uri@vfunction.com>2017-08-07 06:33:01 +0300
commite3a57ead2e604b5da43e0e4238194f6e99abf8e2 (patch)
treee09dd11411145480cd2a974874316da93cdd73f2 /samples
parent6e23736a07359bf87f2ba57eef982bb48b046905 (diff)
[profiler] fixes to profiler sample
- Fix the Linux build instructions. - Remove eglib dependencies, as they complicate the build of an extenral module. - Make instance static instead of heap-allocated. - Make the call counter 64 bits. - Adjustments to accommodate the new profiling API.
Diffstat (limited to 'samples')
-rw-r--r--samples/profiler/sample.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/samples/profiler/sample.c b/samples/profiler/sample.c
index a2953eacbc5..a5ee4435ea6 100644
--- a/samples/profiler/sample.c
+++ b/samples/profiler/sample.c
@@ -3,10 +3,13 @@
/*
* Bare bones profiler. Compile with:
*
- * linux : gcc -shared -o mono-profiler-sample.so sample.c `pkg-config --cflags --libs mono`
+ * linux : gcc -fPIC -shared -o libmono-profiler-sample.so sample.c `pkg-config --cflags --libs mono-2`
* mac : gcc sample.c -o mono-profiler-sample.dylib -Dmono_free=free -lz `pkg-config --cflags mono-2` -undefined suppress -flat_namespace
+ * linux with a custom prefix (e.g. --prefix=/opt/my-mono-build):
+ * gcc -fPIC -shared -o libmono-profiler-sample.so sample.c `PKG_CONFIG_PATH=/opt/my-mono-build/lib/pkgconfig/ pkg-config --cflags --libs mono-2`
*
- * Install the binary where the dynamic loader can find it. eg /usr/lib etc
+ * Install the binary where the dynamic loader can find it. eg /usr/lib etc.
+ * For a custom prefix build, <prefix>/lib would also work.
* Then run mono with:
* mono --profile=sample your_application.exe
*
@@ -14,24 +17,26 @@
*/
struct _MonoProfiler {
- int ncalls;
+ unsigned long long ncalls;
};
+static MonoProfiler prof_instance;
+
/* called at the end of the program */
static void
sample_shutdown (MonoProfiler *prof)
{
- g_print ("total number of calls: %d\n", prof->ncalls);
+ printf("total number of calls: %llu\n", prof->ncalls);
}
static void
-sample_method_enter (MonoProfiler *prof, MonoMethod *method)
+sample_method_enter (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx)
{
prof->ncalls++;
}
static void
-sample_method_leave (MonoProfiler *prof, MonoMethod *method)
+sample_method_leave (MonoProfiler *prof, MonoMethod *method, MonoProfilerCallContext *ctx)
{
}
@@ -45,12 +50,10 @@ sample_instrumentation_filter (MonoProfiler *prof, MonoMethod *method)
void
mono_profiler_init_sample (const char *desc)
{
- MonoProfiler *prof;
-
- prof = g_new0 (MonoProfiler, 1);
+ MonoProfiler *prof = &prof_instance;
MonoProfilerHandle handle = mono_profiler_create (prof);
- mono_profiler_set_runtime_shutdown_callback (handle, sample_shutdown);
+ mono_profiler_set_runtime_shutdown_end_callback (handle, sample_shutdown);
mono_profiler_set_call_instrumentation_filter_callback (handle, sample_instrumentation_filter);
mono_profiler_set_method_enter_callback (handle, sample_method_enter);
mono_profiler_set_method_leave_callback (handle, sample_method_leave);