Mailing-List: contact cygwin-apps-help AT cygwin DOT com; run by ezmlm Sender: cygwin-apps-owner AT cygwin DOT com List-Subscribe: List-Archive: List-Post: List-Help: , Mail-Followup-To: cygwin-apps AT cygwin DOT com Delivered-To: mailing list cygwin-apps AT cygwin DOT com From: "Ralf Habacker" To: "Cygwin-Apps" Subject: time stamp printing for ssp Date: Tue, 30 Apr 2002 17:31:56 +0200 Message-ID: <001201c1f05c$29775b30$651c440a@BRAMSCHE> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4133.2400 Importance: Normal Hi, for application debugging I had the need to see the elapsed time for any step in ssp, so I've added time stamp printing. -------------------------------------------------------------------------------- $ cvs diff -p ssp.c Index: ssp.c =================================================================== RCS file: /cvs/src/src/winsup/utils/ssp.c,v retrieving revision 1.3 diff -u -3 -p -B -p -r1.3 ssp.c --- ssp.c 27 Feb 2002 16:10:17 -0000 1.3 +++ ssp.c 30 Apr 2002 15:30:23 -0000 @@ -20,6 +20,7 @@ #include #include #include +#include #ifdef __GNUC__ const char *help_text = "\ @@ -326,6 +327,8 @@ run_program (char *cmdline) int tix, i; HANDLE hThread; char *string; + long long int starttime,ctime; + struct timeval time; memset (&startup, 0, sizeof (startup)); startup.cb = sizeof (startup); @@ -376,6 +379,13 @@ run_program (char *cmdline) } } + if (verbose) + { + /* init timecounter */ + gettimeofday(&time,NULL); + starttime = time.tv_sec * 1000000 + time.tv_usec; + } + running = 1; while (running) { @@ -407,10 +417,24 @@ run_program (char *cmdline) printf ("\n"); #endif + if (verbose) { + /* print current time */ + gettimeofday(&time,NULL); + ctime = time.tv_sec * 1000000 + time.tv_usec - starttime; + { + int min = (int) (ctime /60000000); + int sec = (int) (ctime /1000000); + int millisec = (int) ((ctime /1000) %1000); + printf("%02d:%02d.%03d ",min,sec,millisec); + } + } + switch (event.dwDebugEventCode) { case CREATE_PROCESS_DEBUG_EVENT: + if (verbose) + printf("create process at %08x\n",event.u.CreateProcessInfo.lpStartAddress); break; case CREATE_THREAD_DEBUG_EVENT: @@ -653,6 +677,10 @@ run_program (char *cmdline) running = 0; break; + + default: + if (verbose) + printf("unknown event\n"); } set_steps (); -------------------------------------------------------------------------------- ----- 2002-04-30 Ralf Habacker * ssp.c (run_program): Added time stamp printing in verbose mode. Regards Ralf