From 88429768bb3cc21d871e912cde3efaf92eec8213 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 26 Feb 2001 09:50:24 +0000 Subject: [PATCH] * strace.cc (strace::vprntf): Move prntf functionality to this function adding an va_list interface to strace. (strace::printf): Calls strace::vprntf now. (strace_printf): New function providing an extern "C" interface to trace output. * include/sys/strace.h: Make plain C clean. (class strace): Add `vprntf' method. --- winsup/cygwin/ChangeLog | 10 ++++++++++ winsup/cygwin/include/sys/strace.h | 19 ++++++++++++++++++- winsup/cygwin/strace.cc | 25 ++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 279a3a579..453d802a9 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,13 @@ +Mon Feb 26 10:42:00 2001 Corinna Vinschen + + * strace.cc (strace::vprntf): Move prntf functionality to this function + adding an va_list interface to strace. + (strace::printf): Calls strace::vprntf now. + (strace_printf): New function providing an extern "C" interface to + trace output. + * include/sys/strace.h: Make plain C clean. + (class strace): Add `vprntf' method. + Mon Feb 26 0:10:00 2001 Corinna Vinschen * shortcut.c: Remove #include . diff --git a/winsup/cygwin/include/sys/strace.h b/winsup/cygwin/include/sys/strace.h index 37e9758dd..66f2c2cff 100644 --- a/winsup/cygwin/include/sys/strace.h +++ b/winsup/cygwin/include/sys/strace.h @@ -21,6 +21,8 @@ #include +#ifdef __cplusplus + class strace { int vsprntf (char *buf, const char *func, const char *infmt, va_list ap); @@ -33,11 +35,14 @@ public: int execing; strace() : version(1) {} void prntf (unsigned, const char *func, const char *, ...); + void vprntf (unsigned, const char *func, const char *, va_list ap); void wm (int message, int word, int lon); }; extern strace strace; +#endif /* __cplusplus */ + #define _STRACE_INTERFACE_ACTIVATE_ADDR -1 #define _STRACE_INTERFACE_ACTIVATE_ADDR1 -2 @@ -63,7 +68,18 @@ extern strace strace; #define _STRACE_THREAD 0x40000 // thread-locking calls #define _STRACE_NOTALL 0x80000 // don't include if _STRACE_ALL -extern "C" void small_printf (const char *, ...); +#ifdef __cplusplus +extern "C" { +#endif + +void small_printf (const char *, ...); +void strace_printf (unsigned, const char *func, const char *, ...); + +#ifdef __cplusplus +} +#endif + +#ifdef __cplusplus #ifdef NOSTRACE #define define_strace(c, f) @@ -120,4 +136,5 @@ extern "C" void small_printf (const char *, ...); #define thread_printf(fmt, args...) strace_printf_wrap1(THREAD, fmt , ## args) #endif /*NEW_MACRO_VARARGS*/ #endif /*NOSTRACE*/ +#endif /* __cplusplus */ #endif /* _SYS_STRACE_H */ diff --git a/winsup/cygwin/strace.cc b/winsup/cygwin/strace.cc index d13596ea4..0b908a7d3 100644 --- a/winsup/cygwin/strace.cc +++ b/winsup/cygwin/strace.cc @@ -183,17 +183,15 @@ strace::write (unsigned category, const char *buf, int count) Warning: DO NOT SET ERRNO HERE! */ void -strace::prntf (unsigned category, const char *func, const char *fmt, ...) +strace::vprntf (unsigned category, const char *func, const char *fmt, va_list ap) { DWORD err = GetLastError (); int count; char buf[10000]; - va_list ap; PROTECT(buf); SetLastError (err); - va_start (ap, fmt); count = this->vsprntf (buf, func, fmt, ap); CHECK(buf); if (category & _STRACE_SYSTEM) @@ -210,6 +208,27 @@ strace::prntf (unsigned category, const char *func, const char *fmt, ...) SetLastError (err); } +void +strace::prntf (unsigned category, const char *func, const char *fmt, ...) +{ + va_list ap; + + va_start (ap, fmt); + this->vprntf (category, func, fmt, ap); +} + +extern "C" void +strace_printf (unsigned category, const char *func, const char *fmt, ...) +{ + va_list ap; + + if ((category & _STRACE_SYSTEM) || strace.active) + { + va_start (ap, fmt); + strace.vprntf (category, func, fmt, ap); + } +} + static NO_COPY const struct tab { int v;