Is it possible to trace a variable and slice all the code it touches using Frama-C? For example consider the following program:
#include <stdio.h>
#define SIZE 512
int storage[SIZE];
void insert(int index, int val) {
storage[index] = val;
}
int main(int argc, char *argv[]) {
int x = 10;
int y = 20;
int z = 30;
z = 0; /* some change to unrelated var */
insert(x, y);
return 0;
}
My expected slice for variable x is:
#include <stdio.h>
#define SIZE 512
int storage[SIZE];
void insert(int index, int val) {
storage[index] = val;
}
int main(int argc, char *argv[]) {
int x = 10;
int y = 20;
insert(x, y);
return 0;
}
How can I achieve this? So far, I have tried following frama-c slice_issue.c -no-frama-c-stdlib -kernel-msg-key -slice-value x -then-on 'Slicing export' -print
. It generates following slice:
/* Generated by Frama-C */
int main(void)
{
int __retres;
int x = 10;
__retres = 0;
return __retres;
}
I can get the expected output if I supply -slice-calls insert
in slice command. But is there any way to get the same effect without specifying the function names explicitly in the slice commands?
Thanks in advance. Any hints or pointing to the documentation will be appreciated.