open Cil_types open Cil_datatype let main () = Ast.compute (); let kf = Globals.Functions.find_by_name "f" in let sites = Kernel_function.find_syntactic_callsites kf in let kf_main, stmt = match sites with | (kf, s)::[] -> kf, s | _ -> assert false in Format.printf "[script] call in '%a' : %a@." Kf.pretty kf_main Stmt.pretty stmt; let pdg = !Db.Pdg.get kf_main in let num_arg = 1 in let exp = match stmt.skind with | Instr (Call (_, _fct, args, _)) -> List.nth args (num_arg-1) | _ -> assert false in let lval = match exp.enode with | Lval lval -> lval | _ -> assert false in Format.printf "[script] lval of %d arg = %a@." num_arg !Ast_printer.d_lval lval; let zone = !Db.Value.lval_to_zone (Kstmt stmt) ~with_alarms:CilE.warn_none_mode lval in let nodes, undef = !Db.Pdg.find_location_nodes_at_stmt pdg stmt ~before:true zone in match undef with None -> Format.printf "[script] %d nodes + no undef @." (List.length nodes) | Some undef -> Format.printf "[script] %d nodes + undef = %a@." (List.length nodes) Locations.Zone.pretty undef let () = Db.Main.extend main