* strace.cc (strace::prntf): Make second argument the function name, rather

than use special format options.
(strace::vprntf): Ditto.
(getfunc): New function.
* include/sys/strace.h: Reflect above changes.
* smallprint.c (__small_vsprintf): Eliminate '%F' formatting.
* pinfo.cc (set_myself): Modify for new strace::prntf parameter.
* errno.cc (seterrno_from_win_error): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__release_output_mutex): Ditto.
This commit is contained in:
Christopher Faylor 2000-08-02 19:26:01 +00:00
parent 5a7b5870ff
commit 20d7f75837
8 changed files with 79 additions and 61 deletions

View File

@ -1,3 +1,16 @@
Wed Aug 2 15:14:51 2000 Christopher Faylor <cgf@cygnus.com>
* strace.cc (strace::prntf): Make second argument the function name,
rather than use special format options.
(strace::vprntf): Ditto.
(getfunc): New function.
* include/sys/strace.h: Reflect above changes.
* smallprint.c (__small_vsprintf): Eliminate '%F' formatting.
* pinfo.cc (set_myself): Modify for new strace::prntf parameter.
* errno.cc (seterrno_from_win_error): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__acquire_output_mutex): Ditto.
* fhandler_tty.cc (fhandler_tty_common::__release_output_mutex): Ditto.
Wed Aug 2 13:20:04 2000 Christopher Faylor <cgf@cygnus.com>
* regexp/regexp.c: Add winsup.h.

View File

