GNU Binutils with patches for OS216
Révision | 7e1c5a0c7517848f08894b8dcc4e54e8832c7180 (tree) |
---|---|
l'heure | 2006-09-17 21:26:21 |
Auteur | Nick Roberts <nickrob@snap...> |
Commiter | Nick Roberts |
Copy code from Apple more carefully and remove redundant code
@@ -23,61 +23,18 @@ | ||
23 | 23 | Boston, MA 02111-1307, USA. */ |
24 | 24 | |
25 | 25 | #include "defs.h" |
26 | -#include "top.h" | |
27 | 26 | #include "inferior.h" |
28 | -#include "target.h" | |
29 | -#include "symfile.h" | |
30 | -#include "symtab.h" | |
31 | 27 | #include "objfiles.h" |
32 | -#include "gdbcmd.h" | |
33 | -#include "gdbcore.h" | |
34 | -#include "gdbthread.h" | |
35 | -#include "regcache.h" | |
36 | -#include "environ.h" | |
37 | 28 | #include "event-top.h" |
38 | -#include "inf-loop.h" | |
39 | -#include "gdb_stat.h" | |
40 | -#include "exceptions.h" | |
41 | - | |
42 | -#include "bfd.h" | |
43 | - | |
44 | -#include <sys/ptrace.h> | |
45 | -#include <sys/signal.h> | |
46 | -#include <setjmp.h> | |
47 | -#include <sys/types.h> | |
48 | -#include <unistd.h> | |
49 | -#include <signal.h> | |
50 | -#include <string.h> | |
51 | -#include <ctype.h> | |
52 | -#include <sys/param.h> | |
53 | -#include <sys/sysctl.h> | |
54 | 29 | |
55 | 30 | #include "async-nat-inferior.h" |
56 | -/* classic-inferior-support */ | |
57 | -//#include "macosx-nat.h" | |
58 | -//#include "macosx-nat-inferior-util.h" | |
59 | - | |
60 | -#ifndef EXC_SOFT_SIGNAL | |
61 | -#define EXC_SOFT_SIGNAL 0 | |
62 | -#endif | |
63 | - | |
64 | -extern bfd *exec_bfd; | |
65 | 31 | |
66 | 32 | gdb_inferior_status *gdb_status = NULL; |
67 | 33 | |
68 | -int inferior_ptrace_flag = 1; | |
69 | -int inferior_ptrace_on_attach_flag = 1; | |
70 | -int inferior_bind_exception_port_flag = 1; | |
71 | -int inferior_handle_exceptions_flag = 1; | |
72 | -int inferior_handle_all_events_flag = 1; | |
73 | - | |
74 | 34 | enum gdb_source_type |
75 | 35 | { |
76 | 36 | NEXT_SOURCE_NONE = 0x0, |
77 | - NEXT_SOURCE_EXCEPTION = 0x1, | |
78 | - NEXT_SOURCE_SIGNAL = 0x2, | |
79 | - NEXT_SOURCE_CFM = 0x4, | |
80 | - NEXT_SOURCE_ALL = 0x7 | |
37 | + NEXT_SOURCE_SIGNAL = 0x1, | |
81 | 38 | }; |
82 | 39 | |
83 | 40 | struct gdb_pending_event |
@@ -139,8 +96,6 @@ gdb_handle_signal (gdb_signal_thread_message *msg, | ||
139 | 96 | |
140 | 97 | gdb_status->stopped_in_ptrace = 1; |
141 | 98 | |
142 | - //prepare_threads_after_stop (gdb_status); | |
143 | - | |
144 | 99 | status->kind = TARGET_WAITKIND_STOPPED; |
145 | 100 | status->value.sig = target_signal_from_host (WSTOPSIG (msg->status)); |
146 | 101 | } |
@@ -292,8 +247,6 @@ gdb_post_pending_event (void) | ||
292 | 247 | if (pending_event_chain == NULL) |
293 | 248 | pending_event_tail = NULL; |
294 | 249 | |
295 | - /*inferior_debug (1, | |
296 | - "gdb_post_pending_event: consuming event off queue\n"); */ | |
297 | 250 | gdb_queue_event (gdb_pending_event_handler, (void *) event, HEAD); |
298 | 251 | |
299 | 252 | return 1; |
@@ -303,7 +256,6 @@ gdb_post_pending_event (void) | ||
303 | 256 | static void |
304 | 257 | gdb_pending_event_handler (void *data) |
305 | 258 | { |
306 | - //inferior_debug (1, "Called in gdb_pending_event_handler\n"); | |
307 | 259 | async_client_callback (INF_REG_EVENT, data); |
308 | 260 | } |
309 | 261 |
@@ -312,15 +264,7 @@ gdb_service_event (enum gdb_source_type source, | ||
312 | 264 | unsigned char *buf, struct target_waitstatus *status) |
313 | 265 | { |
314 | 266 | if (source == NEXT_SOURCE_SIGNAL) |
315 | - { | |
316 | - // inferior_debug (1, "gdb_service_events: got signal message\n"); | |
317 | 267 | gdb_handle_signal ((gdb_signal_thread_message *) buf, status); |
318 | - // CHECK_FATAL (status->kind != TARGET_WAITKIND_SPURIOUS); | |
319 | - if (!inferior_handle_all_events_flag) | |
320 | - { | |
321 | - return 1; | |
322 | - } | |
323 | - } | |
324 | 268 | else |
325 | 269 | { |
326 | 270 | error ("got message from unknown source: 0x%08x\n", source); |
@@ -347,7 +291,7 @@ gdb_process_events (struct gdb_inferior_status *inferior, | ||
347 | 291 | // CHECK_FATAL (status->kind == TARGET_WAITKIND_SPURIOUS); |
348 | 292 | |
349 | 293 | source = gdb_fetch_event (inferior, buf, sizeof (buf), |
350 | - NEXT_SOURCE_ALL, timeout); | |
294 | + NEXT_SOURCE_SIGNAL, timeout); | |
351 | 295 | if (source == NEXT_SOURCE_NONE) |
352 | 296 | { |
353 | 297 | return 0; |
@@ -365,6 +309,32 @@ gdb_process_events (struct gdb_inferior_status *inferior, | ||
365 | 309 | gdb_add_to_pending_events (source, buf); |
366 | 310 | } |
367 | 311 | |
312 | + /* FIXME: we want to poll in gdb_fetch_event because otherwise we | |
313 | + arbitrarily wait however long the wait quanta for select is | |
314 | + (seemingly ~.01 sec). However, if we do this we aren't giving | |
315 | + the mach exception thread a chance to run, and see if there are | |
316 | + any more exceptions available. Normally this is okay, because | |
317 | + there really IS only one message, but to be correct we need to | |
318 | + use some thread synchronization. */ | |
319 | + for (;;) | |
320 | + { | |
321 | + source = gdb_fetch_event (inferior, buf, sizeof (buf), | |
322 | + NEXT_SOURCE_SIGNAL, 0); | |
323 | + if (source == NEXT_SOURCE_NONE) | |
324 | + { | |
325 | + break; | |
326 | + } | |
327 | + else | |
328 | + { | |
329 | + event_count++; | |
330 | + | |
331 | + /* Stuff the remaining events onto the pending_events queue. | |
332 | + These will be dispatched when we run again. */ | |
333 | + /* PENDING_EVENTS */ | |
334 | + gdb_add_to_pending_events (source, buf); | |
335 | + } | |
336 | + } | |
337 | + | |
368 | 338 | return event_count; |
369 | 339 | } |
370 | 340 |
@@ -378,6 +348,7 @@ gdb_process_pending_event (struct gdb_inferior_status *ns, | ||
378 | 348 | |
379 | 349 | //inferior_debug (1, "Processing pending event type: %d\n", event->type); |
380 | 350 | gdb_service_event (event->type, (unsigned char *) event->buf, status); |
351 | + // printf ("IN GDB_PROCESS_PENDING_EVENT %s\n", event->buf); | |
381 | 352 | |
382 | 353 | return ptid_build (gdb_status->pid, gdb_status->pid, 0); |
383 | 354 | } |
@@ -385,8 +356,6 @@ gdb_process_pending_event (struct gdb_inferior_status *ns, | ||
385 | 356 | void |
386 | 357 | gdb_create_inferior (struct gdb_inferior_status *inferior, int pid) |
387 | 358 | { |
388 | - // CHECK_FATAL (inferior != NULL); | |
389 | - | |
390 | 359 | gdb_inferior_destroy (inferior); |
391 | 360 | gdb_inferior_reset (inferior); |
392 | 361 |
@@ -44,8 +44,6 @@ int gdb_post_pending_event (void); | ||
44 | 44 | void (*async_client_callback) (enum inferior_event_type event_type, |
45 | 45 | void *context); |
46 | 46 | |
47 | -void *async_client_context; | |
48 | - | |
49 | 47 | void async_terminal_inferior (void); |
50 | 48 | |
51 | 49 | void async_terminal_ours (void); |
@@ -28,13 +28,8 @@ | ||
28 | 28 | #include "inferior.h" |
29 | 29 | |
30 | 30 | #include "async-nat-sigthread.h" |
31 | -//#include "macosx-nat-inferior.h" | |
32 | -//#include "macosx-nat-mutils.h" | |
33 | 31 | |
34 | -#include <stdlib.h> | |
35 | -#include <stdarg.h> | |
36 | 32 | #include <string.h> |
37 | - | |
38 | 33 | #include <sys/select.h> |
39 | 34 | |
40 | 35 | static FILE *sigthread_stderr_re = NULL; |
@@ -74,7 +69,6 @@ gdb_signal_thread_create (gdb_signal_thread_status *s, int pid) | ||
74 | 69 | int ret; |
75 | 70 | |
76 | 71 | ret = pipe (fd); |
77 | - // CHECK_FATAL (ret == 0); | |
78 | 72 | |
79 | 73 | s->transmit_fd = fd[1]; |
80 | 74 | s->receive_fd = fd[0]; |
@@ -132,7 +126,6 @@ static void* | ||
132 | 126 | gdb_signal_thread (void *arg) |
133 | 127 | { |
134 | 128 | gdb_signal_thread_status *s = (gdb_signal_thread_status *) arg; |
135 | - // CHECK_FATAL (s != NULL); | |
136 | 129 | |
137 | 130 | for (;;) |
138 | 131 | { |
@@ -209,6 +202,13 @@ gdb_pthread_kill (pthread_t pthread) | ||
209 | 202 | { |
210 | 203 | warning ("Unable to cancel thread: %s (%d)", strerror (errno), errno); |
211 | 204 | } |
205 | + | |
206 | + ret = pthread_join (pthread, NULL); | |
207 | + if (ret != 0) | |
208 | + { | |
209 | + warning ("Unable to join to canceled thread: %s (%d)", strerror (errno), | |
210 | + errno); | |
211 | + } | |
212 | 212 | } |
213 | 213 | |
214 | 214 | pthread_t |