From: Eli Zaretskii <eliz@gnu.org>
To: Nick Roberts <nickrob@snap.net.nz>
Cc: gdb-patches@sources.redhat.com
Subject: Re: [PATCH] MI: new timing command
Date: Sat, 27 Jan 2007 14:53:00 -0000 [thread overview]
Message-ID: <u1wlgbjwr.fsf@gnu.org> (raw)
In-Reply-To: <17842.33386.836316.276127@kahikatea.snap.net.nz> (message from Nick Roberts on Sun, 21 Jan 2007 09:58:18 +1300)
> From: Nick Roberts <nickrob@snap.net.nz>
> Date: Sun, 21 Jan 2007 09:58:18 +1300
> Cc: gdb-patches@sources.redhat.com
>
> > I tried, but unfortunately, I cannot compile the patched version. It
> > seems like at least one part of your patch was never sent to the list:
> >
> > * mi/mi-parse.h: Include <sys/resource.h> if present.
> > (mi_timestamp): New structure.
> > (mi_parse): Add mi_timestamp* member.
> >
> > Without this, mi-main.c doesn't compile, because it misses the
> > definition of the mi_timestamp structure.
>
> Yes, sorry. It was part of an earlier patch but got left out somehow.
Okay, I tried this now, and on a system which has sys/resource.h and
getrusage, it works both with HAVE_SYS_RESOURCE_H and HAVE_GETRUSAGE
and without them (I hacked config.h to get it compiled both ways).
However, I don't see how it can work on systems without sys/resource.h
and without getrusage: your patch uses struct rusage unconditionally:
mi-parse.h:
+ #include <sys/resource.h>
+
+ /* Timestamps for current command and last asynchronous command */
+ struct mi_timestamp {
+ struct timeval wallclock;
+ struct rusage rusage;
+ };
+
m-main.c:
+ static void
+ timestamp (struct mi_timestamp *tv)
+ {
+ long usec;
+ #ifdef HAVE_GETRUSAGE
+ gettimeofday (&tv->wallclock, NULL);
+ getrusage (RUSAGE_SELF, &tv->rusage);
+ #else
+ usec = get_run_time ();
+ tv->wallclock.tv_sec = usec/1000000;
+ tv->wallclock.utv_sec = usec - 1000000*tv->wallclock.tv_sec;
+ tv->rusage.ru_utime.tv_sec = 0;
+ tv->rusage.ru_utime.tv_usec = 0;
+ tv->rusage.ru_stime.tv_sec = 0;
+ tv->rusage.ru_stime.tv_usec = 0;
+ #endif
+ }
Note that mi-parse.h includes sys/resource.h unconditionally, which
will fail to compile on systems that don't have that header; and both
mi-parse.h and mi-main.c use struct rusage.
Also, in mi-main.c, there's no need to use gettimeofday only in
the HAVE_GETRUSAGE branch, as its availability is independent of
HAVE_GETRUSAGE.
I suggest to use gettimeofday to compute wallclock time on all
platforms, and avoid using struct rusage in struct mi_timestamp,
e.g. like this:
struct mi_timestamp {
struct timeval wallclock;
struct timeval utime;
struct timeval stime'
}
Then in mi-main.c:timestamp you could copy the values from what
getrusage returns to the utime and stime members of mi_timestamp, when
getrusage is available, and if not, assign the value returned by
get_run_time to members of utime.
If you submit a modified patch that does the above, I will test it on
a platform that doesn't have getrusage.
TIA
next prev parent reply other threads:[~2007-01-27 14:53 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 [this message]
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
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=u1wlgbjwr.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=gdb-patches@sources.redhat.com \
--cc=nickrob@snap.net.nz \
/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