我有一个包含多个 ACSL 断言 ( file.c
) 的文件:
#include <stdio.h>
#include <stdlib.h>
void foo() {
int a=0;
//@ assert(a==0);
}
void print(const char* text) {
int a=0;
//@ assert(a==0);
printf("%s\n",text);
}
int main (int argc, const char* argv[]) {
const char* a1 = argv[2];
print(a1);
foo();
if (!a1)
//@ assert(!a1);
return 0;
else
return 1;
}
我想使用以下命令对所有断言进行切片:
frama-c -slice-assert @all file.c -then-on 'Slicing export' -print -ocode slice.c
但是,切片看起来不像预期的那样(实际上它不包含文件中包含的任何函数):
/* Generated by Frama-C */
typedef unsigned int size_t;
/*@ ghost extern int __fc_heap_status __attribute__((__FRAMA_C_MODEL__)); */
/*@
axiomatic dynamic_allocation {
predicate is_allocable{L}(size_t n)
reads __fc_heap_status;
}
*/
void main(void)
{
char const *a1;
return;
}
相反,我得到这样的输出:
file.c:16:[kernel] warning: out of bounds read. assert \valid_read(argv+2);
[value] Recording results for main
[value] done for function main
file.c:16:[value] Assertion 'Value,mem_access' got final status invalid.
[slicing] making slicing project 'Slicing'...
[slicing] interpreting slicing requests from the command line...
[pdg] computing for function foo
[pdg] warning: unreachable entry point (sid:1, function foo)
[pdg] Bottom for function foo
[slicing] bottom PDG for function 'foo': ignore selection
[pdg] computing for function main
file.c:21:[pdg] warning: no final state. Probably unreachable...
[pdg] done for function main
[pdg] computing for function print
[pdg] warning: unreachable entry point (sid:5, function print)
[pdg] Bottom for function print
[slicing] bottom PDG for function 'print': ignore selection
这里出了什么问题,特别是什么unreachable entry point
?观察:如果我argv[2]
改为argv[1]
我没有这些问题(但仍然在第一行收到警告)。