aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog8
-rw-r--r--winsup/cygwin/cygwin.din1
-rw-r--r--winsup/cygwin/dtable.cc2
-rw-r--r--winsup/cygwin/errno.cc8
-rw-r--r--winsup/cygwin/fhandler.cc2
-rw-r--r--winsup/cygwin/fhandler_tty.cc12
-rw-r--r--winsup/cygwin/include/cygwin/version.h3
-rw-r--r--winsup/cygwin/include/sys/strace.h50
-rw-r--r--winsup/cygwin/localtime.c3
-rw-r--r--winsup/cygwin/pinfo.cc20
-rw-r--r--winsup/cygwin/sigproc.cc5
-rw-r--r--winsup/cygwin/strace.cc61
-rw-r--r--winsup/cygwin/window.cc2
-rw-r--r--winsup/cygwin/winsup.h3
14 files changed, 87 insertions, 93 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 04fdabf..4de0280 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+Tue Mar 7 00:29:34 2000 Christopher Faylor <cgf@cygnus.com>
+
+ Throughout use strace class in place of individual functions and
+ variables.
+ * cygwin.din: Eliminate _strace_wm.
+ * sigproc.cc (wait_sig): Temporarily add more debugging output.
+ * include/cygwin/version.h: Bump minor api to reflect export change.
+
Sun Mar 5 01:17:05 2000 Christopher Faylor <cgf@cygnus.com>
* exceptions.cc (call_handler): Streamline to use only one call to
diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din
index 33046bc..4abde7c 100644
--- a/winsup/cygwin/cygwin.din
+++ b/winsup/cygwin/cygwin.din
@@ -11,7 +11,6 @@ __swbuf
__vc__10pinfo_listi
@ALLOCA@
cygwin_stackdump
-_strace_wm
abort
_abort = abort
abs
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index d7a9ffe..385553a 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -142,9 +142,7 @@ hinfo::release (int fd)
{
if (!not_open (fd))
{
-MALLOC_CHECK;
delete (fds[fd]);
-MALLOC_CHECK;
fds[fd] = NULL;
}
}
diff --git a/winsup/cygwin/errno.cc b/winsup/cygwin/errno.cc
index 02c86cb..c54bdba 100644
--- a/winsup/cygwin/errno.cc
+++ b/winsup/cygwin/errno.cc
@@ -119,15 +119,15 @@ seterrno_from_win_error (const char *file, int line, int code)
if (errmap[i].w != 0)
{
- if (strace_active)
- strace_printf (_STRACE_SYSCALL, "%s:%d seterrno: %d (%s) -> %d",
+ if (strace.active)
+ strace.prntf (_STRACE_SYSCALL, "%s:%d seterrno: %d (%s) -> %d",
file, line, code, errmap[i].s, errmap[i].e);
set_errno (errmap[i].e);
}
else
{
- if (strace_active)
- strace_printf (_STRACE_SYSCALL, "%s:%d seterrno: unknown error %d", file, line, code);
+ if (strace.active)
+ strace.prntf (_STRACE_SYSCALL, "%s:%d seterrno: unknown error %d", file, line, code);
set_errno (EACCES);
}
}
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index f4335a2..c9a493f 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -491,7 +491,7 @@ fhandler_base::read (void *in_ptr, size_t in_len)
rpos_ += copied_chars;
#ifndef NOSTRACE
- if (strace_active)
+ if (strace.active)
{
char buf[16 * 6 + 1];
char *p = buf;
diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc
index 7ae872e..0e6a6ed 100644
--- a/winsup/cygwin/fhandler_tty.cc
+++ b/winsup/cygwin/fhandler_tty.cc
@@ -105,8 +105,8 @@ DWORD
fhandler_tty_common::__acquire_output_mutex (const char *fn, int ln,
DWORD ms)
{
- if (strace_active)
- strace_printf (_STRACE_TERMIOS, "%F (%d): tty output_mutex: waiting %d ms", fn, ln, ms);
+ if (strace.active)
+ strace.prntf (_STRACE_TERMIOS, "%F (%d): tty output_mutex: waiting %d ms", fn, ln, ms);
DWORD res = WaitForSingleObject (output_mutex, ms);
if (res == WAIT_OBJECT_0)
{
@@ -118,8 +118,8 @@ fhandler_tty_common::__acquire_output_mutex (const char *fn, int ln,
osi++;
#endif
}
- if (strace_active)
- strace_printf (_STRACE_TERMIOS, "%F (%d): tty output_mutex: acquired", fn, ln, res);
+ if (strace.active)
+ strace.prntf (_STRACE_TERMIOS, "%F (%d): tty output_mutex: acquired", fn, ln, res);
return res;
}
@@ -136,8 +136,8 @@ fhandler_tty_common::__release_output_mutex (const char *fn, int ln)
ostack[osi].ln = -ln;
#endif
}
- if (strace_active)
- strace_printf (_STRACE_TERMIOS, "%F (%d): tty output_mutex released", fn, ln);
+ if (strace.active)
+ strace.prntf (_STRACE_TERMIOS, "%F (%d): tty output_mutex released", fn, ln);
}
#define acquire_output_mutex(ms) \
diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h
index 8568d80..ad0bcc5 100644
--- a/winsup/cygwin/include/cygwin/version.h
+++ b/winsup/cygwin/include/cygwin/version.h
@@ -93,10 +93,11 @@ details. */
15: Export glob
16: Export cygwin_stackdump
17: Export fast math stuff
+ 18: Stop exporting _strace_wm
*/
#define CYGWIN_VERSION_API_MAJOR 0
-#define CYGWIN_VERSION_API_MINOR 17
+#define CYGWIN_VERSION_API_MINOR 18
/* There is also a compatibity version number associated with the
shared memory regions. It is incremented when incompatible
diff --git a/winsup/cygwin/include/sys/strace.h b/winsup/cygwin/include/sys/strace.h
index 7ee5099..f9db05b 100644
--- a/winsup/cygwin/include/sys/strace.h
+++ b/winsup/cygwin/include/sys/strace.h
@@ -19,11 +19,25 @@
#ifndef _SYS_STRACE_H
#define _SYS_STRACE_H
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define _STRACE_INTERFACE_ACTIVATE_ADDR -1
+#include <stdarg.h>
+
+class strace
+{
+ friend void __system_printf (const char *fmt, ...);
+ int microseconds ();
+ int vsprntf (char *buf, const char *infmt, va_list ap);
+ void write (unsigned category, const char *buf, int count);
+public:
+ int version;
+ int active;
+ int lmicrosec;
+ strace() : version(1) {}
+ void prntf (unsigned category, const char *fmt,...);
+ void wm (int message, int word, int lon);
+};
+
+#define _STRACE_INTERFACE_ACTIVATE_ADDR -1
+#define _STRACE_INTERFACE_ACTIVATE_ADDR1 -2
/* Bitmasks of tracing messages to print. */
@@ -47,33 +61,23 @@ extern "C" {
#define _STRACE_THREAD 0x40000 // thread-locking calls
#define _STRACE_NOTALL 0x80000 // don't include if _STRACE_ALL
-void small_printf (const char *, ...);
+extern "C" void small_printf (const char *, ...);
-#ifdef NOSTRACE
-#define strace_printf(category, fmt...) 0
-#define strace_printf_wrap(category, fmt...) 0
-#define strace_printf_wrap1(category, fmt...) 0
-#define strace_wm(category, msg...) 0
-#else
+#ifndef NOSTRACE
/* Output message to strace log */
-void strace_printf (unsigned, const char *, ...);
-void __system_printf (const char *, ...);
-
#define system_printf(fmt, args...) \
__system_printf("%F: " fmt, __PRETTY_FUNCTION__ , ## args)
-void _strace_wm (int __message, int __word, int __lon);
-
#define strace_printf_wrap(what, fmt, args...) \
((void) ({\
- if (strace_active) \
- strace_printf(_STRACE_ ## what, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
+ if (strace.active) \
+ strace.prntf(_STRACE_ ## what, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
0; \
}))
#define strace_printf_wrap1(what, fmt, args...) \
((void) ({\
- if (strace_active) \
- strace_printf((_STRACE_ ## what) | _STRACE_NOTALL, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
+ if (strace.active) \
+ strace.prntf((_STRACE_ ## what) | _STRACE_NOTALL, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
0; \
}))
#endif /*NOSTRACE*/
@@ -89,8 +93,4 @@ void _strace_wm (int __message, int __word, int __lon);
#define malloc_printf(fmt, args...) strace_printf_wrap1(MALLOC, fmt , ## args)
#define thread_printf(fmt, args...) strace_printf_wrap1(THREAD, fmt , ## args)
-#ifdef __cplusplus
-}
-#endif
-
#endif /* _SYS_STRACE_H */
diff --git a/winsup/cygwin/localtime.c b/winsup/cygwin/localtime.c
index 47efb16..50747df 100644
--- a/winsup/cygwin/localtime.c
+++ b/winsup/cygwin/localtime.c
@@ -7,9 +7,6 @@
/* CYGNUS LOCAL */
#define lint
#include <windows.h>
-#include <sys/strace.h>
-
-extern DWORD strace_active;
#define USG_COMPAT
diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
index 4d6d06c..48709fc 100644
--- a/winsup/cygwin/pinfo.cc
+++ b/winsup/cygwin/pinfo.cc
@@ -43,26 +43,26 @@ set_myself (pinfo *p)
myself->start_time = time (NULL); /* Register our starting time. */
char buf[30];
- __small_sprintf (buf, "cYg%8x %x %x", _STRACE_INTERFACE_ACTIVATE_ADDR,
- &strace_active);
+ __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)
+ if (strace.active)
{
extern char osname[];
- strace_printf (1, "**********************************************");
- strace_printf (1, "Program name: %s", myself->progname);
- strace_printf (1, "App version: %d.%d, api: %d.%d",
+ strace.prntf (1, "**********************************************");
+ strace.prntf (1, "Program name: %s", myself->progname);
+ strace.prntf (1, "App version: %d.%d, api: %d.%d",
user_data->dll_major, user_data->dll_minor,
user_data->api_major, user_data->api_minor);
- strace_printf (1, "DLL version: %d.%d, api: %d.%d",
+ strace.prntf (1, "DLL version: %d.%d, api: %d.%d",
cygwin_version.dll_major, cygwin_version.dll_minor,
cygwin_version.api_major, cygwin_version.api_minor);
- strace_printf (1, "DLL build: %s", cygwin_version.dll_build_date);
- strace_printf (1, "OS version: Windows %s", osname);
- strace_printf (1, "**********************************************");
+ strace.prntf (1, "DLL build: %s", cygwin_version.dll_build_date);
+ strace.prntf (1, "OS version: Windows %s", osname);
+ strace.prntf (1, "**********************************************");
}
return myself;
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index dd4e00f..bd4ded4 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -1262,7 +1262,7 @@ wait_sig (VOID *)
/* Internal signal to force a flush of strace data to disk. */
case __SIGSTRACE:
- // proc_strace (); // Dump cached strace_printf stuff.
+ // proc_strace (); // Dump cached strace.prntf stuff.
break;
/* Signalled from a child process that it has stopped */
@@ -1301,11 +1301,14 @@ wait_sig (VOID *)
{
case 0:
SetEvent (sigcomplete_main);
+sigproc_printf ("signalled sigcomplete_main");
break;
case 1:
ReleaseSemaphore (sigcomplete_nonmain, 1, NULL);
+sigproc_printf ("signalled sigcomplete_nonmain");
break;
default:
+sigproc_printf ("Did not signal anyone");
/* Signal from another process. No need to synchronize. */
break;
}
diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc
index d76f7b8..e13845e 100644
--- a/winsup/cygwin/strace.cc
+++ b/winsup/cygwin/strace.cc
@@ -9,7 +9,6 @@ Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
#include <ctype.h>
-#include <stdarg.h>
#include <stdlib.h>
#include <time.h>
#include "winsup.h"
@@ -17,7 +16,8 @@ details. */
#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); }
-DWORD NO_COPY strace_active = 0;
+
+class strace NO_COPY strace;
/* 'twould be nice to declare this in winsup.h but winsup.h doesn't require
stdarg.h, so we declare it here instead. */
@@ -25,13 +25,15 @@ DWORD NO_COPY strace_active = 0;
#ifndef NOSTRACE
#ifndef STRACE_HHMMSS
-static long long hires_frequency = 0;
-static int hires_initted = 0;
-
-static int strace_microseconds()
+int
+strace::microseconds()
{
static int first_microsec = 0;
+ static long long hires_frequency = 0;
+ static int hires_initted = 0;
+
int microsec;
+
if (!hires_initted)
{
hires_initted = 1;
@@ -59,8 +61,8 @@ static int strace_microseconds()
#endif
/* sprintf analog for use by output routines. */
-static int
-strace_vsprintf (char *buf, const char *infmt, va_list ap)
+int
+strace::vsprntf (char *buf, const char *infmt, va_list ap)
{
int count;
char fmt[80];
@@ -68,8 +70,7 @@ strace_vsprintf (char *buf, const char *infmt, va_list ap)
DWORD err = GetLastError ();
const char *tn = threadname (0);
- static int lmicrosec = 0;
- int microsec = strace_microseconds ();
+ int microsec = microseconds ();
lmicrosec = microsec;
__small_sprintf (fmt, "%7d [%s] %s ", microsec, tn, "%s %d%s");
@@ -125,8 +126,8 @@ done:
}
/* Write to strace file or strace queue. */
-static void
-strace_write (unsigned category, const char *buf, int count)
+void
+strace::write (unsigned category, const char *buf, int count)
{
# define PREFIX (3 + 8 + 1 + 8 + 1)
char outbuf[PREFIX + 1 + count + 1];
@@ -141,10 +142,10 @@ strace_write (unsigned category, const char *buf, int count)
Warning: DO NOT SET ERRNO HERE! */
void
-strace_printf (unsigned category, const char *fmt,...)
+strace::prntf (unsigned category, const char *fmt,...)
{
DWORD err = GetLastError ();
- if (strace_active)
+ if (active)
{
int count;
va_list ap;
@@ -153,11 +154,11 @@ strace_printf (unsigned category, const char *fmt,...)
PROTECT(buf);
va_start (ap, fmt);
SetLastError (err);
- count = strace_vsprintf (buf, fmt, ap);
+ count = this->vsprntf (buf, fmt, ap);
va_end (ap);
CHECK(buf);
- strace_write (category, buf, count);
+ this->write (category, buf, count);
}
SetLastError (err);
}
@@ -325,9 +326,10 @@ ta[] =
{ WM_ASYNCIO, "ASYNCIO" },
{ 0, 0 }};
-void _strace_wm (int message, int word, int lon)
+void
+strace::wm (int message, int word, int lon)
{
- if (strace_active)
+ if (active)
{
int i;
@@ -335,11 +337,11 @@ void _strace_wm (int message, int word, int lon)
{
if (ta[i].v == message)
{
- strace_printf (_STRACE_WM, "wndproc %d %s %d %d", message, ta[i].n, word, lon);
+ this->prntf (_STRACE_WM, "wndproc %d %s %d %d", message, ta[i].n, word, lon);
return;
}
}
- strace_printf (_STRACE_WM, "wndproc %d unknown %d %d", message, word, lon);
+ this->prntf (_STRACE_WM, "wndproc %d unknown %d %d", message, word, lon);
}
}
@@ -356,7 +358,7 @@ __system_printf (const char *fmt,...)
PROTECT (buf);
va_start (ap, fmt);
- count = strace_vsprintf (buf, fmt, ap);
+ count = strace.vsprntf (buf, fmt, ap);
va_end (ap);
CHECK (buf);
@@ -365,25 +367,12 @@ __system_printf (const char *fmt,...)
FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE));
#ifndef NOSTRACE
- if (strace_active)
- strace_write (1, buf, count);
+ if (strace.active)
+ strace.write (1, buf, count);
#endif
#ifdef DEBUGGING
// try_to_debug ();
#endif
}
-
-#else
-
-/* empty functions for when strace is disabled */
-
-void
-strace_init (const char *buf)
-{}
-
-extern "C" {
-void _strace_wm (int message, int word, int lon)
-{}
-}
#endif /*NOSTRACE*/
diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc
index 336196d..1610574 100644
--- a/winsup/cygwin/window.cc
+++ b/winsup/cygwin/window.cc
@@ -24,7 +24,7 @@ static LRESULT CALLBACK
WndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
#ifndef NOSTRACE
- _strace_wm (uMsg, wParam, lParam);
+ strace.wm (uMsg, wParam, lParam);
#endif
switch (uMsg)
{
diff --git a/winsup/cygwin/winsup.h b/winsup/cygwin/winsup.h
index 3e07fb1..a59d192 100644
--- a/winsup/cygwin/winsup.h
+++ b/winsup/cygwin/winsup.h
@@ -392,8 +392,7 @@ void events_terminate (void);
void __stdcall close_all_files (void);
-/* Strace facility. See strace.cc, sys/strace.h and utils/strace.cc. */
-extern DWORD strace_active;
+extern class strace strace;
/* Invisible window initialization/termination. */
HWND __stdcall gethwnd (void);