Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use managed Monitor class instead of gmutex; make things work with 2.…

…6 and trunk.

2010-07-15  Martin Baulig  <martin@ximian.com>

	* configure.in: Support both 2.6 and trunk.

	* backend/EventQueue.cs: Use the managed Monitor class instead of
	glib's threading functions.

	* backend/server/mutex.[ch]: Removed.

svn path=/trunk/debugger/; revision=160444
  • Loading branch information...
commit f619370f2be6afc6a03e4fdb13a97b88c39dc06f 1 parent 333a6eb
Martin Baulig authored
View
9 ChangeLog
@@ -1,3 +1,12 @@
+2010-07-15 Martin Baulig <martin@ximian.com>
+
+ * configure.in: Support both 2.6 and trunk.
+
+ * backend/EventQueue.cs: Use the managed Monitor class instead of
+ glib's threading functions.
+
+ * backend/server/mutex.[ch]: Removed.
+
2010-03-03 Miguel de Icaza <miguel@novell.com>
* Apply patch from Priit Laes <plaes@plaes.org> to build with make -j
View
64 backend/EventQueue.cs
@@ -75,47 +75,28 @@ public void Dispose ()
internal class DebuggerMutex : DebuggerWaitHandle
{
- protected IntPtr handle;
-
- [DllImport("monodebuggerserver")]
- static extern IntPtr mono_debugger_mutex_new ();
-
- [DllImport("monodebuggerserver")]
- static extern void mono_debugger_mutex_free (IntPtr handle);
-
- [DllImport("monodebuggerserver")]
- static extern void mono_debugger_mutex_lock (IntPtr handle);
-
- [DllImport("monodebuggerserver")]
- static extern void mono_debugger_mutex_unlock (IntPtr handle);
-
- [DllImport("monodebuggerserver")]
- static extern bool mono_debugger_mutex_trylock (IntPtr handle);
-
public DebuggerMutex (string name)
: base (name)
- {
- handle = mono_debugger_mutex_new ();
- }
+ { }
public void Lock ()
{
Debug ("{0} locking {1}", CurrentThread, Name);
- mono_debugger_mutex_lock (handle);
+ Monitor.Enter (this);
Debug ("{0} locked {1}", CurrentThread, Name);
}
public void Unlock ()
{
Debug ("{0} unlocking {1}", CurrentThread, Name);
- mono_debugger_mutex_unlock (handle);
+ Monitor.Exit (this);
Debug ("{0} unlocked {1}", CurrentThread, Name);
}
public override bool TryLock ()
{
Debug ("{0} trying to lock {1}", CurrentThread, Name);
- bool success = mono_debugger_mutex_trylock (handle);
+ bool success = Monitor.TryEnter (this);
if (success)
Debug ("{0} locked {1}", CurrentThread, Name);
else
@@ -124,47 +105,25 @@ public override bool TryLock ()
}
protected override void DoDispose ()
- {
- mono_debugger_mutex_free (handle);
- handle = IntPtr.Zero;
- }
+ { }
}
internal class DebuggerEventQueue : DebuggerMutex
{
- IntPtr cond;
-
- [DllImport("monodebuggerserver")]
- static extern IntPtr mono_debugger_cond_new ();
-
- [DllImport("monodebuggerserver")]
- static extern void mono_debugger_cond_free (IntPtr handle);
-
- [DllImport("monodebuggerserver")]
- static extern void mono_debugger_cond_wait (IntPtr mutex, IntPtr cond);
-
- [DllImport ("monodebuggerserver")]
- static extern bool mono_debugger_cond_timed_wait (IntPtr mutex, IntPtr cond, int milliseconds);
-
- [DllImport("monodebuggerserver")]
- static extern void mono_debugger_cond_broadcast (IntPtr cond);
-
public DebuggerEventQueue (string name)
: base (name)
- {
- cond = mono_debugger_cond_new ();
- }
+ { }
public void Wait ()
{
Debug ("{0} waiting {1}", CurrentThread, Name);
- mono_debugger_cond_wait (handle, cond);
+ Monitor.Wait (this);
Debug ("{0} done waiting {1}", CurrentThread, Name);
}
public bool Wait (int milliseconds) {
Debug ("{0} waiting {1}", CurrentThread, Name);
- bool ret = mono_debugger_cond_timed_wait (handle, cond, milliseconds);
+ bool ret = Monitor.Wait (this, milliseconds);
Debug ("{0} done waiting {1}", CurrentThread, Name);
return ret;
}
@@ -172,13 +131,10 @@ public void Wait ()
public void Signal ()
{
Debug ("{0} signal {1}", CurrentThread, Name);
- mono_debugger_cond_broadcast (cond);
+ Monitor.Pulse (this);
}
protected override void DoDispose ()
- {
- mono_debugger_cond_free (cond);
- cond = IntPtr.Zero;
- }
+ { }
}
}
View
16 backend/ThreadManager.cs
@@ -36,9 +36,6 @@ internal ThreadManager (DebuggerServant backend)
address_domain = AddressDomain.Global;
- command_mutex = new DebuggerMutex ("command_mutex");
- command_mutex.DebugFlags = DebugFlags.Wait;
-
wait_event = new ST.AutoResetEvent (false);
engine_event = new ST.ManualResetEvent (true);
ready_event = new ST.ManualResetEvent (false);
@@ -76,7 +73,6 @@ internal ThreadManager (DebuggerServant backend)
DateTime last_pending_sigstop;
Dictionary<int,DateTime> pending_sigstops;
- DebuggerMutex command_mutex;
bool abort_requested;
bool waiting;
@@ -100,6 +96,8 @@ void start_inferior ()
while (!abort_requested) {
engine_thread_main ();
}
+
+ Report.Debug (DebugFlags.Threads, "Engine thread exiting.");
}
// <remarks>
@@ -474,12 +472,17 @@ bool wait_thread_main ()
//
do {
+ Report.Debug (DebugFlags.Wait,
+ "Wait thread reaping children");
pid = mono_debugger_server_global_wait (out status);
Report.Debug (DebugFlags.Wait,
"Wait thread received event: {0} {1:x}",
pid, status);
} while (pid > 0);
+ Report.Debug (DebugFlags.Wait,
+ "Wait thread done");
+
return false;
}
@@ -661,7 +664,10 @@ protected virtual void Dispose (bool disposing)
#if FIXME
RequestWait ();
#endif
- event_queue.Signal();
+ if (event_queue.TryLock ()) {
+ event_queue.Signal();
+ event_queue.Unlock ();
+ }
disposed = true;
}
View
2  backend/server/Makefile.am
@@ -41,8 +41,6 @@ libmonodebuggerserver_la_SOURCES = \
$(platform_sources) \
breakpoints.c \
breakpoints.h \
- mutex.c \
- mutex.h \
libgtop-glue.c \
libgtop-glue.h \
linux-proc-service.h
View
4 backend/server/darwin-ptrace.c
@@ -784,7 +784,11 @@ server_ptrace_get_signal_info (ServerHandle *handle, SignalInfo **sinfo_out)
* user-visible real-time signal. __SIGRTMIN and __SIGRTMIN+1 are used
* internally by glibc. */
sinfo->kernel_sigrtmin = SIGUSR1;
+#ifdef USING_MONO_FROM_TRUNK
+ sinfo->mono_thread_abort = mono_debugger_get_thread_abort_signal ();
+#else
sinfo->mono_thread_abort = mono_thread_get_abort_signal ();
+#endif
*sinfo_out = sinfo;
View
65 backend/server/mutex.c
@@ -1,65 +0,0 @@
-#include <server.h>
-#include <mutex.h>
-
-GMutex *
-mono_debugger_mutex_new (void)
-{
- return g_mutex_new ();
-}
-
-void
-mono_debugger_mutex_free (GMutex *mutex)
-{
- g_mutex_free (mutex);
-}
-
-void
-mono_debugger_mutex_lock (GMutex *mutex)
-{
- g_mutex_lock (mutex);
-}
-
-void
-mono_debugger_mutex_unlock (GMutex *mutex)
-{
- g_mutex_unlock (mutex);
-}
-
-gboolean
-mono_debugger_mutex_trylock (GMutex *mutex)
-{
- return g_mutex_trylock (mutex);
-}
-
-GCond *
-mono_debugger_cond_new (void)
-{
- return g_cond_new ();
-}
-
-void
-mono_debugger_cond_free (GCond *cond)
-{
- g_cond_free (cond);
-}
-
-void
-mono_debugger_cond_wait (GMutex *mutex, GCond *cond)
-{
- g_cond_wait (cond, mutex);
-}
-
-gboolean
-mono_debugger_cond_timed_wait (GMutex *mutex, GCond *cond, int milliseconds)
-{
- GTimeVal time_val;
- g_get_current_time (&time_val);
- g_time_val_add (&time_val, milliseconds);
- return g_cond_timed_wait (cond, mutex, &time_val);
-}
-
-void
-mono_debugger_cond_broadcast (GCond *cond)
-{
- g_cond_broadcast (cond);
-}
View
38 backend/server/mutex.h
@@ -1,38 +0,0 @@
-#ifndef __MONO_DEBUGGER_MUTEX_H__
-#define __MONO_DEBUGGER_MUTEX_H__
-
-#include <glib.h>
-#include <glib/gthread.h>
-
-G_BEGIN_DECLS
-
-GMutex *
-mono_debugger_mutex_new (void);
-
-void
-mono_debugger_mutex_free (GMutex *mutex);
-
-void
-mono_debugger_mutex_lock (GMutex *mutex);
-
-void
-mono_debugger_mutex_unlock (GMutex *mutex);
-
-gboolean
-mono_debugger_mutex_trylock (GMutex *mutex);
-
-GCond *
-mono_debugger_cond_new (void);
-
-void
-mono_debugger_cond_free (GCond *cond);
-
-void
-mono_debugger_cond_wait (GMutex *mutex, GCond *cond);
-
-void
-mono_debugger_cond_broadcast (GCond *cond);
-
-G_END_DECLS
-
-#endif
View
4 backend/server/x86-linux-ptrace.c
@@ -546,7 +546,11 @@ server_ptrace_get_signal_info (ServerHandle *handle, SignalInfo **sinfo_out)
* user-visible real-time signal. __SIGRTMIN and __SIGRTMIN+1 are used
* internally by glibc. */
sinfo->kernel_sigrtmin = __SIGRTMIN;
+#ifdef USING_MONO_FROM_TRUNK
+ sinfo->mono_thread_abort = mono_debugger_get_thread_abort_signal ();
+#else
sinfo->mono_thread_abort = mono_thread_get_abort_signal ();
+#endif
*sinfo_out = sinfo;
View
20 configure.in
@@ -145,8 +145,20 @@ PKG_CHECK_MODULES(BASE_DEPENDENCIES, glib-2.0 >= $GLIB_REQUIRED_VERSION)
AC_SUBST(BASE_DEPENDENCIES_CFLAGS)
AC_SUBST(BASE_DEPENDENCIES_LIBS)
+AC_MSG_CHECKING([Whether we're using Mono from trunk])
+## Check for Mono from trunk
+if pkg-config --modversion mono-2>/dev/null; then
+ have_mono_trunk=true
+ mono_pc=mono-2
+ AC_MSG_RESULT([yes])
+else
+ have_mono_trunk=false
+ mono_pc=mono
+ AC_MSG_RESULT([no])
+fi
+
## Versions of dependencies
-PKG_CHECK_MODULES(SERVER_DEPENDENCIES, mono >= $MONO_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION $martin_deps)
+PKG_CHECK_MODULES(SERVER_DEPENDENCIES, $mono_pc >= $MONO_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION $martin_deps)
AC_SUBST(SERVER_DEPENDENCIES_CFLAGS)
AC_SUBST(SERVER_DEPENDENCIES_LIBS)
@@ -160,7 +172,7 @@ fi
CECIL_ASM=`pkg-config --variable=Libraries cecil`
AC_SUBST(CECIL_ASM)
-PKG_CHECK_MODULES(WRAPPER, mono >= $MONO_REQUIRED_VERSION gthread-2.0 >= $GLIB_REQUIRED_VERSION)
+PKG_CHECK_MODULES(WRAPPER, $mono_pc >= $MONO_REQUIRED_VERSION glib-2.0 >= $GLIB_REQUIRED_VERSION)
AC_SUBST(WRAPPER_CFLAGS)
AC_SUBST(WRAPPER_LIBS)
@@ -348,6 +360,10 @@ AM_CONDITIONAL(MARTIN_PRIVATE, test x$martin_private = xyes)
AM_CONDITIONAL(DISABLED, false)
+if test x$have_mono_trunk = xtrue; then
+ AC_DEFINE([USING_MONO_FROM_TRUNK], [1], [Whether we're using Mono from trunk])
+fi
+
AC_OUTPUT([
Makefile
mono-debugger.pc
Please sign in to comment.
Something went wrong with that request. Please try again.