Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-12

Node outputting feature

3 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

J. Gareth Moreton

Hi everyone,

I've developed a feature to output the compiler-generated node trees into XML files that could prove useful for debugging purposes.  While the ability to print the nodes to the console or a log file already exist, it gets buried especially if the System unit has its nodes output (the XML file it generated for me is 4.8 MB in size!).

I plan to use this to help me debug and analyse code paths for the "pure" feature that's been on my table for a while, and it might help with debugging in general.  I figure it's a bit more convenient than a console output because you can open the file afterwards in Notepad++ or some other editor that can handle XML files (which I hope are valid!!) and hence visually open and close branches.

Note that it is currently very much a work in progress and hasn't been fully tested, and reuses a lot of features like the "printnodeindent" variable and an error message if it fails to access a file. To activate, specify the "-Cm" command line parameter (I wanted either "-Cn" or "-Ci", for 'node' and 'intermediate' respectively, but both are taken!).  It's not documented at present, especially as it might be rejected or changed.  The XML files have .ppx extensions and are placed in the output directory.  Let me know how it works out for you. Gareth aka. Kit

(The patch file may be too large and cause this e-mail to be flagged by the moderators)

Reply by email

J. Gareth Moreton

Seems fair.  Users probably wouldn't find much use for it anyway, and it would only increase the size of the compiler binary.

I figure though it could be very useful for, say, allowing compilation and linking with C++ code (if https://www.freepascal.org/future.html is still accurate!)

I'm happy to know that you like the idea though.

Gareth aka. Kit

On Thu 27/12/18 20:43 , Florian Klämpfl sent:

J. Gareth Moreton wrote
Hi everyone, I've developed a feature to output the compiler-generated node trees

into XML files that could prove useful for

debugging purposes.  While the ability to print the nodes to the

console or a log file already exist, it gets buried

especially if the System unit has its nodes output (the XML file it

generated for me is 4.8 MB in size!).

I plan to use this to help me debug and analyse code paths for the

"pure" feature that's been on my table for a while,

and it might help with debugging in general.  I figure it's a bit more

convenient than a console output because you can

open the file afterwards in Notepad++ or some other editor that can

handle XML files (which I hope are valid!!) and

hence visually open and close branches. Note that it is currently very much a work in progress and hasn't been

fully tested, and reuses a lot of features like

the "printnodeindent" variable and an error message if it fails to

access a file.

To activate, specify the "-Cm" command line parameter (I wanted either

"-Cn" or "-Ci", for 'node' and 'intermediate'

respectively, but both are taken!).  It's not documented at present,

especially as it might be rejected or changed.  The

XML files have .ppx extensions and are placed in the output directory. 

Let me know how it works out for you.

While I like the possibility to output the node tree as xml, I do not think that it should be exposed to users by
command line switches. Instead, if the compiler is compiled with a certain define, it could generate xml node tree output.

Reply by email

Florian Klämpfl
to J. Gareth Moreton: I've developed a feature to output the compiler-generated node trees into XML files that…
J. Gareth Moreton wrote 17 lines
Hi everyone, I've developed a feature to output the compiler-generated node trees into XML files that could prove useful for debugging purposes.  While the ability to print the nodes to the console or a log file already exist, it gets buried especially if the System unit has its nodes output (the XML file it generated for me is 4.8 MB in size!). I plan to use this to help me debug and analyse code paths for the "pure" feature that's been on my table for a while, and it might help with debugging in general.  I figure it's a bit more convenient than a console output because you can open the file afterwards in Notepad++ or some other editor that can handle XML files (which I hope are valid!!) and hence visually open and close branches. Note that it is currently very much a work in progress and hasn't been fully tested, and reuses a lot of features like the "printnodeindent" variable and an error message if it fails to access a file. To activate, specify the "-Cm" command line parameter (I wanted either "-Cn" or "-Ci", for 'node' and 'intermediate' respectively, but both are taken!).  It's not documented at present, especially as it might be rejected or changed.  The XML files have .ppx extensions and are placed in the output directory.  Let me know how it works out for you.

While I like the possibility to output the node tree as xml, I do not think that it should be exposed to users by command line switches. Instead, if the compiler is compiled with a certain define, it could generate xml node tree output.

Reply by email