* sigproc.cc (sigproc_terminate): Don't close sendsig handle when execing since

we're not closing what we think we're closing.
(sig_send): Improve debugging when exiting due to no_signals_available.
* wincap.h (wincaps::cant_debug_dll_entry): New element.
* wincap.cc: Implement above element throughout.
* dcrt0.cc (initial_env): Accommodate changes necessary to allow initial
debugging for systems which do not allow debugging in dll_entry.
(dll_crt0_0): Add initial_env call back here.
* Makefile.in (install-man): Use mandir as target for installation.
* include/cygwin/version.h: Bump DLL minor number to 7 (should have been done
earlier).
This commit is contained in:
Christopher Faylor 2004-01-19 23:03:43 +00:00
parent 403f752cb2
commit d795119cbe
8 changed files with 99 additions and 45 deletions

View File

@ -1,3 +1,23 @@
2004-01-19 Christopher Faylor <cgf@redhat.com>
* sigproc.cc (sigproc_terminate): Don't close sendsig handle when
execing since we're not closing what we think we're closing.
(sig_send): Improve debugging when exiting due to no_signals_available.
* wincap.h (wincaps::cant_debug_dll_entry): New element.
* wincap.cc: Implement above element throughout.
* dcrt0.cc (initial_env): Accommodate changes necessary to allow
initial debugging for systems which do not allow debugging in
dll_entry.
(dll_crt0_0): Add initial_env call back here.
* Makefile.in (install-man): Use mandir as target for installation.
2004-01-19 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump DLL minor number to 7 (should have been
done earlier).
2004-01-19 Christopher Faylor <cgf@redhat.com>
* cygwin/include/signal.h: Add copyright notice.

View File

@ -25,6 +25,7 @@ program_transform_name:=@program_transform_name@
exec_prefix:=@exec_prefix@
bindir:=@bindir@
libdir:=@libdir@
mandir:=@mandir@
ifeq ($(target_alias),$(host_alias))
ifeq ($(build_alias),$(host_alias))
tooldir:=$(exec_prefix)
@ -298,16 +299,16 @@ install-headers:
install-man:
cd $(srcdir); \
for i in `find . -type f -name '*.2'`; do \
$(INSTALL_DATA) $$i $(tooldir)/man/man2/`basename $$i` ; \
$(INSTALL_DATA) $$i $(mandir)/man2/`basename $$i` ; \
done; \
for i in `find . -type f -name '*.3'`; do \
$(INSTALL_DATA) $$i $(tooldir)/man/man3/`basename $$i` ; \
$(INSTALL_DATA) $$i $(mandir)/man3/`basename $$i` ; \
done; \
for i in `find . -type f -name '*.5'`; do \
$(INSTALL_DATA) $$i $(tooldir)/man/man5/`basename $$i` ; \
$(INSTALL_DATA) $$i $(mandir)/man5/`basename $$i` ; \
done; \
for i in `find . -type f -name '*.7'`; do \
$(INSTALL_DATA) $$i $(tooldir)/man/man7/`basename $$i` ; \
$(INSTALL_DATA) $$i $(mandir)/man7/`basename $$i` ; \
done
install_target:

View File

