2

Is it possible to use Frama-C's slicing plugin to slice for more than one assertion?

E.g. given the following code:

#include "assert.h"

int main() {
    double a=3;
    double b=4;
    b=a+b;
    double c=123;

//@ assert(b>=0);

    double d=a/b;
    c=a;

//@ assert(c==0);

    if (a<b)
        a=c;

    return 0;
}

I would like to get the slice for both assertions.

Paddre
  • 798
  • 1
  • 9
  • 19

1 Answers1

3

Option -slice-assert main will choose as slicing criterion all the assertions of function main. In fact, you can't directly choose to slice with respect to only one of them. You'd have to resort to //@ slice pragma expr b; for the first one or //@ slice pragma expr c; for the second one.

More generally, slicing criteria are cumulative: the more criteria you give, the more code will be kept.

Virgile
  • 9,724
  • 18
  • 42
  • Thanks for the answer! That helps a lot. Is there also a possibility to slice for all assertions of the global scope rather than for specific functions? – Paddre Apr 14 '16 at 14:47
  • 3
    @Paddre Technically, there's no such thing as an assertion at global scope: they are tied to a statement. Do you mean all assertions of all functions in the program? If yes, you can use the shortcut `@all` instead of naming all the functions as a comma-separated list argument of `-slice-assert` – Virgile Apr 15 '16 at 07:48
  • The latter nailed it. Thx :-) – Paddre Apr 19 '16 at 12:49