package frama-c
Platform dedicated to the analysis of source code written in C
Install
Dune Dependency
Authors
-
MMichele Alberti
-
TThibaud Antignac
-
GGergö Barany
-
PPatrick Baudin
-
NNicolas Bellec
-
TThibaut Benjamin
-
AAllan Blanchard
-
LLionel Blatter
-
FFrançois Bobot
-
RRichard Bonichon
-
VVincent Botbol
-
QQuentin Bouillaguet
-
DDavid Bühler
-
ZZakaria Chihani
-
LLoïc Correnson
-
JJulien Crétin
-
PPascal Cuoq
-
ZZaynah Dargaye
-
BBasile Desloges
-
JJean-Christophe Filliâtre
-
PPhilippe Herrmann
-
MMaxime Jacquemin
-
FFlorent Kirchner
-
AAlexander Kogtenkov
-
RRemi Lazarini
-
TTristan Le Gall
-
KKilyan Le Gallic
-
JJean-Christophe Léchenet
-
MMatthieu Lemerre
-
DDara Ly
-
DDavid Maison
-
CClaude Marché
-
AAndré Maroneze
-
TThibault Martin
-
FFonenantsoa Maurica
-
MMelody Méaulle
-
BBenjamin Monate
-
YYannick Moy
-
PPierre Nigron
-
AAnne Pacalet
-
VValentin Perrelle
-
GGuillaume Petiot
-
DDario Pinto
-
VVirgile Prevosto
-
AArmand Puccetti
-
FFélix Ridoux
-
VVirgile Robles
-
JJan Rochel
-
MMuriel Roger
-
CCécile Ruet-Cros
-
JJulien Signoles
-
NNicolas Stouls
-
KKostyantyn Vorobyov
-
BBoris Yakobowski
Maintainers
Sources
frama-c-30.0-Zinc.tar.gz
sha256=3ac0f995261ec829a7bd042bf70fc29ac6379029eb9df30bcc044748eb4d2a56
doc/src/frama-c-occurrence.gui/register_gui.ml.html
Source file register_gui.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
(**************************************************************************) (* *) (* This file is part of Frama-C. *) (* *) (* Copyright (C) 2007-2024 *) (* CEA (Commissariat à l'énergie atomique et aux énergies *) (* alternatives) *) (* *) (* you can redistribute it and/or modify it under the terms of the GNU *) (* Lesser General Public License as published by the Free Software *) (* Foundation, version 2.1. *) (* *) (* It is distributed in the hope that it will be useful, *) (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) (* GNU Lesser General Public License for more details. *) (* *) (* See the GNU Lesser General Public License version 2.1 *) (* for more details (enclosed in the file licenses/LGPLv2.1). *) (* *) (**************************************************************************) open Printer_tag open Gtk_helper open Cil_types open Cil_datatype (* Update the 'Occurrence' column of the gui filetree. *) let update_column = ref (fun _ -> ()) (* Are results shown? *) module Enabled = State_builder.Ref (Datatype.Bool) (struct let name = "Occurrence_gui.State" let dependencies = [Register.self] let default () = false end) module ShowRead = State_builder.Ref (Datatype.Bool) (struct let name = "Occurrence_gui.ShowRead" let dependencies = [] let default () = true end) module ShowWrite = State_builder.Ref (Datatype.Bool) (struct let name = "Occurrence_gui.ShowWrite" let dependencies = [] let default () = true end) let consider_access () = match ShowRead.get (), ShowWrite.get () with | false, false -> (fun _ -> false) | true, true -> (fun _ -> true) | true, false -> (fun ak -> ak = Register.Read || ak = Register.Both) | false, true -> (fun ak -> ak = Register.Write || ak = Register.Both) let filter_accesses l = match ShowRead.get (), ShowWrite.get () with | false, false -> [] | true, true -> l | true, false | false, true -> let f = consider_access () in List.filter (fun access -> f (Register.classify_accesses access)) l let _ignore = Dynamic.register ~plugin:"Occurrence" "Enabled.set" (Datatype.func Datatype.bool Datatype.unit) Enabled.set let _ignore = Dynamic.register ~plugin:"Occurrence" "Enabled.get" (Datatype.func Datatype.unit Datatype.bool) Enabled.get let find_occurrence (main_ui:Design.main_window_extension_points) vi () = try ignore (Register.get vi); Enabled.set true; !update_column `Contents; main_ui#rehighlight () with | Globals.No_such_entry_point _ -> GToolbox.message_box ~title:"Error" "Error: Occurrence requires a main function" let apply_on_vi f localizable = match localizable with | PVDecl(_,_,vi) | PLval(_, _, (Var vi, NoOffset)) | PTermLval(_, _, _, (TVar { lv_origin = Some vi }, TNoOffset)) -> if not (Cil.isFunctionType vi.vtype) then f vi | _ -> () let occurrence_highlighter buffer loc ~start ~stop = if Enabled.get () then match Register.get_last_result () with | None -> (* occurrence not computed *) () | Some (result, vi) -> let result = filter_accesses result in let buffer = buffer#buffer in let highlight () = let tag = make_tag buffer ~name:"occurrence" [`BACKGROUND "yellow" ] in apply_tag buffer tag start stop in match loc with | PLval (_, ki, lval) -> let same_lval (_kf, k, l) = Kinstr.equal k ki && Lval.equal l lval in if List.exists same_lval result then highlight () | PTermLval (_,ki,_,term_lval) -> let same_tlval (_kf, k, l) = Logic_utils.is_same_tlval (Logic_utils.lval_to_term_lval l) term_lval && Kinstr.equal k ki in if List.exists same_tlval result then highlight () | PVDecl(_, _,vi') when Varinfo.equal vi vi' -> highlight () | PExp _ | PVDecl _ | PStmt _ | PStmtStart _ | PGlobal _ | PIP _ | PType _ -> () module FollowFocus = State_builder.Ref (Datatype.Bool) (struct let name = "Occurrence_gui.FollowFocus" let dependencies = [] let default () = false end) let occurrence_panel main_ui = let w = GPack.vbox () in (* Selected Var display *) let selected_var_box = GPack.hbox ~packing:w#pack () in ignore (GMisc.label ~xalign:0.0 ~text:"Current var: " ~packing:(selected_var_box#pack ~expand:false) ()); let e = GMisc.label ~xalign:0.0 ~selectable:true ~packing:(selected_var_box#pack ~expand:true ~fill:true) () in e#set_use_markup true; old_gtk_compat e#set_single_line_mode true; (* check_button enabled *) let = on_bool w "Enable" Enabled.get (fun v -> Enabled.set v; !update_column `Visibility; main_ui#rehighlight ()) in (* check_button followFocus *) let refresh_followFocus = on_bool w "Follow focus" FollowFocus.get FollowFocus.set in let h_read_write = GPack.hbox ~packing:w#pack () in let refresh_rw_aux f v = f v; main_ui#file_tree#reset(); main_ui#rehighlight () in let refresh_read = Gtk_helper.on_bool ~tooltip:"Show only occurrences where the zone is read" h_read_write "Read" ShowRead.get (refresh_rw_aux ShowRead.set) in let refresh_write = Gtk_helper.on_bool ~tooltip:"Show only occurrences where the zone is written" h_read_write "Write" ShowWrite.get (refresh_rw_aux ShowWrite.set) in let refresh = let old_vi = ref (-2) in (fun () -> refresh_read(); refresh_write (); refresh_followFocus (); refresh_enabled_button (); let new_result = Register.get_last_result () in (match new_result with | None when !old_vi<> -1 -> old_vi := -1; e#set_label "<i>None</i>" | Some (_,vi) when vi.vid<> !old_vi-> old_vi := vi.vid; e#set_label vi.vname | _ -> ())) in "Occurrence",w#coerce,Some refresh let occurrence_selector (popup_factory:GMenu.menu GMenu.factory) main_ui ~ localizable = apply_on_vi (fun vi -> if button = 3 || FollowFocus.get () then begin let callback = find_occurrence main_ui vi in ignore (popup_factory#add_item "_Occurrence" ~callback); if FollowFocus.get () then ignore (Glib.Idle.add (fun () -> callback (); false)) end) localizable let file_tree_decorate (file_tree:Filetree.t) = update_column := file_tree#append_pixbuf_column ~title:"Occurrence" (fun globs -> match Register.get_last_result () with | None -> (* occurrence not computed *) [`STOCK_ID ""] | Some (result, _) -> let in_globals (kf,ki,_ as access) = (let ak = Register.classify_accesses access in consider_access () ak) && match ki with | Kglobal -> false | Kstmt _ -> let kf = Option.get kf in let v0 = Kernel_function.get_vi kf in List.exists (fun glob -> match glob with | GFun ({svar =v1},_ ) -> Varinfo.equal v1 v0 | _ -> false) globs in if List.exists in_globals result then [`STOCK_ID "gtk-apply"] else [`STOCK_ID ""]) (fun () -> Enabled.get ()); !update_column `Visibility let main main_ui = main_ui#register_source_selector occurrence_selector; main_ui#register_source_highlighter occurrence_highlighter; main_ui#register_panel occurrence_panel; file_tree_decorate main_ui#file_tree; ;; let () = Design.register_extension main (* Local Variables: compile-command: "make -C ../../.." End: *)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>