On Tue, Sep 16, 2025 at 10:56 PM Harald Anlauf <[email protected]> wrote:
>
> Hi Mikael,
>
> > Le 16/09/2025 à 21:07, Harald Anlauf a écrit :
> > > Hi All,
> > >
> > > when trying to debug the gfortran frontend, I often get lost in the
> > > forest: too much forest, trees everywhere, leaves, ...
> > >
> > > OK, seriously, what is an efficient way to debug under e.g. gdb,
> > > when there is code that uses macros on trees, like TREE_TYPE ()
> > > etc., without losing your sanity?
> > >
> > > I do know that there exists e.g. debug_tree, but this can dump a lot
> > > of stuff on me.  And the comment at the top of gcc/print-tree.cc:
> > >
> > > /* Prints out tree in human readable form - GCC
> > >
> > > makes me feel non-human.  :-(
> > >
> > > I was now thinking of writing helper functions, like:
> > >
> > I tend to use debug_generic_expr which is enough in the majority of cases.
> > There is a .gdbinit file in build/gcc that you can source in your gdb
> > session.  It loads many shortcuts most of them coming from the template
> > gcc/gdbinit.in (have a look there, you may find some useful).
>
> Ah, I missed these.  There are indeed some useful ones among them.
> Though not those I was hoping for.
>
> > Otherwise I use the full data references which I pick from the macro
> > definitions.  Not human-enough may be.
>
> Yes, that's why I asked here.  But I got at least some help and hints.

When I don't know what I'm looking for it's indeed debug_tree for me,
when I know what I'm looking for I usually end up hacking
tree-pretty-print.cc to make debug_generic_expr print/highlight that
part of the trees.

There's the abandoned GSOC project from last year that started to
make the -raw dump emit JSON and a JSON -> html transform so
you could have clickable debug_tree ().

For the various TREE_* macros I have the actual struct/union members
memoized... otherwise -g3 might help you here.  Some more python
plumbing in .gdbinit might also make this stuff more accessible ...

Richard.

Reply via email to