@ -122,14 +122,14 @@ seterrno_from_win_error (const char *file, int line, int code)
if (errmap[i].w != 0)
{
if (strace.active)
strace.prntf (_STRACE_SYSCALL, "%s:%d seterrno: %d (%s) -> %d",
strace.prntf (_STRACE_SYSCALL, NULL, "%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.prntf (_STRACE_SYSCALL, "%s:%d seterrno: unknown error %d", file, line, code);
strace.prntf (_STRACE_SYSCALL, NULL, "%s:%d seterrno: unknown error %d", file, line, code);
set_errno (EACCES);
}
}

View File

@ -154,7 +154,7 @@ error_start_init (const char *buf)
static void
exception (EXCEPTION_RECORD *e, CONTEXT *in)
{
const char *exception_name = 0;
const char *exception_name = NULL;
if (e)
{

View File

@ -106,13 +106,13 @@ fhandler_tty_common::__acquire_output_mutex (const char *fn, int ln,
DWORD ms)
{
if (strace.active)
strace.prntf (_STRACE_TERMIOS, "%F (%d): tty output_mutex: waiting %d ms", fn, ln, ms);
strace.prntf (_STRACE_TERMIOS, fn, "(%d): tty output_mutex: waiting %d ms", ln, ms);
DWORD res = WaitForSingleObject (output_mutex, ms);
if (res == WAIT_OBJECT_0)
{
#ifndef DEBUGGING
if (strace.active)
strace.prntf (_STRACE_TERMIOS, "%F (%d): tty output_mutex: acquired", fn, ln, res);
strace.prntf (_STRACE_TERMIOS, fn, "(%d): tty output_mutex: acquired", ln, res);
#else
ostack[osi].fn = fn;
ostack[osi].ln = ln;
@ -131,7 +131,7 @@ fhandler_tty_common::__release_output_mutex (const char *fn, int ln)
{
#ifndef DEBUGGING
if (strace.active)
strace.prntf (_STRACE_TERMIOS, "%F (%d): tty output_mutex released", fn, ln);
strace.prntf (_STRACE_TERMIOS, fn, "(%d): tty output_mutex released", ln);
#else
if (osi > 0)
osi--;

View File

@ -24,14 +24,14 @@
class strace
{
int microseconds ();
int vsprntf (char *buf, const char *infmt, va_list ap);
int vsprntf (char *buf, const char *func, 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, const char *, ...);
void prntf (unsigned, const char *func, const char *, ...);
void wm (int message, int word, int lon);
};
@ -74,7 +74,7 @@ extern "C" void small_printf (const char *, ...);
#define define_strace0(c,...) \
do { \
if ((c & _STRACE_SYSTEM) || strace.active) \
strace.prntf (c, "%F: " __VA_ARGS__); \
strace.prntf (c, __PRETTY_FUNCTION__, __VA_ARGS__); \
} \
while (0)
@ -96,13 +96,13 @@ extern "C" void small_printf (const char *, ...);
#define strace_printf_wrap(what, fmt, args...) \
((void) ({\
if (strace.active) \
strace.prntf(_STRACE_ ## what, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
strace.prntf(_STRACE_ ## what, __PRETTY_FUNCTION__, fmt, ## args); \
0; \
}))
#define strace_printf_wrap1(what, fmt, args...) \
((void) ({\
if (strace.active) \
strace.prntf((_STRACE_ ## what) | _STRACE_NOTALL, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
strace.prntf((_STRACE_ ## what) | _STRACE_NOTALL, __PRETTY_FUNCTION__, fmt, ## args); \
0; \
}))

View File

@ -46,17 +46,17 @@ set_myself (pid_t pid)
if (strace.active)
{
extern char osname[];
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.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.prntf (1, "DLL build: %s", cygwin_version.dll_build_date);
strace.prntf (1, "OS version: Windows %s", osname);
strace.prntf (1, "**********************************************");
strace.prntf (1, NULL, "**********************************************");
strace.prntf (1, NULL, "Program name: %s", myself->progname);
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", osname);
strace.prntf (1, NULL, "**********************************************");
}
return;

View File

@ -154,32 +154,6 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
for (i = 0; *s && i < n; i++)
*dst++ = *s++;
break;
case 'F':
{
const char *p, *pe;
s = va_arg (ap, char *);
for (p = s; (pe = strchr (p, '(')); p = pe + 1)
if (isalnum ((int)pe[-1]) || pe[-1] == '_')
break;
else if (isspace((int)pe[-1]))
{
pe--;
break;
}
if (!pe)
pe = strchr (s, '\0');
for (p = pe; p > s; p--)
if (p != pe && *p == ' ')
{
p++;
break;
}
if (*p == '*')
p++;
while (p < pe)
*dst++ = *p++;
break;
}
default:
*dst++ = '?';
*dst++ = fmt[-1];

View File

@ -13,6 +13,7 @@ details. */
#include <time.h>
#include <wingdi.h>
#include <winuser.h>
#include <ctype.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); }
@ -58,9 +59,43 @@ strace::microseconds()
return microsec - first_microsec;
}
static int __stdcall
getfunc (char *in_dst, const char *func)
{
const char *p;
const char *pe;
char *dst = in_dst;
for (p = func; (pe = strchr (p, '(')); p = pe + 1)
if (isalnum ((int)pe[-1]) || pe[-1] == '_')
break;
else if (isspace((int)pe[-1]))
{
pe--;
break;
}
if (!pe)
pe = strchr (func, '\0');
for (p = pe; p > func; p--)
if (p != pe && *p == ' ')
{
p++;
break;
}
if (*p == '*')
p++;
while (p < pe)
*dst++ = *p++;
*dst++ = ':';
*dst++ = ' ';
*dst = '\0';
return dst - in_dst;
}
/* sprintf analog for use by output routines. */
int
strace::vsprntf (char *buf, const char *infmt, va_list ap)
strace::vsprntf (char *buf, const char *func, const char *infmt, va_list ap)
{
int count;
char fmt[80];
@ -74,15 +109,9 @@ strace::vsprntf (char *buf, const char *infmt, va_list ap)
__small_sprintf (fmt, "%7d [%s] %s ", microsec, tn, "%s %d%s");
SetLastError (err);
if (nonewline)
{
count = 0;
if (strncmp (infmt, "%F: ", 4) == 0)
{
infmt += 4;
(void) va_arg (ap, char *);
}
}
count = 0;
else
{
char *p, progname[sizeof (myself->progname)];
@ -96,6 +125,8 @@ strace::vsprntf (char *buf, const char *infmt, va_list ap)
p = progname;
count = __small_sprintf (buf, fmt, p && *p ? p : "?",
myself->pid, hExeced ? "!" : "");
if (func)
count += getfunc (buf + count, func);
}
count += __small_vsprintf (buf + count, infmt, ap);
@ -140,7 +171,7 @@ strace::write (unsigned category, const char *buf, int count)
Warning: DO NOT SET ERRNO HERE! */
void
strace::prntf (unsigned category, const char *fmt, ...)
strace::prntf (unsigned category, const char *func, const char *fmt, ...)
{
DWORD err = GetLastError ();
int count;
@ -151,7 +182,7 @@ strace::prntf (unsigned category, const char *fmt, ...)
SetLastError (err);
va_start (ap, fmt);
count = this->vsprntf (buf, fmt, ap);
count = this->vsprntf (buf, func, fmt, ap);
CHECK(buf);
if (category & _STRACE_SYSTEM)
{
@ -341,11 +372,11 @@ strace::wm (int message, int word, int lon)
{
if (ta[i].v == message)
{
this->prntf (_STRACE_WM, "wndproc %d %s %d %d", message, ta[i].n, word, lon);
this->prntf (_STRACE_WM, NULL, "wndproc %d %s %d %d", message, ta[i].n, word, lon);
return;
}
}
this->prntf (_STRACE_WM, "wndproc %d unknown %d %d", message, word, lon);
this->prntf (_STRACE_WM, NULL, "wndproc %d unknown %d %d", message, word, lon);
}
}
#endif /*NOSTRACE*/