@ -531,11 +531,20 @@ break_here ()
#endif
static void
initial_env ()
initial_env (bool first)
{
char buf[CYG_MAX_PATH + 1];
if (!first)
/* nothing */;
else if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
_cygwin_testing = 1;
#ifdef DEBUGGING
DWORD len;
static bool NO_COPY did_debugging_stuff;
if (did_debugging_stuff || (first && wincap.cant_debug_dll_entry ()))
return;
did_debugging_stuff = true;
if (GetEnvironmentVariable ("CYGWIN_SLEEP", buf, sizeof (buf) - 1))
{
DWORD ms = atoi (buf);
@ -569,14 +578,13 @@ initial_env ()
}
#endif
if (GetEnvironmentVariable ("CYGWIN_TESTING", buf, sizeof (buf) - 1))
_cygwin_testing = 1;
}
void __stdcall
dll_crt0_0 ()
{
wincap.init ();
initial_env (true);
char zeros[sizeof (child_proc_info->zero)] = {0};
@ -722,7 +730,7 @@ dll_crt0_1 (char *)
/* FIXME: Verify forked children get their exception handler set up ok. */
exception_list cygwin_except_entry;
initial_env ();
initial_env (false);
check_sanity_and_sync (user_data);
malloc_init ();

View File

@ -42,7 +42,7 @@ details. */
changes to the DLL and is mainly informative in nature. */
#define CYGWIN_VERSION_DLL_MAJOR 1005
#define CYGWIN_VERSION_DLL_MINOR 6
#define CYGWIN_VERSION_DLL_MINOR 7
/* Major numbers before CYGWIN_VERSION_DLL_EPOCH are
incompatible. */

View File

@ -28,9 +28,6 @@ static void WINAPI
threadfunc_fe (VOID *arg)
{
_threadinfo::call ((DWORD (*) (void *, void *)) (((char **) _tlsbase)[OLDFUNC_OFFSET]), arg);
// void *threadfunc = (void *) TlsGetValue (tls_func);
// TlsFree (tls_func);
// _threadinfo::call ((DWORD (*) (void *, void *)) (threadfunc), arg);
}
static DWORD WINAPI
@ -39,6 +36,25 @@ calibration_thread (VOID *arg)
ExitThread (0);
}
/* We need to know where the OS stores the address of the thread function
on the stack so that we can intercept the call and insert some tls
stuff on the stack. This function starts a known calibration thread.
When it starts, a call will be made to dll_entry which will call munge_threadfunc
looking for the calibration thread offset on the stack. This offset will
be stored and used by all executing cygwin processes. */
void
prime_threads ()
{
if (!threadfunc_ix)
{
DWORD id;
search_for = (char *) calibration_thread;
sync_startup = CreateThread (NULL, 0, calibration_thread, 0, 0, &id);
}
}
/* If possible, redirect the thread entry point to a cygwin routine which
adds tls stuff to the stack. */
static void
munge_threadfunc (HANDLE cygwin_hmodule)
{
@ -71,18 +87,6 @@ foundit:
}
}
void
prime_threads ()
{
// tls_func = TlsAlloc ();
if (!threadfunc_ix)
{
DWORD id;
search_for = (char *) calibration_thread;
sync_startup = CreateThread (NULL, 0, calibration_thread, 0, 0, &id);
}
}
extern void __stdcall dll_crt0_0 ();
extern "C" int WINAPI
@ -93,15 +97,12 @@ dll_entry (HANDLE h, DWORD reason, void *static_load)
case DLL_PROCESS_ATTACH:
prime_threads ();
dynamically_loaded = (static_load == NULL);
// __cygwin_user_data.impure_ptr = &_my_tls.local_clib;
dll_crt0_0 ();
// small_printf ("%u, %p, %p\n", cygwin_pid (GetCurrentProcessId ()), _tlstop, _tlsbase);
break;
case DLL_PROCESS_DETACH:
break;
case DLL_THREAD_ATTACH:
munge_threadfunc (h);
// small_printf ("%u, %p, %p\n", cygwin_pid (GetCurrentProcessId ()), _tlstop, _tlsbase);
break;
case DLL_THREAD_DETACH:
_my_tls.remove (0);

View File

