1
(* ledit -h jnl bin/toplevel.top -deps -lib-entry g -slice-callers \
2
tests/slicing/min_call.c
9
Cmdline.Slicing.Mode.Calls.set 3;;
11
let kf_get = Globals.Functions.find_by_name "get";;
12
let kf_send = Globals.Functions.find_by_name "send";;
13
let kf_send_bis = Globals.Functions.find_by_name "send_bis";;
14
let kf_k = Globals.Functions.find_def_by_name "k";;
15
let kf_f = Globals.Functions.find_def_by_name "f";;
16
let kf_g = Globals.Functions.find_def_by_name "g";;
18
let top_mark = !Db.Slicing.Mark.make ~addr:true ~ctrl:true ~data:true ;;
20
let add_select_fun_calls project to_call =
21
let selections = !Db.Slicing.Select.empty_selects () in
22
let selections = !Db.Slicing.Select.select_func_calls_into selections
24
in !Db.Slicing.Request.add_persistent_selection project selections
26
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
28
* Select the call to [send_bis] in [k] as a persistent selection :
29
* this will create a fist slice for [k].
30
* Then create manually a second slice for [k] :
31
* the call to [send_bis] is visible as wished. *)
33
let project = mk_project();;
34
(*let pdg_k = !Db.Pdg.get kf_k;;*)
35
let calls = !Db.Pdg.find_call_stmts ~caller:kf_k(*pdg_k*) kf_send_bis;;
36
let sb_call = match calls with c::[] -> c | _ -> assert false;;
37
let mark = !S.Mark.make ~data:true ~addr:false ~ctrl:false;;
39
!S.Select.select_stmt_internal kf_k sb_call mark;;
40
!S.Request.add_selection_internal project select ;;
41
!S.Request.apply_all_internal project;;
42
Format.printf "@[Project1 - result1 :@\n@]";;
43
extract_and_print project;;
45
let ff2_k = !S.Slice.create project kf_k;;
46
Format.printf "@[Project1 - result2 :@\n@]";;
47
!S.Project.pretty fmt project;;
48
extract_and_print project;;
50
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
52
* same than project1, except that we use [select_min_call_internal].
53
* But as [send_bis] is an undefined function, this makes no difference.
55
let project = mk_project();;
56
(*let pdg_k = !Db.Pdg.get kf_k;;*)
57
let calls = !Db.Pdg.find_call_stmts (*pdg_k*)~caller:kf_k kf_send_bis;;
58
let sb_call = match calls with c::[] -> c | _ -> assert false;;
59
let mark = !S.Mark.make ~data:true ~addr:false ~ctrl:false;;
61
!S.Select.select_min_call_internal kf_k sb_call mark;;
62
!S.Request.add_selection_internal project select ;;
63
print_requests project;;
64
!S.Request.apply_all_internal project;;
65
Format.printf "@[Project3 - result :@\n@]";;
66
!S.Project.pretty fmt project;;
67
extract_and_print project;;
69
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
71
* Select the calls to [k] to be visible in a minimal version.
72
* This builds an empty slice [k_1] for [k] and call it in [f] and [g].
73
* [f_1] is also called in [g_1] because it calls [k_1].
76
let project = mk_project();;
77
add_select_fun_calls project kf_k;;
78
print_requests project;;
79
!S.Request.apply_next_internal project;;
80
print_requests project;;
81
!S.Request.apply_all_internal project;;
82
Format.printf "@[Project3 - result :@\n@]";;
83
!S.Project.pretty fmt project;;
84
extract_and_print project;;
87
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
88
(* Project4 is CAS_1 from Patrick's 19th April 2007 mail.
89
* step 1 - select calls to send and apply : OK
90
* step 2 - (automatically done in step1)
91
* step 3 - select calls to send_bis and apply : TODO
92
* step 4 - (automatically done in step3)
96
let project = mk_project();;
98
add_select_fun_calls project kf_send;;
99
print_requests project;;
100
!S.Request.apply_next_internal project;;
101
print_requests project;;
102
!S.Request.apply_all_internal project;;
104
Format.printf "@[CAS 1 - step 1+2 - result :@\n@]";;
105
extract_and_print project;;
107
add_select_fun_calls project kf_send_bis;;
108
print_requests project;;
109
!S.Request.apply_all_internal project;;
111
Format.printf "@[CAS 1 - step 3+4 - result :@\n@]";;
112
!S.Project.pretty fmt project;;
113
extract_and_print project;;
116
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)
117
(* Project5 : same than the previous one,
118
* except that we create the two requests before applying.
122
let project = mk_project();;
124
add_select_fun_calls project kf_send;;
125
add_select_fun_calls project kf_send_bis;;
126
print_requests project;;
128
Format.printf "@[Project 5 - result :@\n@]";;
129
!S.Project.pretty fmt project;;
130
extract_and_print project;;
132
(*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*)