* 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.
This commit is contained in:
parent
a489b37643
commit
494a66d9c5
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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)));
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -55,6 +55,7 @@ class wincapc
|
|||
void *caps;
|
||||
|
||||
public:
|
||||
wincapc (): caps (NULL) {}
|
||||
void init ();
|
||||
|
||||
void set_chunksize (DWORD nchunksize);
|
||||
|
|
Loading…
Reference in New Issue