summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorscottc <scottc>2002-07-14 19:26:23 +0000
committerscottc <scottc>2002-07-14 19:26:23 +0000
commit05878213f2b9b7bf548084f6be3594b09bf06b5d (patch)
treeb3007d12484f49c1d78619b77aec073a9e4cb949
parentfcd4817af1d25a826e6673e34ad92c77ad24c4db (diff)
downloadgdb-05878213f2b9b7bf548084f6be3594b09bf06b5d.tar.gz
Merged changes from HEAD
-rw-r--r--winsup/cygwin/ChangeLog32
-rw-r--r--winsup/cygwin/Makefile.in4
-rw-r--r--winsup/cygwin/dcrt0.cc7
-rw-r--r--winsup/cygwin/debug.cc21
-rw-r--r--winsup/cygwin/debug.h2
-rw-r--r--winsup/cygwin/exceptions.cc2
-rw-r--r--winsup/cygwin/fhandler.cc17
-rw-r--r--winsup/cygwin/shared.cc2
8 files changed, 58 insertions, 29 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 07859fb257c..b8ca8cdc8b7 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,37 @@
2002-07-14 Christopher Faylor <cgf@redhat.com>
+ * dcrt0.cc (dll_crt0_1): Move debug_init call back to here. Avoid a
+ compiler warning.
+ * shared.cc (memory_init): Remove debug_init call.
+ * debug.h (handle_list): Change "clexec" to "inherited".
+ * debug.cc: Remove a spurious declaration.
+ (setclexec): Conditionalize away since it is currently unused.
+ (add_handle): Use inherited field rather than clexec.
+ (debug_fixup_after_fork_exec): Ditto. Move debugging output to
+ delete_handle.
+ (delete_handle): Add debugging output.
+ * fhandler.cc (fhandler_base::set_inheritance): Don't bother setting
+ inheritance in debugging table since the handle was never protected
+ anyway.
+ (fhandler_base::fork_fixup): Ditto.
+
+ * exceptions.cc (debugger_command): Revert.
+
+2002-07-14 Conrad Scott <conrad.scott@dsl.pipex.com>
+
+ * debug.cc (clexec): Add missing `hl = hl->next'.
+
+2002-07-14 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in (cygrun.exe): Add a -lcygwin on the end.
+
+2002-07-14 Christopher Faylor <cgf@redhat.com>
+
+ * Makefile.in (cygserver.exe): Add -lstdc++.
+ (cygrun.exe): Move -lgcc last.
+
+2002-07-14 Christopher Faylor <cgf@redhat.com>
+
* woutsup.h (system_printf): Remove extraneous semicolon from macro
definition.
diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in
index 96982e1a386..2675f8f4d15 100644
--- a/winsup/cygwin/Makefile.in
+++ b/winsup/cygwin/Makefile.in
@@ -310,7 +310,7 @@ winver_stamp: mkvers.sh include/cygwin/version.h winver.rc $(DLL_OFILES)
cygrun.exe : cygrun.o $(LIB_NAME) $(w32api_lib)/libuser32.a \
$(w32api_lib)/libshell32.a $(w32api_lib)/libkernel32.a
- $(CC) -nodefaultlibs -o $@ -lgcc $^
+ $(CC) -nodefaultlibs -o $@ $^ -lgcc -lcygwin
cygserver_transport_outside.o: cygserver_transport.cc
$(COMPILE_CXX) -D__OUTSIDE_CYGWIN__ -o $@ $<
@@ -325,7 +325,7 @@ cygserver_client_outside.o: cygserver_client.cc
$(COMPILE_CXX) -D__OUTSIDE_CYGWIN__ -o $@ $<
cygserver.exe: cygserver.o cygserver_shm.o cygserver_transport_outside.o cygserver_transport_pipes_outside.o cygserver_transport_sockets_outside.o cygserver_client_outside.o cygserver_process.o threaded_queue.o wincap.o version.o smallprint.o
- $(CXX) -o $@ $^
+ $(CXX) -o $@ $^ -lstdc++
#ifdef VERBOSE
# $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,3,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS)
#else
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 0ec84948f41..ed65d630459 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -631,9 +631,14 @@ dll_crt0_1 ()
/* Initialize the cygwin subsystem if this is the first process,
or attach to shared data structures if it's already running. */
memory_init ();
+
ProtectHandle (hMainProc);
ProtectHandle (hMainThread);
+ /* Initialize debug muto, if DLL is built with --enable-debugging.
+ Need to do this before any helper threads start. */
+ debug_init ();
+
cygheap->fdtab.vfork_child_fixup ();
(void) SetErrorMode (SEM_FAILCRITICALERRORS);
@@ -803,7 +808,7 @@ initial_env ()
len = GetModuleFileName (NULL, buf1, MAX_PATH);
char *p = strchr (buf, '=');
if (!p)
- p = "gdb.exe -nw";
+ p = (char *) "gdb.exe -nw";
else
*p++ = '\0';
if (strstr (buf1, buf))
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index fa01773843d..f918b87c008 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -173,8 +173,6 @@ threadname (DWORD tid, int lockit)
#include <stdlib.h>
#define NFREEH (sizeof (cygheap->debug.freeh) / sizeof (cygheap->debug.freeh[0]))
-void debug_init ();
-
class lock_debug
{
static muto *locker;
@@ -223,16 +221,19 @@ out:
return hl;
}
+#ifdef DEBUGGING_AND_FDS_PROTECTED
void
-setclexec (HANDLE oh, HANDLE nh, bool setit)
+setclexec (HANDLE oh, HANDLE nh, bool not_inheriting)
{
handle_list *hl = find_handle (oh);
if (hl)
{
- hl->clexec = setit;
+ hl = hl->next;
+ hl->inherited = !not_inheriting;
hl->h = nh;
}
}
+#endif
/* Create a new handle record */
static handle_list * __stdcall
@@ -287,11 +288,11 @@ add_handle (const char *func, int ln, HANDLE h, const char *name, bool inh)
hl->func = func;
hl->ln = ln;
hl->next = NULL;
- hl->clexec = !inh;
+ hl->inherited = inh;
hl->pid = GetCurrentProcessId ();
cygheap->debug.endh->next = hl;
cygheap->debug.endh = hl;
- debug_printf ("protecting handle '%s', clexec flag %d", hl->name, hl->clexec);
+ debug_printf ("protecting handle '%s', inherited flag %d", hl->name, hl->inherited);
return;
}
@@ -300,6 +301,7 @@ static void __stdcall
delete_handle (handle_list *hl)
{
handle_list *hnuke = hl->next;
+ debug_printf ("nuking handle '%s'", hnuke->name);
hl->next = hl->next->next;
if (hnuke->allocated)
free (hnuke);
@@ -313,13 +315,10 @@ debug_fixup_after_fork_exec ()
/* No lock needed at this point */
handle_list *hl;
for (hl = &cygheap->debug.starth; hl->next != NULL; /* nothing */)
- if (!hl->next->clexec)
+ if (hl->next->inherited)
hl = hl->next;
else
- {
- debug_printf ("nuking handle '%s'", hl->next->name);
- delete_handle (hl); // removes hl->next
- }
+ delete_handle (hl); // removes hl->next
}
static bool __stdcall
diff --git a/winsup/cygwin/debug.h b/winsup/cygwin/debug.h
index 6abdcb0e23a..719641f6fe3 100644
--- a/winsup/cygwin/debug.h
+++ b/winsup/cygwin/debug.h
@@ -92,7 +92,7 @@ struct handle_list
const char *name;
const char *func;
int ln;
- bool clexec;
+ bool inherited;
DWORD pid;
struct handle_list *next;
};
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index cd0bb258687..1eb3fbac20c 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -25,7 +25,7 @@ details. */
#define CALL_HANDLER_RETRY 20
-char debugger_command[2 * MAX_PATH + 20] = "dumper.exe %s";
+char debugger_command[2 * MAX_PATH + 20];
extern "C" {
static int handle_exceptions (EXCEPTION_RECORD *, void *, CONTEXT *, void *);
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index e0f065b1467..591bc72f50c 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -1067,7 +1067,7 @@ fhandler_dev_null::dump (void)
void
fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
{
-#ifdef DEBUGGING
+#ifdef DEBUGGING_AND_FDS_PROTECTED
HANDLE oh = h;
#endif
/* Note that we could use SetHandleInformation here but it is not available
@@ -1078,7 +1078,7 @@ fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
if (!DuplicateHandle (hMainProc, h, hMainProc, &h, 0, !not_inheriting,
DUPLICATE_SAME_ACCESS | DUPLICATE_CLOSE_SOURCE))
debug_printf ("DuplicateHandle failed, %E");
-#ifdef DEBUGGING
+#ifdef DEBUGGING_AND_FDS_PROTECTED
if (h)
setclexec (oh, h, not_inheriting);
#endif
@@ -1087,21 +1087,16 @@ fhandler_base::set_inheritance (HANDLE &h, int not_inheriting)
void
fhandler_base::fork_fixup (HANDLE parent, HANDLE &h, const char *name)
{
-#ifdef DEBUGGING
- HANDLE oh = h;
-#endif
if (/* !is_socket () && */ !get_close_on_exec ())
debug_printf ("handle %p already opened", h);
else if (!DuplicateHandle (parent, h, hMainProc, &h, 0, !get_close_on_exec (),
DUPLICATE_SAME_ACCESS))
system_printf ("%s - %E, handle %s<%p>", get_name (), name, h);
-#ifdef DEBUGGING
+#ifdef DEBUGGING_AND_FDS_PROTECTED
+ else if (get_close_on_exec ())
+ ProtectHandle (h); /* would have to be fancier than this */
else
- {
- debug_printf ("%s success - oldh %p, h %p", get_name (), oh, h);
- // someday, maybe ProtectHandle2 (h, name);
- setclexec (oh, h, !get_close_on_exec ());
- }
+ /* ProtectHandleINH (h) */; /* Should already be protected */
#endif
}
diff --git a/winsup/cygwin/shared.cc b/winsup/cygwin/shared.cc
index 2c3ba8da6b2..dd8e67c6342 100644
--- a/winsup/cygwin/shared.cc
+++ b/winsup/cygwin/shared.cc
@@ -143,8 +143,6 @@ memory_init ()
cygheap->user.set_name (user_name);
}
- debug_init ();
-
cygheap->shared_h = shared_h;
ProtectHandleINH (cygheap->shared_h);