frama-c

Analyzing a simple C++ program with Frama-C

一笑奈何 提交于 2021-02-10 20:15:37
问题 I started learning C++ from a great tutorial available at https://learnxinyminutes.com/docs/c++/ and would like to analyze in Frama-C a simplest example that shows references: using namespace std; #include <iostream> #include <string> int main() { string foo = "I am foo"; string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" // Doesn't reassign "fooRef". This is the

Analyzing a simple C++ program with Frama-C

这一生的挚爱 提交于 2021-02-10 20:11:08
问题 I started learning C++ from a great tutorial available at https://learnxinyminutes.com/docs/c++/ and would like to analyze in Frama-C a simplest example that shows references: using namespace std; #include <iostream> #include <string> int main() { string foo = "I am foo"; string bar = "I am bar"; string& fooRef = foo; // This creates a reference to foo. fooRef += ". Hi!"; // Modifies foo through the reference cout << fooRef; // Prints "I am foo. Hi!" // Doesn't reassign "fooRef". This is the

Frama-C order function

隐身守侯 提交于 2021-01-28 14:40:19
问题 I am trying to prove the correctness of my sorting function 'order' with Frama-C with the ACSL language. I have an additional 'swap' function to permute two values of my array 't'. EDIT : I updated my code. /*@ requires \valid (t+ (0..(l-1))); requires l > 0; requires i<l && j<l && i>=0 && j>=0; assigns t[i], t[j]; ensures t[j] == \old(t[i]); ensures t[i] == \old(t[j]); */ void swap(int *t, int l, int i,int j){ int tmp; tmp = t[i]; t[i] = t[j]; t[j] = tmp; return; } /*@ requires \valid (t+ (0

Verifying matrix transpose function in FRAMA-C

烈酒焚心 提交于 2020-05-16 22:37:29
问题 I have a simple matrix transpose function which I would like to verify with a postcondition such that matrix_transpose(matrix_transpose(original_matrix)==original_matrix What would be the syntax for that? I've tried ensures \result(\result)==a; where a is the original matrix, but that doesn't seem to work. Edit: This is my code void transpose_matrix(int[][10],int,int); int main() { int r=3; int c=3; int a[10][10]={ {1,1,1}, {2,2,2}, {3,3,3} }; transpose_matrix(a,r,c); return 0; } /*@ ensures

How to handle printf(“ ”, ) and scanf(“ ”) with frama-c command?

这一生的挚爱 提交于 2020-01-14 19:27:18
问题 I am using this code to generate the control flow graph of a C program. It is working fine for all the function except built-in function like printf and scanf . What can I change in this code to output the built in function as it is? open Cil open Cil_types let print_stmt out = function | Instr i -> !Ast_printer.d_instr out i | Return _ -> Format.pp_print_string out "<return>" | Goto _ -> Format.pp_print_string out "<goto>" | Break _ -> Format.pp_print_string out "<break>" | Continue _ ->

How to handle printf(“ ”, ) and scanf(“ ”) with frama-c command?

元气小坏坏 提交于 2020-01-14 19:27:08
问题 I am using this code to generate the control flow graph of a C program. It is working fine for all the function except built-in function like printf and scanf . What can I change in this code to output the built in function as it is? open Cil open Cil_types let print_stmt out = function | Instr i -> !Ast_printer.d_instr out i | Return _ -> Format.pp_print_string out "<return>" | Goto _ -> Format.pp_print_string out "<goto>" | Break _ -> Format.pp_print_string out "<break>" | Continue _ ->

Frama-C-Plugin: Set value of variable in plugin

左心房为你撑大大i 提交于 2020-01-07 06:58:29
问题 I am writing a Frama-C Plugin. I want to develop a plugin, that sets the value of a local variable. By this idea I try to do the value-analysis afterwards, and then I can analyze the reachablility, path analysis and other things by my second plugin. Is it possible to set the value of a local variable within a plugin (at the start of a function where I know the name)? EDIT I now found out how to make new local variables, how to get the Varinfo of variables and how to create new varinfos. The

Syntax error in Frama-C due to custom machdep

。_饼干妹妹 提交于 2020-01-05 08:12:14
问题 I am using MPLAB XC16 C Compiler for my application. If I use machdep x86_16, the Frama-C works normally. For example, I can launche Frama-C in this way: $ frama-c-gui machdep x86_16 -cpp-command 'C:\\"Program Files (x86)"\\Microchip\\xc16\\v1.26\\bin\\xc16-gcc.exe -E' -no-cpp-gnu-like D:\\project\\*.c But machdep x86_16 do not comply fully with XC16. So I want to customize machdep. Following the instructions, I created file machdep_xc16.ml that contain: open Cil_types let xc16 = { version =