Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Nick Roberts <nickrob@snap.net.nz>
To: Eli Zaretskii <eliz@gnu.org>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] MI: new timing command
Date: Fri, 02 Feb 2007 23:28:00 -0000	[thread overview]
Message-ID: <17859.51456.360072.344506@kahikatea.snap.net.nz> (raw)
In-Reply-To: <ups8s3cqy.fsf@gnu.org>

[-- Attachment #1: message body and .signature --]
[-- Type: text/plain, Size: 2595 bytes --]

 > This is okay with me, but please use 1000000L rather than just 1000000
 > here:
 > 
 > > +     tv->utime.tv_usec = usec - 1000000*tv->utime.tv_sec;
 > 
 > and here:
 >
 > > + static long 
 > > + timeval_diff (struct timeval start, struct timeval end)
 > > +   {
 > > +     return ((end.tv_sec - start.tv_sec) * 1000000)
 > > +       + (end.tv_usec - start.tv_usec);
 > > +   }
 > 
 > This is to avoid a possible overflow of a 32-bit int on systems where
 > tv_sec is a 32-bit type.

I was so immersed in trying to commit my changes correctly that I missed
this so I had to do it retrospectively.

 > Other than that, this patch can go in, but please show here the exact
 > patch you commit, since you didn't show it in the message to which I'm
 > replying.

I am sending it as an attachment with your change listed separately.  Maybe
I've made mistakes (I've not made changes to configury before) but I'll
be available to correct it if necessary.

Thanks for your help.

-- 
Nick                                           http://www.inet.net.nz/~nickrob


*** mi-main.c	03 Feb 2007 11:31:46 +1300	1.92
--- mi-main.c	03 Feb 2007 12:17:14 +1300	
*************** mi_load_progress (const char *section_na
*** 1461,1467 ****
    if (delta.tv_usec < 0)
      {
        delta.tv_sec -= 1;
!       delta.tv_usec += 1000000;
      }
  
    new_section = (previous_sect_name ?
--- 1461,1467 ----
    if (delta.tv_usec < 0)
      {
        delta.tv_sec -= 1;
!       delta.tv_usec += 1000000L;
      }
  
    new_section = (previous_sect_name ?
*************** timestamp (struct mi_timestamp *tv)
*** 1537,1544 ****
      tv->stime.tv_usec = rusage.ru_stime.tv_usec;
  #else
      usec = get_run_time ();
!     tv->utime.tv_sec = usec/1000000;
!     tv->utime.tv_usec = usec - 1000000*tv->utime.tv_sec;
      tv->stime.tv_sec = 0;
      tv->stime.tv_usec = 0;
  #endif
--- 1537,1544 ----
      tv->stime.tv_usec = rusage.ru_stime.tv_usec;
  #else
      usec = get_run_time ();
!     tv->utime.tv_sec = usec/1000000L;
!     tv->utime.tv_usec = usec - 1000000L*tv->utime.tv_sec;
      tv->stime.tv_sec = 0;
      tv->stime.tv_usec = 0;
  #endif
*************** print_diff_now (struct mi_timestamp *sta
*** 1555,1561 ****
  static long 
  timeval_diff (struct timeval start, struct timeval end)
    {
!     return ((end.tv_sec - start.tv_sec) * 1000000)
        + (end.tv_usec - start.tv_usec);
    }
  
--- 1555,1561 ----
  static long 
  timeval_diff (struct timeval start, struct timeval end)
    {
!     return ((end.tv_sec - start.tv_sec) * 1000000L)
        + (end.tv_usec - start.tv_usec);
    }
  

[-- Attachment #2: timing patch --]
[-- Type: application/octet-stream, Size: 19829 bytes --]

Index: configure.ac
===================================================================
RCS file: /cvs/src/src/gdb/configure.ac,v
retrieving revision 1.41
diff -c -p -r1.41 configure.ac
*** configure.ac	9 Jan 2007 21:34:29 -0000	1.41
--- configure.ac	2 Feb 2007 22:42:59 -0000
*************** AC_CHECK_HEADERS(sys/file.h)
*** 376,381 ****
--- 376,382 ----
  AC_CHECK_HEADERS(sys/filio.h)
  AC_CHECK_HEADERS(sys/ioctl.h)
  AC_CHECK_HEADERS(sys/param.h)
+ AC_CHECK_HEADERS(sys/resource.h)
  AC_CHECK_HEADERS(sys/proc.h, [], [],
  [#if HAVE_SYS_PARAM_H
  # include <sys/param.h>
*************** AC_FUNC_ALLOCA
*** 463,468 ****
--- 464,470 ----
  AC_FUNC_MMAP
  AC_FUNC_VFORK
  AC_CHECK_FUNCS(canonicalize_file_name realpath)
+ AC_CHECK_FUNCS(getrusage)
  AC_CHECK_FUNCS(getuid getgid)
  AC_CHECK_FUNCS(poll)
  AC_CHECK_FUNCS(pread64)
Index: configure
===================================================================
RCS file: /cvs/src/src/gdb/configure,v
retrieving revision 1.220
diff -c -p -r1.220 configure
*** configure	9 Jan 2007 21:34:30 -0000	1.220
--- configure	2 Feb 2007 22:43:47 -0000
*************** fi
*** 9061,9066 ****
--- 9061,9216 ----
  done
  
  
+ for ac_header in sys/resource.h
+ do
+ as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo "$as_me:$LINENO: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ fi
+ echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ else
+   # Is the header compilable?
+ echo "$as_me:$LINENO: checking $ac_header usability" >&5
+ echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+ $ac_includes_default
+ #include <$ac_header>
+ _ACEOF
+ rm -f conftest.$ac_objext
+ if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
+   (eval $ac_compile) 2>conftest.er1
+   ac_status=$?
+   grep -v '^ *+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+ 	 { ac_try='test -z "$ac_c_werror_flag"
+ 			 || test ! -s conftest.err'
+   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }; } &&
+ 	 { ac_try='test -s conftest.$ac_objext'
+   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   ac_header_compiler=yes
+ else
+   echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+ 
+ ac_header_compiler=no
+ fi
+ rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
+ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+ echo "${ECHO_T}$ac_header_compiler" >&6
+ 
+ # Is the header present?
+ echo "$as_me:$LINENO: checking $ac_header presence" >&5
+ echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6
+ cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+ #include <$ac_header>
+ _ACEOF
+ if { (eval echo "$as_me:$LINENO: \"$ac_cpp conftest.$ac_ext\"") >&5
+   (eval $ac_cpp conftest.$ac_ext) 2>conftest.er1
+   ac_status=$?
+   grep -v '^ *+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } >/dev/null; then
+   if test -s conftest.err; then
+     ac_cpp_err=$ac_c_preproc_warn_flag
+     ac_cpp_err=$ac_cpp_err$ac_c_werror_flag
+   else
+     ac_cpp_err=
+   fi
+ else
+   ac_cpp_err=yes
+ fi
+ if test -z "$ac_cpp_err"; then
+   ac_header_preproc=yes
+ else
+   echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+ 
+   ac_header_preproc=no
+ fi
+ rm -f conftest.err conftest.$ac_ext
+ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+ echo "${ECHO_T}$ac_header_preproc" >&6
+ 
+ # So?  What about this header?
+ case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+   yes:no: )
+     { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5
+ echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;}
+     { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5
+ echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;}
+     ac_header_preproc=yes
+     ;;
+   no:yes:* )
+     { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5
+ echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;}
+     { echo "$as_me:$LINENO: WARNING: $ac_header:     check for missing prerequisite headers?" >&5
+ echo "$as_me: WARNING: $ac_header:     check for missing prerequisite headers?" >&2;}
+     { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5
+ echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;}
+     { echo "$as_me:$LINENO: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&5
+ echo "$as_me: WARNING: $ac_header:     section \"Present But Cannot Be Compiled\"" >&2;}
+     { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5
+ echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;}
+     { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5
+ echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;}
+     (
+       cat <<\_ASBOX
+ ## ------------------------------------------ ##
+ ## Report this to the AC_PACKAGE_NAME lists.  ##
+ ## ------------------------------------------ ##
+ _ASBOX
+     ) |
+       sed "s/^/$as_me: WARNING:     /" >&2
+     ;;
+ esac
+ echo "$as_me:$LINENO: checking for $ac_header" >&5
+ echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_Header+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   eval "$as_ac_Header=\$ac_header_preproc"
+ fi
+ echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_Header'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_Header'}'`" >&6
+ 
+ fi
+ if test `eval echo '${'$as_ac_Header'}'` = yes; then
+   cat >>confdefs.h <<_ACEOF
+ #define `echo "HAVE_$ac_header" | $as_tr_cpp` 1
+ _ACEOF
+ 
+ fi
+ 
+ done
+ 
+ 
  for ac_header in sys/proc.h
  do
  as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
*************** fi
*** 16561,16566 ****
--- 16711,16818 ----
  done
  
  
+ for ac_func in getrusage
+ do
+ as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ echo "$as_me:$LINENO: checking for $ac_func" >&5
+ echo $ECHO_N "checking for $ac_func... $ECHO_C" >&6
+ if eval "test \"\${$as_ac_var+set}\" = set"; then
+   echo $ECHO_N "(cached) $ECHO_C" >&6
+ else
+   cat >conftest.$ac_ext <<_ACEOF
+ /* confdefs.h.  */
+ _ACEOF
+ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
+ /* Define $ac_func to an innocuous variant, in case <limits.h> declares $ac_func.
+    For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+ #define $ac_func innocuous_$ac_func
+ 
+ /* System header to define __stub macros and hopefully few prototypes,
+     which can conflict with char $ac_func (); below.
+     Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+     <limits.h> exists even on freestanding compilers.  */
+ 
+ #ifdef __STDC__
+ # include <limits.h>
+ #else
+ # include <assert.h>
+ #endif
+ 
+ #undef $ac_func
+ 
+ /* Override any gcc2 internal prototype to avoid an error.  */
+ #ifdef __cplusplus
+ extern "C"
+ {
+ #endif
+ /* We use char because int might match the return type of a gcc2
+    builtin and then its argument prototype would still apply.  */
+ char $ac_func ();
+ /* The GNU C library defines this for functions which it implements
+     to always fail with ENOSYS.  Some functions are actually named
+     something starting with __ and the normal name is an alias.  */
+ #if defined (__stub_$ac_func) || defined (__stub___$ac_func)
+ choke me
+ #else
+ char (*f) () = $ac_func;
+ #endif
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ int
+ main ()
+ {
+ return f != $ac_func;
+   ;
+   return 0;
+ }
+ _ACEOF
+ rm -f conftest.$ac_objext conftest$ac_exeext
+ if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
+   (eval $ac_link) 2>conftest.er1
+   ac_status=$?
+   grep -v '^ *+' conftest.er1 >conftest.err
+   rm -f conftest.er1
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); } &&
+ 	 { ac_try='test -z "$ac_c_werror_flag"
+ 			 || test ! -s conftest.err'
+   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }; } &&
+ 	 { ac_try='test -s conftest$ac_exeext'
+   { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
+   (eval $ac_try) 2>&5
+   ac_status=$?
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   (exit $ac_status); }; }; then
+   eval "$as_ac_var=yes"
+ else
+   echo "$as_me: failed program was:" >&5
+ sed 's/^/| /' conftest.$ac_ext >&5
+ 
+ eval "$as_ac_var=no"
+ fi
+ rm -f conftest.err conftest.$ac_objext \
+       conftest$ac_exeext conftest.$ac_ext
+ fi
+ echo "$as_me:$LINENO: result: `eval echo '${'$as_ac_var'}'`" >&5
+ echo "${ECHO_T}`eval echo '${'$as_ac_var'}'`" >&6
+ if test `eval echo '${'$as_ac_var'}'` = yes; then
+   cat >>confdefs.h <<_ACEOF
+ #define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
+ _ACEOF
+ 
+ fi
+ done
+ 
+ 
  
  for ac_func in getuid getgid
  do
Index: config.in
===================================================================
RCS file: /cvs/src/src/gdb/config.in,v
retrieving revision 1.87
diff -c -p -r1.87 config.in
*** config.in	9 Jan 2007 21:34:30 -0000	1.87
--- config.in	2 Feb 2007 22:43:49 -0000
***************
*** 122,127 ****
--- 122,130 ----
  /* Define to 1 if you have the `getpagesize' function. */
  #undef HAVE_GETPAGESIZE
  
+ /* Define to 1 if you have the `getrusage' function. */
+ #undef HAVE_GETRUSAGE
+ 
  /* Define to 1 if you have the `getuid' function. */
  #undef HAVE_GETUID
  
***************
*** 388,393 ****
--- 391,399 ----
  /* Define to 1 if you have the <sys/reg.h> header file. */
  #undef HAVE_SYS_REG_H
  
+ /* Define to 1 if you have the <sys/resource.h> header file. */
+ #undef HAVE_SYS_RESOURCE_H
+ 
  /* Define to 1 if you have the <sys/select.h> header file. */
  #undef HAVE_SYS_SELECT_H
  
Index: mi/mi-main.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-main.c,v
retrieving revision 1.91
diff -c -p -r1.91 mi-main.c
*** mi/mi-main.c	23 Jan 2007 20:27:58 -0000	1.91
--- mi/mi-main.c	2 Feb 2007 22:43:51 -0000
***************
*** 50,55 ****
--- 50,63 ----
  #include <ctype.h>
  #include <sys/time.h>
  
+ #if defined HAVE_SYS_RESOURCE_H
+ #include <sys/resource.h>
+ #endif
+ 
+ #ifdef HAVE_GETRUSAGE
+ struct rusage rusage;
+ #endif
+ 
  enum
    {
      FROM_TTY = 0
*************** struct captured_mi_execute_command_args
*** 81,86 ****
--- 89,100 ----
  int mi_debug_p;
  struct ui_file *raw_stdout;
  
+ /* This is used to pass the current command timestamp
+    down to continuation routines.  */
+ static struct mi_timestamp *current_command_ts;
+ 
+ static int do_timings = 0;
+ 
  /* The token of the last asynchronous command */
  static char *last_async_command;
  static char *previous_async_command;
*************** static int get_register (int regnum, int
*** 103,108 ****
--- 117,127 ----
     layer that calls libgdb.  Any operation used in the below should be
     formalized. */
  
+ static void timestamp (struct mi_timestamp *tv);
+ 
+ static void print_diff_now (struct mi_timestamp *start);
+ static void print_diff (struct mi_timestamp *start, struct mi_timestamp *end);
+ 
  enum mi_cmd_result
  mi_cmd_gdb_exit (char *command, char **argv, int argc)
  {
*************** mi_cmd_exec_continue (char *args, int fr
*** 194,200 ****
  }
  
  /* Interrupt the execution of the target. Note how we must play around
!    with the token varialbes, in order to display the current token in
     the result of the interrupt command, and the previous execution
     token when the target finally stops. See comments in
     mi_cmd_execute. */
--- 213,219 ----
  }
  
  /* Interrupt the execution of the target. Note how we must play around
!    with the token variables, in order to display the current token in
     the result of the interrupt command, and the previous execution
     token when the target finally stops. See comments in
     mi_cmd_execute. */
*************** mi_cmd_data_write_memory (char *command,
*** 1013,1018 ****
--- 1032,1061 ----
    return MI_CMD_DONE;
  }
  
+ enum mi_cmd_result
+ mi_cmd_enable_timings (char *command, char **argv, int argc)
+ {
+   if (argc == 0)
+     do_timings = 1;
+   else if (argc == 1)
+     {
+       if (strcmp (argv[0], "yes") == 0)
+ 	do_timings = 1;
+       else if (strcmp (argv[0], "no") == 0)
+ 	do_timings = 0;
+       else
+ 	goto usage_error;
+     }
+   else
+     goto usage_error;
+     
+   return MI_CMD_DONE;
+ 
+  usage_error:
+   error ("mi_cmd_enable_timings: Usage: %s {yes|no}", command);
+   return MI_CMD_ERROR;
+ }
+ 
  /* Execute a command within a safe environment.
     Return <0 for error; >=0 for ok.
  
*************** captured_mi_execute_command (struct ui_o
*** 1027,1032 ****
--- 1070,1077 ----
      (struct captured_mi_execute_command_args *) data;
    struct mi_parse *context = args->command;
  
+   struct mi_timestamp cmd_finished;
+ 
    switch (context->op)
      {
  
*************** captured_mi_execute_command (struct ui_o
*** 1041,1048 ****
--- 1086,1100 ----
           indication of what action is required and then switch on
           that. */
        args->action = EXECUTE_COMMAND_DISPLAY_PROMPT;
+ 
+       if (do_timings)
+ 	current_command_ts = context->cmd_start;
+ 
        args->rc = mi_cmd_execute (context);
  
+       if (do_timings)
+           timestamp (&cmd_finished);
+ 
        if (!target_can_async_p () || !target_executing)
  	{
  	  /* print the result if there were no errors
*************** captured_mi_execute_command (struct ui_o
*** 1057,1062 ****
--- 1109,1118 ----
  	      fputs_unfiltered ("^done", raw_stdout);
  	      mi_out_put (uiout, raw_stdout);
  	      mi_out_rewind (uiout);
+ 	      /* Have to check cmd_start, since the command could be
+ 		 -enable-timings.  */
+ 	      if (do_timings && context->cmd_start)
+ 		  print_diff (context->cmd_start, &cmd_finished);
  	      fputs_unfiltered ("\n", raw_stdout);
  	    }
  	  else if (args->rc == MI_CMD_ERROR)
*************** mi_execute_command (char *cmd, int from_
*** 1152,1157 ****
--- 1208,1221 ----
    if (command != NULL)
      {
        struct gdb_exception result;
+ 
+       if (do_timings)
+ 	{
+ 	  command->cmd_start = (struct mi_timestamp *)
+ 	    xmalloc (sizeof (struct mi_timestamp));
+ 	  timestamp (command->cmd_start);
+ 	}
+ 
        /* FIXME: cagney/1999-11-04: Can this use of catch_exceptions either
           be pushed even further down or even eliminated? */
        args.command = command;
*************** mi_execute_async_cli_command (char *mi, 
*** 1341,1346 ****
--- 1405,1412 ----
        fputs_unfiltered ("*stopped", raw_stdout);
        mi_out_put (uiout, raw_stdout);
        mi_out_rewind (uiout);
+       if (do_timings)
+       	print_diff_now (current_command_ts);
        fputs_unfiltered ("\n", raw_stdout);
        return MI_CMD_QUIET;
      }
*************** _initialize_mi_main (void)
*** 1457,1459 ****
--- 1523,1571 ----
    DEPRECATED_REGISTER_GDBARCH_SWAP (old_regs);
    deprecated_register_gdbarch_swap (NULL, 0, mi_setup_architecture_data);
  }
+ 
+ static void 
+ timestamp (struct mi_timestamp *tv)
+   {
+     long usec;
+     gettimeofday (&tv->wallclock, NULL);
+ #ifdef HAVE_GETRUSAGE
+     getrusage (RUSAGE_SELF, &rusage);
+     tv->utime.tv_sec = rusage.ru_utime.tv_sec;
+     tv->utime.tv_usec = rusage.ru_utime.tv_usec;
+     tv->stime.tv_sec = rusage.ru_stime.tv_sec;
+     tv->stime.tv_usec = rusage.ru_stime.tv_usec;
+ #else
+     usec = get_run_time ();
+     tv->utime.tv_sec = usec/1000000;
+     tv->utime.tv_usec = usec - 1000000*tv->utime.tv_sec;
+     tv->stime.tv_sec = 0;
+     tv->stime.tv_usec = 0;
+ #endif
+   }
+ 
+ static void 
+ print_diff_now (struct mi_timestamp *start)
+   {
+     struct mi_timestamp now;
+     timestamp (&now);
+     print_diff (start, &now);
+   }
+ 
+ static long 
+ timeval_diff (struct timeval start, struct timeval end)
+   {
+     return ((end.tv_sec - start.tv_sec) * 1000000)
+       + (end.tv_usec - start.tv_usec);
+   }
+ 
+ static void 
+ print_diff (struct mi_timestamp *start, struct mi_timestamp *end)
+   {
+     fprintf_unfiltered
+       (raw_stdout,
+        ",time={wallclock=\"%0.5f\",user=\"%0.5f\",system=\"%0.5f\"}", 
+        timeval_diff (start->wallclock, end->wallclock) / 1000000.0, 
+        timeval_diff (start->utime, end->utime) / 1000000.0, 
+        timeval_diff (start->stime, end->stime) / 1000000.0);
+   }
Index: mi/mi-cmds.c
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.c,v
retrieving revision 1.23
diff -c -p -r1.23 mi-cmds.c
*** mi/mi-cmds.c	9 Jan 2007 17:59:08 -0000	1.23
--- mi/mi-cmds.c	2 Feb 2007 22:43:52 -0000
*************** struct mi_cmd mi_cmds[] =
*** 53,58 ****
--- 53,59 ----
    { "data-read-memory", { NULL, 0 }, 0, mi_cmd_data_read_memory},
    { "data-write-memory", { NULL, 0 }, 0, mi_cmd_data_write_memory},
    { "data-write-register-values", { NULL, 0 }, 0, mi_cmd_data_write_register_values},
+   { "enable-timings", { NULL, 0 }, 0, mi_cmd_enable_timings},
    { "environment-cd", { NULL, 0 }, 0, mi_cmd_env_cd},
    { "environment-directory", { NULL, 0 }, 0, mi_cmd_env_dir},
    { "environment-path", { NULL, 0 }, 0, mi_cmd_env_path},
Index: mi/mi-cmds.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-cmds.h,v
retrieving revision 1.20
diff -c -p -r1.20 mi-cmds.h
*** mi/mi-cmds.h	9 Jan 2007 17:59:08 -0000	1.20
--- mi/mi-cmds.h	2 Feb 2007 22:43:52 -0000
*************** extern mi_cmd_argv_ftype mi_cmd_data_lis
*** 72,77 ****
--- 72,78 ----
  extern mi_cmd_argv_ftype mi_cmd_data_read_memory;
  extern mi_cmd_argv_ftype mi_cmd_data_write_memory;
  extern mi_cmd_argv_ftype mi_cmd_data_write_register_values;
+ extern mi_cmd_argv_ftype mi_cmd_enable_timings;
  extern mi_cmd_argv_ftype mi_cmd_env_cd;
  extern mi_cmd_argv_ftype mi_cmd_env_dir;
  extern mi_cmd_argv_ftype mi_cmd_env_path;
Index: mi/mi-parse.h
===================================================================
RCS file: /cvs/src/src/gdb/mi/mi-parse.h,v
retrieving revision 1.6
diff -c -p -r1.6 mi-parse.h
*** mi/mi-parse.h	9 Jan 2007 17:59:08 -0000	1.6
--- mi/mi-parse.h	2 Feb 2007 22:43:52 -0000
***************
*** 24,29 ****
--- 24,36 ----
  
  /* MI parser */
  
+ /* Timestamps for current command and last asynchronous command.  */
+ struct mi_timestamp {
+   struct timeval wallclock;
+   struct timeval utime;
+   struct timeval stime;
+ };
+ 
  enum mi_command_type
    {
      MI_COMMAND, CLI_COMMAND
*************** struct mi_parse
*** 35,40 ****
--- 42,48 ----
      char *command;
      char *token;
      const struct mi_cmd *cmd;
+     struct mi_timestamp *cmd_start;
      char *args;
      char **argv;
      int argc;

  reply	other threads:[~2007-02-02 23:28 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-30  8:52 Nick Roberts
2006-12-30 12:09 ` Vladimir Prus
2006-12-30 16:10   ` Eli Zaretskii
2006-12-31  3:26     ` Nick Roberts
2006-12-31  4:26       ` Eli Zaretskii
2006-12-31  6:55   ` Nick Roberts
2006-12-31 15:10     ` Daniel Jacobowitz
2007-01-01  4:11       ` Nick Roberts
2007-01-03 18:01         ` Daniel Jacobowitz
2007-01-03 21:50           ` Nick Roberts
2007-01-03 22:59             ` Daniel Jacobowitz
2007-01-04  2:50               ` Nick Roberts
2006-12-31 15:33     ` Vladimir Prus
2006-12-30 16:09 ` Eli Zaretskii
2006-12-30 22:10   ` Nick Roberts
2006-12-31  4:22     ` Eli Zaretskii
2006-12-31  4:25       ` Daniel Jacobowitz
2006-12-31  5:18         ` Nick Roberts
2006-12-31  5:49           ` Daniel Jacobowitz
2006-12-31  7:47             ` Nick Roberts
2006-12-31 15:15               ` Daniel Jacobowitz
2006-12-31 15:24                 ` Mark Kettenis
2006-12-31 15:39                   ` Vladimir Prus
2006-12-31 16:09                     ` Mark Kettenis
2006-12-31 16:21                       ` Vladimir Prus
2006-12-31 19:29                         ` Daniel Jacobowitz
2006-12-31 22:08                         ` Eli Zaretskii
2007-01-01  4:24                           ` Nick Roberts
2007-01-01  6:06                             ` Eli Zaretskii
2007-01-01  4:07                       ` Nick Roberts
2007-01-01  5:58                         ` Eli Zaretskii
2007-01-01 22:07                           ` Nick Roberts
2007-01-02  4:20                             ` Eli Zaretskii
2007-01-16  5:57                               ` Nick Roberts
2007-01-16 22:17                                 ` Eli Zaretskii
2007-01-16 22:30                                   ` Nick Roberts
2007-01-16 23:01                                     ` Eli Zaretskii
2007-01-20 17:27                                 ` Eli Zaretskii
2007-01-20 20:58                                   ` Nick Roberts
2007-01-27 14:53                                     ` Eli Zaretskii
2007-01-27 15:10                                       ` Eli Zaretskii
2007-01-27 22:12                                         ` Nick Roberts
2007-01-27 22:19                                           ` Nick Roberts
2007-01-27 22:08                                       ` Nick Roberts
2007-01-28  4:17                                         ` Eli Zaretskii
2007-01-28  5:31                                           ` Nick Roberts
2007-02-02 13:33                                             ` Eli Zaretskii
2007-02-02 23:28                                               ` Nick Roberts [this message]
2007-02-03 11:10                                                 ` Eli Zaretskii
2007-01-01  9:18                 ` Nick Roberts
2007-01-01 16:21                   ` Daniel Jacobowitz
2006-12-31 15:34               ` Vladimir Prus
2006-12-31 11:58       ` Mark Kettenis
2006-12-31  7:50   ` Nick Roberts
2006-12-31 18:33     ` Vladimir Prus
2007-01-01  4:18       ` Nick Roberts
2006-12-31 22:10     ` Eli Zaretskii

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=17859.51456.360072.344506@kahikatea.snap.net.nz \
    --to=nickrob@snap.net.nz \
    --cc=eliz@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox