Mail Archives: cygwin-apps/2002/04/30/11:38:34
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 <time.h>
#include <ctype.h>
#include <windows.h>
+#include <sys/time.h>
#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 <ralf DOT habacker AT freenet DOT de>
* ssp.c (run_program): Added time stamp printing in verbose mode.
Regards
Ralf
- Raw text -