@ -633,6 +633,7 @@ sigproc_init ()
void __stdcall
sigproc_terminate (void)
{
extern HANDLE hExeced;
hwait_sig = NULL;
if (myself->sendsig == INVALID_HANDLE_VALUE)
@ -642,9 +643,12 @@ sigproc_terminate (void)
sigproc_printf ("entering");
// finished with anything it is doing
ForceCloseHandle (sigcomplete_main);
HANDLE sendsig = myself->sendsig;
myself->sendsig = INVALID_HANDLE_VALUE;
CloseHandle (sendsig);
if (!hExeced)
{
HANDLE sendsig = myself->sendsig;
myself->sendsig = INVALID_HANDLE_VALUE;
CloseHandle (sendsig);
}
}
proc_terminate (); // Terminate process handling thread
@ -680,7 +684,11 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
else
{
if (no_signals_available ())
goto out; // Either exiting or not yet initializing
{
sigproc_printf ("hwait_sig %p, myself->sendsig %p, exit_state %d",
hwait_sig, myself->sendsig, exit_state);
goto out; // Either exiting or not yet initializing
}
if (wait_sig_inited)
wait_for_sigthread ();
wait_for_completion = p != myself_nowait && _my_tls.isinitialized ();
@ -697,8 +705,6 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
goto out;
}
sigproc_printf ("pid %d, signal %d, its_me %d", p->pid, si.si_signo, its_me);
if (its_me)
{
sendsig = myself->sendsig;
@ -727,6 +733,8 @@ sig_send (_pinfo *p, siginfo_t& si, _threadinfo *tls)
pack.wakeup = NULL;
}
sigproc_printf ("sendsig %p, pid %d, signal %d, its_me %d", sendsig, p->pid, si.si_signo, its_me);
sigset_t pending;
if (!its_me)
pack.mask = NULL;
@ -1104,6 +1112,8 @@ wait_sig (VOID *self)
exception_list el;
_my_tls.init_threadlist_exceptions (&el);
debug_printf ("entering ReadFile loop, readsig %p, myself->sendsig %p",
readsig, myself->sendsig);
for (;;)
{

View File

@ -51,7 +51,8 @@ static NO_COPY wincaps wincap_unknown = {
needs_memory_protection:false,
pty_needs_alloc_console:false,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:false
};
static NO_COPY wincaps wincap_95 = {
@ -94,7 +95,8 @@ static NO_COPY wincaps wincap_95 = {
needs_memory_protection:false,
pty_needs_alloc_console:false,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:true
};
static NO_COPY wincaps wincap_95osr2 = {
@ -137,7 +139,8 @@ static NO_COPY wincaps wincap_95osr2 = {
needs_memory_protection:false,
pty_needs_alloc_console:false,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:true
};
static NO_COPY wincaps wincap_98 = {
@ -180,7 +183,8 @@ static NO_COPY wincaps wincap_98 = {
needs_memory_protection:false,
pty_needs_alloc_console:false,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:true
};
static NO_COPY wincaps wincap_98se = {
@ -223,7 +227,8 @@ static NO_COPY wincaps wincap_98se = {
needs_memory_protection:false,
pty_needs_alloc_console:false,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:true
};
static NO_COPY wincaps wincap_me = {
@ -266,7 +271,8 @@ static NO_COPY wincaps wincap_me = {
needs_memory_protection:false,
pty_needs_alloc_console:false,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:true
};
static NO_COPY wincaps wincap_nt3 = {
@ -309,7 +315,8 @@ static NO_COPY wincaps wincap_nt3 = {
needs_memory_protection:true,
pty_needs_alloc_console:true,
has_terminal_services:false,
has_switch_to_thread:false
has_switch_to_thread:false,
cant_debug_dll_entry:false
};
static NO_COPY wincaps wincap_nt4 = {
@ -352,7 +359,8 @@ static NO_COPY wincaps wincap_nt4 = {
needs_memory_protection:true,
pty_needs_alloc_console:true,
has_terminal_services:false,
has_switch_to_thread:true
has_switch_to_thread:true,
cant_debug_dll_entry:false
};
static NO_COPY wincaps wincap_nt4sp4 = {
@ -395,7 +403,8 @@ static NO_COPY wincaps wincap_nt4sp4 = {
needs_memory_protection:true,
pty_needs_alloc_console:true,
has_terminal_services:false,
has_switch_to_thread:true
has_switch_to_thread:true,
cant_debug_dll_entry:false
};
static NO_COPY wincaps wincap_2000 = {
@ -438,7 +447,8 @@ static NO_COPY wincaps wincap_2000 = {
needs_memory_protection:true,
pty_needs_alloc_console:true,
has_terminal_services:true,
has_switch_to_thread:true
has_switch_to_thread:true,
cant_debug_dll_entry:false
};
static NO_COPY wincaps wincap_xp = {
@ -481,7 +491,8 @@ static NO_COPY wincaps wincap_xp = {
needs_memory_protection:true,
pty_needs_alloc_console:true,
has_terminal_services:true,
has_switch_to_thread:true
has_switch_to_thread:true,
cant_debug_dll_entry:false
};
static NO_COPY wincaps wincap_2003 = {
@ -524,7 +535,8 @@ static NO_COPY wincaps wincap_2003 = {
needs_memory_protection:true,
pty_needs_alloc_console:true,
has_terminal_services:true,
has_switch_to_thread:true
has_switch_to_thread:true,
cant_debug_dll_entry:false
};
wincapc wincap;

View File

@ -53,6 +53,7 @@ struct wincaps
unsigned pty_needs_alloc_console : 1;
unsigned has_terminal_services : 1;
unsigned has_switch_to_thread : 1;
unsigned cant_debug_dll_entry : 1;
};
class wincapc
@ -110,6 +111,7 @@ public:
bool IMPLEMENT (pty_needs_alloc_console)
bool IMPLEMENT (has_terminal_services)
bool IMPLEMENT (has_switch_to_thread)
bool IMPLEMENT (cant_debug_dll_entry)
#undef IMPLEMENT
};