I want to use it for compiler optimizations. I have actually looked at Frama-C. I can extract PDG using it but not AST. Any idea on how to extract AST using Frama-C? Thanks. Zuhal On Wed, May 14, 2025 at 12:17 PM Basile Starynkevitch < basile@xxxxxxxxxxxxxxxxx> wrote: > Zuhal Altuntaş zuhaltuntas@xxxxxxxxx asked on Mon May 12 10:59:01 GMT > 2025 > > > > > I would like to dump AST using GCC in the same manner one can with option > > -ast-view using clang. I have tried options such as -fdump-tree-all-raw, > > but they do not give the output I want. Is there a way to extract AST of > a > > program with a GCC option? > > > > I know that it is possible to extract it with a plugin. If the answer to > > above question is no, are there plugins that extract AST that I can use? > > > > Why do you want to extract that AST? For what purposes? Checking coding > rules, > improve optimizations, adding project specific warnings, etc... > > In general the AST is GCC specific (think of asm statements -some of them > exist > inside standard C headers ...- and GCC builtins). In practice (and in the > details) it is is even specific to a particular major version of GCC > > AFAIU your GCC plugin has to be open source. > > The one I wrote (it is obsolete so you need to work on improving it) could > be a > starting point: https://github.com/bstarynk/bismon (but I don't maintain > it > anymore, and you need to improve it a lot) with obsolete documentation on > http://www.starynkevitch.net/Basile/bismon-chariot-doc.pdf > > https://arxiv.org/abs/1109.0779 is also relevant. > > If static analysis is your major concern see also https://frama-c.com/ and > https://www.absint.com/products.htm and of course improve the GCC static > analysis with your (open source) plugin. > > If runtime optimization is your major concern then consider also partial > evaluation techniques with runtime code generation (e.g. GNU lightning or > asmjit > or libjit based). > > Regards. > -- > Basile STARYNKEVITCH <basile@xxxxxxxxxxxxxxxxx> > 8 rue de la Faïencerie > http://starynkevitch.net/Basile/ > 92340 Bourg-la-Reine https://github.com/bstarynk > France > https://github.com/RefPerSys/RefPerSys > -- Zuhal Altuntaş