OSDN Git Service

* pinfo.cc (pinfo_basic): New class.
authorcgf <cgf>
Fri, 19 Dec 2008 19:09:48 +0000 (19:09 +0000)
committercgf <cgf>
Fri, 19 Dec 2008 19:09:48 +0000 (19:09 +0000)
(pinfo_basic::pinfo_basic): Define constructor for new class.
(myself): Initialize from myself_initial.
(set_myself): Set pid and progname from already myself_initial.
* strace.cc (strace::strace): Split apart strace::hello.  Send notification to
strace as early as possible.
(strace::hello): Just send clause which describes the current process.  This
can now be preceded by early initialization strace output.
* include/sys/strace.h (strace::strace): Declare new constructor.

winsup/cygwin/ChangeLog
winsup/cygwin/include/sys/strace.h
winsup/cygwin/pinfo.cc
winsup/cygwin/strace.cc

index 3ee453f..f9aec8b 100644 (file)
@@ -1,3 +1,15 @@
+2008-12-19  Christopher Faylor  <me+cygwin@cgf.cx>
+
+       * pinfo.cc (pinfo_basic): New class.
+       (pinfo_basic::pinfo_basic): Define constructor for new class.
+       (myself): Initialize from myself_initial.
+       (set_myself): Set pid and progname from already myself_initial.
+       * strace.cc (strace::strace): Split apart strace::hello.  Send
+       notification to strace as early as possible.
+       (strace::hello): Just send clause which describes the current process.
+       This can now be preceded by early initialization strace output.
+       * include/sys/strace.h (strace::strace): Declare new constructor.
+
 2008-12-19  Christian Franke  <franke@computer.org>
 
        * fhandler_registry.cc (perf_data_files): New table.
index 9b9da17..4685e5f 100644 (file)
@@ -39,6 +39,7 @@ class strace
   void write (unsigned category, const char *buf, int count);
   unsigned char _active;
 public:
+  strace ();
   int microseconds ();
   int version;
   int lmicrosec;
index 3cfa82a..d5b3bc0 100644 (file)
@@ -30,9 +30,21 @@ details. */
 #include "tls_pbuf.h"
 #include "child_info.h"
 
-static char NO_COPY pinfo_dummy[sizeof (_pinfo)] = {0};
+class pinfo_basic: public _pinfo
+{
+public:
+  pinfo_basic();
+};
 
-pinfo NO_COPY myself ((_pinfo *)&pinfo_dummy); // Avoid myself != NULL checks
+pinfo_basic::pinfo_basic()
+{
+  pid = dwProcessId = GetCurrentProcessId ();
+  GetModuleFileName (NULL, progname, sizeof (progname));
+}
+
+pinfo_basic myself_initial NO_COPY;
+
+pinfo NO_COPY myself (static_cast<_pinfo *> (&myself_initial));        // Avoid myself != NULL checks
 
 bool is_toplevel_proc;
 
@@ -43,12 +55,12 @@ void __stdcall
 set_myself (HANDLE h)
 {
   if (!h)
-    cygheap->pid = cygwin_pid (GetCurrentProcessId ());
+    cygheap->pid = cygwin_pid (myself_initial.pid);
+
   myself.init (cygheap->pid, PID_IN_USE, h ?: INVALID_HANDLE_VALUE);
   myself->process_state |= PID_IN_USE;
-  myself->dwProcessId = GetCurrentProcessId ();
-
-  GetModuleFileName (NULL, myself->progname, sizeof (myself->progname));
+  myself->dwProcessId = myself_initial.pid;
+  strcpy (myself->progname, myself_initial.progname);
   strace.hello ();
   debug_printf ("myself->dwProcessId %u", myself->dwProcessId);
   if (h)
index 4672615..b9af9df 100644 (file)
@@ -31,16 +31,19 @@ class strace NO_COPY strace;
 
 #ifndef NOSTRACE
 
+strace::strace ()
+{
+  if (!dynamically_loaded && !_active && being_debugged ())
+    {
+      char buf[30];
+      __small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR, &_active);
+      OutputDebugString (buf);
+    }
+}
+
 void
 strace::hello ()
 {
-  if (_active || !being_debugged ())
-    return;
-
-  char buf[30];
-  __small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR, &_active);
-  OutputDebugString (buf);
-
   if (active ())
     {
       char pidbuf[40];