在Frama-C的Value Analysis日志中抑制[value]消息

时间:2015-02-13 16:15:01

标签: frama-c

我想使用Frama-C中的Value插件分析结果(批处理模式)来进一步评估函数中的变量。但是,输出似乎很大,有很多[value]标签,我需要的只是来自[value] ====== VALUES COMPUTED ======的部分,每个函数末尾都有计算值。 Frama-C是否支持允许我这样做的选项?

1 个答案:

答案 0 :(得分:3)

您可能会发现命令行选项frama-c -no-val-show-initial-state -no-val-show-progress …使输出更符合您的口味。

使用后一个选项时,您可能会感谢-val-print-callstacks,每次发出消息时都会打印 消息对应的调用堆栈,因为该上下文不再可用于日志中的前一行。

为了说明,在回答时Frama-C的开发版本默认显示以下消息:

int x;

/*@ assigns x; */
void f(void);

void g(int y) {
  f();
  x += y;
}

int main(void) {
  g(1);
}

使用frama-c -val t.c进行分析:

[value] Analyzing a complete application starting at main
[value] Computing initial state
[value] Initial state computed
[value] Values of globals at initialization
  x ∈ {0}
[value] computing for function g <- main.
        Called from t.c:12.
[value] computing for function f <- g <- main.
        Called from t.c:7.
[value] using specification for function f
t.c:3:[value] warning: no \from part for clause 'assigns x;' of function f
[value] Done for function f
t.c:8:[kernel] warning: signed overflow. assert x+y ≤ 2147483647;
[value] Recording results for g
[value] Done for function g
[value] Recording results for main
[value] done for function main
[value] ====== VALUES COMPUTED ======
[value] Values at end of function g:
  x ∈ [-2147483647..2147483647]
[value] Values at end of function main:
  x ∈ [-2147483647..2147483647]
  __retres ∈ {0}

使用frama-c -val t.c -no-val-show-initial-state -no-val-show-progress进行分析:

[value] Analyzing a complete application starting at main
[value] Computing initial state
[value] Initial state computed
[value] using specification for function f
t.c:3:[value] warning: no \from part for clause 'assigns x;' of function f
t.c:8:[kernel] warning: signed overflow. assert x+y ≤ 2147483647;
[value] done for function main
[value] ====== VALUES COMPUTED ======
[value] Values at end of function g:
  x ∈ [-2147483647..2147483647]
[value] Values at end of function main:
  x ∈ [-2147483647..2147483647]
  __retres ∈ {0}

添加选项-val-show-callstack意味着对于第8行的警报,上下文显示如下:

t.c:8:[kernel] warning: signed overflow. assert x+y ≤ 2147483647;
                  stack: g :: t.c:12 <- main