简体   繁体   中英

Frama-c: save plugin analysis results in c file

I'am new in frama-c. So I apologize in advance for my question.

I would like to make a plugin that will modify the source code, clone some functions, insert some functions calls and I would like my plugin to generate a second file that will contain the modified version of the input file.

I would like to know if it is possible to generate a new file c with frama-c. For example, the results of the Sparecode and Semantic constant folding plugins are displayed on the terminal directly and not in a file. So I would like to know if Frama-c has the function to write to a file instead of sending the result of the analysis to the standard output.

Of course we can redirect the output of frama-c to a file.c for example, but in this case, for the plugin scf for example, the results of value is there and I found that frama-c replaces for example the "for" loops by while.

But what I would like is that frama-c can generate a file that will contain my original code plus the modifications that I would have inserted.

I looked in the directory src / kernel_services / ast_printing but I have not really found functions that can guide me.

Thanks.

On the command line, option -ocode <file> indicates that any subsequent -print will be done in <file> instead of the standard output (use -ocode "" after that if you want to print on stdout again). Note that -print prints the code corresponding to the current project. You can use -then-on <prj> to change the project you're interested in. More information is of course available in the user manual .

All of this is of course available programmatically. In particular, File.pretty_ast by defaults pretty-prints (ie output a C program) the AST of the current project on stdout, but takes two optional argument for changing the project or the formatter to which the output should be done.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM