From 86fbc3d90be4aa7a039e3800e3bf0f9a36c2944a Mon Sep 17 00:00:00 2001 From: Egor Duda Date: Sun, 4 Nov 2001 12:57:55 +0000 Subject: [PATCH] * strace.cc (main): New option '-w'. Start traced process in separate window. New option '-S x'. Flush buffered output every x seconds. (create_child): Start child process in new window, when requested. When requested, periodically flush debugging output. --- winsup/utils/ChangeLog | 7 +++++++ winsup/utils/strace.cc | 27 ++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 3 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index e52de1e3b..9df1877a9 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,10 @@ +2001-11-04 Egor Duda + + * strace.cc (main): New option '-w'. Start traced process in separate + window. New option '-S x'. Flush buffered output every x seconds. + (create_child): Start child process in new window, when requested. + When requested, periodically flush debugging output. + 2001-10-24 Christopher Faylor * Makefile.in: Remove EXEEXT consideration. We always need .exe diff --git a/winsup/utils/strace.cc b/winsup/utils/strace.cc index 58547ed4a..bd68d4a98 100644 --- a/winsup/utils/strace.cc +++ b/winsup/utils/strace.cc @@ -16,6 +16,7 @@ details. */ #include #include #include +#include #include #include #include "sys/strace.h" @@ -36,6 +37,8 @@ static int usecs = 1; static int delta = 1; static int hhmmss = 0; static int bufsize = 0; +static int new_window = 0; +static long flush_period = 0; static BOOL close_handle (HANDLE h, DWORD ok); @@ -264,8 +267,8 @@ create_child (char **argv) /* cygwin32_conv_to_win32_path (exec_file, real_path); */ flags = forkdebug ? 0 : DEBUG_ONLY_THIS_PROCESS; - flags |= - /*CREATE_NEW_PROCESS_GROUP | */ CREATE_DEFAULT_ERROR_MODE | DEBUG_PROCESS; + flags |= CREATE_DEFAULT_ERROR_MODE | DEBUG_PROCESS; + flags |= (new_window ? CREATE_NEW_CONSOLE | CREATE_NEW_PROCESS_GROUP : 0); make_command_line (one_line, argv); @@ -524,11 +527,22 @@ proc_child (unsigned mask, FILE *ofile) { DEBUG_EVENT ev; int processes = 0; + time_t cur_time, last_time; + SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); + last_time = time (NULL); while (1) { BOOL debug_event = WaitForDebugEvent (&ev, 1000); DWORD status = DBG_CONTINUE; + + if (bufsize && flush_period > 0 && + (cur_time = time (NULL)) >= last_time + flush_period) + { + last_time = cur_time; + fflush (ofile); + } + if (!debug_event) continue; @@ -600,7 +614,7 @@ main (int argc, char **argv) else pgm++; - while ((opt = getopt (argc, argv, "b:m:o:fndut")) != EOF) + while ((opt = getopt (argc, argv, "b:m:o:fndutwS:")) != EOF) switch (opt) { case 'f': @@ -630,6 +644,13 @@ main (int argc, char **argv) break; case 'u': usecs ^= 1; + break; + case 'w': + new_window ^= 1; + break; + case 'S': + flush_period = strtol (optarg, NULL, 10); + break; } if (!mask)