* 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:
parent
5a7b5870ff
commit
20d7f75837
|
@ -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>
|
Wed Aug 2 13:20:04 2000 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
* regexp/regexp.c: Add winsup.h.
|
* regexp/regexp.c: Add winsup.h.
|
||||||
|
|
|
@ -122,14 +122,14 @@ seterrno_from_win_error (const char *file, int line, int code)
|
||||||
if (errmap[i].w != 0)
|
if (errmap[i].w != 0)
|
||||||
{
|
{
|
||||||
if (strace.active)
|
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);
|
file, line, code, errmap[i].s, errmap[i].e);
|
||||||
set_errno (errmap[i].e);
|
set_errno (errmap[i].e);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strace.active)
|
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);
|
set_errno (EACCES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,7 +154,7 @@ error_start_init (const char *buf)
|
||||||
static void
|
static void
|
||||||
exception (EXCEPTION_RECORD *e, CONTEXT *in)
|
exception (EXCEPTION_RECORD *e, CONTEXT *in)
|
||||||
{
|
{
|
||||||
const char *exception_name = 0;
|
const char *exception_name = NULL;
|
||||||
|
|
||||||
if (e)
|
if (e)
|
||||||
{
|
{
|
||||||
|
|
|
@ -106,13 +106,13 @@ fhandler_tty_common::__acquire_output_mutex (const char *fn, int ln,
|
||||||
DWORD ms)
|
DWORD ms)
|
||||||
{
|
{
|
||||||
if (strace.active)
|
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);
|
DWORD res = WaitForSingleObject (output_mutex, ms);
|
||||||
if (res == WAIT_OBJECT_0)
|
if (res == WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
#ifndef DEBUGGING
|
#ifndef DEBUGGING
|
||||||
if (strace.active)
|
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
|
#else
|
||||||
ostack[osi].fn = fn;
|
ostack[osi].fn = fn;
|
||||||
ostack[osi].ln = ln;
|
ostack[osi].ln = ln;
|
||||||
|
@ -131,7 +131,7 @@ fhandler_tty_common::__release_output_mutex (const char *fn, int ln)
|
||||||
{
|
{
|
||||||
#ifndef DEBUGGING
|
#ifndef DEBUGGING
|
||||||
if (strace.active)
|
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
|
#else
|
||||||
if (osi > 0)
|
if (osi > 0)
|
||||||
osi--;
|
osi--;
|
||||||
|
|
|
@ -24,14 +24,14 @@
|
||||||
class strace
|
class strace
|
||||||
{
|
{
|
||||||
int microseconds ();
|
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);
|
void write (unsigned category, const char *buf, int count);
|
||||||
public:
|
public:
|
||||||
int version;
|
int version;
|
||||||
int active;
|
int active;
|
||||||
int lmicrosec;
|
int lmicrosec;
|
||||||
strace() : version(1) {}
|
strace() : version(1) {}
|
||||||
void prntf (unsigned, const char *, ...);
|
void prntf (unsigned, const char *func, const char *, ...);
|
||||||
void wm (int message, int word, int lon);
|
void wm (int message, int word, int lon);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ extern "C" void small_printf (const char *, ...);
|
||||||
#define define_strace0(c,...) \
|
#define define_strace0(c,...) \
|
||||||
do { \
|
do { \
|
||||||
if ((c & _STRACE_SYSTEM) || strace.active) \
|
if ((c & _STRACE_SYSTEM) || strace.active) \
|
||||||
strace.prntf (c, "%F: " __VA_ARGS__); \
|
strace.prntf (c, __PRETTY_FUNCTION__, __VA_ARGS__); \
|
||||||
} \
|
} \
|
||||||
while (0)
|
while (0)
|
||||||
|
|
||||||
|
@ -96,13 +96,13 @@ extern "C" void small_printf (const char *, ...);
|
||||||
#define strace_printf_wrap(what, fmt, args...) \
|
#define strace_printf_wrap(what, fmt, args...) \
|
||||||
((void) ({\
|
((void) ({\
|
||||||
if (strace.active) \
|
if (strace.active) \
|
||||||
strace.prntf(_STRACE_ ## what, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
|
strace.prntf(_STRACE_ ## what, __PRETTY_FUNCTION__, fmt, ## args); \
|
||||||
0; \
|
0; \
|
||||||
}))
|
}))
|
||||||
#define strace_printf_wrap1(what, fmt, args...) \
|
#define strace_printf_wrap1(what, fmt, args...) \
|
||||||
((void) ({\
|
((void) ({\
|
||||||
if (strace.active) \
|
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; \
|
0; \
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
|
|
@ -46,17 +46,17 @@ set_myself (pid_t pid)
|
||||||
if (strace.active)
|
if (strace.active)
|
||||||
{
|
{
|
||||||
extern char osname[];
|
extern char osname[];
|
||||||
strace.prntf (1, "**********************************************");
|
strace.prntf (1, NULL, "**********************************************");
|
||||||
strace.prntf (1, "Program name: %s", myself->progname);
|
strace.prntf (1, NULL, "Program name: %s", myself->progname);
|
||||||
strace.prntf (1, "App version: %d.%d, api: %d.%d",
|
strace.prntf (1, NULL, "App version: %d.%d, api: %d.%d",
|
||||||
user_data->dll_major, user_data->dll_minor,
|
user_data->dll_major, user_data->dll_minor,
|
||||||
user_data->api_major, user_data->api_minor);
|
user_data->api_major, user_data->api_minor);
|
||||||
strace.prntf (1, "DLL version: %d.%d, api: %d.%d",
|
strace.prntf (1, NULL, "DLL version: %d.%d, api: %d.%d",
|
||||||
cygwin_version.dll_major, cygwin_version.dll_minor,
|
cygwin_version.dll_major, cygwin_version.dll_minor,
|
||||||
cygwin_version.api_major, cygwin_version.api_minor);
|
cygwin_version.api_major, cygwin_version.api_minor);
|
||||||
strace.prntf (1, "DLL build: %s", cygwin_version.dll_build_date);
|
strace.prntf (1, NULL, "DLL build: %s", cygwin_version.dll_build_date);
|
||||||
strace.prntf (1, "OS version: Windows %s", osname);
|
strace.prntf (1, NULL, "OS version: Windows %s", osname);
|
||||||
strace.prntf (1, "**********************************************");
|
strace.prntf (1, NULL, "**********************************************");
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -154,32 +154,6 @@ __small_vsprintf (char *dst, const char *fmt, va_list ap)
|
||||||
for (i = 0; *s && i < n; i++)
|
for (i = 0; *s && i < n; i++)
|
||||||
*dst++ = *s++;
|
*dst++ = *s++;
|
||||||
break;
|
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:
|
default:
|
||||||
*dst++ = '?';
|
*dst++ = '?';
|
||||||
*dst++ = fmt[-1];
|
*dst++ = fmt[-1];
|
||||||
|
|
|
@ -13,6 +13,7 @@ details. */
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <wingdi.h>
|
#include <wingdi.h>
|
||||||
#include <winuser.h>
|
#include <winuser.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
|
||||||
#define PROTECT(x) x[sizeof(x)-1] = 0
|
#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); }
|
#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;
|
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. */
|
/* sprintf analog for use by output routines. */
|
||||||
int
|
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;
|
int count;
|
||||||
char fmt[80];
|
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");
|
__small_sprintf (fmt, "%7d [%s] %s ", microsec, tn, "%s %d%s");
|
||||||
|
|
||||||
SetLastError (err);
|
SetLastError (err);
|
||||||
|
|
||||||
if (nonewline)
|
if (nonewline)
|
||||||
{
|
count = 0;
|
||||||
count = 0;
|
|
||||||
if (strncmp (infmt, "%F: ", 4) == 0)
|
|
||||||
{
|
|
||||||
infmt += 4;
|
|
||||||
(void) va_arg (ap, char *);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char *p, progname[sizeof (myself->progname)];
|
char *p, progname[sizeof (myself->progname)];
|
||||||
|
@ -96,6 +125,8 @@ strace::vsprntf (char *buf, const char *infmt, va_list ap)
|
||||||
p = progname;
|
p = progname;
|
||||||
count = __small_sprintf (buf, fmt, p && *p ? p : "?",
|
count = __small_sprintf (buf, fmt, p && *p ? p : "?",
|
||||||
myself->pid, hExeced ? "!" : "");
|
myself->pid, hExeced ? "!" : "");
|
||||||
|
if (func)
|
||||||
|
count += getfunc (buf + count, func);
|
||||||
}
|
}
|
||||||
|
|
||||||
count += __small_vsprintf (buf + count, infmt, ap);
|
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! */
|
Warning: DO NOT SET ERRNO HERE! */
|
||||||
|
|
||||||
void
|
void
|
||||||
strace::prntf (unsigned category, const char *fmt, ...)
|
strace::prntf (unsigned category, const char *func, const char *fmt, ...)
|
||||||
{
|
{
|
||||||
DWORD err = GetLastError ();
|
DWORD err = GetLastError ();
|
||||||
int count;
|
int count;
|
||||||
|
@ -151,7 +182,7 @@ strace::prntf (unsigned category, const char *fmt, ...)
|
||||||
SetLastError (err);
|
SetLastError (err);
|
||||||
|
|
||||||
va_start (ap, fmt);
|
va_start (ap, fmt);
|
||||||
count = this->vsprntf (buf, fmt, ap);
|
count = this->vsprntf (buf, func, fmt, ap);
|
||||||
CHECK(buf);
|
CHECK(buf);
|
||||||
if (category & _STRACE_SYSTEM)
|
if (category & _STRACE_SYSTEM)
|
||||||
{
|
{
|
||||||
|
@ -341,11 +372,11 @@ strace::wm (int message, int word, int lon)
|
||||||
{
|
{
|
||||||
if (ta[i].v == message)
|
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;
|
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*/
|
#endif /*NOSTRACE*/
|
||||||
|
|
Loading…
Reference in New Issue