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
e1f4a931
Commit
e1f4a931
authored
4 years ago
by
David Bühler
Committed by
Andre Maroneze
4 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[Eva] Allocation builtins: renames some functions.
parent
edf4674f
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/domains/cvalue/builtins_malloc.ml
+21
-21
21 additions, 21 deletions
src/plugins/value/domains/cvalue/builtins_malloc.ml
with
21 additions
and
21 deletions
src/plugins/value/domains/cvalue/builtins_malloc.ml
+
21
−
21
View file @
e1f4a931
...
@@ -315,7 +315,7 @@ let pp_validity fmt (v1, v2) =
...
@@ -315,7 +315,7 @@ let pp_validity fmt (v1, v2) =
Returns the new base, and its maximum validity.
Returns the new base, and its maximum validity.
Note that [_state] is not used, but it is present to ensure a compatible
Note that [_state] is not used, but it is present to ensure a compatible
signature with [alloc_by_stack]. *)
signature with [alloc_by_stack]. *)
let
alloc_
abstract
weak
deallocation
prefix
sizev
_state
=
let
alloc_
fresh
weak
deallocation
prefix
sizev
_state
=
let
stack
=
call_stack_no_wrappers
()
in
let
stack
=
call_stack_no_wrappers
()
in
let
tsize
=
guess_intended_malloc_type
stack
sizev
(
weak
=
Strong
)
in
let
tsize
=
guess_intended_malloc_type
stack
sizev
(
weak
=
Strong
)
in
let
type_base
=
type_from_nb_elems
tsize
in
let
type_base
=
type_from_nb_elems
tsize
in
...
@@ -373,7 +373,7 @@ let string_of_region = function
...
@@ -373,7 +373,7 @@ let string_of_region = function
|
Base
.
Alloca
->
"via alloca"
|
Base
.
Alloca
->
"via alloca"
(* Only called when the 'weakest base' needs to be allocated. *)
(* Only called when the 'weakest base' needs to be allocated. *)
let
alloc_imprecis
e_weakest_
alloc
region
=
let
creat
e_weakest_
base
region
=
let
stack
=
[
fst
(
Globals
.
entry_point
()
)
,
Kglobal
]
in
let
stack
=
[
fst
(
Globals
.
entry_point
()
)
,
Kglobal
]
in
let
type_base
=
let
type_base
=
TArray
(
Cil
.
charType
,
None
,
Cil
.
empty_size_cache
()
,
[]
)
TArray
(
Cil
.
charType
,
None
,
Cil
.
empty_size_cache
()
,
[]
)
...
@@ -393,14 +393,14 @@ let alloc_imprecise_weakest_alloc region =
...
@@ -393,14 +393,14 @@ let alloc_imprecise_weakest_alloc region =
new_base
,
max_alloc
new_base
,
max_alloc
(* used by calloc_abstract *)
(* used by calloc_abstract *)
let
alloc_
imprecise_weakest_abstract
region
=
let
alloc_
weakest_base
region
=
let
memo
=
let
memo
=
match
region
with
match
region
with
|
Base
.
Malloc
->
MallocedSingleMalloc
.
memo
|
Base
.
Malloc
->
MallocedSingleMalloc
.
memo
|
Base
.
VLA
->
MallocedSingleVLA
.
memo
|
Base
.
VLA
->
MallocedSingleVLA
.
memo
|
Base
.
Alloca
->
MallocedSingleAlloca
.
memo
|
Base
.
Alloca
->
MallocedSingleAlloca
.
memo
in
in
memo
(
fun
()
->
alloc_imprecis
e_weakest_
alloc
region
)
memo
(
fun
()
->
creat
e_weakest_
base
region
)
(* Variables that have been returned by a call to an allocation function
(* Variables that have been returned by a call to an allocation function
at this callstack. The first allocated variable is at the top of the
at this callstack. The first allocated variable is at the top of the
...
@@ -444,7 +444,7 @@ let update_variable_validity ?(make_weak=false) base sizev =
...
@@ -444,7 +444,7 @@ let update_variable_validity ?(make_weak=false) base sizev =
base
,
max_valid_bits
base
,
max_valid_bits
|
_
->
Value_parameters
.
fatal
"base is not Allocated: %a"
Base
.
pretty
base
|
_
->
Value_parameters
.
fatal
"base is not Allocated: %a"
Base
.
pretty
base
let
alloc_by_stack
_aux
region
prefix
sizev
state
=
let
alloc_by_stack
region
prefix
sizev
state
=
let
stack
=
call_stack_no_wrappers
()
in
let
stack
=
call_stack_no_wrappers
()
in
let
max_level
=
Value_parameters
.
MallocLevel
.
get
()
in
let
max_level
=
Value_parameters
.
MallocLevel
.
get
()
in
let
all_vars
=
let
all_vars
=
...
@@ -454,7 +454,7 @@ let alloc_by_stack_aux region prefix sizev state =
...
@@ -454,7 +454,7 @@ let alloc_by_stack_aux region prefix sizev state =
let
rec
aux
nb
vars
=
let
rec
aux
nb
vars
=
match
vars
with
match
vars
with
|
[]
->
(* must allocate a new variable *)
|
[]
->
(* must allocate a new variable *)
let
b
,
_
as
r
=
alloc_
abstract
Strong
region
prefix
sizev
state
in
let
b
,
_
as
r
=
alloc_
fresh
Strong
region
prefix
sizev
state
in
MallocedByStack
.
replace
stack
(
all_vars
@
[
b
]);
MallocedByStack
.
replace
stack
(
all_vars
@
[
b
]);
r
r
|
b
::
q
->
|
b
::
q
->
...
@@ -490,21 +490,21 @@ let register_malloc ?replace name ?returns_null allocate_base =
...
@@ -490,21 +490,21 @@ let register_malloc ?replace name ?returns_null allocate_base =
let
()
=
let
()
=
register_malloc
"malloc_fresh"
register_malloc
"malloc_fresh"
(
alloc_
abstract
Strong
Base
.
Malloc
"malloc"
);
(
alloc_
fresh
Strong
Base
.
Malloc
"malloc"
);
register_malloc
"malloc_fresh_weak"
register_malloc
"malloc_fresh_weak"
(
alloc_
abstract
Weak
Base
.
Malloc
"malloc"
);
(
alloc_
fresh
Weak
Base
.
Malloc
"malloc"
);
register_malloc
~
replace
:
"malloc"
"malloc_by_stack"
register_malloc
~
replace
:
"malloc"
"malloc_by_stack"
(
alloc_by_stack
_aux
Base
.
Malloc
"malloc"
);
(
alloc_by_stack
Base
.
Malloc
"malloc"
);
register_malloc
~
replace
:
"__fc_vla_alloc"
"vla_alloc_by_stack"
register_malloc
~
replace
:
"__fc_vla_alloc"
"vla_alloc_by_stack"
(
alloc_by_stack
_aux
Base
.
VLA
"malloc"
)
~
returns_null
:
false
;
(
alloc_by_stack
Base
.
VLA
"malloc"
)
~
returns_null
:
false
;
register_malloc
~
replace
:
"alloca"
"alloca"
register_malloc
~
replace
:
"alloca"
"alloca"
(
alloc_by_stack
_aux
Base
.
Alloca
"alloca"
)
~
returns_null
:
false
;
(
alloc_by_stack
Base
.
Alloca
"alloca"
)
~
returns_null
:
false
;
register_malloc
"malloc_imprecise"
register_malloc
"malloc_imprecise"
(
fun
_
_
->
alloc_
imprecise_weakest_abstract
Base
.
Malloc
);
(
fun
_
_
->
alloc_
weakest_base
Base
.
Malloc
);
register_malloc
"vla_alloc_imprecise"
register_malloc
"vla_alloc_imprecise"
(
fun
_
_
->
alloc_
imprecise_weakest_abstract
Base
.
VLA
);
(
fun
_
_
->
alloc_
weakest_base
Base
.
VLA
);
register_malloc
"alloca_imprecise"
register_malloc
"alloca_imprecise"
(
fun
_
_
->
alloc_
imprecise_weakest_abstract
Base
.
Alloca
)
(
fun
_
_
->
alloc_
weakest_base
Base
.
Alloca
)
(* --------------------------------- Calloc --------------------------------- *)
(* --------------------------------- Calloc --------------------------------- *)
...
@@ -559,12 +559,12 @@ let register_calloc ?replace name allocate_base =
...
@@ -559,12 +559,12 @@ let register_calloc ?replace name allocate_base =
Builtins
.
register_builtin
?
replace
name
builtin
~
typ
Builtins
.
register_builtin
?
replace
name
builtin
~
typ
let
()
=
let
()
=
register_calloc
"calloc_fresh"
(
alloc_
abstract
Strong
Base
.
Malloc
);
register_calloc
"calloc_fresh"
(
alloc_
fresh
Strong
Base
.
Malloc
);
register_calloc
"calloc_fresh_weak"
(
alloc_
abstract
Weak
Base
.
Malloc
);
register_calloc
"calloc_fresh_weak"
(
alloc_
fresh
Weak
Base
.
Malloc
);
register_calloc
~
replace
:
"calloc"
"calloc_by_stack"
register_calloc
~
replace
:
"calloc"
"calloc_by_stack"
(
alloc_by_stack
_aux
Base
.
Malloc
);
(
alloc_by_stack
Base
.
Malloc
);
register_calloc
"calloc_imprecise"
register_calloc
"calloc_imprecise"
(
fun
_
_
_
->
alloc_
imprecise_weakest_abstract
Base
.
Malloc
)
(
fun
_
_
_
->
alloc_
weakest_base
Base
.
Malloc
)
(* ---------------------------------- Free ---------------------------------- *)
(* ---------------------------------- Free ---------------------------------- *)
...
@@ -761,8 +761,8 @@ let realloc_alloc_copy weak bases_to_realloc null_in_arg sizev state =
...
@@ -761,8 +761,8 @@ let realloc_alloc_copy weak bases_to_realloc null_in_arg sizev state =
let
base
,
max_valid
=
let
base
,
max_valid
=
let
prefix
=
"realloc"
in
let
prefix
=
"realloc"
in
match
weak
with
match
weak
with
|
Strong
->
alloc_
abstract
Strong
Base
.
Malloc
prefix
sizev
state
|
Strong
->
alloc_
fresh
Strong
Base
.
Malloc
prefix
sizev
state
|
Weak
->
alloc_by_stack
_aux
Base
.
Malloc
prefix
sizev
state
|
Weak
->
alloc_by_stack
Base
.
Malloc
prefix
sizev
state
in
in
(* Make sure that [ret] will be present in the result: we bind it at least
(* Make sure that [ret] will be present in the result: we bind it at least
to bottom everywhere *)
to bottom everywhere *)
...
@@ -821,7 +821,7 @@ let realloc_multiple bases null size state =
...
@@ -821,7 +821,7 @@ let realloc_multiple bases null size state =
else
res
else
res
let
realloc_imprecise_weakest
_bases
_null
_size
state
=
let
realloc_imprecise_weakest
_bases
_null
_size
state
=
let
new_base
,
max_alloc
=
alloc_
imprecise_weakest_abstract
Base
.
Malloc
in
let
new_base
,
max_alloc
=
alloc_
weakest_base
Base
.
Malloc
in
let
state
=
add_uninitialized
state
new_base
max_alloc
in
let
state
=
add_uninitialized
state
new_base
max_alloc
in
let
ret
=
V
.
inject
new_base
Ival
.
zero
in
let
ret
=
V
.
inject
new_base
Ival
.
zero
in
ret
,
state
ret
,
state
...
...
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