[Mono-bugs] [Bug 80672][Nor] New - Implement statistical profiling on Win32

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Tue Jan 30 11:40:54 EST 2007


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by tml at novell.com.

http://bugzilla.ximian.com/show_bug.cgi?id=80672

--- shadow/80672	2007-01-30 11:40:54.000000000 -0500
+++ shadow/80672.tmp.13328	2007-01-30 11:40:54.000000000 -0500
@@ -0,0 +1,128 @@
+Bug#: 80672
+Product: Mono: Runtime
+Version: 1.2
+OS: 
+OS Details: 
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Normal
+Component: misc
+AssignedTo: mono-bugs at ximian.com                            
+ReportedBy: tml at novell.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: Implement statistical profiling on Win32
+
+A first try, seems to work on XP at least. Will not work on Win9x, but do
+we care?
+
+Index: mono/mini/mini.c
+===================================================================
+--- mono/mini/mini.c	(revision 71775)
++++ mono/mini/mini.c	(working copy)
+@@ -22,6 +22,10 @@
+ #include <pthread.h>
+ #endif
+ 
++#ifdef PLATFORM_WIN32
++#define _WIN32_WINNT 0x0500
++#endif
++
+ #ifdef HAVE_VALGRIND_MEMCHECK_H
+ #include <valgrind/memcheck.h>
+ #endif
+@@ -11111,6 +11115,8 @@
+ 	mono_arch_handle_exception (ctx, exc, FALSE);
+ }
+ 
++#ifndef PLATFORM_WIN32
++
+ static void
+ SIG_HANDLER_SIGNATURE (sigabrt_signal_handler)
+ {
+@@ -11181,6 +11187,16 @@
+ }
+ 
+ static void
++SIG_HANDLER_SIGNATURE (sigusr2_signal_handler)
++{
++	gboolean enabled = mono_trace_is_enabled ();
++
++	mono_trace_enable (!enabled);
++}
++
++#endif
++
++static void
+ SIG_HANDLER_SIGNATURE (sigint_signal_handler)
+ {
+ 	MonoException *exc;
+@@ -11191,14 +11207,6 @@
+ 	mono_arch_handle_exception (ctx, exc, FALSE);
+ }
+ 
+-static void
+-SIG_HANDLER_SIGNATURE (sigusr2_signal_handler)
+-{
+-	gboolean enabled = mono_trace_is_enabled ();
+-
+-	mono_trace_enable (!enabled);
+-}
+-
+ #ifdef PLATFORM_MACOSX
+ 
+ /*
+@@ -11452,6 +11460,21 @@
+ }
+ #endif
+ 
++#ifdef PLATFORM_WIN32
++static HANDLE win32_main_thread;
++static MMRESULT win32_timer;
++
++static void CALLBACK
++win32_time_proc (UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
++{
++	CONTEXT context;
++
++	context.ContextFlags = CONTEXT_CONTROL;
++	if (GetThreadContext (win32_main_thread, &context))
++		mono_profiler_stat_hit ((guchar *) context.Eip, &context);
++}
++#endif
++
+ static void
+ setup_stat_profiler (void)
+ {
+@@ -11504,6 +11527,27 @@
+ 		return;
+ 	inited = 1;
+ 	add_signal_handler (SIGPROF, sigprof_signal_handler);
++#elif defined (PLATFORM_WIN32)
++	static int inited = 0;
++	TIMECAPS timecaps;
++
++	if (inited)
++		return;
++
++	inited = 1;
++	if (timeGetDevCaps (&timecaps, sizeof (timecaps)) != TIMERR_NOERROR)
++		return;
++
++	if ((win32_main_thread = OpenThread (READ_CONTROL | THREAD_GET_CONTEXT,
+FALSE, GetCurrentThreadId ())) == NULL)
++		return;
++
++	if (timeBeginPeriod (1) != TIMERR_NOERROR)
++		return;
++
++	if ((win32_timer = timeSetEvent (1, 0, win32_time_proc, 0,
+TIME_PERIODIC)) == 0) {
++		timeEndPeriod (1);
++		return;
++	}
+ #endif
+ }


More information about the mono-bugs mailing list