Author: toshok
Date: 2005-04-26 22:20:11 -0400 (Tue, 26 Apr 2005)
New Revision: 43636
Added:
trunk/debugger/backends/server/x86-freebsd-ptrace.c
trunk/debugger/backends/server/x86-freebsd-ptrace.h
Removed:
trunk/debugger/backends/server/i386-freebsd-ptrace.c
trunk/debugger/backends/server/i386-freebsd-ptrace.h
Modified:
trunk/debugger/ChangeLog
trunk/debugger/backends/Inferior.cs
trunk/debugger/backends/SingleSteppingEngine.cs
trunk/debugger/backends/ThreadManager.cs
trunk/debugger/backends/server/x86-ptrace.c
Log:
2005-04-26 Chris Toshok <[EMAIL PROTECTED]>
* backends/Inferior.cs (Inferior.Dispose): don't call Kill here.
* backends/ThreadManager.cs (ThreadManager.Dispose): use a
two-stage method. first we Kill all the processes, then we
Dispose of them.
* backends/SingleSteppingEngine.cs (SingleSteppingEngine.Dispose):
don't Kill the inferior here, only Dispose of it.
* backends/server/x86-ptrace.c (server_ptrace_finalize): only kill
the pid in server_ptrace_kill. in finalize we do_wait.
(server_ptrace_kill): PT_KILL here as well, although i'm sure
that's unnecessary.
* backends/server/x86-freebsd-ptrace.[ch]: rename
i386-freebsd-ptrace.[ch].
Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog 2005-04-27 00:48:35 UTC (rev 43635)
+++ trunk/debugger/ChangeLog 2005-04-27 02:20:11 UTC (rev 43636)
@@ -1,5 +1,24 @@
2005-04-26 Chris Toshok <[EMAIL PROTECTED]>
+ * backends/Inferior.cs (Inferior.Dispose): don't call Kill here.
+
+ * backends/ThreadManager.cs (ThreadManager.Dispose): use a
+ two-stage method. first we Kill all the processes, then we
+ Dispose of them.
+
+ * backends/SingleSteppingEngine.cs (SingleSteppingEngine.Dispose):
+ don't Kill the inferior here, only Dispose of it.
+
+ * backends/server/x86-ptrace.c (server_ptrace_finalize): only kill
+ the pid in server_ptrace_kill. in finalize we do_wait.
+ (server_ptrace_kill): PT_KILL here as well, although i'm sure
+ that's unnecessary.
+
+ * backends/server/x86-freebsd-ptrace.[ch]: rename
+ i386-freebsd-ptrace.[ch].
+
+2005-04-26 Chris Toshok <[EMAIL PROTECTED]>
+
[ fixes bug #61196 ]
* classes/SymbolTableManager.cs: rework the Dispose stuff so that
it doesn't use Thread.Abort.
Modified: trunk/debugger/backends/Inferior.cs
===================================================================
--- trunk/debugger/backends/Inferior.cs 2005-04-27 00:48:35 UTC (rev 43635)
+++ trunk/debugger/backends/Inferior.cs 2005-04-27 02:20:11 UTC (rev 43636)
@@ -1166,7 +1166,6 @@
// If this is a call to Dispose,
// dispose all managed resources.
if (disposing) {
- Kill ();
bfd_container.CloseBfd (bfd);
if (bfd_disassembler != null)
bfd_disassembler.Dispose ();
Modified: trunk/debugger/backends/SingleSteppingEngine.cs
===================================================================
--- trunk/debugger/backends/SingleSteppingEngine.cs 2005-04-27 00:48:35 UTC
(rev 43635)
+++ trunk/debugger/backends/SingleSteppingEngine.cs 2005-04-27 02:20:11 UTC
(rev 43636)
@@ -2350,10 +2350,8 @@
// Check to see if Dispose has already been called.
// If this is a call to Dispose, dispose all managed
resources.
if (disposing) {
- if (inferior != null) {
- inferior.Kill ();
+ if (inferior != null)
inferior.Dispose ();
- }
inferior = null;
}
Modified: trunk/debugger/backends/ThreadManager.cs
===================================================================
--- trunk/debugger/backends/ThreadManager.cs 2005-04-27 00:48:35 UTC (rev
43635)
+++ trunk/debugger/backends/ThreadManager.cs 2005-04-27 02:20:11 UTC (rev
43636)
@@ -692,13 +692,25 @@
// If this is a call to Dispose, dispose all managed
resources.
if (disposing) {
+ int i;
+ bool main_in_threads = false;
+
SingleSteppingEngine[] threads = new
SingleSteppingEngine [thread_hash.Count];
thread_hash.Values.CopyTo (threads, 0);
- for (int i = 0; i < threads.Length; i++)
- threads [i].Dispose ();
+ for (i = 0; i < threads.Length; i++) {
+ if (main_process != null &&
main_process == threads[i].Process)
+ main_in_threads = true;
+ threads [i].Kill ();
+ }
- if (main_process != null)
+ if (!main_in_threads)
+ main_process.Kill ();
+
+ for (i = 0; i < threads.Length; i ++)
+ threads[i].Dispose ();
+
+ if (!main_in_threads)
main_process.Dispose ();
}
}
Deleted: trunk/debugger/backends/server/i386-freebsd-ptrace.c
===================================================================
--- trunk/debugger/backends/server/i386-freebsd-ptrace.c 2005-04-27
00:48:35 UTC (rev 43635)
+++ trunk/debugger/backends/server/i386-freebsd-ptrace.c 2005-04-27
02:20:11 UTC (rev 43636)
@@ -1,169 +0,0 @@
-static ServerCommandError
-server_get_registers (InferiorHandle *handle, INFERIOR_REGS_TYPE *regs)
-{
- if (ptrace (PT_GETREGS, handle->pid, (caddr_t) regs, 0) != 0) {
- if (errno == ESRCH)
- return COMMAND_ERROR_NOT_STOPPED;
- else if (errno) {
- g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
- return COMMAND_ERROR_UNKNOWN_ERROR;
- }
- }
-
- return COMMAND_ERROR_NONE;
-}
-
-static ServerCommandError
-server_set_registers (InferiorHandle *handle, INFERIOR_REGS_TYPE *regs)
-{
- if (ptrace (PT_SETREGS, handle->pid, (caddr_t) regs, 0) != 0) {
- if (errno == ESRCH)
- return COMMAND_ERROR_NOT_STOPPED;
- else if (errno) {
- g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
- return COMMAND_ERROR_UNKNOWN_ERROR;
- }
- }
-
- return COMMAND_ERROR_NONE;
-}
-
-static ServerCommandError
-server_get_fp_registers (InferiorHandle *handle, INFERIOR_FPREGS_TYPE *regs)
-{
- if (ptrace (PT_GETFPREGS, handle->pid, (caddr_t) regs, 0) != 0) {
- if (errno == ESRCH)
- return COMMAND_ERROR_NOT_STOPPED;
- else if (errno) {
- g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
- return COMMAND_ERROR_UNKNOWN_ERROR;
- }
- }
-
- return COMMAND_ERROR_NONE;
-}
-
-static ServerCommandError
-server_set_fp_registers (InferiorHandle *handle, INFERIOR_FPREGS_TYPE *regs)
-{
- if (ptrace (PT_SETFPREGS, handle->pid, (caddr_t) regs, 0) != 0) {
- if (errno == ESRCH)
- return COMMAND_ERROR_NOT_STOPPED;
- else if (errno) {
- g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
- return COMMAND_ERROR_UNKNOWN_ERROR;
- }
- }
-
- return COMMAND_ERROR_NONE;
-}
-
-static ServerCommandError
-server_ptrace_read_data (InferiorHandle *handle, ArchInfo *arch, guint64 start,
- guint32 size, gpointer buffer)
-{
- guint32 old_size = size;
- int *ptr = buffer;
- int addr = (int) start;
-
- while (size) {
- int word;
-
- errno = 0;
- word = ptrace (PT_READ_D, handle->pid, (gpointer) addr, 0);
- if (errno == ESRCH)
- return COMMAND_ERROR_NOT_STOPPED;
- else if (errno) {
- g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
- return COMMAND_ERROR_UNKNOWN_ERROR;
- }
-
- if (size >= sizeof (int)) {
- *ptr++ = word;
- addr += sizeof (int);
- size -= sizeof (int);
- } else {
- memcpy (ptr, &word, size);
- size = 0;
- }
- }
-
- i386_arch_remove_breakpoints_from_target_memory (handle, arch, start,
old_size, buffer);
-
- return COMMAND_ERROR_NONE;
-}
-
-static ServerCommandError
-server_set_dr (InferiorHandle *handle, int regnum, unsigned long value)
-{
- return COMMAND_ERROR_UNKNOWN_ERROR;
-}
-
-static int
-server_do_wait (InferiorHandle *handle)
-{
- int options, ret, status = 0;
- sigset_t mask, oldmask;
-
- sigemptyset (&mask);
- sigaddset (&mask, SIGCHLD);
- sigaddset (&mask, SIGINT);
-
- sigprocmask (SIG_BLOCK, &mask, &oldmask);
-
- again:
- options = WUNTRACED;
- if (handle->is_thread)
- options |= WLINUXCLONE;
- ret = waitpid (handle->pid, &status, options);
- if (ret < 0) {
- g_warning (G_STRLOC ": Can't waitpid (%d): %s", handle->pid,
g_strerror (errno));
- status = -1;
- goto out;
- } else if (ret) {
- goto out;
- }
-
- sigsuspend (&oldmask);
- goto again;
-
- out:
- sigprocmask (SIG_SETMASK, &oldmask, NULL);
- return status;
-}
-
-static void
-server_setup_inferior (InferiorHandle *handle, ArchInfo *arch)
-{
- sigset_t mask;
-
- sigemptyset (&mask);
- sigaddset (&mask, SIGINT);
- sigprocmask (SIG_BLOCK, &mask, NULL);
-
- server_do_wait (handle);
-
- if (server_get_registers (handle, &arch->current_regs) !=
COMMAND_ERROR_NONE)
- g_error (G_STRLOC ": Can't get registers");
- if (server_get_fp_registers (handle, &arch->current_fpregs) !=
COMMAND_ERROR_NONE)
- g_error (G_STRLOC ": Can't get fp registers");
-}
-
-static ServerCommandError
-server_ptrace_get_signal_info (InferiorHandle *handle, ArchInfo *arch,
SignalInfo *sinfo)
-{
- sinfo->sigkill = SIGKILL;
- sinfo->sigstop = SIGSTOP;
- sinfo->sigint = SIGINT;
- sinfo->sigchld = SIGCHLD;
- sinfo->sigprof = SIGPROF;
- sinfo->sigpwr = SIGPWR;
- sinfo->sigxcpu = SIGXCPU;
-
- sinfo->thread_abort = SIGUSR1;
- sinfo->thread_restart = SIGUSR2;
- sinfo->thread_debug = -1;
- sinfo->mono_thread_debug = SIGINFO;
-
- return COMMAND_ERROR_NONE;
-}
Deleted: trunk/debugger/backends/server/i386-freebsd-ptrace.h
===================================================================
--- trunk/debugger/backends/server/i386-freebsd-ptrace.h 2005-04-27
00:48:35 UTC (rev 43635)
+++ trunk/debugger/backends/server/i386-freebsd-ptrace.h 2005-04-27
02:20:11 UTC (rev 43636)
@@ -1,29 +0,0 @@
-#ifndef __MONO_DEBUGGER_I386_FREEBSD_PTRACE_H__
-#define __MONO_DEBUGGER_I386_FREEBSD_PTRACE_H__
-
-#include <machine/reg.h>
-
-#define INFERIOR_REGS_TYPE struct reg
-#define INFERIOR_FPREGS_TYPE struct fpreg
-
-#define INFERIOR_REG_EIP(r) r.r_eip
-#define INFERIOR_REG_ESP(r) r.r_esp
-#define INFERIOR_REG_EBP(r) r.r_ebp
-#define INFERIOR_REG_EAX(r) r.r_eax
-#define INFERIOR_REG_EBX(r) r.r_ebx
-#define INFERIOR_REG_ECX(r) r.r_ecx
-#define INFERIOR_REG_EDX(r) r.r_edx
-#define INFERIOR_REG_ESI(r) r.r_esi
-#define INFERIOR_REG_EDI(r) r.r_edi
-#define INFERIOR_REG_EFLAGS(r) r.r_eflags
-#define INFERIOR_REG_ESP(r) r.r_esp
-#define INFERIOR_REG_FS(r) r.r_fs
-#define INFERIOR_REG_ES(r) r.r_es
-#define INFERIOR_REG_DS(r) r.r_ds
-#define INFERIOR_REG_CS(r) r.r_cs
-#define INFERIOR_REG_SS(r) r.r_ss
-#define INFERIOR_REG_GS(r) r.r_gs
-
-#include "i386-ptrace.h"
-
-#endif
Copied: trunk/debugger/backends/server/x86-freebsd-ptrace.c (from rev 43510,
trunk/debugger/backends/server/i386-freebsd-ptrace.c)
===================================================================
--- trunk/debugger/backends/server/i386-freebsd-ptrace.c 2005-04-24
06:46:09 UTC (rev 43510)
+++ trunk/debugger/backends/server/x86-freebsd-ptrace.c 2005-04-27 02:20:11 UTC
(rev 43636)
@@ -0,0 +1,169 @@
+static ServerCommandError
+server_get_registers (InferiorHandle *handle, INFERIOR_REGS_TYPE *regs)
+{
+ if (ptrace (PT_GETREGS, handle->pid, (caddr_t) regs, 0) != 0) {
+ if (errno == ESRCH)
+ return COMMAND_ERROR_NOT_STOPPED;
+ else if (errno) {
+ g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
+ return COMMAND_ERROR_UNKNOWN_ERROR;
+ }
+ }
+
+ return COMMAND_ERROR_NONE;
+}
+
+static ServerCommandError
+server_set_registers (InferiorHandle *handle, INFERIOR_REGS_TYPE *regs)
+{
+ if (ptrace (PT_SETREGS, handle->pid, (caddr_t) regs, 0) != 0) {
+ if (errno == ESRCH)
+ return COMMAND_ERROR_NOT_STOPPED;
+ else if (errno) {
+ g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
+ return COMMAND_ERROR_UNKNOWN_ERROR;
+ }
+ }
+
+ return COMMAND_ERROR_NONE;
+}
+
+static ServerCommandError
+server_get_fp_registers (InferiorHandle *handle, INFERIOR_FPREGS_TYPE *regs)
+{
+ if (ptrace (PT_GETFPREGS, handle->pid, (caddr_t) regs, 0) != 0) {
+ if (errno == ESRCH)
+ return COMMAND_ERROR_NOT_STOPPED;
+ else if (errno) {
+ g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
+ return COMMAND_ERROR_UNKNOWN_ERROR;
+ }
+ }
+
+ return COMMAND_ERROR_NONE;
+}
+
+static ServerCommandError
+server_set_fp_registers (InferiorHandle *handle, INFERIOR_FPREGS_TYPE *regs)
+{
+ if (ptrace (PT_SETFPREGS, handle->pid, (caddr_t) regs, 0) != 0) {
+ if (errno == ESRCH)
+ return COMMAND_ERROR_NOT_STOPPED;
+ else if (errno) {
+ g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
+ return COMMAND_ERROR_UNKNOWN_ERROR;
+ }
+ }
+
+ return COMMAND_ERROR_NONE;
+}
+
+static ServerCommandError
+server_ptrace_read_data (InferiorHandle *handle, ArchInfo *arch, guint64 start,
+ guint32 size, gpointer buffer)
+{
+ guint32 old_size = size;
+ int *ptr = buffer;
+ int addr = (int) start;
+
+ while (size) {
+ int word;
+
+ errno = 0;
+ word = ptrace (PT_READ_D, handle->pid, (gpointer) addr, 0);
+ if (errno == ESRCH)
+ return COMMAND_ERROR_NOT_STOPPED;
+ else if (errno) {
+ g_message (G_STRLOC ": %d - %s", handle->pid,
g_strerror (errno));
+ return COMMAND_ERROR_UNKNOWN_ERROR;
+ }
+
+ if (size >= sizeof (int)) {
+ *ptr++ = word;
+ addr += sizeof (int);
+ size -= sizeof (int);
+ } else {
+ memcpy (ptr, &word, size);
+ size = 0;
+ }
+ }
+
+ i386_arch_remove_breakpoints_from_target_memory (handle, arch, start,
old_size, buffer);
+
+ return COMMAND_ERROR_NONE;
+}
+
+static ServerCommandError
+server_set_dr (InferiorHandle *handle, int regnum, unsigned long value)
+{
+ return COMMAND_ERROR_UNKNOWN_ERROR;
+}
+
+static int
+do_wait (int pid, guint32 *status)
+{
+ int options, ret;
+ sigset_t mask, oldmask;
+
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGCHLD);
+ sigaddset (&mask, SIGINT);
+
+ sigprocmask (SIG_BLOCK, &mask, &oldmask);
+
+ again:
+ options = WUNTRACED;
+ if (handle->is_thread)
+ options |= WLINUXCLONE;
+ ret = waitpid (handle->pid, status, options);
+ if (ret < 0) {
+ g_warning (G_STRLOC ": Can't waitpid (%d): %s", handle->pid,
g_strerror (errno));
+ *status = -1;
+ goto out;
+ } else if (ret) {
+ goto out;
+ }
+
+ sigsuspend (&oldmask);
+ goto again;
+
+ out:
+ sigprocmask (SIG_SETMASK, &oldmask, NULL);
+ return ret;
+}
+
+static void
+server_setup_inferior (InferiorHandle *handle, ArchInfo *arch)
+{
+ sigset_t mask;
+
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGINT);
+ sigprocmask (SIG_BLOCK, &mask, NULL);
+
+ do_wait (handle->inferior->pid, &status);
+
+ if (server_get_registers (handle, &arch->current_regs) !=
COMMAND_ERROR_NONE)
+ g_error (G_STRLOC ": Can't get registers");
+ if (server_get_fp_registers (handle, &arch->current_fpregs) !=
COMMAND_ERROR_NONE)
+ g_error (G_STRLOC ": Can't get fp registers");
+}
+
+static ServerCommandError
+server_ptrace_get_signal_info (InferiorHandle *handle, ArchInfo *arch,
SignalInfo *sinfo)
+{
+ sinfo->sigkill = SIGKILL;
+ sinfo->sigstop = SIGSTOP;
+ sinfo->sigint = SIGINT;
+ sinfo->sigchld = SIGCHLD;
+ sinfo->sigprof = SIGPROF;
+ sinfo->sigpwr = SIGPWR;
+ sinfo->sigxcpu = SIGXCPU;
+
+ sinfo->thread_abort = SIGUSR1;
+ sinfo->thread_restart = SIGUSR2;
+ sinfo->thread_debug = -1;
+ sinfo->mono_thread_debug = SIGINFO;
+
+ return COMMAND_ERROR_NONE;
+}
Copied: trunk/debugger/backends/server/x86-freebsd-ptrace.h (from rev 43510,
trunk/debugger/backends/server/i386-freebsd-ptrace.h)
Modified: trunk/debugger/backends/server/x86-ptrace.c
===================================================================
--- trunk/debugger/backends/server/x86-ptrace.c 2005-04-27 00:48:35 UTC (rev
43635)
+++ trunk/debugger/backends/server/x86-ptrace.c 2005-04-27 02:20:11 UTC (rev
43636)
@@ -36,7 +36,7 @@
#endif
#ifdef __FreeBSD__
-#include "i386-freebsd-ptrace.h"
+#include "x86-freebsd-ptrace.h"
#endif
#include "x86-arch.h"
@@ -59,12 +59,9 @@
server_ptrace_finalize (ServerHandle *handle)
{
if (handle->inferior->pid) {
- /* int status; */
+ int status;
- ptrace (PT_KILL, handle->inferior->pid, NULL, 0);
- ptrace (PT_DETACH, handle->inferior->pid, NULL, 0);
- kill (handle->inferior->pid, SIGKILL);
- /* do_wait (handle->inferior->pid, &status); */
+ do_wait (-1, &status);
}
x86_arch_finalize (handle->arch);
g_free (handle->inferior);
@@ -119,10 +116,13 @@
static ServerCommandError
server_ptrace_kill (ServerHandle *handle)
{
+ int status;
InferiorHandle *inferior = handle->inferior;
- if (inferior->pid)
+ if (inferior->pid) {
+ ptrace (PT_KILL, inferior->pid, NULL, 0);
kill (inferior->pid, SIGKILL);
+ }
return COMMAND_ERROR_NONE;
}
@@ -416,7 +416,7 @@
#endif
#ifdef __FreeBSD__
-#include "i386-freebsd-ptrace.c"
+#include "x86-freebsd-ptrace.c"
#endif
#if defined(__i386__)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches