* strace.h: Add kludgy workarounds to avoid using deprecated methods for

variable argument macros when possible.
* sigproc.cc: Throughout, use sigproc_printf rather than sip_printf.
* strace.cc (strace::prntf): Remove 'active' check, since callers are supposed
to ensure this.
(__system_printf): Remove.  Subsumed by strace::prntf.
* winsup.h: Define "NEW_MACRO_VARARGS" to indicate when to use new macro
varargs capability.
This commit is contained in:
Christopher Faylor 2000-08-02 03:42:31 +00:00
parent 749d9bcd4b
commit a5a965ff62
5 changed files with 140 additions and 126 deletions

View File

@ -1,3 +1,14 @@
Tue Aug 1 23:37:08 2000 Christopher Faylor <cgf@cygnus.com>
* strace.h: Add kludgy workarounds to avoid using deprecated methods
for variable argument macros when possible.
* sigproc.cc: Throughout, use sigproc_printf rather than sip_printf.
* strace.cc (strace::prntf): Remove 'active' check, since callers are
supposed to ensure this.
(__system_printf): Remove. Subsumed by strace::prntf.
* winsup.h: Define "NEW_MACRO_VARARGS" to indicate when to use new
macro varargs capability.
Sun Jul 30 13:54:35 2000 Christopher Faylor <cgf@cygnus.com>
* fhandler_console.cc: Remove VK_DIVIDE detection.

View File

@ -23,7 +23,6 @@
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);
@ -32,10 +31,12 @@ public:
int active;
int lmicrosec;
strace() : version(1) {}
void prntf (unsigned category, const char *fmt,...);
void prntf (unsigned, const char *, ...);
void wm (int message, int word, int lon);
};
extern strace strace;
#define _STRACE_INTERFACE_ACTIVATE_ADDR -1
#define _STRACE_INTERFACE_ACTIVATE_ADDR1 -2
@ -55,7 +56,7 @@ public:
#define _STRACE_SIGP 0x00800 // trace signal and process handling
#define _STRACE_MINIMAL 0x01000 // very minimal strace output
#define _STRACE_EXITDUMP 0x04000 // dump strace cache on exit
#define _STRACE_CACHE 0x08000 // cache strace messages
#define _STRACE_SYSTEM 0x08000 // cache strace messages
#define _STRACE_NOMUTEX 0x10000 // don't use mutex for synchronization
#define _STRACE_MALLOC 0x20000 // trace malloc calls
#define _STRACE_THREAD 0x40000 // thread-locking calls
@ -63,11 +64,35 @@ public:
extern "C" void small_printf (const char *, ...);
#ifndef NOSTRACE
#ifdef NOSTRACE
#define define_strace(c, f)
#define define_strace1(c, f)
#else
#ifdef NEW_MACRO_VARARGS
/* Output message to strace log */
#define system_printf(fmt, args...) \
__system_printf("%F: " fmt, __PRETTY_FUNCTION__ , ## args)
#define define_strace0(c,...) \
do { \
if (c & _STRACE_SYSTEM || strace.active) \
strace.prntf (c, "%F: " __VA_ARGS__); \
} \
while (0)
#define define_strace(c, ...) define_strace0 (_STRACE_ ## c, __VA_ARGS__)
#define define_strace1(c, ...) define_strace0 (_STRACE_ ## c | _STRACE_NOTALL, __VA_ARGS__)
#define debug_printf(...) define_strace (DEBUG, __VA_ARGS__)
#define paranoid_printf(...) define_strace (PARANOID, __VA_ARGS__)
#define select_printf(...) define_strace (SELECT, __VA_ARGS__)
#define sigproc_printf(...) define_strace (SIGP, __VA_ARGS__)
#define syscall_printf(...) define_strace (SYSCALL, __VA_ARGS__)
#define system_printf(...) define_strace (SYSTEM, __VA_ARGS__)
#define termios_printf(...) define_strace (TERMIOS, __VA_ARGS__)
#define wm_printf(...) define_strace (WM, __VA_ARGS__)
#define minimal_printf(...) define_strace1 (MINIMAL, __VA_ARGS__)
#define malloc_printf(...) define_strace1 (MALLOC, __VA_ARGS__)
#define thread_printf(...) define_strace1 (THREAD, __VA_ARGS__)
#else
#define strace_printf_wrap(what, fmt, args...) \
((void) ({\
if (strace.active) \
@ -80,17 +105,18 @@ extern "C" void small_printf (const char *, ...);
strace.prntf((_STRACE_ ## what) | _STRACE_NOTALL, "%F: " fmt, __PRETTY_FUNCTION__ , ## args); \
0; \
}))
#endif /*NOSTRACE*/
#define debug_printf(fmt, args...) strace_printf_wrap(DEBUG, fmt , ## args)
#define syscall_printf(fmt, args...) strace_printf_wrap(SYSCALL, fmt , ## args)
#define paranoid_printf(fmt, args...) strace_printf_wrap(PARANOID, fmt , ## args)
#define termios_printf(fmt, args...) strace_printf_wrap(TERMIOS, fmt , ## args)
#define select_printf(fmt, args...) strace_printf_wrap(SELECT, fmt , ## args)
#define wm_printf(fmt, args...) strace_printf_wrap(WM, fmt , ## args)
#define sigproc_printf(fmt, args...) strace_printf_wrap(SIGP, fmt , ## args)
#define syscall_printf(fmt, args...) strace_printf_wrap(SYSCALL, fmt , ## args)
#define system_printf(fmt, args...) strace_printf_wrap(SYSTEM, fmt , ## args)
#define termios_printf(fmt, args...) strace_printf_wrap(TERMIOS, fmt , ## args)
#define wm_printf(fmt, args...) strace_printf_wrap(WM, fmt , ## args)
#define minimal_printf(fmt, args...) strace_printf_wrap1(MINIMAL, fmt , ## args)
#define malloc_printf(fmt, args...) strace_printf_wrap1(MALLOC, fmt , ## args)
#define thread_printf(fmt, args...) strace_printf_wrap1(THREAD, fmt , ## args)
#endif /*NEW_MACRO_VARARGS*/
#endif /*NOSTRACE*/
#endif /* _SYS_STRACE_H */

View File

@ -31,8 +31,6 @@ extern BOOL allow_ntsec;
#define TOTSIGS (NSIG + __SIGOFFSET)
#define sip_printf(fmt, args...) sigproc_printf (fmt , ## args)
#define wake_wait_subproc() SetEvent (events[0])
#define no_signals_available() (!hwait_sig || !sig_loop_wait)
@ -205,11 +203,11 @@ proc_exists (_pinfo *p)
if (p->process_state == PID_NOT_IN_USE || !p->dwProcessId)
return FALSE;
sip_printf ("checking for existence of pid %d, window pid %d", p->pid,
sigproc_printf ("checking for existence of pid %d, window pid %d", p->pid,
p->dwProcessId);
if (p->ppid == myself->pid && p->hProcess != NULL)
{
sip_printf ("it's mine, process_state %x", p->process_state);
sigproc_printf ("it's mine, process_state %x", p->process_state);
return proc_can_be_signalled (p);
}
@ -217,7 +215,7 @@ proc_exists (_pinfo *p)
if (((h = OpenProcess (STANDARD_RIGHTS_REQUIRED, FALSE, p->dwProcessId))
!= NULL) || (GetLastError () == ERROR_ACCESS_DENIED))
{
sip_printf ("it exists, %p", h);
sigproc_printf ("it exists, %p", h);
if (h)
{
DWORD rc = WaitForSingleObject (h, 0);
@ -228,7 +226,7 @@ proc_exists (_pinfo *p)
return proc_can_be_signalled (p);
}
sip_printf ("it doesn't exist");
sigproc_printf ("it doesn't exist");
/* If the parent pid does not exist, clean this process out of the pinfo
* table. It must have died abnormally.
*/
@ -255,11 +253,11 @@ proc_subproc (DWORD what, DWORD val)
#define wval ((waitq *) val)
sip_printf ("args: %x, %d", what, val);
sigproc_printf ("args: %x, %d", what, val);
if (!get_proc_lock (what, val)) // Serialize access to this function
{
sip_printf ("I am not ready");
sigproc_printf ("I am not ready");
goto out1;
}
@ -282,7 +280,7 @@ proc_subproc (DWORD what, DWORD val)
pchildren[nchildren] = vchild;
hchildren[nchildren] = vchild->hProcess;
ProtectHandle1 (vchild->hProcess, childhProc);
sip_printf ("added pid %d to wait list, slot %d, winpid %p, handle %p",
sigproc_printf ("added pid %d to wait list, slot %d, winpid %p, handle %p",
vchild->pid, nchildren, vchild->dwProcessId,
vchild->hProcess);
@ -302,7 +300,7 @@ proc_subproc (DWORD what, DWORD val)
if (GetExitCodeProcess (hchildren[val], &exitcode) &&
hchildren[val] != pchildren[val]->hProcess)
{
sip_printf ("pid %d[%d], reparented old hProcess %p, new %p",
sigproc_printf ("pid %d[%d], reparented old hProcess %p, new %p",
pchildren[val]->pid, val, hchildren[val], pchildren[val]->hProcess);
ForceCloseHandle1 (hchildren[val], childhProc);
hchildren[val] = pchildren[val]->hProcess; /* Filled out by child */
@ -310,7 +308,7 @@ proc_subproc (DWORD what, DWORD val)
break; // This was an exec()
}
sip_printf ("pid %d[%d] terminated, handle %p, nchildren %d, nzombies %d",
sigproc_printf ("pid %d[%d] terminated, handle %p, nchildren %d, nzombies %d",
pchildren[val]->pid, val, hchildren[val], nchildren, nzombies);
zombies[nzombies] = pchildren[val]; // Add to zombie array
zombies[nzombies++]->process_state = PID_ZOMBIE;// Walking dead
@ -327,7 +325,7 @@ proc_subproc (DWORD what, DWORD val)
*/
case PROC_CHILDSTOPPED:
child = myself; // Just to avoid accidental NULL dereference
sip_printf ("Received stopped notification");
sigproc_printf ("Received stopped notification");
clearing = 0;
goto scan_wait;
@ -338,9 +336,9 @@ proc_subproc (DWORD what, DWORD val)
case PROC_CLEARWAIT:
/* Clear all "wait"ing threads. */
if (val)
sip_printf ("clear waiting threads");
sigproc_printf ("clear waiting threads");
else
sip_printf ("looking for processes to reap");
sigproc_printf ("looking for processes to reap");
clearing = val;
scan_wait:
@ -350,12 +348,12 @@ proc_subproc (DWORD what, DWORD val)
for (w = &waitq_head; w->next != NULL; w = w->next)
{
if ((potential_match = checkstate (w)) > 0)
sip_printf ("released waiting thread");
sigproc_printf ("released waiting thread");
else if (!clearing && potential_match < 0)
sip_printf ("only found non-terminated children");
sigproc_printf ("only found non-terminated children");
else if (potential_match <= 0) // nothing matched
{
sip_printf ("waiting thread found no children");
sigproc_printf ("waiting thread found no children");
HANDLE oldw = w->next->ev;
if (clearing)
w->next->status = -1; /* flag that a signal was received */
@ -370,11 +368,11 @@ proc_subproc (DWORD what, DWORD val)
}
if (!clearing)
sip_printf ("finished processing terminated/stopped child");
sigproc_printf ("finished processing terminated/stopped child");
else
{
waitq_head.next = NULL;
sip_printf ("finished clearing");
sigproc_printf ("finished clearing");
}
break;
@ -398,7 +396,7 @@ proc_subproc (DWORD what, DWORD val)
break;
wval->next = NULL; /* This will be last in the list */
sip_printf ("wval->pid %d, wval->options %d", wval->pid, wval->options);
sigproc_printf ("wval->pid %d, wval->options %d", wval->pid, wval->options);
/* If the first time for this thread, create a new event, otherwise
* reset the event.
@ -426,7 +424,7 @@ proc_subproc (DWORD what, DWORD val)
{
w->next = NULL; // don't want to keep looking
wval->ev = NULL; // flag that there are no children
sip_printf ("no appropriate children, %p, %p",
sigproc_printf ("no appropriate children, %p, %p",
wval->thread_ev, wval->ev);
}
else if (wval->options & WNOHANG)
@ -435,23 +433,23 @@ proc_subproc (DWORD what, DWORD val)
wval->pid = 0; // didn't find a pid
if (!SetEvent (wval->ev)) // wake up wait4 () immediately
system_printf ("Couldn't wake up wait event, %E");
sip_printf ("WNOHANG and no terminated children, %p, %p",
sigproc_printf ("WNOHANG and no terminated children, %p, %p",
wval->thread_ev, wval->ev);
}
}
if (w->next != NULL)
sip_printf ("wait activated %p, %p", wval->thread_ev, wval->ev);
sigproc_printf ("wait activated %p, %p", wval->thread_ev, wval->ev);
else if (wval->ev != NULL)
sip_printf ("wait activated %p. Reaped zombie.", wval->ev);
sigproc_printf ("wait activated %p. Reaped zombie.", wval->ev);
else
sip_printf ("wait not activated %p, %p", wval->thread_ev, wval->ev);
sigproc_printf ("wait not activated %p, %p", wval->thread_ev, wval->ev);
break;
}
out:
sync_proc_subproc->release (); // Release the lock
out1:
sip_printf ("returning %d", rc);
sigproc_printf ("returning %d", rc);
return rc;
}
@ -464,7 +462,7 @@ out1:
void __stdcall
proc_terminate (void)
{
sip_printf ("nchildren %d, nzombies %d", nchildren, nzombies);
sigproc_printf ("nchildren %d, nzombies %d", nchildren, nzombies);
/* Signal processing is assumed to be blocked in this routine. */
if (hwait_subproc)
{
@ -506,7 +504,7 @@ proc_terminate (void)
if (pchildren[i]->process_state == PID_NOT_IN_USE)
continue; // Should never happen
if (!pchildren[i]->hProcess)
sip_printf ("%d(%d) hProcess cleared already?", pchildren[i]->pid,
sigproc_printf ("%d(%d) hProcess cleared already?", pchildren[i]->pid,
pchildren[i]->dwProcessId);
else
{
@ -514,13 +512,13 @@ proc_terminate (void)
pchildren[i]->hProcess = NULL;
if (!proc_exists (pchildren[i]))
{
sip_printf ("%d(%d) doesn't exist", pchildren[i]->pid,
sigproc_printf ("%d(%d) doesn't exist", pchildren[i]->pid,
pchildren[i]->dwProcessId);
pchildren[i]->process_state = PID_NOT_IN_USE; /* a reaped child CGF FIXME -- still needed? */
}
else
{
sip_printf ("%d(%d) closing active child handle", pchildren[i]->pid,
sigproc_printf ("%d(%d) closing active child handle", pchildren[i]->pid,
pchildren[i]->dwProcessId);
pchildren[i]->ppid = 1;
if (pchildren[i]->pgid == myself->pid)
@ -541,7 +539,7 @@ proc_terminate (void)
delete m;
}
}
sip_printf ("leaving");
sigproc_printf ("leaving");
}
/* Clear pending signal from the sigtodo array
@ -563,11 +561,11 @@ sig_dispatch_pending (int justwake)
int was_pending = pending_signals;
#ifdef DEBUGGING
sip_printf ("pending_signals %d", was_pending);
sigproc_printf ("pending_signals %d", was_pending);
#endif
if (!was_pending && !justwake)
#ifdef DEBUGGING
sip_printf ("no need to wake anything up");
sigproc_printf ("no need to wake anything up");
#else
;
#endif
@ -578,12 +576,12 @@ sig_dispatch_pending (int justwake)
(void) sig_send (myself, __SIGFLUSH);
else if (ReleaseSemaphore (sigcatch_nosync, 1, NULL))
#ifdef DEBUGGING
sip_printf ("woke up wait_sig");
sigproc_printf ("woke up wait_sig");
#else
;
#endif
else if (no_signals_available ())
/*sip_printf ("I'm going away now")*/;
/*sigproc_printf ("I'm going away now")*/;
else
system_printf ("%E releasing sigcatch_nosync(%p)", sigcatch_nosync);
@ -633,7 +631,7 @@ sigproc_init ()
}
memset (w, 0, sizeof *w); // Just to be safe
sip_printf ("process/signal handling enabled(%x)", myself->process_state);
sigproc_printf ("process/signal handling enabled(%x)", myself->process_state);
return;
}
@ -658,7 +656,7 @@ sigproc_terminate (void)
proc_terminate (); // Terminate process handling thread
if (!sig_loop_wait)
sip_printf ("sigproc_terminate: sigproc handling not active");
sigproc_printf ("sigproc_terminate: sigproc handling not active");
else
{
sigproc_printf ("entering");
@ -680,7 +678,7 @@ sigproc_terminate (void)
if (!myself->dwProcessId || myself->dwProcessId == GetCurrentProcessId ())
myself->process_state &= ~PID_ACTIVE;
else
sip_printf ("Did not clear PID_ACTIVE since %d != %d",
sigproc_printf ("Did not clear PID_ACTIVE since %d != %d",
myself->dwProcessId, GetCurrentProcessId ());
/* In case of a sigsuspend */
@ -695,7 +693,7 @@ sigproc_terminate (void)
ForceCloseHandle (sigcatch_nosync);
}
}
sip_printf ("done");
sigproc_printf ("done");
}
/* Set this so that subsequent tests will succeed. */
@ -739,13 +737,13 @@ sig_send (_pinfo *p, int sig, DWORD ebp)
*/
if (!proc_can_be_signalled (p)) /* Is the process accepting messages? */
{
sip_printf ("invalid pid %d(%x), signal %d",
sigproc_printf ("invalid pid %d(%x), signal %d",
p->pid, p->process_state, sig);
set_errno (ESRCH);
goto out;
}
sip_printf ("pid %d, signal %d, its_me %d", p->pid, sig, its_me);
sigproc_printf ("pid %d, signal %d, its_me %d", p->pid, sig, its_me);
if (its_me)
{
@ -799,7 +797,7 @@ sigproc_printf ("ReleaseSemaphore failed, %E");
else
{
if (no_signals_available ())
sip_printf ("I'm going away now");
sigproc_printf ("I'm going away now");
else if ((int) GetLastError () == -1)
rc = WaitForSingleObject (thiscomplete, 500);
else
@ -820,13 +818,13 @@ sigproc_printf ("ReleaseSemaphore succeeded");
if (!wait_for_completion)
{
rc = WAIT_OBJECT_0;
sip_printf ("Not waiting for sigcomplete. its_me %d sig %d", its_me, sig);
sigproc_printf ("Not waiting for sigcomplete. its_me %d sig %d", its_me, sig);
if (!its_me)
ForceCloseHandle (thiscatch);
}
else
{
sip_printf ("Waiting for thiscomplete %p", thiscomplete);
sigproc_printf ("Waiting for thiscomplete %p", thiscomplete);
SetLastError (0);
rc = WaitForSingleObject (thiscomplete, WSSC);
@ -856,7 +854,7 @@ sigproc_printf ("ReleaseSemaphore succeeded");
}
out:
sip_printf ("returning %d from sending signal %d", rc, sig);
sigproc_printf ("returning %d from sending signal %d", rc, sig);
return rc;
}
@ -886,7 +884,7 @@ subproc_init (void)
system_printf ("cannot create wait_subproc thread, %E");
ProtectHandle (events[0]);
ProtectHandle (hwait_subproc);
sip_printf ("started wait_subproc thread %p", hwait_subproc);
sigproc_printf ("started wait_subproc thread %p", hwait_subproc);
}
/* Initialize some of the memory block passed to child processes
@ -919,7 +917,7 @@ checkstate (waitq *w)
int i, x, potential_match = 0;
_pinfo *child;
sip_printf ("nchildren %d, nzombies %d", nchildren, nzombies);
sigproc_printf ("nchildren %d, nzombies %d", nchildren, nzombies);
/* Check already dead processes first to see if they match the criteria
* given in w->next.
@ -934,7 +932,7 @@ checkstate (waitq *w)
goto out;
}
sip_printf ("checking alive children");
sigproc_printf ("checking alive children");
/* No dead terminated children matched. Check for stopped children. */
for (i = 0; i < nchildren; i++)
@ -947,7 +945,7 @@ checkstate (waitq *w)
}
out:
sip_printf ("returning %d", potential_match);
sigproc_printf ("returning %d", potential_match);
return potential_match;
}
@ -966,7 +964,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
return NULL;
}
int wait = 10000;
sip_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
sigproc_printf ("pid %d, ppid %d, wait %d, initializing %x", p->pid, p->ppid, wait,
ISSTATE (p, PID_INITIALIZING));
for (int i = 0; ISSTATE (p, PID_INITIALIZING) && i < wait; i++)
Sleep (1);
@ -1010,7 +1008,7 @@ getsem (_pinfo *p, const char *str, int init, int max)
* Attempt to handle case where process is exiting as we try to grab
* the mutex.
*/
static __inline__ BOOL
static BOOL
get_proc_lock (DWORD what, DWORD val)
{
Static int lastwhat = -1;
@ -1034,7 +1032,7 @@ get_proc_lock (DWORD what, DWORD val)
static void __stdcall
remove_child (int ci)
{
sip_printf ("removing [%d], pid %d, handle %p, nchildren %d",
sigproc_printf ("removing [%d], pid %d, handle %p, nchildren %d",
ci, pchildren[ci]->pid, hchildren[ci], nchildren);
if (ci < --nchildren)
{
@ -1050,7 +1048,7 @@ remove_child (int ci)
static void __stdcall
remove_zombie (int ci)
{
sip_printf ("removing %d, pid %d, nzombies %d", ci, zombies[ci]->pid,
sigproc_printf ("removing %d, pid %d, nzombies %d", ci, zombies[ci]->pid,
nzombies);
if (zombies[ci])
@ -1078,7 +1076,7 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
int potential_match;
waitq *w = parent_w->next;
sip_printf ("considering pid %d", child->pid);
sigproc_printf ("considering pid %d", child->pid);
if (w->pid == -1)
potential_match = 1;
else if (w->pid == 0)
@ -1101,7 +1099,7 @@ stopped_or_terminated (waitq *parent_w, _pinfo *child)
if (!terminated)
{
sip_printf ("stopped child");
sigproc_printf ("stopped child");
w->status = (child->stopsig << 8) | 0x7f;
child->stopsig = 0;
}
@ -1229,7 +1227,7 @@ wait_sig (VOID *)
rc -= WAIT_OBJECT_0;
int dispatched = FALSE;
sip_printf ("awake");
sigproc_printf ("awake");
/* A sigcatch semaphore has been signaled. Scan the sigtodo
* array looking for any unprocessed signals.
*/
@ -1246,12 +1244,12 @@ wait_sig (VOID *)
(sigismember (& myself->getsigmask (), sig) ||
myself->process_state & PID_STOPPED))
{
sip_printf ("sig %d blocked", sig);
sigproc_printf ("sig %d blocked", sig);
break;
}
/* Found a signal to process */
sip_printf ("processing signal %d", sig);
sigproc_printf ("processing signal %d", sig);
switch (sig)
{
case __SIGFLUSH:
@ -1265,7 +1263,7 @@ wait_sig (VOID *)
/* Signalled from a child process that it has stopped */
case __SIGCHILDSTOPPED:
sip_printf ("Received child stopped notification");
sigproc_printf ("Received child stopped notification");
dispatched |= sig_handle (SIGCHLD);
if (proc_subproc (PROC_CHILDSTOPPED, 0))
dispatched |= 1;
@ -1273,7 +1271,7 @@ wait_sig (VOID *)
/* A normal UNIX signal */
default:
sip_printf ("Got signal %d", sig);
sigproc_printf ("Got signal %d", sig);
int wasdispatched = sig_handle (sig);
dispatched |= wasdispatched;
if (sig == SIGCHLD && wasdispatched)
@ -1308,10 +1306,10 @@ wait_sig (VOID *)
if (dispatched < 0)
pending_signals = 1;
sip_printf ("looping");
sigproc_printf ("looping");
}
sip_printf ("done");
sigproc_printf ("done");
return 0;
}
@ -1319,7 +1317,7 @@ wait_sig (VOID *)
static DWORD WINAPI
wait_subproc (VOID *)
{
sip_printf ("starting");
sigproc_printf ("starting");
int errloop = 0;
for (;;)
@ -1360,12 +1358,12 @@ wait_subproc (VOID *)
rc -= WAIT_OBJECT_0;
if (rc-- != 0)
(void)proc_subproc (PROC_CHILDTERMINATED, rc);
sip_printf ("looping");
sigproc_printf ("looping");
}
ForceCloseHandle (events[0]);
events[0] = NULL;
sip_printf ("done");
sigproc_printf ("done");
return 0;
}

View File

@ -17,7 +17,6 @@ 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); }
class strace NO_COPY strace;
/* 'twould be nice to declare this in winsup.h but winsup.h doesn't require
@ -141,24 +140,30 @@ 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 *fmt, ...)
{
DWORD err = GetLastError ();
if (active)
int count;
char buf[10000];
va_list ap;
PROTECT(buf);
SetLastError (err);
va_start (ap, fmt);
count = this->vsprntf (buf, fmt, ap);
CHECK(buf);
if (category & _STRACE_SYSTEM)
{
int count;
va_list ap;
char buf[10000];
PROTECT(buf);
va_start (ap, fmt);
SetLastError (err);
count = this->vsprntf (buf, fmt, ap);
va_end (ap);
CHECK(buf);
this->write (category, buf, count);
DWORD done;
WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, count, &done, 0);
FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE));
}
#ifndef NOSTRACE
if (active)
this->write (category, buf, count);
#endif
SetLastError (err);
}
@ -343,35 +348,4 @@ strace::wm (int message, int word, int lon)
this->prntf (_STRACE_WM, "wndproc %d unknown %d %d", message, word, lon);
}
}
/* Print a message on stderr (bypassing anything that could prevent the
message from being printed, for example a buggy or corrupted stdio).
This is used, for example, to print diagnostics of fatal errors. */
void
__system_printf (const char *fmt,...)
{
char buf[6000];
va_list ap;
int count;
PROTECT (buf);
va_start (ap, fmt);
count = strace.vsprntf (buf, fmt, ap);
va_end (ap);
CHECK (buf);
DWORD done;
WriteFile (GetStdHandle (STD_ERROR_HANDLE), buf, count, &done, 0);
FlushFileBuffers (GetStdHandle (STD_ERROR_HANDLE));
#ifndef NOSTRACE
if (strace.active)
strace.write (1, buf, count);
#endif
#ifdef DEBUGGING
// try_to_debug ();
#endif
}
#endif /*NOSTRACE*/

View File

@ -23,6 +23,10 @@ details. */
# define memset __builtin_memset
#endif
#if !defined(__STDC_VERSION__) || __STDC_VERSION__ >= 199900L
#define NEW_MACRO_VARARGS
#endif
#include <sys/types.h>
#include <sys/strace.h>
#include <sys/resource.h>
@ -279,8 +283,11 @@ extern unsigned int signal_shift_subtract;
#define MARK() mark (__FILE__,__LINE__)
#endif
#define api_fatal(fmt, args...) \
__api_fatal ("%P: *** " fmt,##args)
#ifdef NEW_MACRO_VARARGS
# define api_fatal(...) __api_fatal ("%P: *** " __VA_ARGS__)
#else
# define api_fatal(fmt, args...) __api_fatal ("%P: *** " fmt,## args)
#endif
#undef issep
#define issep(ch) (strchr (" \t\n\r", (ch)) != NULL)
@ -325,8 +332,6 @@ void events_terminate (void);
void __stdcall close_all_files (void);
extern class strace strace;
/* Invisible window initialization/termination. */
HWND __stdcall gethwnd (void);
void __stdcall window_terminate (void);