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
fb4d9f67
Commit
fb4d9f67
authored
4 years ago
by
Julien Signoles
Browse files
Options
Downloads
Patches
Plain Diff
[kernel] restructure special_hooks.ml
parent
670a9b68
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/kernel_internals/runtime/special_hooks.ml
+60
-41
60 additions, 41 deletions
src/kernel_internals/runtime/special_hooks.ml
with
60 additions
and
41 deletions
src/kernel_internals/runtime/special_hooks.ml
+
60
−
41
View file @
fb4d9f67
...
@@ -20,18 +20,13 @@
...
@@ -20,18 +20,13 @@
(* *)
(* *)
(**************************************************************************)
(**************************************************************************)
(* just after loading all plug-ins, add the dependencies between the AST
(**************************************************************************)
and the command line options that depend on it. *)
(* Hooks run very early *)
let
()
=
(**************************************************************************)
Cmdline
.
run_after_extended_stage
(
fun
()
->
State_dependency_graph
.
add_dependencies
~
from
:
Ast
.
self
!
Parameter_builder
.
ast_dependencies
)
let
print_config
()
=
let
print_config
()
=
if
Kernel
.
PrintConfig
.
get
()
then
begin
if
Kernel
.
PrintConfig
.
get
()
then
begin
Log
.
print_on_output
Log
.
print_on_output
(
fun
fmt
->
Format
.
fprintf
fmt
(
fun
fmt
->
Format
.
fprintf
fmt
"Frama-C %s@
\n
\
"Frama-C %s@
\n
\
Environment:@
\n
\
Environment:@
\n
\
...
@@ -72,6 +67,39 @@ let print_pluginpath =
...
@@ -72,6 +67,39 @@ let print_pluginpath =
print_config
Kernel
.
PrintPluginPath
.
get
Fc_config
.
plugin_path
print_config
Kernel
.
PrintPluginPath
.
get
Fc_config
.
plugin_path
let
()
=
Cmdline
.
run_after_early_stage
print_pluginpath
let
()
=
Cmdline
.
run_after_early_stage
print_pluginpath
(**************************************************************************)
(* Hooks run after loading plug-ins *)
(**************************************************************************)
(* just after loading all plug-ins, add the dependencies between the AST
and the command line options that depend on it. *)
let
()
=
Cmdline
.
run_after_extended_stage
(
fun
()
->
State_dependency_graph
.
add_dependencies
~
from
:
Ast
.
self
!
Parameter_builder
.
ast_dependencies
)
(**************************************************************************)
(* Hooks run when restoring a saved file *)
(**************************************************************************)
(* Load Frama-c from disk if required *)
let
load_binary
()
=
let
filepath
=
Kernel
.
LoadState
.
get
()
in
if
filepath
<>
Filepath
.
Normalized
.
unknown
then
begin
try
Project
.
load_all
filepath
with
Project
.
IOError
s
->
Kernel
.
abort
"problem while loading file %a (%s)"
Filepath
.
Normalized
.
pretty
filepath
s
end
let
()
=
Cmdline
.
run_after_loading_stage
load_binary
(**************************************************************************)
(* Hooks run when exiting *)
(**************************************************************************)
let
print_machdep
()
=
let
print_machdep
()
=
if
Kernel
.
PrintMachdep
.
get
()
then
begin
if
Kernel
.
PrintMachdep
.
get
()
then
begin
File
.
pretty_machdep
()
;
File
.
pretty_machdep
()
;
...
@@ -80,7 +108,6 @@ let print_machdep () =
...
@@ -80,7 +108,6 @@ let print_machdep () =
Cmdline
.
nop
Cmdline
.
nop
let
()
=
Cmdline
.
run_after_exiting_stage
print_machdep
let
()
=
Cmdline
.
run_after_exiting_stage
print_machdep
(* Time *)
(* Time *)
let
time
()
=
let
time
()
=
let
filename
=
Kernel
.
Time
.
get
()
in
let
filename
=
Kernel
.
Time
.
get
()
in
...
@@ -118,13 +145,13 @@ let save_binary error_extension =
...
@@ -118,13 +145,13 @@ let save_binary error_extension =
modifying filename into `%s'."
s
;
modifying filename into `%s'."
s
;
Filepath
.
Normalized
.
of_string
s
Filepath
.
Normalized
.
of_string
s
in
in
try
try
Project
.
save_all
realname
Project
.
save_all
realname
with
Project
.
IOError
s
->
with
Project
.
IOError
s
->
Kernel
.
error
"problem while saving to file %a (%s)."
Kernel
.
error
"problem while saving to file %a (%s)."
Filepath
.
Normalized
.
pretty
realname
s
Filepath
.
Normalized
.
pretty
realname
s
end
end
let
()
=
let
()
=
(* implement a refinement of the behavior described in BTS #1388:
(* implement a refinement of the behavior described in BTS #1388:
- on normal exit: save
- on normal exit: save
- on Sys.break, system error or feature request: do not save
- on Sys.break, system error or feature request: do not save
...
@@ -137,29 +164,14 @@ let () =
...
@@ -137,29 +164,14 @@ let () =
|
Log
.
AbortError
_
->
save_binary
(
Some
".error"
)
|
Log
.
AbortError
_
->
save_binary
(
Some
".error"
)
|
_
->
save_binary
(
Some
".crash"
))
|
_
->
save_binary
(
Some
".crash"
))
(* Load Frama-c from disk if required *)
(* Write JSON files to disk if required *)
let
load_binary
()
=
let
flush_json_files
()
=
let
filepath
=
Kernel
.
LoadState
.
get
()
in
let
written
=
Json
.
flush_cache
()
in
if
filepath
<>
Filepath
.
Normalized
.
unknown
then
begin
List
.
iter
(
fun
fp
->
try
Kernel
.
feedback
"Wrote: %a"
Filepath
.
Normalized
.
pretty
fp
)
Project
.
load_all
filepath
written
with
Project
.
IOError
s
->
Kernel
.
abort
"problem while loading file %a (%s)"
Filepath
.
Normalized
.
pretty
filepath
s
end
let
()
=
Cmdline
.
run_after_loading_stage
load_binary
(* This hook cannot be registered directly in Kernel or Cabs2cil, as it
depends on Ast_info *)
let
on_call_to_undeclared_function
vi
=
let
name
=
vi
.
Cil_types
.
vname
in
if
not
(
Ast_info
.
is_frama_c_builtin
name
)
then
Kernel
.
warning
~
wkey
:
Kernel
.
wkey_implicit_function_declaration
~
current
:
true
~
once
:
true
"Calling undeclared function %s. Old style K&R code?"
name
let
()
=
let
()
=
Cmdline
.
at_normal_exit
(
fun
()
->
flush_json_files
()
)
Cabs2cil
.
register_implicit_prototype_hook
on_call_to_undeclared_function
let
run_list_all_plugin_options
()
=
let
run_list_all_plugin_options
()
=
if
not
(
Kernel
.
AutocompleteHelp
.
is_empty
()
)
then
begin
if
not
(
Kernel
.
AutocompleteHelp
.
is_empty
()
)
then
begin
...
@@ -221,14 +233,21 @@ let run_list_all_plugin_options () =
...
@@ -221,14 +233,21 @@ let run_list_all_plugin_options () =
else
Cmdline
.
nop
else
Cmdline
.
nop
let
()
=
Cmdline
.
run_after_exiting_stage
run_list_all_plugin_options
let
()
=
Cmdline
.
run_after_exiting_stage
run_list_all_plugin_options
(* Write JSON files to disk if required *)
(**************************************************************************)
let
flush_json_files
()
=
(* Hooks independent from cmdline ordering *)
let
written
=
Json
.
flush_cache
()
in
(**************************************************************************)
List
.
iter
(
fun
fp
->
Kernel
.
feedback
"Wrote: %a"
Filepath
.
Normalized
.
pretty
fp
)
written
let
()
=
Cmdline
.
at_normal_exit
(
fun
()
->
flush_json_files
()
)
(* This hook cannot be registered directly in Kernel or Cabs2cil, as it
depends on Ast_info *)
let
on_call_to_undeclared_function
vi
=
let
name
=
vi
.
Cil_types
.
vname
in
if
not
(
Ast_info
.
is_frama_c_builtin
name
)
then
Kernel
.
warning
~
wkey
:
Kernel
.
wkey_implicit_function_declaration
~
current
:
true
~
once
:
true
"Calling undeclared function %s. Old style K&R code?"
name
let
()
=
Cabs2cil
.
register_implicit_prototype_hook
on_call_to_undeclared_function
(*
(*
Local Variables:
Local Variables:
...
...
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