]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add a new flag --cachegrind-log-file to cg_annotate, which tells it
authorJulian Seward <jseward@acm.org>
Thu, 8 Feb 2007 06:47:19 +0000 (06:47 +0000)
committerJulian Seward <jseward@acm.org>
Thu, 8 Feb 2007 06:47:19 +0000 (06:47 +0000)
precisely the name of the profile data file it should use (instead of
assuming cachegrind.out.<pid> where <pid> is specified by the --<pid>
flag).  The old mechanism is still supported though.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@6573

cachegrind/cg_annotate.in
cachegrind/docs/cg-manual.xml

index 811e5a8466b2f3a2bb185ef2319385ee5f7dbff9..21bc4e8b31c0c316c5e82bd66bf92a9f8c6d5417 100644 (file)
@@ -142,11 +142,13 @@ my $version = "@VERSION@";
 
 # Usage message.
 my $usage = <<END
-usage: cg_annotate [options] --<pid> [source-files]
+usage: cg_annotate [options] [source-files]
 
   options for the user, with defaults in [ ], are:
     -h --help             show this message
     -v --version          show version
+    --<pid>               read profile data from cachegrind.out.<pid>
+    --cachegrind-out-file=<file>   read profile data from <file>
     --show=A,B,C          only show figures for events A,B,C [all]
     --sort=A,B,C          sort columns by events A,B,C [event column order]
     --threshold=<0--100>  percentage of counts (of primary sort event) we
@@ -158,8 +160,11 @@ usage: cg_annotate [options] --<pid> [source-files]
     -I<d> --include=<d>   add <d> to list of directories to search for 
                           source files
 
-  Cachegrind is Copyright (C) 2002-2005 Nicholas Nethercote.
-  Both are licensed under the GNU General Public License, version 2.
+  You must use either --<pid> or --cachegrind-out-file exactly once
+  in order that cg_annotate knows what file to read profile data from.
+
+  cg_annotate is Copyright (C) 2002-2007 Nicholas Nethercote.
+  and licensed under the GNU General Public License, version 2.
   Bug reports, feedback, admiration, abuse, etc, to: njn\@valgrind.org.
                                                 
 END
@@ -236,12 +241,23 @@ sub process_cmd_line()
                 $inc =~ s|/$||;         # trim trailing '/'
                 push(@include_dirs, "$inc/");
 
+            # --cachegrind-out-file=<filename>
+            } elsif ($arg =~ /^--cachegrind-out-file=(.*)$/) {
+                if (not defined $input_file) {
+                    $input_file = $1;
+                } else {
+                    die("You may only specify one input file\n" .
+                        "using the --<pid> and --cachegrind-out-file options.\n");
+                }
+
+            # --<pid>
             } elsif ($arg =~ /^--(\d+)$/) {
                 my $pid = $1;
                 if (not defined $input_file) {
                     $input_file = "cachegrind.out.$pid";
                 } else {
-                    die("One cachegrind.out.<pid> file at a time, please\n");
+                    die("You may only specify one input file\n" .
+                        "using the --<pid> and --cachegrind-out-file options.\n");
                 }
 
             } else {            # -h and --help fall under this case
@@ -307,7 +323,8 @@ sub line_to_CC ($)
 
 sub read_input_file() 
 {
-    open(INPUTFILE, "< $input_file") || die "File $input_file not opened\n";
+    open(INPUTFILE, "< $input_file") 
+         || die "Cannot open $input_file for reading\n";
 
     # Read "desc:" lines.
     my $line;
index cfc1c8339c0e0f6000e18d0bb9143a4497458afc..91bcfc16a3a886e7b6ae56e72ca628dca3486504 100644 (file)
@@ -278,13 +278,17 @@ file:</para>
     recycled).</para>
     <para>
     To use a basename other than the default
-    <computeroutput>cachegrind.out.</computeroutput>,
+    <computeroutput>cachegrind.out</computeroutput>,
     use the <computeroutput>--cachegrind-out-file</computeroutput>
     switch.</para>
     <para>
     To add further qualifiers to the output filename you can use 
     the core's <computeroutput>--log-file-qualifier</computeroutput>
-    flag.</para>
+    flag.  This extends the file name further with the text
+    <computeroutput>.lfq.</computeroutput>followed by the
+    contents of the environment variable specified by 
+    <computeroutput>--log-file-qualifier</computeroutput>.
+      </para>
   </listitem>
   <listitem>
     <para>It can be huge: <computeroutput>ls -l</computeroutput>
@@ -359,9 +363,10 @@ configuration, or failing that, via defaults).</para>
       <option><![CDATA[--cachegrind-out-file=<basename> ]]></option>
     </term>
     <listitem>
-      <para>Write the profile data to <![CDATA[<basename>.<pid>]]>
+      <para>Write the profile data to 
+            <computeroutput>basename.pid</computeroutput>
             rather than to the default output file, 
-            <![CDATA[cachegrind.out.<pid>]]>.
+            <computeroutput>cachegrind.out.pid</computeroutput>.
       </para>
     </listitem>
   </varlistentry>
@@ -732,9 +737,26 @@ way as for C/C++ programs.</para>
 
   <listitem id="pid">
     <para><computeroutput>--pid</computeroutput></para>
-    <para>Indicates which
-    <computeroutput>cachegrind.out.pid</computeroutput> file to
-    read.  Not actually an option -- it is required.</para>
+    <para>Indicates that profile data should be read from 
+    the file
+    <computeroutput>cachegrind.out.pid</computeroutput>.
+    read.  
+    Note that you must specify either
+    <computeroutput>--pid</computeroutput>
+    or <computeroutput>--cachegrind-out-file=filename</computeroutput>
+    exactly once.
+    </para>
+  </listitem>
+    
+  <listitem id="cachegrind-out-file">
+    <para><computeroutput>--cachegrind-out-file=filename</computeroutput></para>
+    <para>Indicates that profile data
+    should be read from <computeroutput>filename</computeroutput>.
+    Note that you must specify either
+    <computeroutput>--pid</computeroutput>
+    or <computeroutput>--cachegrind-out-file=filename</computeroutput>
+    exactly once.
+    </para>
   </listitem>
     
   <listitem>