comp.lang.ada
 help / color / mirror / Atom feed
* Source code instrumentation as compilation part?
@ 2014-02-09  7:18 droiddermo
  2014-02-09  8:55 ` Simon Wright
  0 siblings, 1 reply; 2+ messages in thread
From: droiddermo @ 2014-02-09  7:18 UTC (permalink / raw)


Hello! I'm looking for a best way to integrate GNAT compiler with our custom code analysis/modification tools. We are using custom tools to perform different code metrics (like execution time, test coverage and etc) and even do some code obfuscation. So for example for measuring code execution time I need to insert 2 function calls into each function/procedure (the first one where the function starts, and the other one for each function exit). The code for these 2 functions are implemented in a separate translation unit. 

So what is the best way to do these code instrumentations with GNAT compiler in terms of simplicity and performance? 

Looks like the ASIS library can help me out, but it is made for creating separate tools. Is it possible to integrate ASIS-based tool with GNAT? So for example to write a tool that would be loaded by GNAT during compilation, and would modify nodes in the AST before it (the AST) is about to be transformed into GIMPLE.

Or is it possible to get GIMPLE from GNAT compiler, modify and pass it to GCC? I couldn't find if there is a working GIMPLE front-end inside GCC, but it seems that GIMPLE is used internally only. I can dump it with pretty much and GCC compiler, but I can't recompile modified GIMPLE afterwards.

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Source code instrumentation as compilation part?
  2014-02-09  7:18 Source code instrumentation as compilation part? droiddermo
@ 2014-02-09  8:55 ` Simon Wright
  0 siblings, 0 replies; 2+ messages in thread
From: Simon Wright @ 2014-02-09  8:55 UTC (permalink / raw)


droiddermo@gmail.com writes:

> Looks like the ASIS library can help me out, but it is made for
> creating separate tools. Is it possible to integrate ASIS-based tool
> with GNAT? So for example to write a tool that would be loaded by GNAT
> during compilation, and would modify nodes in the AST before it (the
> AST) is about to be transformed into GIMPLE.

Avatox[1], Ada Via Asis TO Xml, contains a prototype of a tool "axf2ada"
to take an XML representation of code (generated by avatox and possibly
modified on the lines you suggest) and (re)generate Ada.

GNAT contains various tools built using ASIS, including the formatter
gnatpp (which clearly regenerates Ada). ASIS GPL 2013 contains in
tools/gnat2xml a converter like Avatox and a regenerator xml2gnat (I
think they may only have included this for testing gnat2xml, but still
...)

> Or is it possible to get GIMPLE from GNAT compiler, modify and pass it
> to GCC? I couldn't find if there is a working GIMPLE front-end inside
> GCC, but it seems that GIMPLE is used internally only. I can dump it
> with pretty much and GCC compiler, but I can't recompile modified
> GIMPLE afterwards.

There's also the possibility of LLVM via DragonEgg[2], but it seems to
be rather behind the GCC wavefront (not surprising, it's a major
project).

[1] http://www.mckae.com/avatox.html
[2] http://dragonegg.llvm.org


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-02-09  8:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-09  7:18 Source code instrumentation as compilation part? droiddermo
2014-02-09  8:55 ` Simon Wright

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox