static int flag_gcov_file = 1;
+/* Output to stdout instead to a gcov file. */
+
+static int flag_use_stdout = 0;
+
/* Output progress indication if this is true. This is off by default
and can be turned on by the -d option. */
fnotice (file, " -p, --preserve-paths Preserve all pathname components\n");
fnotice (file, " -r, --relative-only Only show data for relative sources\n");
fnotice (file, " -s, --source-prefix DIR Source prefix to elide\n");
+ fnotice (file, " -t, --stdout Output to stdout instead of a file\n");
fnotice (file, " -u, --unconditional-branches Show unconditional branch counts too\n");
fnotice (file, " -v, --version Print version number, then exit\n");
fnotice (file, " -w, --verbose Print verbose informations\n");
{ "object-directory", required_argument, NULL, 'o' },
{ "object-file", required_argument, NULL, 'o' },
{ "source-prefix", required_argument, NULL, 's' },
+ { "stdout", no_argument, NULL, 't' },
{ "unconditional-branches", no_argument, NULL, 'u' },
{ "display-progress", no_argument, NULL, 'd' },
{ "hash-filenames", no_argument, NULL, 'x' },
{
int opt;
- const char *opts = "abcdfhijklmno:prs:uvwx";
+ const char *opts = "abcdfhijklmno:prs:tuvwx";
while ((opt = getopt_long (argc, argv, opts, options, NULL)) != -1)
{
switch (opt)
case 'w':
flag_verbose = 1;
break;
+ case 't':
+ flag_use_stdout = 1;
+ break;
case 'v':
print_version ();
/* print_version will exit. */
file_name = canonicalize_name (file_name);
}
- if (flag_gcov_file && flag_intermediate_format)
+ if (flag_gcov_file && flag_intermediate_format && !flag_use_stdout)
{
/* Open the intermediate file. */
gcov_intermediate_filename = get_gcov_intermediate_filename (file_name);
}
accumulate_line_counts (src);
- function_summary (&src->coverage, "File");
+
+ if (!flag_use_stdout)
+ function_summary (&src->coverage, "File");
total_lines += src->coverage.lines;
total_executed += src->coverage.lines_executed;
if (flag_gcov_file)
if (flag_intermediate_format)
/* Output the intermediate format without requiring source
files. This outputs a section to a *single* file. */
- output_intermediate_file (gcov_intermediate_file, src);
+ output_intermediate_file ((flag_use_stdout
+ ? stdout : gcov_intermediate_file), src);
else
- output_gcov_file (file_name, src);
- fnotice (stdout, "\n");
+ {
+ if (flag_use_stdout)
+ {
+ if (src->coverage.lines)
+ output_lines (stdout, src);
+ }
+ else
+ {
+ output_gcov_file (file_name, src);
+ fnotice (stdout, "\n");
+ }
+ }
}
}
- if (flag_gcov_file && flag_intermediate_format)
+ if (flag_gcov_file && flag_intermediate_format && !flag_use_stdout)
{
/* Now we've finished writing the intermediate file. */
fclose (gcov_intermediate_file);