From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6663 invoked by alias); 27 Jan 2007 14:53:45 -0000 Received: (qmail 6651 invoked by uid 22791); 27 Jan 2007 14:53:43 -0000 X-Spam-Check-By: sourceware.org Received: from romy.inter.net.il (HELO romy.inter.net.il) (213.8.233.24) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sat, 27 Jan 2007 14:53:36 +0000 Received: from HOME-C4E4A596F7 (IGLD-80-230-247-172.inter.net.il [80.230.247.172]) by romy.inter.net.il (MOS 3.7.3-GA) with ESMTP id GYZ29591 (AUTH halo1); Sat, 27 Jan 2007 16:53:34 +0200 (IST) Date: Sat, 27 Jan 2007 14:53:00 -0000 Message-Id: From: Eli Zaretskii To: Nick Roberts CC: gdb-patches@sources.redhat.com In-reply-to: <17842.33386.836316.276127@kahikatea.snap.net.nz> (message from Nick Roberts on Sun, 21 Jan 2007 09:58:18 +1300) Subject: Re: [PATCH] MI: new timing command Reply-to: Eli Zaretskii References: <17814.10139.269708.848818@kahikatea.snap.net.nz> <17814.58031.865155.682869@kahikatea.snap.net.nz> <20061231042547.GA3236@nevyn.them.org> <17815.18190.987950.612053@kahikatea.snap.net.nz> <20061231054946.GA4873@nevyn.them.org> <17815.27092.497145.908734@kahikatea.snap.net.nz> <20061231151527.GC16449@nevyn.them.org> <200612311524.kBVFObud010411@brahms.sibelius.xs4all.nl> <200612311609.kBVG9Fgh022431@brahms.sibelius.xs4all.nl> <17816.34925.514170.51734@farnswood.snap.net.nz> <17817.34304.221915.628057@kahikatea.snap.net.nz> <17836.26941.915573.399839@kahikatea.snap.net.nz> <17842.33386.836316.276127@kahikatea.snap.net.nz> X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2007-01/txt/msg00553.txt.bz2 > From: Nick Roberts > 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 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 + + /* 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