From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2155) id BA7663896C07; Tue, 3 Aug 2021 08:03:48 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BA7663896C07 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Cygwin: Make gmondump conform to its doc + adjust doc X-Act-Checkin: newlib-cygwin X-Git-Author: Mark Geisert X-Git-Refname: refs/heads/master X-Git-Oldrev: 15c53a34bc944346fde129700a020647095b1b7d X-Git-Newrev: 99a4b087d41b71ccb2d39900c74ef4b8cf0320fc Message-Id: <20210803080348.BA7663896C07@sourceware.org> Date: Tue, 3 Aug 2021 08:03:48 +0000 (GMT) X-BeenThere: cygwin-cvs@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Cygwin core component git logs List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Aug 2021 08:03:48 -0000 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=99a4b087d41b71ccb2d39900c74ef4b8cf0320fc commit 99a4b087d41b71ccb2d39900c74ef4b8cf0320fc Author: Mark Geisert Date: Mon Aug 2 02:25:53 2021 -0700 Cygwin: Make gmondump conform to its doc + adjust doc The doc for gmondump says 1 or more FILENAME are expected, but 0 is handled. That's an oversight. Make invocation with 0 FILENAMEs print a one-line help message. Reword the beginning of profiler's description doc to clarify target's child processes are run but only optionally profiled. Diff: --- winsup/doc/utils.xml | 7 ++++--- winsup/utils/gmondump.c | 12 ++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/winsup/doc/utils.xml b/winsup/doc/utils.xml index 659541f00..0b9e38549 100644 --- a/winsup/doc/utils.xml +++ b/winsup/doc/utils.xml @@ -2240,9 +2240,10 @@ specifying an empty password. Description - The profiler utility executes a given program, and - optionally the children of that program, collecting the location of the - CPU instruction pointer (IP) many times per second. This gives a profile + The profiler utility executes a given program and + any children of that program, collecting the location of the CPU + instruction pointer (IP) many times per second. (It is optional to + collect this info from child processes.) This info gives a profile of the program's execution, showing where the most time is being spent. This profiling technique is called "IP sampling". diff --git a/winsup/utils/gmondump.c b/winsup/utils/gmondump.c index e469f01f1..ec9db0598 100644 --- a/winsup/utils/gmondump.c +++ b/winsup/utils/gmondump.c @@ -46,6 +46,14 @@ OPTIONS are:\n\ exit (where == stderr ? 1 : 0 ); } +void __attribute__ ((__noreturn__)) +usage1 (FILE *where) +{ + fprintf (where, "Usage: %s [OPTIONS] FILENAME...\n", pgm); + + exit (where == stderr ? 1 : 0 ); +} + void note (const char *fmt, ...) { @@ -248,6 +256,10 @@ main(int argc, char **argv) ; } + if (optind >= argc) + /* Print one-line help and exit. */ + usage1 (ofile); + for (int i = optind; i < argc; i++) gmondump1 (argv[i]);