diff options
author | Christopher Faylor <me@cgf.cx> | 2002-01-29 05:02:03 +0300 |
---|---|---|
committer | Christopher Faylor <me@cgf.cx> | 2002-01-29 05:02:03 +0300 |
commit | 494a66d9c5799091ccefcfd2f3d22226b16f4c38 (patch) | |
tree | bbcd6f02ad3860e2cfb35b6065c2beec2bfd5e88 /winsup | |
parent | a489b37643af9b02d8a31b0e584713f90bbd9ba7 (diff) |
* external.cc (cygwin_internal): Initialize various internal settings if
required to allow use of some things from user loaded DLL.
(CW_STRACE_ON): Add new feature.
(CW_CYGWIN_PID_TO_WINPID): Ditto.
* pinfo.cc (set_myself): Call "strace.hello" to initiate possible strace
session.
(pinfo::init): Guard against dereferencing uninitialized myself.
* sigproc.cc (wait_sig): Call strace.hello() when __SIGTRACE "signal" received.
* strace.cc (strace::hello): New method.
* wincap.cc (wincapc::init): Avoid initializing if already initialized.
* wincap.h (wincapc::wincapc): New method.
* include/sys/cygwin.h: Add new CW_ enums. Kludge typedefs of {g,u}id_t if
required.
* strace.h (strace::hello): Declare new method.
Diffstat (limited to 'winsup')
-rw-r--r-- | winsup/cygwin/ChangeLog | 18 | ||||
-rw-r--r-- | winsup/cygwin/external.cc | 32 | ||||
-rw-r--r-- | winsup/cygwin/include/sys/cygwin.h | 10 | ||||
-rw-r--r-- | winsup/cygwin/include/sys/strace.h | 1 | ||||
-rw-r--r-- | winsup/cygwin/pinfo.cc | 27 | ||||
-rw-r--r-- | winsup/cygwin/sigproc.cc | 2 | ||||
-rw-r--r-- | winsup/cygwin/strace.cc | 25 | ||||
-rw-r--r-- | winsup/cygwin/wincap.cc | 3 | ||||
-rw-r--r-- | winsup/cygwin/wincap.h | 1 |
9 files changed, 94 insertions, 25 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 57f67d242..d119f7be8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,21 @@ +2002-01-28 Christopher Faylor <cgf@redhat.com> + + * external.cc (cygwin_internal): Initialize various internal settings + if required to allow use of some things from user loaded DLL. + (CW_STRACE_ON): Add new feature. + (CW_CYGWIN_PID_TO_WINPID): Ditto. + * pinfo.cc (set_myself): Call "strace.hello" to initiate possible + strace session. + (pinfo::init): Guard against dereferencing uninitialized myself. + * sigproc.cc (wait_sig): Call strace.hello() when __SIGTRACE "signal" + received. + * strace.cc (strace::hello): New method. + * wincap.cc (wincapc::init): Avoid initializing if already initialized. + * wincap.h (wincapc::wincapc): New method. + * include/sys/cygwin.h: Add new CW_ enums. Kludge typedefs of + {g,u}id_t if required. + * strace.h (strace::hello): Declare new method. + 2002-01-28 Earnie Boyd <earnie@users.sf.net> * include/sys/strace.h (_STRACE_ON): Define. diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 1589e92a1..8a9f3bf9b 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -26,6 +26,8 @@ details. */ #include "path.h" #include "dtable.h" #include "cygheap.h" +#include "wincap.h" +#include "heap.h" static external_pinfo * fillout_pinfo (pid_t pid, int winpid) @@ -121,6 +123,16 @@ cygwin_internal (cygwin_getinfo_types t, ...) { va_list arg; va_start (arg, t); + if (t != CW_USER_DATA) + { + wincap.init (); + if (!myself) + { + memory_init (); + malloc_init (); + set_myself (1); + } + } switch (t) { @@ -194,6 +206,26 @@ cygwin_internal (cygwin_getinfo_types t, ...) # undef cr } + case CW_STRACE_ON: + { + pid_t pid = va_arg (arg, pid_t); + pinfo p (pid); + if (p) + { + sig_send (p, __SIGSTRACE); + return 0; + } + else + { + set_errno (ESRCH); + return (DWORD) -1; + } + } + case CW_CYGWIN_PID_TO_WINPID: + { + pinfo p (va_arg (arg, pid_t)); + return p ? p->dwProcessId : 0; + } default: return (DWORD) -1; } diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index a4a8cf699..b8add0efe 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -66,7 +66,10 @@ typedef enum CW_INIT_EXCEPTIONS, CW_GET_CYGDRIVE_INFO, CW_SET_CYGWIN_REGISTRY_NAME, - CW_GET_CYGWIN_REGISTRY_NAME + CW_GET_CYGWIN_REGISTRY_NAME, + CW_STRACE_ON, + CW_STRACE_OFF, + CW_CYGWIN_PID_TO_WINPID } cygwin_getinfo_types; #define CW_NEXTPID 0x80000000 // or with pid to get next one @@ -205,6 +208,11 @@ extern int cygwin_attach_handle_to_fd (char *, int, HANDLE, mode_t, DWORD); #define TTY_CONSOLE 0x40000000 +#ifndef _SYS_TYPES_H +typedef short uid_t; +typedef short gid_t; +#endif + struct external_pinfo { pid_t pid; diff --git a/winsup/cygwin/include/sys/strace.h b/winsup/cygwin/include/sys/strace.h index 7b0e1a2cc..8039c1838 100644 --- a/winsup/cygwin/include/sys/strace.h +++ b/winsup/cygwin/include/sys/strace.h @@ -44,6 +44,7 @@ public: int lmicrosec; int execing; strace() : version(1) {} + void hello (); void prntf (unsigned, const char *func, const char *, ...) /*__attribute__ ((regparm(3)))*/; void vprntf (unsigned, const char *func, const char *, va_list ap) /*__attribute__ ((regparm(3)))*/; void wm (int message, int word, int lon) __attribute__ ((regparm(3))); diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 43e3c5aae..fb6f2fd41 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -62,33 +62,14 @@ set_myself (pid_t pid, HANDLE h) myself->process_state |= PID_IN_USE; myself->start_time = time (NULL); /* Register our starting time. */ - char buf[30]; - __small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR, - &strace.active); - OutputDebugString (buf); - (void) GetModuleFileName (NULL, myself->progname, sizeof(myself->progname)); - if (strace.active) - { - strace.prntf (1, NULL, "**********************************************"); - strace.prntf (1, NULL, "Program name: %s (%d)", myself->progname, myself->pid); - strace.prntf (1, NULL, "App version: %d.%d, api: %d.%d", - user_data->dll_major, user_data->dll_minor, - user_data->api_major, user_data->api_minor); - strace.prntf (1, NULL, "DLL version: %d.%d, api: %d.%d", - cygwin_version.dll_major, cygwin_version.dll_minor, - cygwin_version.api_major, cygwin_version.api_minor); - strace.prntf (1, NULL, "DLL build: %s", cygwin_version.dll_build_date); - strace.prntf (1, NULL, "OS version: Windows %s", wincap.osname ()); - strace.prntf (1, NULL, "**********************************************"); - } - + strace.hello (); return; } /* Initialize the process table entry for the current task. - This is not called for fork'd tasks, only exec'd ones. */ + This is not called for forked tasks, only execed ones. */ void __stdcall pinfo_init (char **envp, int envc) { @@ -136,7 +117,7 @@ _pinfo::exit (UINT n, bool norecord) void pinfo::init (pid_t n, DWORD flag, HANDLE in_h) { - if (n == myself->pid) + if (myself && n == myself->pid) { procinfo = myself; destroy = 0; @@ -276,7 +257,7 @@ a cygwin pid.</para> extern "C" pid_t cygwin_winpid_to_pid (int winpid) { - pinfo p (winpid); + pinfo p (cygwin_pid (winpid)); if (p) return p->pid; diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc index bfe5f9901..2cac0a006 100644 --- a/winsup/cygwin/sigproc.cc +++ b/winsup/cygwin/sigproc.cc @@ -1184,7 +1184,7 @@ wait_sig (VOID *) /* Internal signal to force a flush of strace data to disk. */ case __SIGSTRACE: - // proc_strace (); // Dump cached strace.prntf stuff. + strace.hello (); break; /* A normal UNIX signal */ diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index b7e0a2a32..993bfe1ef 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -17,6 +17,8 @@ details. */ #include "sync.h" #include "sigproc.h" #include "pinfo.h" +#include "perprocess.h" +#include "cygwin_version.h" #define PROTECT(x) x[sizeof(x)-1] = 0 #define CHECK(x) if (x[sizeof(x)-1] != 0) { small_printf("array bound exceeded %d\n", __LINE__); ExitProcess(1); } @@ -28,6 +30,29 @@ class NO_COPY strace strace; #ifndef NOSTRACE +void +strace::hello() +{ + char buf[30]; + __small_sprintf (buf, "cYg%8x %x", _STRACE_INTERFACE_ACTIVATE_ADDR, &active); + OutputDebugString (buf); + + if (active) + { + prntf (1, NULL, "**********************************************"); + prntf (1, NULL, "Program name: %s (%d)", myself->progname, myself->pid); + prntf (1, NULL, "App version: %d.%d, api: %d.%d", + user_data->dll_major, user_data->dll_minor, + user_data->api_major, user_data->api_minor); + prntf (1, NULL, "DLL version: %d.%d, api: %d.%d", + cygwin_version.dll_major, cygwin_version.dll_minor, + cygwin_version.api_major, cygwin_version.api_minor); + prntf (1, NULL, "DLL build: %s", cygwin_version.dll_build_date); + prntf (1, NULL, "OS version: Windows %s", wincap.osname ()); + prntf (1, NULL, "**********************************************"); + } +} + int strace::microseconds() { diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 14211a5e8..dc4a8d266 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -414,6 +414,9 @@ wincapc::init () { const char *os; + if (caps) + return; // already initialized + memset (&version, 0, sizeof version); version.dwOSVersionInfoSize = sizeof version; GetVersionEx (&version); diff --git a/winsup/cygwin/wincap.h b/winsup/cygwin/wincap.h index a3cd3176c..ad9238611 100644 --- a/winsup/cygwin/wincap.h +++ b/winsup/cygwin/wincap.h @@ -55,6 +55,7 @@ class wincapc void *caps; public: + wincapc (): caps (NULL) {} void init (); void set_chunksize (DWORD nchunksize); |