Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
frama-c
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
frama-c
Commits
77bc2659
Commit
77bc2659
authored
3 years ago
by
David Bühler
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Values_request: rewrites some functions in the hope of making them clearer.
parent
116fdd88
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/plugins/value/api/values_request.ml
+29
-26
29 additions, 26 deletions
src/plugins/value/api/values_request.ml
with
29 additions
and
26 deletions
src/plugins/value/api/values_request.ml
+
29
−
26
View file @
77bc2659
...
@@ -72,7 +72,7 @@ let handle_top_or_bottom ~top ~bottom compute = function
...
@@ -72,7 +72,7 @@ let handle_top_or_bottom ~top ~bottom compute = function
(* --- Marker Utilities --- *)
(* --- Marker Utilities --- *)
(* -------------------------------------------------------------------------- *)
(* -------------------------------------------------------------------------- *)
let
next_steps
s
:
step
list
=
let
next_steps
s
=
match
s
.
skind
with
match
s
.
skind
with
|
If
(
cond
,
_
,
_
,
_
)
->
[
`Then
cond
;
`Else
cond
]
|
If
(
cond
,
_
,
_
,
_
)
->
[
`Then
cond
;
`Else
cond
]
|
Instr
(
Set
_
|
Call
_
|
Local_init
_
|
Asm
_
|
Code_annot
_
)
|
Instr
(
Set
_
|
Call
_
|
Local_init
_
|
Asm
_
|
Code_annot
_
)
...
@@ -252,10 +252,6 @@ module Proxy(A : Analysis.S) : EvaProxy = struct
...
@@ -252,10 +252,6 @@ module Proxy(A : Analysis.S) : EvaProxy = struct
open
Eval
open
Eval
type
dstate
=
A
.
Dom
.
state
or_top_or_bottom
type
dstate
=
A
.
Dom
.
state
or_top_or_bottom
let
dnone
=
{
alarms
=
[]
;
values
=
[]
}
let
dtop
=
{
alarms
=
[]
;
values
=
[
`Here
,
"Not available."
]
}
let
dbottom
=
{
alarms
=
[]
;
values
=
[
`Here
,
"Unreachable."
]
}
let
callstacks
stmt
=
let
callstacks
stmt
=
match
A
.
get_stmt_state_by_callstack
~
after
:
false
stmt
with
match
A
.
get_stmt_state_by_callstack
~
after
:
false
stmt
with
|
`Top
|
`Bottom
->
[]
|
`Top
|
`Bottom
->
[]
...
@@ -358,29 +354,36 @@ module Proxy(A : Analysis.S) : EvaProxy = struct
...
@@ -358,29 +354,36 @@ module Proxy(A : Analysis.S) : EvaProxy = struct
let
f
alarm
status
pool
=
(
status
,
descr
alarm
)
::
pool
in
let
f
alarm
status
pool
=
(
status
,
descr
alarm
)
::
pool
in
Alarmset
.
fold
f
[]
alarms
|>
List
.
rev
Alarmset
.
fold
f
[]
alarms
|>
List
.
rev
let
fold_steps
f
stmt
callstack
state
acc
=
let
get_next_dstate
stmt
callstack
state
=
function
let
steps
=
`Here
::
next_steps
stmt
in
|
`After
->
dstate
~
after
:
true
stmt
callstack
let
add_state
=
function
|
`Then
cond
->
(
A
.
assume_cond
stmt
state
cond
true
:>
dstate
)
|
`Here
->
`Value
state
|
`Else
cond
->
(
A
.
assume_cond
stmt
state
cond
false
:>
dstate
)
|
`After
->
dstate
~
after
:
true
stmt
callstack
|
`Then
cond
->
(
A
.
assume_cond
stmt
state
cond
true
:>
dstate
)
let
eval_steps
eval
stmt
callstack
=
|
`Else
cond
->
(
A
.
assume_cond
stmt
state
cond
false
:>
dstate
)
let
before
=
dstate
~
after
:
false
stmt
callstack
in
let
value
,
alarms
=
eval
before
in
let
others
=
match
before
with
|
`Bottom
|
`Top
->
[]
|
`Value
state
->
let
steps
=
next_steps
stmt
in
let
eval_next
step
=
eval
(
get_next_dstate
stmt
callstack
state
step
)
in
List
.
map
(
fun
step
->
(
step
:>
step
)
,
fst
(
eval_next
step
))
steps
in
in
List
.
fold_left
(
fun
acc
step
->
f
acc
step
@@
add_state
step
)
acc
steps
{
values
=
(
`Here
,
value
)
::
others
;
alarms
=
dalarms
alarms
;
let
domain_step
typ
eval
((
values
,
alarms
)
as
acc
)
step
=
}
let
to_str
=
Pretty_utils
.
to_string
(
Bottom
.
pretty
(
pp_evaluation
typ
))
in
handle_top_or_bottom
~
top
:
acc
~
bottom
:
acc
@@
fun
state
->
let
step_value
,
step_alarms
=
eval
state
in
let
alarms
=
match
step
with
`Here
->
step_alarms
|
_
->
alarms
in
(
step
,
to_str
step_value
)
::
values
,
alarms
let
domain_eval
typ
eval
stmt
callstack
=
let
domain_eval
typ
eval
stmt
callstack
=
let
fold
=
fold_steps
(
domain_step
typ
eval
)
stmt
callstack
in
let
to_str
=
Pretty_utils
.
to_string
(
Bottom
.
pretty
(
pp_evaluation
typ
))
in
let
build
(
vs
,
als
)
=
{
values
=
List
.
rev
vs
;
alarms
=
dalarms
als
}
in
let
eval
=
function
let
compute_domain
state
=
fold
state
([]
,
Alarmset
.
none
)
|>
build
in
|
`Bottom
->
"Unreachable"
,
Alarmset
.
none
handle_top_or_bottom
~
top
:
dtop
~
bottom
:
dbottom
compute_domain
@@
|
`Top
->
"No information"
,
Alarmset
.
none
dstate
~
after
:
false
stmt
callstack
|
`Value
state
->
let
value
,
alarms
=
eval
state
in
to_str
value
,
alarms
in
eval_steps
eval
stmt
callstack
let
domain
p
callstack
=
let
domain
p
callstack
=
match
p
with
match
p
with
...
@@ -388,7 +391,7 @@ module Proxy(A : Analysis.S) : EvaProxy = struct
...
@@ -388,7 +391,7 @@ module Proxy(A : Analysis.S) : EvaProxy = struct
domain_eval
(
Cil
.
typeOfLval
lval
)
(
eval_lval
lval
)
stmt
callstack
domain_eval
(
Cil
.
typeOfLval
lval
)
(
eval_lval
lval
)
stmt
callstack
|
Pexpr
(
expr
,
stmt
)
->
|
Pexpr
(
expr
,
stmt
)
->
domain_eval
(
Cil
.
typeOf
expr
)
(
eval_expr
expr
)
stmt
callstack
domain_eval
(
Cil
.
typeOf
expr
)
(
eval_expr
expr
)
stmt
callstack
|
Pnone
->
dnone
|
Pnone
->
{
alarms
=
[]
;
values
=
[]
}
let
var_of_base
base
acc
=
let
var_of_base
base
acc
=
let
add
vi
acc
=
if
Cil
.
isFunctionType
vi
.
vtype
then
acc
else
vi
::
acc
in
let
add
vi
acc
=
if
Cil
.
isFunctionType
vi
.
vtype
then
acc
else
vi
::
acc
in
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment