* 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.
This commit is contained in:
Corinna Vinschen 2001-02-26 09:50:24 +00:00
parent 6626ebfef7
commit 88429768bb
3 changed files with 50 additions and 4 deletions

View File

@ -1,3 +1,13 @@
Mon Feb 26 10:42:00 2001 Corinna Vinschen <corinna@vinschen.de>
* 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 <corinna@vinschen.de>
* shortcut.c: Remove #include <sys/strace.h>.

View File

@ -21,6 +21,8 @@
#include <stdarg.h>
#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 */

View File

@ -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;