Permalink
Browse files

Use 'Console.CancelKeyPress' instead of unmanaged semaphores.

  • Loading branch information...
1 parent 757dc9c commit a5088ebf3e2dfc8fb1d02dd9ea4a2b4d7a774101 Martin Baulig committed Jul 31, 2010
@@ -83,9 +83,6 @@ internal ThreadManager (DebuggerServant backend)
static extern int mono_debugger_server_global_wait (out int status);
[DllImport("monodebuggerserver")]
- static extern int mono_debugger_server_get_pending_sigint ();
-
- [DllImport("monodebuggerserver")]
static extern Inferior.ChildEventType mono_debugger_server_dispatch_simple (int status, out int arg);
void start_inferior ()
@@ -1086,35 +1086,6 @@ server_ptrace_kill (ServerHandle *handle)
return COMMAND_ERROR_NONE;
}
-static sem_t *manager_semaphore;
-
-static void
-server_ptrace_sem_init (void)
-{
- manager_semaphore = sem_open ("mdb", O_CREAT, 0666, 1);
-}
-
-static void
-server_ptrace_sem_wait (void)
-{
- sem_wait (manager_semaphore);
-}
-
-static void
-server_ptrace_sem_post (void)
-{
- sem_post (manager_semaphore);
-}
-
-static int
-server_ptrace_sem_get_value (void)
-{
- int ret;
-
- sem_getvalue (manager_semaphore, &ret);
- return ret;
-}
-
static ServerType
server_ptrace_get_server_type (void)
{
@@ -522,33 +522,3 @@ mono_debugger_server_static_init (void)
{
(* global_vtable->static_init) ();
}
-
-int
-mono_debugger_server_get_pending_sigint (void)
-{
- return (* global_vtable->get_pending_sigint) ();
-}
-
-void
-mono_debugger_server_sem_init (void)
-{
- (* global_vtable->sem_init) ();
-}
-
-void
-mono_debugger_server_sem_wait (void)
-{
- (* global_vtable->sem_wait) ();
-}
-
-void
-mono_debugger_server_sem_post (void)
-{
- (* global_vtable->sem_post) ();
-}
-
-int
-mono_debugger_server_sem_get_value (void)
-{
- return (* global_vtable->sem_get_value) ();
-}
@@ -13,7 +13,6 @@ mono_debugger_mutex_unlock
mono_debugger_mutex_trylock
mono_debugger_server_static_init
-mono_debugger_server_get_pending_sigint
mono_debugger_server_global_init
mono_debugger_server_create_inferior
mono_debugger_server_spawn
@@ -23,11 +22,6 @@ mono_debugger_server_get_current_pid
mono_debugger_server_get_current_thread
mono_debugger_server_get_signal_info
-mono_debugger_server_sem_init
-mono_debugger_server_sem_wait
-mono_debugger_server_sem_post
-mono_debugger_server_sem_get_value
-
mono_debugger_server_get_target_info
mono_debugger_server_dispatch_event
mono_debugger_server_get_application
@@ -47,4 +41,4 @@ mono_debugger_breakpoint_manager_lookup_by_id
mono_debugger_breakpoint_manager_get_breakpoints
mono_debugger_breakpoint_manager_remove
mono_debugger_breakpoint_info_get_id
-mono_debugger_breakpoint_info_get_is_enabled
+mono_debugger_breakpoint_info_get_is_enabled
@@ -446,16 +446,6 @@ struct InferiorVTable {
guint32 (*get_current_pid) (void);
guint64 (*get_current_thread) (void);
-
- void (*sem_init) (void);
-
- void (*sem_wait) (void);
-
- void (*sem_post) (void);
-
- int (*sem_get_value) (void);
-
- int (*get_pending_sigint) (void);
};
/*
@@ -738,16 +728,6 @@ mono_debugger_server_get_current_pid (void);
guint64
mono_debugger_server_get_current_thread (void);
-
-/* POSIX semaphores */
-
-void mono_debugger_server_sem_init (void);
-void mono_debugger_server_sem_wait (void);
-void mono_debugger_server_sem_post (void);
-int mono_debugger_server_sem_get_value (void);
-
-int mono_debugger_server_get_pending_sigint (void);
-
G_END_DECLS
#endif
@@ -1,32 +1,3 @@
-static sem_t manager_semaphore;
-
-static void
-server_ptrace_sem_init (void)
-{
- sem_init (&manager_semaphore, 1, 0);
-}
-
-static void
-server_ptrace_sem_wait (void)
-{
- sem_wait (&manager_semaphore);
-}
-
-static void
-server_ptrace_sem_post (void)
-{
- sem_post (&manager_semaphore);
-}
-
-static int
-server_ptrace_sem_get_value (void)
-{
- int ret;
-
- sem_getvalue (&manager_semaphore, &ret);
- return ret;
-}
-
static ServerType
server_ptrace_get_server_type (void)
{
@@ -574,40 +574,9 @@ server_ptrace_get_current_thread (void)
return pthread_self ();
}
-static gboolean initialized = FALSE;
-int pending_sigint = 0;
-
-static void
-sigint_signal_handler (int _dummy)
-{
- pending_sigint++;
- server_ptrace_sem_post ();
-}
-
static void
server_ptrace_static_init (void)
{
- struct sigaction sa;
-
- if (initialized)
- return;
-
- /* catch SIGINT */
- sa.sa_handler = sigint_signal_handler;
- sigemptyset (&sa.sa_mask);
- sa.sa_flags = 0;
- g_assert (sigaction (SIGINT, &sa, NULL) != -1);
-
- initialized = TRUE;
-}
-
-static int
-server_ptrace_get_pending_sigint (void)
-{
- if (pending_sigint > 0)
- return pending_sigint--;
-
- return 0;
}
extern void GC_start_blocking (void);
@@ -690,10 +659,5 @@ InferiorVTable i386_ptrace_inferior = {
server_ptrace_restart_notification,
server_ptrace_get_registers_from_core_file,
server_ptrace_get_current_pid,
- server_ptrace_get_current_thread,
- server_ptrace_sem_init,
- server_ptrace_sem_wait,
- server_ptrace_sem_post,
- server_ptrace_sem_get_value,
- server_ptrace_get_pending_sigint,
+ server_ptrace_get_current_thread
};
@@ -43,8 +43,6 @@ struct InferiorHandle
#endif /* PTRACE_EVENT_FORK */
-extern int pending_sigint;
-
static ServerCommandError
_server_ptrace_check_errno (InferiorHandle *);
@@ -110,16 +108,4 @@ server_ptrace_get_signal_info (ServerHandle *handle, SignalInfo **sinfo);
static gboolean
_server_ptrace_wait_for_new_thread (ServerHandle *handle);
-static void
-server_ptrace_sem_init (void);
-
-static void
-server_ptrace_sem_wait (void);
-
-static void
-server_ptrace_sem_post (void);
-
-static int
-server_ptrace_sem_get_value (void);
-
#endif
@@ -307,13 +307,8 @@ but how and which information should be placed there is not yet clear. To shield
internal changes accessor function will be used. This accessor functions are yet to be written and
one must expect them to change over time */
static DEBUG_INFO m_debug_info;
-static gboolean initialized = FALSE;
-static HANDLE manager_semaphore;
-static LONG sem_count = 0;
static GAsyncQueue *bridge;
-static int pending_sigint = 0;
-
@@ -332,7 +327,6 @@ static int get_set_registers (CONTEXT *context, enum READ_FLAG flag);
static int single_step_checks (guint32 eip);
static BOOL decrement_ip (HANDLE debuggee_thread_handle);
static int resume_from_imports_table (int flag);
-static void emul_sem_post (void);
static BreakpointInfo* on_breakpoint_exception (DWORD address,int *b_continue);
@@ -655,8 +649,6 @@ static BOOL do_debug_exception_event (LPDEBUG_EVENT pde, HANDLE debuggee_handle,
}
m_debug_info.debuggee.thread_handle = save_thread_handle;
m_debug_info.debuggee.thread_id = save_thread_id;
- pending_sigint++;
- emul_sem_post ();
return (b_continue);
}
@@ -1198,25 +1190,11 @@ static void format_windows_error_message (DWORD error_code)
}
}
-static BOOL WINAPI HandlerRoutine (DWORD dwCtrlType)
-{
- ReleaseSemaphore (manager_semaphore, 1, &sem_count);
- return TRUE;
-}
-
static void
server_win32_static_init (void)
{
- if (initialized)
- return;
-
- SetConsoleCtrlHandler (HandlerRoutine, TRUE);
- g_thread_init (NULL);
-
- initialized = TRUE;
}
-
static ServerCommandError
server_win32_get_signal_info (ServerHandle *handle, SignalInfo **sinfo_out)
{
@@ -2306,74 +2284,6 @@ server_win32_get_current_thread (void)
return GetCurrentThreadId ();
}
-static void emul_sem_post (void) {
-
- LONG l_val;
- BOOL b_rval;
-
- SetLastError (0);
- b_rval = ReleaseSemaphore (manager_semaphore, pending_sigint, &l_val);
- if (! b_rval) {
- format_windows_error_message (GetLastError ());
- g_debug ("%s", windows_error_message);
- }
- /* frido test 2009-05-22 */
- //SetEvent (m_command_events [EVENT_RESUME]);
-}
-
-
-
-
-static void
-server_win32_sem_init (void)
-{
- manager_semaphore = CreateSemaphore (
- NULL, // default security attributes
- 0, // initial count
- 12, // maximum count
- NULL); // unnamed semaphore
- if (! manager_semaphore) {
- format_windows_error_message (GetLastError ());
- g_debug ("sever_win32_sem_init, error: %s", windows_error_message);
- }
-}
-
-static void
-server_win32_sem_wait (void)
-{
- WaitForSingleObject ( manager_semaphore, INFINITE);
- // WaitForSingleObject ( manager_semaphore, 45000);
-}
-
-
-
-static void
-server_win32_sem_post (void)
-{
-
- BOOL b_rval;
- SetLastError (0);
- b_rval = ReleaseSemaphore (manager_semaphore, 1, &sem_count);
- if (! b_rval) {
- format_windows_error_message (GetLastError ());
- g_debug ("%s, sem_count = %d", windows_error_message,sem_count);
- }
-}
-
-static int
-server_win32_sem_get_value (void)
-{
- return sem_count;
-}
-
-static int
-server_win32_get_pending_sigint (void)
-{
- if (pending_sigint > 0)
- return pending_sigint--;
-
- return 0;
-}
static ServerCommandError
read_write_memory (ServerHandle *server_handle, guint64 start, guint32 size, gpointer buffer, int read)
@@ -2528,12 +2438,7 @@ InferiorVTable i386_windows_inferior = {
NULL, /*server_ptrace_restart_notification, */
NULL, /*get_registers_from_core_file, */
server_win32_get_current_pid, /*get_current_pid, */
- server_win32_get_current_thread, /*get_current_thread, */
- server_win32_sem_init, /*sem_init, */
- server_win32_sem_wait, /*sem_wait, */
- server_win32_sem_post, /*sem_post, */
- server_win32_sem_get_value, /*sem_get_value, */
- server_win32_get_pending_sigint, /*get_pending_sigint, */
+ server_win32_get_current_thread /*get_current_thread, */
};
Oops, something went wrong.

0 comments on commit a5088eb

Please sign in to comment.