On Wed, 2011-08-31 at 16:28 +0200, Richard Guenther wrote: > On Wed, Aug 31, 2011 at 4:24 PM, Basile Starynkevitch > <bas...@starynkevitch.net> wrote: > > Hello Folks > > > > What is the intended role of the dump_file [the one known in tree-pass.h > > near line 101] for plugins? > > > > May plugins print their arbitrary things (e.g. their own debug printing) > > inside? I believe that yea, but I am not sure. > > > > May plugins set the dump_file variable (for instance to stderr). I believe > > that no, but I am not sure. > > > > Can dump_file be used outside passes (e.g. in the initialization part of a > > plugin)? I believe that no, but I hesitate. > > Look at how it is set.. That answers all of your questions.
FWIW, I wrapped writing to "dump_file" in my Python gcc plugin as the API entrypoint: gcc.dump(obj) but given that it didn't seem to be possible to enable dumping for a given custom pass by name directly from the command-line, it didn't seem very useful (you can toggle the dfi->state when the pass is created to manually enable it, which I've wrapped as the "dump_enabled" property of a gcc.Pass instance). Given all of this I tend to simply use "dump_base_name", which I wrapped as: gcc.get_dump_base_name() to supply a meaningful filename, which I use open a regular file for writing. See: http://readthedocs.org/docs/gcc-python-plugin/en/latest/passes.html#dumping-per-pass-information and http://readthedocs.org/docs/gcc-python-plugin/en/latest/passes.html#gcc.Pass.dump_enabled for more notes on how the Python plugin approaches this. The relevant code is mostly in: http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=blob;f=gcc-python.c;h=f6c5f5f284ffddff61195c40bbf6b8d62f7a7a9d;hb=HEAD#l675 and http://git.fedorahosted.org/git/?p=gcc-python-plugin.git;a=blob;f=gcc-python-pass.c;h=a54ea9b6d6bd8ecc26f8a305c4e96605d2bd14ab;hb=HEAD#l253 Hope this is helpful Dave