diff options
author | Nick Roberts <nickrob@snap.net.nz> | 2006-09-17 12:26:21 +0000 |
---|---|---|
committer | Nick Roberts <nickrob@snap.net.nz> | 2006-09-17 12:26:21 +0000 |
commit | 7e1c5a0c7517848f08894b8dcc4e54e8832c7180 (patch) | |
tree | 59a1096f70e902b7be9d793e14585466ffb977ce | |
parent | 862b0845986dfee5e96e88c65a98bb5d2dc5a0dd (diff) | |
download | fsf-binutils-gdb-7e1c5a0c7517848f08894b8dcc4e54e8832c7180.zip fsf-binutils-gdb-7e1c5a0c7517848f08894b8dcc4e54e8832c7180.tar.gz fsf-binutils-gdb-7e1c5a0c7517848f08894b8dcc4e54e8832c7180.tar.bz2 |
Copy code from Apple more carefully and remove redundant code
-rw-r--r-- | gdb/async-nat-inferior.c | 89 | ||||
-rw-r--r-- | gdb/async-nat-inferior.h | 2 | ||||
-rw-r--r-- | gdb/async-nat-sigthread.c | 14 |
3 files changed, 36 insertions, 69 deletions
diff --git a/gdb/async-nat-inferior.c b/gdb/async-nat-inferior.c index f5b46e2..2f7da77 100644 --- a/gdb/async-nat-inferior.c +++ b/gdb/async-nat-inferior.c @@ -23,61 +23,18 @@ Boston, MA 02111-1307, USA. */ #include "defs.h" -#include "top.h" #include "inferior.h" -#include "target.h" -#include "symfile.h" -#include "symtab.h" #include "objfiles.h" -#include "gdbcmd.h" -#include "gdbcore.h" -#include "gdbthread.h" -#include "regcache.h" -#include "environ.h" #include "event-top.h" -#include "inf-loop.h" -#include "gdb_stat.h" -#include "exceptions.h" - -#include "bfd.h" - -#include <sys/ptrace.h> -#include <sys/signal.h> -#include <setjmp.h> -#include <sys/types.h> -#include <unistd.h> -#include <signal.h> -#include <string.h> -#include <ctype.h> -#include <sys/param.h> -#include <sys/sysctl.h> #include "async-nat-inferior.h" -/* classic-inferior-support */ -//#include "macosx-nat.h" -//#include "macosx-nat-inferior-util.h" - -#ifndef EXC_SOFT_SIGNAL -#define EXC_SOFT_SIGNAL 0 -#endif - -extern bfd *exec_bfd; gdb_inferior_status *gdb_status = NULL; -int inferior_ptrace_flag = 1; -int inferior_ptrace_on_attach_flag = 1; -int inferior_bind_exception_port_flag = 1; -int inferior_handle_exceptions_flag = 1; -int inferior_handle_all_events_flag = 1; - enum gdb_source_type { NEXT_SOURCE_NONE = 0x0, - NEXT_SOURCE_EXCEPTION = 0x1, - NEXT_SOURCE_SIGNAL = 0x2, - NEXT_SOURCE_CFM = 0x4, - NEXT_SOURCE_ALL = 0x7 + NEXT_SOURCE_SIGNAL = 0x1, }; struct gdb_pending_event @@ -139,8 +96,6 @@ gdb_handle_signal (gdb_signal_thread_message *msg, gdb_status->stopped_in_ptrace = 1; - //prepare_threads_after_stop (gdb_status); - status->kind = TARGET_WAITKIND_STOPPED; status->value.sig = target_signal_from_host (WSTOPSIG (msg->status)); } @@ -292,8 +247,6 @@ gdb_post_pending_event (void) if (pending_event_chain == NULL) pending_event_tail = NULL; - /*inferior_debug (1, - "gdb_post_pending_event: consuming event off queue\n"); */ gdb_queue_event (gdb_pending_event_handler, (void *) event, HEAD); return 1; @@ -303,7 +256,6 @@ gdb_post_pending_event (void) static void gdb_pending_event_handler (void *data) { - //inferior_debug (1, "Called in gdb_pending_event_handler\n"); async_client_callback (INF_REG_EVENT, data); } @@ -312,15 +264,7 @@ gdb_service_event (enum gdb_source_type source, unsigned char *buf, struct target_waitstatus *status) { if (source == NEXT_SOURCE_SIGNAL) - { - // inferior_debug (1, "gdb_service_events: got signal message\n"); gdb_handle_signal ((gdb_signal_thread_message *) buf, status); - // CHECK_FATAL (status->kind != TARGET_WAITKIND_SPURIOUS); - if (!inferior_handle_all_events_flag) - { - return 1; - } - } else { error ("got message from unknown source: 0x%08x\n", source); @@ -347,7 +291,7 @@ gdb_process_events (struct gdb_inferior_status *inferior, // CHECK_FATAL (status->kind == TARGET_WAITKIND_SPURIOUS); source = gdb_fetch_event (inferior, buf, sizeof (buf), - NEXT_SOURCE_ALL, timeout); + NEXT_SOURCE_SIGNAL, timeout); if (source == NEXT_SOURCE_NONE) { return 0; @@ -365,6 +309,32 @@ gdb_process_events (struct gdb_inferior_status *inferior, gdb_add_to_pending_events (source, buf); } + /* FIXME: we want to poll in gdb_fetch_event because otherwise we + arbitrarily wait however long the wait quanta for select is + (seemingly ~.01 sec). However, if we do this we aren't giving + the mach exception thread a chance to run, and see if there are + any more exceptions available. Normally this is okay, because + there really IS only one message, but to be correct we need to + use some thread synchronization. */ + for (;;) + { + source = gdb_fetch_event (inferior, buf, sizeof (buf), + NEXT_SOURCE_SIGNAL, 0); + if (source == NEXT_SOURCE_NONE) + { + break; + } + else + { + event_count++; + + /* Stuff the remaining events onto the pending_events queue. + These will be dispatched when we run again. */ + /* PENDING_EVENTS */ + gdb_add_to_pending_events (source, buf); + } + } + return event_count; } @@ -378,6 +348,7 @@ gdb_process_pending_event (struct gdb_inferior_status *ns, //inferior_debug (1, "Processing pending event type: %d\n", event->type); gdb_service_event (event->type, (unsigned char *) event->buf, status); + // printf ("IN GDB_PROCESS_PENDING_EVENT %s\n", event->buf); return ptid_build (gdb_status->pid, gdb_status->pid, 0); } @@ -385,8 +356,6 @@ gdb_process_pending_event (struct gdb_inferior_status *ns, void gdb_create_inferior (struct gdb_inferior_status *inferior, int pid) { - // CHECK_FATAL (inferior != NULL); - gdb_inferior_destroy (inferior); gdb_inferior_reset (inferior); diff --git a/gdb/async-nat-inferior.h b/gdb/async-nat-inferior.h index 68e5d20..32a94c0 100644 --- a/gdb/async-nat-inferior.h +++ b/gdb/async-nat-inferior.h @@ -44,8 +44,6 @@ int gdb_post_pending_event (void); void (*async_client_callback) (enum inferior_event_type event_type, void *context); -void *async_client_context; - void async_terminal_inferior (void); void async_terminal_ours (void); diff --git a/gdb/async-nat-sigthread.c b/gdb/async-nat-sigthread.c index e1a4823..d84a785 100644 --- a/gdb/async-nat-sigthread.c +++ b/gdb/async-nat-sigthread.c @@ -28,13 +28,8 @@ #include "inferior.h" #include "async-nat-sigthread.h" -//#include "macosx-nat-inferior.h" -//#include "macosx-nat-mutils.h" -#include <stdlib.h> -#include <stdarg.h> #include <string.h> - #include <sys/select.h> static FILE *sigthread_stderr_re = NULL; @@ -74,7 +69,6 @@ gdb_signal_thread_create (gdb_signal_thread_status *s, int pid) int ret; ret = pipe (fd); - // CHECK_FATAL (ret == 0); s->transmit_fd = fd[1]; s->receive_fd = fd[0]; @@ -132,7 +126,6 @@ static void* gdb_signal_thread (void *arg) { gdb_signal_thread_status *s = (gdb_signal_thread_status *) arg; - // CHECK_FATAL (s != NULL); for (;;) { @@ -209,6 +202,13 @@ gdb_pthread_kill (pthread_t pthread) { warning ("Unable to cancel thread: %s (%d)", strerror (errno), errno); } + + ret = pthread_join (pthread, NULL); + if (ret != 0) + { + warning ("Unable to join to canceled thread: %s (%d)", strerror (errno), + errno); + } } pthread_t |