diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7a47897ba..ffc0f38b4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,23 @@ +2012-12-22 Christopher Faylor + + * select.h (select_stuff): Remove variable names from parameter + declarations. + (select_info): Ditto. + (select_record::dump_select_record): Declare new debugging-only + function. + (select_info): Zero all fields. + (select_pipe_info): Ditto. + (select_socket_info): Ditto. + (select_serial_info): Ditto. + (select_mailslot_info): Ditto. + * select.cc (select_record::dump_select_record): Define new + debugging-only function. + (select_stuff::test_and_set): Call dump_select_record when debugging. + + * thread.cc (pthread_mutex::unlock): Revert setting of tid to NULL + since, in this context, it is a number, not a pointer. + (pthread_spinlock::unlock): Ditto. + 2012-12-21 Christopher Faylor * sigproc.cc (exit_thread): undef ExitThread or suffer recursion. diff --git a/winsup/cygwin/select.cc b/winsup/cygwin/select.cc index c67471cbc..143e8c4e7 100644 --- a/winsup/cygwin/select.cc +++ b/winsup/cygwin/select.cc @@ -286,6 +286,22 @@ select_stuff::~select_stuff () destroy (); } +#ifdef DEBUGGING +void +select_record::dump_select_record () +{ + select_printf ("fd %d, h %p, fh %p, thread_errno %d, windows_handle %p", + fd, h, fh, thread_errno, windows_handle); + select_printf ("read_ready %d, write_ready %d, except_ready %d", + read_ready, write_ready, except_ready); + select_printf ("read_selected %d, write_selected %d, except_selected %d, except_on_write %d", + read_selected, write_selected, except_selected, except_on_write); + + select_printf ("startup %p, peek %p, verify %p cleanup %p, next %p", + startup, peek, verify, cleanup, next); +} +#endif /*DEBUGGING*/ + /* Add a record to the select chain */ bool select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds, @@ -315,6 +331,9 @@ select_stuff::test_and_set (int i, fd_set *readfds, fd_set *writefds, if (s->windows_handle) windows_used = true; +#ifdef DEBUGGING + s->dump_select_record (); +#endif return true; err: diff --git a/winsup/cygwin/select.h b/winsup/cygwin/select.h index f9df95d93..5e746768c 100644 --- a/winsup/cygwin/select.h +++ b/winsup/cygwin/select.h @@ -22,11 +22,10 @@ struct select_record bool read_ready, write_ready, except_ready; bool read_selected, write_selected, except_selected; bool except_on_write; - int (*startup) (select_record *me, class select_stuff *stuff); + int (*startup) (select_record *, class select_stuff *); int (*peek) (select_record *, bool); - int (*verify) (select_record *me, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds); - void (*cleanup) (select_record *me, class select_stuff *stuff); + int (*verify) (select_record *, fd_set *, fd_set *, fd_set *); + void (*cleanup) (select_record *, class select_stuff *); struct select_record *next; void set_select_errno () {__seterrno (); thread_errno = errno;} int saw_error () {return thread_errno;} @@ -37,6 +36,9 @@ struct select_record except_selected (false), except_on_write (false), startup (NULL), peek (NULL), verify (NULL), cleanup (NULL), next (NULL) {} +#ifdef DEBUGGING + void dump_select_record (); +#endif }; struct select_info @@ -44,11 +46,12 @@ struct select_info cygthread *thread; bool stop_thread; select_record *start; - select_info () {} + select_info (): thread (NULL), stop_thread (0), start (NULL) {} }; struct select_pipe_info: public select_info { + select_pipe_info (): select_info () {} }; struct select_socket_info: public select_info @@ -56,14 +59,17 @@ struct select_socket_info: public select_info int num_w4; LONG *ser_num; HANDLE *w4; + select_socket_info (): select_info (), num_w4 (0), ser_num (0), w4 (NULL) {} }; struct select_serial_info: public select_info { + select_serial_info (): select_info () {} }; struct select_mailslot_info: public select_info { + select_mailslot_info (): select_info () {} }; class select_stuff @@ -88,10 +94,9 @@ public: select_serial_info *device_specific_serial; select_mailslot_info *device_specific_mailslot; - bool test_and_set (int i, fd_set *readfds, fd_set *writefds, - fd_set *exceptfds); - int poll (fd_set *readfds, fd_set *writefds, fd_set *exceptfds); - wait_states wait (fd_set *readfds, fd_set *writefds, fd_set *exceptfds, DWORD ms); + bool test_and_set (int, fd_set *, fd_set *, fd_set *); + int poll (fd_set *, fd_set *, fd_set *); + wait_states wait (fd_set *, fd_set *, fd_set *, DWORD); void cleanup (); void destroy (); diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc index 187ea52fd..ba3221cc9 100644 --- a/winsup/cygwin/thread.cc +++ b/winsup/cygwin/thread.cc @@ -1778,7 +1778,7 @@ pthread_mutex::unlock () { owner = (pthread_t) _unlocked_mutex; #ifdef DEBUGGING - tid = NULL; + tid = 0; // thread-id #endif if (InterlockedDecrement ((long *) &lock_counter)) ::SetEvent (win32_obj_id); // Another thread is waiting @@ -1905,7 +1905,7 @@ pthread_spinlock::unlock () { owner = (pthread_t) _unlocked_mutex; #ifdef DEBUGGING - tid = NULL; + tid = 0; // thread-id #endif InterlockedExchange ((long *) &lock_counter, 0); ::SetEvent (win32_obj_id);