[patch] allow '-' for stdout dump

https://gcc.gnu.org/ml/gcc-patches/2018-04/msg01303.html
	* dumpfile.c (dump_open): Allow '-' for stdout.
	* doc/invoke.texi (Developer Options): Document dump filename
	determination early.  Document stdin/stdout selection.

Co-Authored-By: Sandra Loosemore <sandra@codesourcery.com>

From-SVN: r259760
This commit is contained in:
Nathan Sidwell 2018-04-30 11:47:04 +00:00 committed by Nathan Sidwell
parent e693ebce81
commit bd9918c411
3 changed files with 31 additions and 37 deletions

View File

@ -1,3 +1,10 @@
2018-04-30 Nathan Sidwell <nathan@acm.org>
Sandra Loosemore <sandra@codesourcery.com>
* dumpfile.c (dump_open): Allow '-' for stdout.
* doc/invoke.texi (Developer Options): Document dump filename
determination early. Document stdin/stdout selection.
2018-04-30 Andrew Sadek <andrew.sadek.se@gmail.com>
Microblaze Target: PIC data text relative

View File

@ -13358,6 +13358,26 @@ configuration, such as where it searches for libraries. You should
rarely need to use any of these options for ordinary compilation and
linking tasks.
Many developer options that cause GCC to dump output to a file take an
optional @samp{=@var{filename}} suffix. You can specify @samp{stdout}
or @samp{-} to dump to standard output, and @samp{stderr} for standard
error.
If @samp{=@var{filename}} is omitted, a default dump file name is
constructed by concatenating the base dump file name, a pass number,
phase letter, and pass name. The base dump file name is the name of
output file produced by the compiler if explicitly specified and not
an executable; otherwise it is the source file name.
The pass number is determined by the order passes are registered with
the compiler's pass manager.
This is generally the same as the order of execution, but passes
registered by plugins, target-specific passes, or passes that are
otherwise registered late are numbered higher than the pass named
@samp{final}, even if they are executed earlier. The phase letter is
one of @samp{i} (inter-procedural analysis), @samp{l}
(language-specific), @samp{r} (RTL), or @samp{t} (tree).
The files are created in the directory of the output file.
@table @gcctabopt
@item -d@var{letters}
@ -13367,20 +13387,7 @@ linking tasks.
@opindex fdump-rtl-@var{pass}
Says to make debugging dumps during compilation at times specified by
@var{letters}. This is used for debugging the RTL-based passes of the
compiler. The file names for most of the dumps are made by appending
a pass number and a word to the @var{dumpname}, and the files are
created in the directory of the output file. In case of
@option{=@var{filename}} option, the dump is output on the given file
instead of the pass numbered dump files. Note that the pass number is
assigned as passes are registered into the pass manager. Most passes
are registered in the order that they will execute and for these passes
the number corresponds to the pass execution order. However, passes
registered by plugins, passes specific to compilation targets, or
passes that are otherwise registered after all the other passes are
numbered higher than a pass named "final", even if they are executed
earlier. @var{dumpname} is generated from the name of the output
file if explicitly specified and not an executable, otherwise it is
the basename of the source file.
compiler.
Some @option{-d@var{letters}} switches have different meaning when
@option{-E} is used for preprocessing. @xref{Preprocessor Options},
@ -13768,11 +13775,7 @@ counters for each function compiled.
@opindex fdump-tree-all
@opindex fdump-tree
Control the dumping at various stages of processing the intermediate
language tree to a file. The file name is generated by appending a
switch-specific suffix to the source file name, and the file is
created in the same directory as the output file. In case of
@option{=@var{filename}} option, the dump is output on the given file
instead of the auto named dump files. If the @samp{-@var{options}}
language tree to a file. If the @samp{-@var{options}}
form is used, @var{options} is a list of @samp{-} separated options
which control the details of the dump. Not all options are applicable
to all dumps; those that are not meaningful are ignored. The
@ -13839,26 +13842,9 @@ passes).
@item note
Enable other detailed optimization information (only available in
certain passes).
@item =@var{filename}
Instead of an auto named dump file, output into the given file
name. The file names @file{stdout} and @file{stderr} are treated
specially and are considered already open standard streams. For
example,
@smallexample
gcc -O2 -ftree-vectorize -fdump-tree-vect-blocks=foo.dump
-fdump-tree-pre=/dev/stderr file.c
@end smallexample
outputs vectorizer dump into @file{foo.dump}, while the PRE dump is
output on to @file{stderr}. If two conflicting dump filenames are
given for the same pass, then the latter option overrides the earlier
one.
@item all
Turn on all options, except @option{raw}, @option{slim}, @option{verbose}
and @option{lineno}.
@item optall
Turn on all optimization options, i.e., @option{optimized},
@option{missed}, and @option{note}.

View File

@ -323,7 +323,8 @@ dump_open (const char *filename, bool trunc)
if (strcmp ("stderr", filename) == 0)
return stderr;
if (strcmp ("stdout", filename) == 0)
if (strcmp ("stdout", filename) == 0
|| strcmp ("-", filename) == 0)
return stdout;
FILE *stream = fopen (filename, trunc ? "w" : "a");