This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: pretty printing trends and questions


On Mon, Sep 8, 2008 at 10:13, Basile STARYNKEVITCH
<basile@starynkevitch.net> wrote:
> Hello All,
>
> I am correct in assuming that pretty printing & debug dumping in GCC tend to
> go thru the pretty printer abstraction of gcc/pretty-printer.h   hence that
> the old way of printing directly to a file (like e.g. dump_bb or debug_bb in
> gcc/cfg.c for printing basic_block-s) is deprecated, or is it the other way
> round (that using pretty-printer.h is deprecated in favor of routines with a
> FILE* argument)?

They're orthogonal.  The pretty printer uses its own buffering, but
the final target is always a FILE *.  All the dump_*() routines are
implemented with a FILE * argument and the debug_*() routines are just
calls to dump_*() with FILE set to stderr.

> Also (I asked on #gcc chat), I do not understand what code is supposed to
> free the memory allocated with
>  pp->buffer = XCNEW (output_buffer);
> in function pp_construct of gcc/pretty-print.c. I'm supposing that this code
> is for debugging only, and a tiny memory leak does not matter in that case.

Yes.  The buffer is allocated the first time a pretty printer routine
is called and never deallocated.

>> void
>> pp_construct_routdata (pretty_printer *pp, const char *prefix, int
>> maximum_length, void (*flushrout)(const char*,void*), void *flushdata)
>
> I would like to avoid using fmemopen; it seems very GNU GLIBC specific...

Using fmemopen is probably the easiest way.  Another way would be
adding support in the pretty-printer basic routines to emit to a char
* buffer.  It would probably need several changes but I'm not quite
sure how extensive would that be.


Diego.

>
> To Ian Taylor (and other C++ heroes) I suppose all the prettyprinting code
> is supposed to be replaced by some ostream trick in the C++ branch.
>
> Regards.
> --
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
> *** opinions {are only mines, sont seulement les miennes} ***
>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]