├── benchmarks ├── pycli │ ├── __init__.py │ └── README.md └── csmith │ └── .gitignore ├── .ocamlformat-ignore ├── doc ├── getting-started │ ├── test.c │ └── dune ├── types-tutorial │ ├── example.exe │ ├── example.typedc │ ├── example-nn-ptr.typedc │ ├── example-lasso.typedc │ ├── example-refined.typedc │ ├── example-param.typedc │ ├── example-sugar.typedc │ ├── example.c │ └── example_full.c ├── while-tutorial │ └── While tutorial.mld ├── dune └── Tutorials.mld ├── frontends ├── binsec │ ├── index.mld │ ├── x86_arch.mli │ ├── benchmark.ml │ ├── codex_main.ml │ ├── Makefile │ └── interval2symbol.mli └── frama-c │ ├── index.mld │ ├── test.types │ ├── t062.exp_dump │ ├── main.cdump │ ├── CodexPlugin.mli │ ├── codexPlugin.ml │ ├── post_analysis.mli │ ├── test.c │ ├── varinfo_Enclosing_Function.mli │ ├── codex_register.mli │ ├── Makefile.frama-c │ ├── printhtml.mli │ ├── globals_needed.mli │ ├── frama_c_codex.ml │ └── exp_dump.mli ├── dependency_graph.png ├── examples ├── abs │ ├── abs.exe │ ├── abs.types │ ├── abs.cdump │ ├── abs.c │ └── Makefile ├── README ├── calc │ └── TODO └── os_message │ └── os_message.types ├── .github ├── dependabot.yml └── workflows │ ├── opam-dependency-submission.yml │ ├── build-gui-deps.yml │ ├── deploy-doc.yml │ └── build-test.yml ├── utils ├── gui │ ├── deps │ │ └── js │ │ │ ├── bundle-input.js │ │ │ ├── package.json │ │ │ ├── rollup.config.js │ │ │ ├── default.nix │ │ │ └── dune │ ├── js │ │ ├── TODO │ │ ├── main_layout.mli │ │ ├── widget.mli │ │ ├── modal_input_string.mli │ │ ├── tag.mli │ │ ├── unique_prefix.mli │ │ ├── tag.ml │ │ ├── sourceview.mli │ │ └── unique_prefix.ml │ ├── gui.ml │ └── print_html_webapp.mli ├── not_implemented.ml ├── cfg │ └── dune ├── tracelog │ ├── README.org │ ├── common.ml │ ├── dune │ └── tutorial.tlog ├── smallmap.mli ├── record_time.ml ├── compressor │ └── dune ├── unionFind │ └── dune ├── emit_alarm.mli ├── dynamic_array.mli ├── int_builtins_ml.ml └── online_nearest_common_ancestor_skiplist.mli ├── META ├── .dockerignore ├── devenv ├── nix │ ├── pacomb.nix │ ├── sv-benchmarks.nix │ ├── diff2junit.nix │ ├── cudd.nix │ ├── patricia-tree.nix │ ├── binsec.nix │ └── mdx.nix └── headers │ ├── CEA_LGPL21 │ └── CEA_LGPL21_patricia-tree ├── .gitmodules ├── codex.opam.template ├── ext ├── frama_c_with_cudd │ ├── opam-frama-c-27.1-Cobalt.patch │ ├── opam-frama-c-28.0-Nickel.patch │ ├── opam-frama-c-28.1-Nickel.patch │ ├── patch-frama-c.patch │ └── internalize_machdeps.patch ├── dune └── framac_ival │ ├── fc_float.mli │ ├── float_interval.mli │ ├── dune │ ├── pretty_utils.ml │ ├── .depend │ └── pretty_utils.mli ├── binsec_codex.opam ├── Makefile.common ├── frama_c_codex.opam ├── .gitignore ├── types └── test.types ├── single_value_abstraction ├── sva_known_bits.mli ├── sva_ival_with_sentinel.mli ├── binary_collecting.mli ├── sva_binary_to_integer.mli ├── sva_sentinel.mli ├── sva_prod.mli ├── sva_bitfield.mli ├── sva_log.mli └── dune ├── lattices ├── unit_Lattice.mli ├── bitfield_Lattice.mli ├── dune ├── boolean_standard.ml ├── unit_Lattice.ml ├── set_Lattice.mli ├── unimplemented_Lattice.mli └── prod_Lattice.mli ├── operator └── dune ├── fixpoint └── dune ├── smtbackend ├── dune ├── smtbackend.ml ├── smtbackend_aliases.ml └── smtbackend_smtlib.mli ├── domains ├── term_based │ ├── assert_false.mli │ └── product.mli ├── extend.mli ├── integer2binary.mli ├── memory_domains │ ├── block_smashing.mli │ ├── region_separation.mli │ ├── typed_address.mli │ └── wholify.mli └── bitwise.mli ├── .ocamlformat ├── terms ├── builder.mli ├── slicing.mli └── smt.mli └── codex.ml /benchmarks/pycli/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.ocamlformat-ignore: -------------------------------------------------------------------------------- 1 | **/*.ml 2 | **/*.mli -------------------------------------------------------------------------------- /doc/getting-started/test.c: -------------------------------------------------------------------------------- 1 | int main(int i) { int x = i; if(i > 8) x = 8; return x; } 2 | -------------------------------------------------------------------------------- /frontends/binsec/index.mld: -------------------------------------------------------------------------------- 1 | {0 The Binsec frontend to the Codex static analyzer} 2 | -------------------------------------------------------------------------------- /frontends/frama-c/index.mld: -------------------------------------------------------------------------------- 1 | {0 The Frama-C frontend to the Codex static analyser} 2 | -------------------------------------------------------------------------------- /dependency_graph.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codex-semantics-library/codex/HEAD/dependency_graph.png -------------------------------------------------------------------------------- /examples/abs/abs.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codex-semantics-library/codex/HEAD/examples/abs/abs.exe -------------------------------------------------------------------------------- /examples/abs/abs.types: -------------------------------------------------------------------------------- 1 | /* -*- mode:c -*- */ 2 | int abs((int with self < 1000 && self + 2000 >= 0) a); 3 | -------------------------------------------------------------------------------- /doc/types-tutorial/example.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/codex-semantics-library/codex/HEAD/doc/types-tutorial/example.exe -------------------------------------------------------------------------------- /benchmarks/csmith/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore all generated c files and analysis results, only commit folder 2 | c*.c 3 | c*.main.cdump 4 | -------------------------------------------------------------------------------- /examples/README: -------------------------------------------------------------------------------- 1 | - abs: start here, shows refinement types. 2 | - calc: shows variant types. 3 | - os_msessage: shows non-local invariants. -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | - package-ecosystem: github-actions 4 | directory: / 5 | schedule: 6 | interval: monthly 7 | -------------------------------------------------------------------------------- /utils/gui/deps/js/bundle-input.js: -------------------------------------------------------------------------------- 1 | import { graphviz} from 'd3-graphviz'; 2 | import { transition } from 'd3-transition'; 3 | window.d3 = { graphviz, transition }; 4 | -------------------------------------------------------------------------------- /META: -------------------------------------------------------------------------------- 1 | archive(byte) = "Codex.cma" 2 | archive(native) = "Codex.cmxa" 3 | plugin(byte) = "Codex.cma" 4 | plugin(native) = "Codex.cmxs" 5 | requires = "cudd zarith ocamlgraph" 6 | -------------------------------------------------------------------------------- /examples/calc/TODO: -------------------------------------------------------------------------------- 1 | A reverse polish notation calculator, that creates the expressions from a string and then evaluates it. 2 | 3 | Actually, do two versions: one with internal tags, and one with external tags. -------------------------------------------------------------------------------- /.dockerignore: -------------------------------------------------------------------------------- 1 | _build 2 | ext/frama_c_with_cudd/frama-c* 3 | utils/patricia-tree 4 | .dockerignore 5 | 6 | .git 7 | .vscode 8 | .gitmodules 9 | .gitlab-ci.yml 10 | 11 | .mypy_cache 12 | .ruff_cache 13 | __pycache__ 14 | -------------------------------------------------------------------------------- /frontends/frama-c/test.types: -------------------------------------------------------------------------------- 1 | /* -*- mode:c -*- */ 2 | struct foo { 3 | (int with self = 3) i; 4 | (int with self >= 5) j; 5 | }; 6 | 7 | region a = struct foo /* With a comment. */ 8 | 9 | int main(struct foo? p); 10 | 11 | -------------------------------------------------------------------------------- /utils/gui/js/TODO: -------------------------------------------------------------------------------- 1 | - Improve support for trace: handle more things in the read-only 2 | portion of trace, by building some packed data structure which is a 3 | map from continuously-increasing trace ids, to the correct position 4 | in the file. -------------------------------------------------------------------------------- /benchmarks/pycli/README.md: -------------------------------------------------------------------------------- 1 | # Pycli library 2 | 3 | This folder contains a small python library used by the `../manage.py` script. 4 | It is mostly centered around helpers to create pretty terminal displays. 5 | It requires python > 3.10 for the lightweight type annotation syntax. 6 | -------------------------------------------------------------------------------- /doc/types-tutorial/example.typedc: -------------------------------------------------------------------------------- 1 | region buffer = ∃ len : int. (char[len]) 2 | 3 | struct message { 4 | struct message* next; 5 | buffer* buffer; 6 | }; 7 | 8 | struct message_box { 9 | int length; 10 | struct message* first; 11 | }; 12 | 13 | void zeros_buffer(struct message_box* box); 14 | -------------------------------------------------------------------------------- /doc/types-tutorial/example-nn-ptr.typedc: -------------------------------------------------------------------------------- 1 | region buffer = ∃ len : int. (char[len]) 2 | 3 | struct message { 4 | struct message* next; 5 | buffer* buffer; 6 | }; 7 | 8 | struct message_box { 9 | int length; 10 | struct message* first; 11 | }; 12 | 13 | void zeros_buffer(struct message_box+ box); 14 | -------------------------------------------------------------------------------- /doc/types-tutorial/example-lasso.typedc: -------------------------------------------------------------------------------- 1 | region buffer = ∃ len : integer with self >= 0. (char[len]) 2 | 3 | struct message { 4 | struct message+ next; 5 | buffer+ buffer; 6 | }; 7 | 8 | struct message_box { 9 | integer with self >= 0 length; 10 | struct message+ first; 11 | }; 12 | 13 | void zeros_buffer(struct message_box+ box); 14 | -------------------------------------------------------------------------------- /doc/types-tutorial/example-refined.typedc: -------------------------------------------------------------------------------- 1 | region buffer = ∃ len : integer with self >= 0. (char[len]) 2 | 3 | struct message { 4 | struct message* next; 5 | buffer+ buffer; 6 | }; 7 | 8 | struct message_box { 9 | integer with self >= 0 length; 10 | struct message+ first; 11 | }; 12 | 13 | void zeros_buffer(struct message_box+ box); 14 | -------------------------------------------------------------------------------- /doc/types-tutorial/example-param.typedc: -------------------------------------------------------------------------------- 1 | region struct message(len) = struct { 2 | struct message(len)+ next; 3 | char[len]+ buffer; 4 | }; 5 | 6 | region struct message_box = ∃ mlen:integer with self > 0. 7 | struct { 8 | integer with self = mlen length; 9 | struct message(mlen)+ first; 10 | }; 11 | 12 | void zeros_buffer(struct message_box+ box) 13 | -------------------------------------------------------------------------------- /doc/types-tutorial/example-sugar.typedc: -------------------------------------------------------------------------------- 1 | region buffer = ∃ len : int. (char[len]) 2 | 3 | // Here "struct message" is the new region name 4 | region struct message = struct { 5 | struct message* next; 6 | buffer* buffer; 7 | }; 8 | 9 | // The struct prefix is optional, I can also simply name thie struct "message_box" 10 | region message_box = struct { 11 | int length; 12 | struct message* first; 13 | }; 14 | 15 | void zeros_buffer(message_box* box); 16 | -------------------------------------------------------------------------------- /utils/gui/deps/js/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hello", 3 | "version": "1.0.0", 4 | "main": "bundle-input.js", 5 | "type": "module", 6 | "dependencies": { 7 | "d3-graphviz": "^5.6.0", 8 | "d3-transition": "^3.0.1" 9 | }, 10 | "devDependencies": { 11 | "@rollup/plugin-commonjs": "^28.0.3", 12 | "@rollup/plugin-node-resolve": "^16.0.1", 13 | "@rollup/plugin-terser": "^0.4.4", 14 | "@rollup/plugin-wasm": "^6.2.2", 15 | "rollup": "^4.40.0" 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /devenv/nix/pacomb.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { }, ocamlPackages }: 2 | with pkgs; 3 | with ocamlPackages; 4 | 5 | buildDunePackage rec { 6 | pname = "pacomb"; 7 | version = "1.3"; 8 | src = pkgs.fetchzip { 9 | url = "https://github.com/craff/pacomb/archive/refs/tags/1.3.tar.gz"; 10 | hash = "sha256-7y5/57FVLBLPH951LBESEXW/WnvgsZiWc6XG954jTGc="; 11 | }; 12 | 13 | duneVersion = "3"; 14 | doCheck = true; 15 | checkInputs = [ stdlib-shims ]; 16 | buildInputs = [ ppxlib stdlib-shims ]; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /doc/types-tutorial/example.c: -------------------------------------------------------------------------------- 1 | struct message { 2 | struct message *next; 3 | char *buffer; 4 | }; 5 | 6 | struct message_box { 7 | int length; 8 | struct message *first; 9 | }; 10 | 11 | void zeros_buffer(struct message_box *box) { 12 | struct message *first = box->first; 13 | struct message *current = first; 14 | 15 | int length = box->length; 16 | 17 | do { 18 | for (int i = 0; i < length; i++) { 19 | current->buffer[i] = 0; 20 | } 21 | current = current->next; 22 | } while (current != first); 23 | } 24 | -------------------------------------------------------------------------------- /devenv/nix/sv-benchmarks.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import {} }: 2 | # {stdenv, lib, fetchzip, fetchgit}: 3 | pkgs.stdenv.mkDerivation { 4 | pname = "sv-benchmarks"; 5 | version = "svcomp24-final"; 6 | 7 | src = pkgs.fetchgit { 8 | url = "https://gitlab-ci-token:${builtins.getEnv "CI_JOB_TOKEN"}@git.frama-c.com/codex/sv-benchmarks"; 9 | hash = "sha256-Vsq5XL2W4Jb+0AcHcDH4wEmKhjf/+wrUEcbu05mWJa8="; 10 | }; 11 | 12 | installPhase = '' 13 | echo "SVBENCHMARK INSTALL PHASE" 14 | mkdir -p $out 15 | cp -r $src/* $out 16 | ''; 17 | } 18 | -------------------------------------------------------------------------------- /devenv/nix/diff2junit.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { }, ocamlPackages }: 2 | with pkgs; 3 | with ocamlPackages; 4 | buildDunePackage{ 5 | pname = "diff2junit"; 6 | version = "dev"; 7 | duneVersion = "3"; 8 | src = pkgs.fetchgit { 9 | url = "https://gitlab-ci-token:${ 10 | builtins.getEnv "CI_JOB_TOKEN" 11 | }@git.frama-c.com/codex/diff2junit"; 12 | hash = "sha256-4JzQahF+Y/d42k5hcoaLGIN6HVvlFcAqwR5II6KOqKY="; 13 | }; 14 | 15 | nativeBuildInputs = [ ]; 16 | buildInputs = [ ]; 17 | checkInputs = [ ]; 18 | doCheck = true; 19 | } 20 | -------------------------------------------------------------------------------- /frontends/frama-c/t062.exp_dump: -------------------------------------------------------------------------------- 1 | reduce.c:7.28-29: `m' -> [0..0x7FFFFFFD],0%5 2 | reduce.c:10.15-16: `j' -> [0..0x7FFFFFFD],0%5 3 | reduce.c:10.18-19: `k' -> [0..0x7FFFFFFD],0%5 4 | reduce.c:11.8-13: `b + 5' -> [5..0x7FFFFFFD],0%5 5 | reduce.c:11.8-9: `b' -> [0..0x7FFFFFFD],0%5 6 | reduce.c:12.8-9: `j' -> [0..0x7FFFFFFD],0%5 7 | reduce.c:13.8-9: `i' -> [5..0x7FFFFFFD],0%5 8 | reduce.c:14.8-9: `g' -> {0; 5} 9 | Unproved alarms: 10 | Additional alarms: 11 | Proved 0/0 alarms 12 | Unproved 0 regular alarms and 0 additional alarms. 13 | Solved 0/0 user assertions, proved 0 14 | -------------------------------------------------------------------------------- /devenv/nix/cudd.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { }, ocamlPackages }: 2 | with ocamlPackages; 3 | with pkgs; 4 | buildDunePackage { 5 | pname = "cudd"; 6 | version = "${builtins.getEnv "CUDDML_REV"}"; 7 | duneVersion = "3"; 8 | # WE use fetchGit and not fetchgit here, because it does not require a hash. 9 | src = builtins.fetchGit { 10 | url = "https://git.frama-c.com/pub/codex/cudd.ml"; 11 | rev = "${builtins.getEnv "CUDDML_REV"}"; 12 | }; 13 | 14 | nativeBuildInputs = [ curl cacert ]; 15 | buildInputs = [ ]; 16 | checkInputs = [ ]; 17 | doCheck = true; 18 | } 19 | -------------------------------------------------------------------------------- /doc/types-tutorial/example_full.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include "example.c" 4 | 5 | int main(void) { 6 | // Allocates the message box 7 | struct message_box *box = malloc(sizeof(struct message_box)); 8 | box->length = 20; 9 | box->first = NULL; 10 | for (int i = 0; i < 10; i++) { 11 | struct message *lst = malloc(sizeof(struct message)); 12 | lst->buffer = malloc(sizeof(char) * box->length); 13 | lst->next = box->first; 14 | box->first = lst; 15 | } 16 | 17 | // Fills the content of message box with zeros 18 | zeros_buffer(box); 19 | 20 | return 0; 21 | } 22 | -------------------------------------------------------------------------------- /examples/abs/abs.cdump: -------------------------------------------------------------------------------- 1 | abs.c:3.5-10: `i < 0' -> {0; 1} 2 | abs.c:3.5-6: `i' -> [--..--] 3 | abs.c:4.10-12: `- i' -> [1..0x7FFFFFFF] 4 | abs.c:4.11-12: `i' -> [-0x80000000..-1] 5 | abs.c:7.10-11: `i' -> [0..0x7FFFFFFF] 6 | abs.c:9.2-16: `res + 0 / res' -> [1..0x7FFFFFFF] 7 | abs.c:9.2-5: `res' -> [0..0x7FFFFFFF] 8 | abs.c:9.9-16: `0 / res' -> {0} 9 | abs.c:9.13-16: `res' -> [0..0x7FFFFFFF] 10 | abs.c:10.9-12: `res' -> [1..0x7FFFFFFF] 11 | Unproved alarms: 12 | abs.c:9: Division_by_zero(res) {true;false} 13 | Proved 0/1 alarms 14 | Unproved 1 regular alarms and 0 additional alarms. 15 | Solved 0/0 user assertions, proved 0 16 | -------------------------------------------------------------------------------- /devenv/nix/patricia-tree.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { }, ocamlPackages }: 2 | with pkgs; 3 | with ocamlPackages; 4 | 5 | buildDunePackage rec { 6 | pname = "patricia-tree"; 7 | version = "${builtins.getEnv "PATRICIA_TREE_REV"}"; 8 | 9 | # WE use fetchGit and not fetchgit here, because it does not require a hash. 10 | src = builtins.fetchGit { 11 | url = "https://github.com/codex-semantics-library/patricia-tree.git"; 12 | rev = "${builtins.getEnv "PATRICIA_TREE_REV"}"; 13 | }; 14 | 15 | duneVersion = "3"; 16 | doCheck = false; 17 | checkInputs = [ ]; 18 | buildInputs = [ zarith qcheck ppx_inline_test mdx ]; 19 | } 20 | -------------------------------------------------------------------------------- /.github/workflows/opam-dependency-submission.yml: -------------------------------------------------------------------------------- 1 | name: Opam Dependency Submission 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | opam-dependency-submission: 9 | permissions: 10 | contents: write 11 | 12 | runs-on: ubuntu-latest 13 | steps: 14 | - name: Checkout tree 15 | uses: actions/checkout@v6 16 | 17 | - name: Set-up OCaml 5.3 18 | uses: ocaml/setup-ocaml@v3 19 | with: 20 | ocaml-compiler: 5.3 21 | dune-cache: true 22 | allow-prerelease-opam: true 23 | 24 | - name: Opam Dependency Submission 25 | uses: ocaml/setup-ocaml/analysis@v3 26 | -------------------------------------------------------------------------------- /utils/gui/deps/js/rollup.config.js: -------------------------------------------------------------------------------- 1 | import resolve from '@rollup/plugin-node-resolve'; 2 | import commonjs from '@rollup/plugin-commonjs'; 3 | import wasm from '@rollup/plugin-wasm'; 4 | import terser from '@rollup/plugin-terser'; 5 | 6 | export default { 7 | input: 'bundle-input.js', 8 | output: [ 9 | { 10 | file: 'bundle-output.js', 11 | format: 'iife', 12 | name: 'BundleOutput', 13 | sourcemap: 'inline' 14 | }, 15 | { 16 | file: 'bundle-output.min.js', 17 | format: 'iife', 18 | name: 'BundleOutput', 19 | plugins: [terser()] 20 | } 21 | ], 22 | plugins: [ 23 | resolve(), 24 | commonjs(), 25 | wasm({ maxFileSize: 100000000 }) 26 | ] 27 | }; 28 | -------------------------------------------------------------------------------- /devenv/headers/CEA_LGPL21: -------------------------------------------------------------------------------- 1 | This file is part of the Codex semantics library. 2 | 3 | Copyright (C) 2013-2025 4 | CEA (Commissariat à l'énergie atomique et aux énergies 5 | alternatives) 6 | 7 | you can redistribute it and/or modify it under the terms of the GNU 8 | Lesser General Public License as published by the Free Software 9 | Foundation, version 2.1. 10 | 11 | It is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU Lesser General Public License for more details. 15 | 16 | See the GNU Lesser General Public License version 2.1 17 | for more details (enclosed in the file LICENSE). 18 | 19 | -------------------------------------------------------------------------------- /devenv/headers/CEA_LGPL21_patricia-tree: -------------------------------------------------------------------------------- 1 | This file is part of the Codex semantics library 2 | (patricia-tree sub-component). 3 | 4 | 5 | Copyright (C) 2013-2025 6 | CEA (Commissariat à l'énergie atomique et aux énergies 7 | alternatives) 8 | 9 | You can redistribute it and/or modify it under the terms of the GNU 10 | Lesser General Public License as published by the Free Software 11 | Foundation, version 2.1. 12 | 13 | It is distributed in the hope that it will be useful, 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | GNU Lesser General Public License for more details. 17 | 18 | See the GNU Lesser General Public License version 2.1 19 | for more details (enclosed in the file LICENSE). 20 | -------------------------------------------------------------------------------- /frontends/frama-c/main.cdump: -------------------------------------------------------------------------------- 1 | test.c:29.10-23: `p->i + p->j' -> [8..0x7FFFFFFF] 2 | test.c:29.10-14: `p->i' -> {3} 3 | test.c:29.10-11: `p' -> {0} or ([1..0xFFFFFFFF] : struct foo*) 4 | test.c:29.17-23: `p->j' -> [5..0x7FFFFFFF] 5 | test.c:29.17-18: `p' -> ([1..0xFFFFFFFF] : struct foo*) 6 | test.c:30.9-12: `a + 1' -> [9..0x7FFFFFFF] 7 | test.c:30.9-10: `a' -> [8..0x7FFFFFFF] 8 | test.c:30.2-13: `__retres' -> [9..0x7FFFFFFF] 9 | Unproved regular alarms: 10 | test.c:29: Memory_access(p->i, read) {true;false} 11 | test.c:29: Signed_overflow(p->i + p->j <= 2147483647) {true;false} 12 | test.c:30: Signed_overflow(a + 1 <= 2147483647) {true;false} 13 | Unproved additional alarms: 14 | Proved 3/6 regular alarms 15 | Unproved 3 regular alarms and 0 additional alarms. 16 | Solved 0/0 user assertions, proved 0 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "binsec/binsec"] 2 | path = binsec/binsec 3 | url = git@git.frama-c.com:binary/binsec.git 4 | [submodule "benchmarks/types"] 5 | path = benchmarks/types 6 | url = git@git.frama-c.com:codex/types-benchmarks.git 7 | [submodule "utils/patricia-tree"] 8 | path = utils/patricia-tree 9 | url = git@github.com:codex-semantics-library/patricia-tree.git 10 | branch = main 11 | [submodule "benchmarks/sv-benchmarks4codex"] 12 | path = benchmarks/sv-benchmarks4codex 13 | url = git@git.frama-c.com:codex/sv-benchmarks4codex.git 14 | [submodule "benchmarks/whole-program"] 15 | path = benchmarks/whole-program 16 | url = git@git.frama-c.com:codex/whole-program-examples.git 17 | branch = main 18 | [submodule "utils/cudd.ml"] 19 | path = utils/cudd.ml 20 | url = git@git.frama-c.com:pub/codex/cudd.ml.git 21 | branch = main 22 | -------------------------------------------------------------------------------- /.github/workflows/build-gui-deps.yml: -------------------------------------------------------------------------------- 1 | name: Build GUI deps and publish bundle 2 | 3 | # Build the GUI only for tags. 4 | on: 5 | push: 6 | tags: 7 | - "*" 8 | 9 | permissions: 10 | contents: write 11 | 12 | jobs: 13 | build: 14 | runs-on: ubuntu-latest 15 | 16 | steps: 17 | - name: Checkout 18 | uses: actions/checkout@v4 19 | 20 | - name: Setup Node 21 | uses: actions/setup-node@v4 22 | with: 23 | node-version: 20 24 | 25 | - name: Build bundle using Makefile 26 | run: | 27 | make -C utils/gui/deps js/bundle-output.js tailwind4.1.5.css graphviz.umd.js 28 | 29 | - name: Create GitHub release and upload bundle 30 | uses: softprops/action-gh-release@v2 31 | with: 32 | files: | 33 | utils/gui/deps/js/bundle-output.js 34 | utils/gui/deps/tailwind4.1.5.css 35 | utils/gui/deps/graphviz.umd.js 36 | -------------------------------------------------------------------------------- /utils/gui/deps/js/default.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { } }: 2 | let 3 | graphvizJs = pkgs.fetchurl { 4 | url = "https://cdn.jsdelivr.net/npm/@hpcc-js/wasm@2.22.4/dist/graphviz.umd.js"; 5 | sha256 = "sha256-JeT1R2S8FhCSAcL0zsJjx7ai+bL1X3AjHcgEniwm33c="; 6 | }; 7 | tailwind4 = pkgs.fetchurl { 8 | url = "https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.1.5"; 9 | sha256 = "sha256-HgE6gWIf2+0W908sYIjhUDYkUnsIz0mJN2nHqXY3QD8="; 10 | }; 11 | 12 | in pkgs.stdenv.mkDerivation { 13 | pname = "codex-js-deps"; 14 | version = "1.0.0"; 15 | 16 | src = ./.; 17 | 18 | buildInputs = [ pkgs.nodejs pkgs.nodePackages.rollup pkgs.curl pkgs.cacert ]; 19 | 20 | buildPhase = '' 21 | export HOME=$TMPDIR 22 | npm install 23 | npx rollup -c 24 | cp ${graphvizJs} graphviz.umd.js 25 | cp ${tailwind4} tailwind4.1.5.css 26 | ''; 27 | 28 | installPhase = '' 29 | mkdir -p $out 30 | cp bundle-output.js $out/ 31 | cp graphviz.umd.js $out/ 32 | cp *.css $out/ 33 | ''; 34 | } 35 | -------------------------------------------------------------------------------- /codex.opam.template: -------------------------------------------------------------------------------- 1 | # Automatically generated by utils/gui/deps/Makefile. 2 | extra-source "utils/gui/deps/tailwind4.1.5.css" { 3 | src: "https://github.com/codex-semantics-library/codex/releases/download/1.0-rc4/tailwind4.1.5.css" 4 | checksum: [ 5 | "sha256=1e013a81621fdbed16f74f2c6088e1503624527b08cf49893769c7a97637403f" 6 | "md5=c176214ae22bb4d3ec8932799b9f1c12" 7 | ] 8 | } 9 | 10 | extra-source "utils/gui/deps/graphviz.umd.js" { 11 | src: "https://github.com/codex-semantics-library/codex/releases/download/1.0-rc4/graphviz.umd.js" 12 | checksum: [ 13 | "sha256=25e4f54764bc16109201c2f4cec263c7b6a2f9b2f55f70231dc8049e2c26df77" 14 | "md5=3df78b9584961e99bf8d6ae1bb7eaff8" 15 | ] 16 | } 17 | 18 | extra-source "utils/gui/deps/js/bundle-output.js" { 19 | src: "https://github.com/codex-semantics-library/codex/releases/download/1.0-rc4/bundle-output.js" 20 | checksum: [ 21 | "sha256=e6240883caa8625cae154797e6c423278ffc87faa4c079f52e6fb4c11948f30f" 22 | "md5=51738d1345c24849a597d1a3bf26282c" 23 | ] 24 | } 25 | 26 | -------------------------------------------------------------------------------- /devenv/nix/binsec.nix: -------------------------------------------------------------------------------- 1 | { pkgs ? import { }, ocamlPackages }: 2 | with pkgs; 3 | with ocamlPackages; 4 | buildDunePackage { 5 | pname = "binsec"; 6 | version = "0.10.0"; 7 | duneVersion = "3"; 8 | 9 | src = fetchgit { 10 | url = "https://gitlab-ci-token:${ 11 | builtins.getEnv "CI_JOB_TOKEN" 12 | }@git.frama-c.com/binary/binsec"; 13 | # version 0.10.0. 14 | rev = "2792ee4e9508255f7afd17c2cbd20303e939b409"; 15 | hash = "sha256-eGysV2vTRnpV0muE/yANf1+PZqz4OUhoiQPoaXG5nC8="; 16 | }; 17 | 18 | nativeBuildInputs = [ dune-site menhir dypgen ]; 19 | 20 | buildInputs = [ 21 | gmp # for zarith 22 | ocamlgraph 23 | zarith 24 | dune-site 25 | # llvm 26 | menhir 27 | dypgen 28 | toml 29 | # unisim_archisec 30 | curses 31 | mmap 32 | ]; 33 | 34 | checkInputs = [ 35 | qtest 36 | ounit 37 | qcheck 38 | seq 39 | bubblewrap 40 | python3 41 | z3 42 | bitwuzla 43 | boolector 44 | gdb 45 | file 46 | ]; 47 | 48 | doCheck = false; 49 | } 50 | -------------------------------------------------------------------------------- /ext/frama_c_with_cudd/opam-frama-c-27.1-Cobalt.patch: -------------------------------------------------------------------------------- 1 | --- a/opam 2024-01-12 02:21:09.771672337 +0100 2 | +++ b/opam 2024-01-12 02:29:11.010315374 +0100 3 | @@ -120,15 +120,11 @@ 4 | "dune-configurator" 5 | "dune-site" 6 | 7 | - ( "alt-ergo-free" | "alt-ergo" ) 8 | - "conf-graphviz" { post } 9 | "conf-time" { with-test } 10 | "menhir" { >= "20181006" & build } 11 | "ocaml" { >= "4.11.1" } 12 | "ocamlfind" # needed beyond build stage, used by -load-module 13 | "ocamlgraph" { >= "1.8.8" } 14 | - "odoc" { with-doc } 15 | - "why3" { >= "1.6.0" } 16 | "yaml" { >= "3.0.0" } 17 | "yojson" {>= "1.6.0" & (>= "2.0.1" | !with-test)} 18 | "zarith" { >= "1.5" } 19 | @@ -138,11 +134,6 @@ 20 | "ppx_deriving_yojson" 21 | "ppx_deriving_yaml" { >= "0.2.0" } 22 | "ppx_import" 23 | - 24 | - # GTK3 for non-macos only 25 | - "lablgtk3" { >= "3.1.0" & os!="macos" } 26 | - "lablgtk3-sourceview3" { os!="macos" } 27 | - "conf-gtksourceview3" { os!="macos" } 28 | ] 29 | 30 | # Note: do not put particular versions here, if some version is *incompatible*, 31 | -------------------------------------------------------------------------------- /doc/while-tutorial/While tutorial.mld: -------------------------------------------------------------------------------- 1 | {0 Extending Codex to a simple while language} 2 | 3 | 4 | {%html: 5 | 6 | 7 | %} 8 | 9 | We present a tutorial on a simple imperative [while] language, and demonstrates 10 | how to statically analyze programs written in it using Codex, a modular abstract 11 | interpretation library. This also serves as a nice introduction to various codex 12 | components ({!Lattices}, {!Single_value_abstraction}, {!Domains}...). It is mostly 13 | meant for developers who wish to use and extend Codex. 14 | - {{!page-"While tutorial - chapter 1"}Chapter 1}: Contains the syntax which is defined with variables, arithmetic, boolean expressions, and control structures (e.g., [if] and [while]). It also provides a concrete interpreter for the [while] language; 15 | - {{!page-"While tutorial - chapter 2"}Chapter 2}: Describes {!Lattices} and {!Single_value_abstraction} with simpler implementations; 16 | - {{!page-"While tutorial - chapter 3"}Chapter 3}: Contains simple interval abstract domain which is then used to run the analysis on simple while programs; 17 | - {{!page-"While tutorial - chapter 4"}Chapter 4}: Shows how one can use Codex building blocks to recreate the interval domain from chapter 3. 18 | -------------------------------------------------------------------------------- /ext/frama_c_with_cudd/opam-frama-c-28.0-Nickel.patch: -------------------------------------------------------------------------------- 1 | --- a/opam 2023-11-30 01:00:00.000000000 +0100 2 | +++ b/opam 2024-01-12 13:03:11.817050752 +0100 3 | @@ -123,16 +123,12 @@ 4 | "dune-configurator" 5 | "dune-site" { >= "3.7.0" } 6 | 7 | - ( "alt-ergo-free" | "alt-ergo" ) 8 | - "conf-graphviz" { post } 9 | "conf-time" { with-test } 10 | "menhir" { >= "20181006" & build } 11 | "ocaml" { >= "4.13.1" } 12 | "ocamlgraph" { >= "1.8.8" } 13 | "ocamlgraph" { with-test & >= "2.1.0" } 14 | - "odoc" { with-doc } 15 | "unionFind" { >= "20220107" } 16 | - "why3" { >= "1.6.0" & ( < "1.7.0" | !with-test ) } 17 | "yaml" { >= "3.0.0" } 18 | "yojson" {>= "1.6.0" & (>= "2.0.1" | !with-test)} 19 | "zarith" { >= "1.5" } 20 | @@ -143,11 +139,6 @@ 21 | "ppx_deriving_yaml" { >= "0.2.0" } 22 | "ppx_import" 23 | 24 | - # GTK3 disabled on macOS (segfaults), and made optional on Windows 25 | - # (due to complex situation with Cygwin + MinGW). 26 | - "lablgtk3" { >= "3.1.0" & os!="macos" & os-family!="windows" } 27 | - "lablgtk3-sourceview3" { os!="macos" & os-family!="windows" } 28 | - "conf-gtksourceview3" { os!="macos" & os-family!="windows" } 29 | ] 30 | 31 | # Note: do not put particular versions here, if some version is *incompatible*, 32 | -------------------------------------------------------------------------------- /ext/frama_c_with_cudd/opam-frama-c-28.1-Nickel.patch: -------------------------------------------------------------------------------- 1 | --- a/opam 2023-11-30 01:00:00.000000000 +0100 2 | +++ b/opam 2024-01-12 13:03:11.817050752 +0100 3 | @@ -123,16 +123,12 @@ 4 | "dune-configurator" 5 | "dune-site" { >= "3.7.0" } 6 | 7 | - ( "alt-ergo-free" | "alt-ergo" ) 8 | - "conf-graphviz" { post } 9 | "conf-time" { with-test } 10 | "menhir" { >= "20181006" & build } 11 | "ocaml" { >= "4.13.1" } 12 | "ocamlgraph" { >= "1.8.8" } 13 | "ocamlgraph" { with-test & >= "2.1.0" } 14 | - "odoc" { with-doc } 15 | "unionFind" { >= "20220107" } 16 | - "why3" { >= "1.6.0" & ( < "1.7.0" | !with-test ) } 17 | "yaml" { >= "3.0.0" } 18 | "yojson" {>= "1.6.0" & (>= "2.0.1" | !with-test)} 19 | "zarith" { >= "1.5" } 20 | @@ -143,11 +139,6 @@ 21 | "ppx_deriving_yaml" { >= "0.2.0" } 22 | "ppx_import" 23 | 24 | - # GTK3 disabled on macOS (segfaults), and made optional on Windows 25 | - # (due to complex situation with Cygwin + MinGW). 26 | - "lablgtk3" { >= "3.1.0" & os!="macos" & os-family!="windows" } 27 | - "lablgtk3-sourceview3" { os!="macos" & os-family!="windows" } 28 | - "conf-gtksourceview3" { os!="macos" & os-family!="windows" } 29 | ] 30 | 31 | # Note: do not put particular versions here, if some version is *incompatible*, 32 | -------------------------------------------------------------------------------- /binsec_codex.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: 4 | "A modular static analyser for machine code program based on abstract interpretation" 5 | maintainer: ["Matthieu Lemerre "] 6 | authors: [ 7 | "Matthieu Lemerre" 8 | "Julien Simonnet" 9 | "Olivier Nicole" 10 | "Paul Robert" 11 | "Dorian Lesbre" 12 | "Iker Canut" 13 | "Corentin Gendreau" 14 | "Guillaume Girol" 15 | "Charles Babu" 16 | "Jérôme Faucheux" 17 | ] 18 | license: "LGPL-2.1-or-later" 19 | homepage: "https://codex.top" 20 | bug-reports: "https://github.com/codex-semantics-library/codex/issues" 21 | depends: [ 22 | "dune" {>= "3.14"} 23 | "binsec" {>= "0.10"} 24 | "ocamlgraph" {>= "2.2.0"} 25 | "zarith" {>= "1.14"} 26 | "codex" {>= "1.0-rc4"} 27 | "mdx" {with-test} 28 | "odoc" {with-doc} 29 | ] 30 | build: [ 31 | ["dune" "subst"] {dev} 32 | [ 33 | "dune" 34 | "build" 35 | "-p" 36 | name 37 | "-j" 38 | jobs 39 | "--promote-install-files=false" 40 | "@install" 41 | "@runtest" {with-test} 42 | "@doc" {with-doc} 43 | ] 44 | ["dune" "install" "-p" name "--create-install-files" name] 45 | ] 46 | dev-repo: "git+https://github.com/codex-semantics-library/codex.git" 47 | -------------------------------------------------------------------------------- /Makefile.common: -------------------------------------------------------------------------------- 1 | default: help 2 | 3 | ################ Help ################ 4 | # set to ON/OFF to toggle ANSI escape sequences 5 | COLOR = ON 6 | 7 | ifeq ($(COLOR),ON) 8 | color_yellow = \033[93;1m 9 | color_orange = \033[33m 10 | color_red = \033[31m 11 | color_green = \033[32m 12 | color_blue = \033[34;1m 13 | color_reset = \033[0m 14 | endif 15 | 16 | # padding for help on targets 17 | # should be > than the longest target 18 | HELP_PADDING = 20 19 | 20 | # Argument: $1 = the additional argument to make. 21 | PRINT_HELP_TITLE = echo -e "useful $(color_yellow)make $1$(color_reset) targets:" 22 | 23 | PRINT_HELP_BODY = egrep -h '\s\#\#\s' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?\#\# "}; {printf " $(color_blue)%-$(HELP_PADDING)s$(color_reset) %s\n", $$1, $$2}' 24 | 25 | # Usage: $(call PRINT_HELP,-C directory/Makefile) 26 | PRINT_HELP = @$(call PRINT_HELP_TITLE,$1); $(PRINT_HELP_BODY) 27 | 28 | 29 | ################ Executing Frama-C/Codex ################ 30 | 31 | THIS_MK := $(lastword $(MAKEFILE_LIST)) 32 | THIS_DIR := $(dir $(THIS_MK)) 33 | FRAMA_C_CODEX = $(abspath $(THIS_DIR)_build/default/frontends/frama-c/frama_c_codex.exe) 34 | 35 | # For use in shell scripts: do make -f path-to-this-file which_frama_c_codex. 36 | which_frama_c_codex: 37 | @echo $(FRAMA_C_CODEX) 38 | 39 | # Local Variables: 40 | # mode: makefile 41 | # End: 42 | -------------------------------------------------------------------------------- /frama_c_codex.opam: -------------------------------------------------------------------------------- 1 | # This file is generated by dune, edit dune-project instead 2 | opam-version: "2.0" 3 | synopsis: 4 | "A modular static analyser of C programs, based on abstract interpretation. The package contains both a standalone frama_c_codex executable, as well as a Frama-C plugin" 5 | maintainer: ["Matthieu Lemerre "] 6 | authors: [ 7 | "Matthieu Lemerre" 8 | "Julien Simonnet" 9 | "Olivier Nicole" 10 | "Paul Robert" 11 | "Dorian Lesbre" 12 | "Iker Canut" 13 | "Corentin Gendreau" 14 | "Guillaume Girol" 15 | "Charles Babu" 16 | "Jérôme Faucheux" 17 | ] 18 | license: "LGPL-2.1-or-later" 19 | homepage: "https://codex.top" 20 | bug-reports: "https://github.com/codex-semantics-library/codex/issues" 21 | depends: [ 22 | "dune" {>= "3.14"} 23 | "frama-c" {= "31.0"} 24 | "codex" {>= "1.0-rc4"} 25 | "fmt" {>= "0.11.0"} 26 | "patricia-tree" {>= "0.11.0"} 27 | "zarith" {>= "1.14"} 28 | "mdx" {with-test} 29 | "odoc" {with-doc} 30 | ] 31 | build: [ 32 | ["dune" "subst"] {dev} 33 | [ 34 | "dune" 35 | "build" 36 | "-p" 37 | name 38 | "-j" 39 | jobs 40 | "--promote-install-files=false" 41 | "@install" 42 | "@runtest" {with-test} 43 | "@doc" {with-doc} 44 | ] 45 | ["dune" "install" "-p" name "--create-install-files" name] 46 | ] 47 | dev-repo: "git+https://github.com/codex-semantics-library/codex.git" 48 | -------------------------------------------------------------------------------- /.github/workflows/deploy-doc.yml: -------------------------------------------------------------------------------- 1 | name: Deploy odoc to GitHub Pages 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: read-all 9 | 10 | concurrency: 11 | group: deploy-odoc 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | deploy-odoc: 16 | name: Deploy odoc to GitHub Pages 17 | 18 | environment: 19 | name: github-pages 20 | url: ${{ steps.deployment.outputs.page_url }} 21 | 22 | permissions: 23 | contents: read 24 | id-token: write 25 | pages: write 26 | 27 | runs-on: ubuntu-latest 28 | 29 | steps: 30 | - name: Checkout tree 31 | uses: actions/checkout@v6 32 | 33 | - name: Set-up OCaml 34 | uses: ocaml/setup-ocaml@v3 35 | with: 36 | ocaml-compiler: "5.3" 37 | dune-cache: true 38 | allow-prerelease-opam: true 39 | 40 | - name: Install dependencies 41 | run: opam install . --deps-only --with-doc 42 | 43 | - name: Build documentation 44 | run: opam exec -- dune build @doc 45 | 46 | - name: Set-up Pages 47 | uses: actions/configure-pages@v5 48 | 49 | - name: Upload artifact 50 | uses: actions/upload-pages-artifact@v4 51 | with: 52 | path: _build/default/_doc/_html 53 | 54 | - name: Deploy odoc to GitHub Pages 55 | id: deployment 56 | uses: actions/deploy-pages@v4 57 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.cmti 2 | *.cmx 3 | *~ 4 | *.cmo 5 | *.cmi 6 | *.o 7 | *.cmt 8 | *.annot 9 | *.cma 10 | *.cmxa 11 | *.so 12 | *.a 13 | *.install 14 | *.objdump 15 | /a.out 16 | /unused 17 | /Codex.cmxs 18 | /Codex_DEP 19 | /doc/slides*.vrb 20 | /test/hostname* 21 | /doc/slides.pdf 22 | *_additional_notes.txt 23 | /test/unused 24 | /doc/*.org 25 | /test/*.c 26 | /deps.dot 27 | /depsred.dot 28 | /tests/*.diff 29 | /tests/*.sav 30 | unused/ 31 | /reduce.sh 32 | /test.c 33 | /.depend 34 | /maybe/ 35 | /frama-c/.Makefile.plugin.generated 36 | /frama-c/.depend 37 | /frama-c/CodexPlugin.check_mli_exists 38 | /frama-c/CodexPlugin.mli 39 | /frama-c/META.frama-c-codex 40 | /frama-c/META.frama-c-codexplugin 41 | frama-c/top/* 42 | /ext/framac_ival/dllc_bindings.so 43 | /_build/ 44 | /tests/vmcai2022/liSemanticDirected2017/*.alarms 45 | *-junit.xml 46 | /frama_c_codex.exe 47 | /binsec_codex.exe 48 | /ext/frama_c_with_cudd/frama-c-* 49 | /bin_trace.codex 50 | 51 | __pycache__ 52 | .mypy_cache 53 | .ruff_cache 54 | .manage-py-config.json 55 | .saves 56 | *.stats.txt 57 | *.log 58 | 59 | /utils/gui/assets/ 60 | _opam 61 | /utils/gui/deps/js/bundle-output.js 62 | /utils/gui/deps/js/bundle-output.min.js 63 | /utils/gui/deps/js/node_modules/ 64 | /utils/gui/deps/js/package-lock.json 65 | /utils/gui/deps/tailwind4.1.5.css 66 | /utils/gui/deps/graphviz.umd.js 67 | flake.lock 68 | 69 | .vscode 70 | /tests/types/tmp.typedc 71 | /tests/types/*.html 72 | -------------------------------------------------------------------------------- /devenv/nix/mdx.nix: -------------------------------------------------------------------------------- 1 | { pkgs, ocamlPackages }: 2 | with pkgs; 3 | with ocamlPackages; 4 | 5 | buildDunePackage rec { 6 | pname = "mdx"; 7 | version = "2.5.0"; 8 | 9 | minimalOCamlVersion = "4.08"; 10 | 11 | src = fetchurl { 12 | url = "https://github.com/realworldocaml/mdx/releases/download/${version}/mdx-${version}.tbz"; 13 | hash = "sha256-wtpY19UYLxXARvsyC7AsFmAtLufLmfNJ4/SEHCY2UCk="; 14 | }; 15 | 16 | nativeBuildInputs = [ cppo ]; 17 | propagatedBuildInputs = [ 18 | astring 19 | fmt 20 | logs 21 | csexp 22 | ocaml-version 23 | camlp-streams 24 | re 25 | result 26 | findlib 27 | ]; 28 | checkInputs = [ 29 | alcotest 30 | lwt 31 | ]; 32 | 33 | doCheck = true; 34 | 35 | outputs = [ 36 | "bin" 37 | "lib" 38 | "out" 39 | ]; 40 | 41 | installPhase = '' 42 | runHook preInstall 43 | dune install --prefix=$bin --libdir=$lib/lib/ocaml/${ocaml.version}/site-lib ${pname} 44 | runHook postInstall 45 | ''; 46 | 47 | passthru.updateScript = gitUpdater { }; 48 | 49 | meta = { 50 | description = "Executable OCaml code blocks inside markdown files"; 51 | homepage = "https://github.com/realworldocaml/mdx"; 52 | changelog = "https://github.com/realworldocaml/mdx/raw/${version}/CHANGES.md"; 53 | license = lib.licenses.isc; 54 | maintainers = [ lib.maintainers.romildo ]; 55 | mainProgram = "ocaml-mdx"; 56 | }; 57 | } -------------------------------------------------------------------------------- /types/test.types: -------------------------------------------------------------------------------- 1 | /* Testing a comment. */ 2 | /* A more difficult one **/ 3 | 4 | // Should still print a 5 | type a = int 6 | type b = int+ 7 | type c = struct { int i; /* comment */ int j; } 8 | type d = union { int i; struct { int i;}+ n; } 9 | type e = int with self = 3 10 | 11 | 12 | int func(void); 13 | int func(); 14 | int func(int i); 15 | int func(int i, int j); 16 | inline struct bar* func(int a, int b); 17 | 18 | struct foo { 19 | int i; 20 | int j; 21 | }; 22 | 23 | union bar { int a; short b; }; 24 | 25 | void test2 (([int] -> void)+ funptr); 26 | 27 | 28 | 29 | 30 | // Expressions. 31 | type e1 = int with self == 4 + 3 32 | type e2 = int with self + 1 == 4 33 | type e3 = int with self + 1 * 5 == 4 34 | type e3 = int with self * 1 + 2 * 5 == 4 35 | type e4 = int with self * 5 + 2 == 4 36 | type e5 = int with self * 5 * 6 == 4 37 | type e6 = int with self + 5 - 6 == 4 38 | type e7 = int with (self << 5) == 4 39 | type e8 = int with self == (4 >> 2) 40 | type e9 = int with self <= 8 && self >= 2 41 | type e10 = int with self <= 8 && self >= 2 && self % 4 == 0 42 | type e11 = int with self <= 8 || self >= 2 || self % 4 == 0 43 | type e12 = int with (self & 3) == 4 44 | type e13 = int(+)(int,int) 45 | 46 | 47 | // Those fail as we cannot compare the precedence of operators. 48 | // type e = int with self << 5 == 4 49 | // type e = int with self < 3 < 5 50 | // type a = int with self + 2 + 3 = 4 << 8 51 | // type e10 = int with self <= 8 && self >= 2 || self % 4 == 0 52 | // type e12 = int with self & 3 == 4 53 | // type e13 = \exists n:int. int+ 54 | -------------------------------------------------------------------------------- /ext/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (dirs framac_ival) 23 | -------------------------------------------------------------------------------- /frontends/frama-c/CodexPlugin.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | -------------------------------------------------------------------------------- /frontends/frama-c/codexPlugin.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | -------------------------------------------------------------------------------- /single_value_abstraction/sva_known_bits.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | -------------------------------------------------------------------------------- /doc/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (documentation 23 | (package codex)) 24 | -------------------------------------------------------------------------------- /examples/os_message/os_message.types: -------------------------------------------------------------------------------- 1 | 2 | /* Every message takes two implicit parameters: the size of the 3 | message, and the task that will receive the message. 4 | 5 | These parameters guarantee that messages of different tasks or 6 | adressed to different tasks will not be mixed up (non-interference 7 | security property). */ 8 | type message(msize,taskid) = struct { 9 | message(msize,taskid)+ next; 10 | 11 | /* XXX: Flexible array member ne marche pas ici. */ 12 | /* Flexible array member: the size of struct message is variable. */ 13 | char[msize]+ buffer; 14 | } 15 | 16 | /* The \exists constructs allows linking the size of the buffers in 17 | all the messages with the integer holding the size of the message 18 | (which is stored only once). */ 19 | type message_box(taskid) = \exists msize:int. struct { 20 | /* Size of the message. */ 21 | (int with self == msize) size; 22 | 23 | /* Pointer to the list of messages to process. */ 24 | message(msize,taskid)* to_read; 25 | message(msize,taskid)* free_list; 26 | } 27 | 28 | /* A task structures takes a pointer to itself as unique identifier, 29 | used to guaranteed non-interference between datastructures 30 | corresponding to different tasks, ensuring confidentiality. */ 31 | type task(self) = struct{ 32 | /* The message box is part of the structure. */ 33 | message_box(self)+ mbox; 34 | } 35 | 36 | /* A non-null pointer to a task refering to itself. */ 37 | type task_ptr = \exists taskid:task(taskid)+. (task(taskid)+ with self == taskid) 38 | 39 | void main(task_ptr task); 40 | 41 | 42 | 43 | /* Local Variables: */ 44 | /* mode: c */ 45 | /* End: */ 46 | -------------------------------------------------------------------------------- /frontends/binsec/x86_arch.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module Make : Arch_settings.S 23 | -------------------------------------------------------------------------------- /utils/not_implemented.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | let not_implemented() = assert false;; 23 | -------------------------------------------------------------------------------- /single_value_abstraction/sva_ival_with_sentinel.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | include Sva_sig.NUMERIC 23 | -------------------------------------------------------------------------------- /utils/gui/gui.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module Interface = Interface 23 | module Print_html_webapp = Print_html_webapp 24 | -------------------------------------------------------------------------------- /lattices/unit_Lattice.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | include Lattice_sig.LATTICE with type t = unit 23 | val singleton: 'a -> unit 24 | -------------------------------------------------------------------------------- /frontends/binsec/benchmark.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | let make x = 0 23 | 24 | let sub a b = 0 25 | 26 | let to_string x = "" 27 | -------------------------------------------------------------------------------- /utils/gui/js/main_layout.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | include Component.Self_contained with type initial_data = Main_area.initial_data 23 | -------------------------------------------------------------------------------- /single_value_abstraction/binary_collecting.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | include Sva_sig.BITVECTOR with type bitvector = Lattices.BVSet.t;; 23 | -------------------------------------------------------------------------------- /utils/cfg/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.cfg") 24 | (name cfg) 25 | (modules_without_implementation cfg_sig) 26 | ) -------------------------------------------------------------------------------- /ext/frama_c_with_cudd/patch-frama-c.patch: -------------------------------------------------------------------------------- 1 | diff --git a/src/dune b/src/dune 2 | index 31106c84ff..dc31e5c493 100644 3 | --- a/src/dune 4 | +++ b/src/dune 5 | @@ -49,7 +49,7 @@ 6 | (public_name frama-c.kernel) 7 | (foreign_stubs (language c) (names c_bindings)) 8 | (flags :standard -w -9) 9 | - (libraries frama-c.init fpath str unix zarith ocamlgraph dynlink bytes yaml.unix yojson menhirLib dune-site dune-site.plugins) 10 | + (libraries frama-c.init cudd fpath str unix zarith ocamlgraph dynlink bytes yaml.unix yojson menhirLib dune-site dune-site.plugins) 11 | (instrumentation (backend landmarks)) 12 | (preprocess (staged_pps ppx_import ppx_deriving.eq ppx_deriving_yaml)) 13 | ) 14 | diff --git a/src/kernel_services/ast_queries/cil_builtins.ml b/src/kernel_services/ast_queries/cil_builtins.ml 15 | index a596fa02ee..336ece58fe 100644 16 | --- a/src/kernel_services/ast_queries/cil_builtins.ml 17 | +++ b/src/kernel_services/ast_queries/cil_builtins.ml 18 | @@ -414,7 +414,7 @@ let init_builtins () = 19 | Kernel.fatal ~current:true "You must call initCIL before init_builtins" ; 20 | if Builtin_functions.length () <> 0 then 21 | Kernel.fatal ~current:true "Cil builtins already initialized." ; 22 | - init_builtins_from_json (); 23 | + let _ = init_builtins_from_json in 24 | Queue.iter (fun f -> register_custom_builtin (f())) custom_builtins 25 | 26 | (** This is used as the location of the prototypes of builtin functions. *) 27 | --- a/src/libraries/utils/c_bindings.c 2023-10-10 04:03:10.009564948 +0200 28 | +++ a/src/libraries/utils/c_bindings.c 2023-10-10 04:02:19.785242488 +0200 29 | @@ -252,3 +252,5 @@ 30 | double d = f; 31 | return caml_copy_double(d); 32 | } 33 | + 34 | +intnat caml_stat_compactions; 35 | -------------------------------------------------------------------------------- /lattices/bitfield_Lattice.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* A bitfield implemented using a positive Z.t. *) 23 | include Lattice_sig.ENUM_LATTICE with type t = Z.t 24 | -------------------------------------------------------------------------------- /operator/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.operator") 24 | (name operator) 25 | (libraries zarith tracelog codex.hashing codex.units)) 26 | -------------------------------------------------------------------------------- /frontends/frama-c/post_analysis.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module type Runner = sig 23 | val runner : unit -> unit 24 | end 25 | 26 | module Make (R : Runner) : Runner 27 | -------------------------------------------------------------------------------- /ext/frama_c_with_cudd/internalize_machdeps.patch: -------------------------------------------------------------------------------- 1 | --- a/src/kernel_services/ast_queries/file.ml 2024-01-12 22:44:28.140139150 +0100 2 | +++ b/src/kernel_services/ast_queries/ofile.ml 2024-01-12 22:52:54.602187024 +0100 3 | @@ -270,27 +270,20 @@ 4 | (if m.has__builtin_va_list then "has" else "has not") ; 5 | end 6 | 7 | -let machdep_dir () = Kernel.Share.get_dir ~mode:`Must_exist "machdeps" 8 | +(* let machdep_dir () = Kernel.Share.get_dir ~mode:`Must_exist "machdeps" *) 9 | 10 | let regexp_machdep = Str.regexp "^machdep_\\([^.]*\\).yaml$" 11 | 12 | let default_machdep_file machdep = 13 | let filename = "machdep_" ^ machdep ^ ".yaml" in 14 | - Filepath.Normalized.concat (machdep_dir()) filename 15 | + Obj.magic filename 16 | 17 | let is_default_machdep machdep = 18 | - Filepath.Normalized.is_file (default_machdep_file machdep) 19 | + List.mem ((default_machdep_file machdep):>string) Internalized_machdeps.default_machdeps 20 | 21 | let mem_machdep s = is_default_machdep s || Sys.file_exists s 22 | 23 | -let default_machdeps () = 24 | - Array.fold_right 25 | - (fun s acc -> 26 | - if Str.string_match regexp_machdep s 0 then 27 | - Str.matched_group 1 s :: acc 28 | - else acc) 29 | - (Sys.readdir (machdep_dir() :> string)) 30 | - [] 31 | +let default_machdeps () = Internalized_machdeps.default_machdeps 32 | 33 | let pretty_machdeps fmt = 34 | List.iter (fun s -> Format.fprintf fmt "@ %s" s) (default_machdeps()) 35 | @@ -403,7 +398,7 @@ 36 | in 37 | let res = 38 | Result.bind 39 | - (Yaml_unix.of_file (Fpath.v (file:>string))) 40 | + (Yaml.of_string @@ Internalized_machdeps.get_machdep_content (Filename.basename (file:>string))) 41 | mach_of_yaml 42 | in 43 | match res with 44 | -------------------------------------------------------------------------------- /fixpoint/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.fixpoint") 24 | (libraries tracelog codex.codex_log codex.datatype_sig patricia-tree) 25 | (name Fixpoint)) 26 | -------------------------------------------------------------------------------- /smtbackend/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.smtbackend") 24 | (name Smtbackend) 25 | (libraries zarith codex.codex_log codex.codex_config unix) 26 | ) 27 | -------------------------------------------------------------------------------- /frontends/binsec/codex_main.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | let () = 23 | Codex.Codex_config.set_assume_simple_asts false; 24 | Cli.Boot.enlist ~name:"codex analysis" ~f:Analyze.run_codex 25 | -------------------------------------------------------------------------------- /smtbackend/smtbackend.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* External interface for smtbackend files. *) 23 | 24 | module Smtlib_sig = Smtbackend_smtlib_sig 25 | module Smtlib = Smtbackend_smtlib 26 | -------------------------------------------------------------------------------- /smtbackend/smtbackend_aliases.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Module aliases internal to smtbackend.. *) 23 | 24 | module Smtlib = Smtbackend_smtlib 25 | module Smtlib_sig = Smtbackend_smtlib_sig 26 | -------------------------------------------------------------------------------- /frontends/frama-c/test.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* This file is part of the Codex semantics library. */ 3 | /* */ 4 | /* Copyright (C) 2013-2025 */ 5 | /* CEA (Commissariat à l'énergie atomique et aux énergies */ 6 | /* alternatives) */ 7 | /* */ 8 | /* you can redistribute it and/or modify it under the terms of the GNU */ 9 | /* Lesser General Public License as published by the Free Software */ 10 | /* Foundation, version 2.1. */ 11 | /* */ 12 | /* It is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU Lesser General Public License for more details. */ 16 | /* */ 17 | /* See the GNU Lesser General Public License version 2.1 */ 18 | /* for more details (enclosed in the file LICENSE). */ 19 | /* */ 20 | /**************************************************************************/ 21 | 22 | struct foo { 23 | int i; 24 | int j; 25 | }; 26 | 27 | 28 | int main(struct foo* p){ 29 | int a = p->i + p -> j; 30 | return a+1; 31 | } 32 | 33 | -------------------------------------------------------------------------------- /utils/gui/js/widget.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | val red_button : onclick:(Vdom.mouse_event -> 'a) -> string -> 'a Vdom.vdom 23 | val button : onclick:(Vdom.mouse_event -> 'a) -> string -> 'a Vdom.vdom 24 | -------------------------------------------------------------------------------- /utils/gui/print_html_webapp.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Dump the HTML with the program data to an out channel (typically a file). *) 23 | val print_html_webapp : out_channel -> Interface.marshalled -> unit 24 | -------------------------------------------------------------------------------- /domains/term_based/assert_false.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Dummy domain; start here for a new implementation. *) 23 | module Make(Terms: Terms.Sig.TERMS) : 24 | Term_based_sig.Domain_S 25 | with module Terms = Terms 26 | -------------------------------------------------------------------------------- /frontends/frama-c/varinfo_Enclosing_Function.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Print varinfo with their enclosing function; useful when inlining. *) 23 | val pretty: Format.formatter -> Frama_c_kernel.Cil_types.varinfo -> unit 24 | -------------------------------------------------------------------------------- /doc/getting-started/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (documentation 23 | (package codex)) 24 | 25 | (mdx 26 | (files *.mld) 27 | (enabled_if (= %{profile} dev)) 28 | (deps 29 | (package codex) 30 | (package frama_c_codex))) 31 | -------------------------------------------------------------------------------- /frontends/binsec/Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This file is part of the Codex semantics library. # 3 | # # 4 | # Copyright (C) 2013-2025 # 5 | # CEA (Commissariat à l'énergie atomique et aux énergies # 6 | # alternatives) # 7 | # # 8 | # you can redistribute it and/or modify it under the terms of the GNU # 9 | # Lesser General Public License as published by the Free Software # 10 | # Foundation, version 2.1. # 11 | # # 12 | # It is distributed in the hope that it will be useful, # 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 | # GNU Lesser General Public License for more details. # 16 | # # 17 | # See the GNU Lesser General Public License version 2.1 # 18 | # for more details (enclosed in the file LICENSE). # 19 | # # 20 | ########################################################################## 21 | 22 | include ../../Makefile.common 23 | 24 | .PHONY: help 25 | help:: ## Show this help 26 | $(call PRINT_HELP,-C frontends/binsec) 27 | 28 | 29 | build: ## Build the Binsec/Codex plugin 30 | dune build binsec_codex.exe 31 | -------------------------------------------------------------------------------- /lattices/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.lattices") 24 | (name lattices) 25 | (modules_without_implementation lattice_sig) 26 | (libraries zarith tracelog codex.datatype_sig codex.hashing codex.units)) 27 | -------------------------------------------------------------------------------- /frontends/frama-c/codex_register.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** This file contains [run], the entry point to the Frama-C/Codex plugin. 23 | 24 | It also contains the construction of the main abstract domain (and 25 | its variations). *) 26 | -------------------------------------------------------------------------------- /examples/abs/abs.c: -------------------------------------------------------------------------------- 1 | /**************************************************************************/ 2 | /* This file is part of the Codex semantics library. */ 3 | /* */ 4 | /* Copyright (C) 2013-2025 */ 5 | /* CEA (Commissariat à l'énergie atomique et aux énergies */ 6 | /* alternatives) */ 7 | /* */ 8 | /* you can redistribute it and/or modify it under the terms of the GNU */ 9 | /* Lesser General Public License as published by the Free Software */ 10 | /* Foundation, version 2.1. */ 11 | /* */ 12 | /* It is distributed in the hope that it will be useful, */ 13 | /* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 14 | /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */ 15 | /* GNU Lesser General Public License for more details. */ 16 | /* */ 17 | /* See the GNU Lesser General Public License version 2.1 */ 18 | /* for more details (enclosed in the file LICENSE). */ 19 | /* */ 20 | /**************************************************************************/ 21 | 22 | int abs(int i){ 23 | int res; 24 | if(i < 0){ 25 | res = -i; 26 | } 27 | else { 28 | res = i; 29 | } 30 | res += 0 / res; 31 | return res; 32 | } 33 | 34 | int main(){ 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /.ocamlformat: -------------------------------------------------------------------------------- 1 | # The goal of code is to be read, and formatting conveys meaning that 2 | # helps readability. Thus, we don't use ocamlformat by 3 | # default. However, it can help improve badly-formatted code. Here, we 4 | # setup ocamlformat to minimize changes in the code (and to fight its 5 | # tendency to take up a lot of vertical space). Remember to review the 6 | # changes introduced by a call to ocamlformat. 7 | 8 | # We recommend the use of ocp-indent. 9 | # ocp-indent-compat = true 10 | 11 | # Preserve as much of the original input as possible 12 | module-item-spacing = preserve 13 | sequence-blank-line = preserve-one 14 | 15 | # Line length / margin 16 | margin = 100 # fewer forced breaks 17 | wrap-fun-args = false # do not force wrapping of function arguments 18 | wrap-comments = false # keep comment layout as-is 19 | parse-docstrings = false 20 | 21 | # Reduce vertical expansion 22 | break-sequences = false # do not break sequences (e.g., a; b; c) across lines unnecessarily 23 | break-infix = wrap # avoid breaking infix expressions across lines 24 | # break-constructs = false # avoid breaking control constructs unless necessary 25 | break-struct = natural # avoid extra line breaks in structures 26 | break-fun-decl = wrap # avoid breaking function declarations unnecessarily 27 | break-fun-sig = wrap # avoid breaking function declarations unnecessarily 28 | break-collection-expressions = wrap 29 | break-before-in = auto 30 | 31 | # Misc alignment 32 | let-binding-spacing = compact # keep spacing around let bindings 33 | type-decl = compact 34 | 35 | # Expression grouping 36 | exp-grouping = preserve # Retain original grouping (`begin`/`end` vs. parentheses) 37 | 38 | space-around-arrays = false 39 | space-around-lists = false 40 | space-around-records = false 41 | space-around-variants = false 42 | field-space = tight -------------------------------------------------------------------------------- /single_value_abstraction/sva_binary_to_integer.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | open Sva_sig 23 | 24 | module Lift 25 | (I:INTEGER with type boolean = Sva_quadrivalent.boolean): 26 | BITVECTOR with type bitvector = I.integer 27 | and type boolean = I.boolean 28 | 29 | -------------------------------------------------------------------------------- /utils/tracelog/README.org: -------------------------------------------------------------------------------- 1 | One of the target is the tools used for compiling, typing, interpreting or analyzing ASTs, an application domain where OCaml is known to shine! But it is really useful for any recursive or decomposable algorithm. 2 | 3 | 4 | 5 | * Buttons 6 | 7 | We currently define three kinds of button: 8 | 9 | - pos :: position in a file. E.g. opens file.c at line 3, while open `a.c' at line 3 and column 4. 10 | - url :: Url: Examples: , , etc. 11 | - define :: Allows to define new buttons by curryfication. E.g. allows to be equivalent to and to be equivalent to . 12 | 13 | 14 | * Examples 15 | 16 | - Simple evaluation of arithmetic expressions 17 | - Symbolic execution or its generalization, SSA translation. This time, you do not want to dump the whole symbolic expression (it would require a log quadratic in the size of the program). 18 | - Instead: incrementally dump the symbolic expressions in a file (with some mode) and point to it (file-name:position of the point). 19 | - For symbolic execution: quite simple as this can directly be the formula fed to the SMT solver. 20 | - In the future: specialized modes for btree, etc. (Basically: dump the commands, and reconstruct the state in emacs) 21 | - Actually, it can be a tracelog- function symbol that is executed (with defaults one, such as open at some point) 22 | - Similar: an algorithm that works on trees (e.g. binary heaps) 23 | 24 | * Caveat 25 | 26 | - Works for relatively large logs, but huge ones will kill performance 27 | - However, you can copy and paste to select the part you need. 28 | 29 | * Tracelog format 30 | 31 | - The .el file only understands the unicode format. 32 | - The source of truth is tracelog-mode.el 33 | -------------------------------------------------------------------------------- /doc/Tutorials.mld: -------------------------------------------------------------------------------- 1 | {0 Tutorials} 2 | 3 | {%html: 4 | 5 | 6 | %} 7 | 8 | We have written a few tutorials to show how codex can be used and extended. 9 | 10 | {1 Quick start} 11 | 12 | There is a short {{!page-"Quick start"}quick start} tutorial that shows the 13 | steps needed to run Frama-C/codex on a simple C file. For a more in depth look 14 | at the interface, check out the {{!page-"Types tutorial"}types tutorial}. 15 | 16 | {1 Using Codex on a custom language} 17 | 18 | The {{!page-"While tutorial"}while tutorial} describes how Codex's components can be used to build 19 | an analyzer for a simple imperative [while] language. Along the way, it introduces 20 | many of the core components of codex. It is mostly intended for developers who 21 | want to use or extend the codex library. 22 | 23 | {1:tt Analyzing C or binary using Codex types} 24 | 25 | The {{!page-"Types tutorial"}types tutorial} presents Codex's refinement type system and how it 26 | can be used to precisely specify memory layouts. 27 | It was written to accompany the 28 | {{: https://codex.top/papers/2024-oopsla-typedc-dependent-nominal-physical-type-system.html}OOPLSA 2024} paper. 29 | It also describes the Frama-C/Codex 30 | and Binsec/Codex interfaces (command line arguments, terminal and HTML outputs...). 31 | 32 | It covers in particular: 33 | 34 | - How to run the analysis on a C program, how to configure the C 35 | analysis, and how to inspect the results. 36 | - How to run the analysis on a binary executable, how to configure 37 | the machine code analysis, and how to inspect the results. 38 | - How to specify the types used in a C programs to refine the results 39 | of the analysis (which is generally a necessary step to obtain 40 | memory safety). 41 | 42 | This one is more targeted to users wishing to use Codex to verify C or binary code. 43 | -------------------------------------------------------------------------------- /ext/framac_ival/fc_float.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Implementation of floating-point values of different precision, 23 | using the standard ocaml floating-point numbers in double precision. 24 | Long_Double and Real are inexact. *) 25 | 26 | include Float_sig.S with type t = float 27 | -------------------------------------------------------------------------------- /lattices/boolean_standard.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* This definition is here only to break cyclic dependencies. Use 23 | Quadrivalent_Lattices instead. *) 24 | module Quadrivalent = struct 25 | 26 | type t = 27 | | Bottom 28 | | True 29 | | False 30 | | Top 31 | 32 | end 33 | -------------------------------------------------------------------------------- /frontends/binsec/interval2symbol.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type 'a t 23 | val empty: 'a t 24 | 25 | (* Insert; and tell what to do when there are several values at the 26 | same address. *) 27 | val insert: merge:(old:'a -> 'a -> 'a) -> int -> 'a -> 'a t -> 'a t 28 | val find: int -> 'a t -> 'a 29 | -------------------------------------------------------------------------------- /domains/extend.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module Make(D: Sig.Minimal): Sig.Ext 23 | with module Context := D.Context 24 | and type boolean := D.boolean 25 | 26 | module MakeForAADT(D:Memory_sig.AADT_WITH_BOOLEAN):sig 27 | val imperative_assume: D.Scalar.Context.t -> D.boolean -> unit 28 | end 29 | 30 | -------------------------------------------------------------------------------- /single_value_abstraction/sva_sentinel.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** A domain that abstracts a bitvector, trying to track whether it is equal to 23 | zero or not. *) 24 | include Sva_sig.NUMERIC 25 | 26 | val is_zero : Bitvector_Lattice.t -> bool 27 | val zero : Bitvector_Lattice.t 28 | val nonzero : Bitvector_Lattice.t 29 | -------------------------------------------------------------------------------- /utils/gui/deps/js/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (rule 23 | (target bundle-output.js) 24 | (deps ../Makefile package.json rollup.config.js bundle-input.js) 25 | (mode fallback) ; if already exists in the source tree, don't run. And don't clean by default. 26 | (action 27 | (progn 28 | (system "cd .. && make js/%{target}")))) -------------------------------------------------------------------------------- /single_value_abstraction/sva_prod.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | open Sva_sig 23 | 24 | module Prod_Bitvector 25 | (A:BITVECTOR with type boolean = Sva_quadrivalent.boolean) 26 | (B:BITVECTOR 27 | with type boolean = A.boolean) 28 | :BITVECTOR with type boolean = A.boolean 29 | and type bitvector = A.bitvector * B.bitvector 30 | -------------------------------------------------------------------------------- /domains/term_based/product.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Simple product of domains. *) 23 | module Make 24 | (Terms: Terms.Sig.TERMS) 25 | (A: Term_based_sig.Domain_S with module Terms = Terms) 26 | (B: Term_based_sig.Domain_S with module Terms = Terms): 27 | Term_based_sig.Domain_S 28 | with module Terms = Terms 29 | and type t = A.t * B.t 30 | -------------------------------------------------------------------------------- /.github/workflows/build-test.yml: -------------------------------------------------------------------------------- 1 | name: Build and Test 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | build-and-test: 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | os: 13 | - macos-latest 14 | - ubuntu-latest 15 | # - windows-latest 16 | ocaml-version: 17 | - 4.14 18 | - 5.3 19 | 20 | runs-on: ${{ matrix.os }} 21 | 22 | steps: 23 | - name: Checkout code 24 | uses: actions/checkout@v6 25 | 26 | - name: Use OCaml ${{ matrix.ocaml-version }} 27 | uses: ocaml/setup-ocaml@v3 28 | with: 29 | ocaml-compiler: ${{ matrix.ocaml-version }} 30 | dune-cache: true 31 | allow-prerelease-opam: true 32 | 33 | 34 | - name: Install system dependencies (Ubuntu) 35 | if: runner.os == 'Linux' 36 | run: | 37 | sudo apt-get update 38 | sudo apt-get install -y cproto 39 | 40 | - name: Install system dependencies (macOS) 41 | if: runner.os == 'macOS' 42 | run: | 43 | brew update 44 | brew install cproto 45 | 46 | - run: opam install . --deps-only --with-test 47 | 48 | - name: build Codex 49 | run: opam exec -- dune build 50 | 51 | - name: build Binsec/Codex 52 | run: opam exec -- make frontends/binsec 53 | 54 | - name: build Frama-C/Codex 55 | run: opam exec -- make frontends/frama-c 56 | 57 | - name: run test 58 | run: opam exec -- dune runtest 59 | 60 | # This tests building the project with lower bounds. 61 | 62 | - run: opam install . --deps-only --with-test --criteria='+removed,+count[version-lag,solution]' --solver=builtin-0install 63 | 64 | - name: build project with lower bounds 65 | run: opam exec -- dune build 66 | 67 | - name: run test with lower bounds 68 | run: opam exec -- dune runtest 69 | -------------------------------------------------------------------------------- /ext/framac_ival/float_interval.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Builds a semantics of floating-point intervals for different precisions, 23 | from a module providing the floating-point numbers used for the bounds 24 | of the intervals. 25 | Supports NaN and infinite values. *) 26 | module Make (Float: Float_sig.S) : 27 | Float_interval_sig.S with type float := Float.t 28 | -------------------------------------------------------------------------------- /ext/framac_ival/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.framac_ival") 24 | (name Framac_ival) 25 | (flags -w +a-3-4-6-9-40-41-42-44-45-48-34-27-32-50-60-26-33-67-70) 26 | (foreign_stubs (language c) (names "c_bindings")) 27 | (libraries str zarith codex.datatype_sig codex.codex_log) 28 | (modules_without_implementation float_interval_sig float_sig) 29 | ) 30 | -------------------------------------------------------------------------------- /frontends/frama-c/Makefile.frama-c: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This file is part of the Codex semantics library. # 3 | # # 4 | # Copyright (C) 2013-2025 # 5 | # CEA (Commissariat à l'énergie atomique et aux énergies # 6 | # alternatives) # 7 | # # 8 | # you can redistribute it and/or modify it under the terms of the GNU # 9 | # Lesser General Public License as published by the Free Software # 10 | # Foundation, version 2.1. # 11 | # # 12 | # It is distributed in the hope that it will be useful, # 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 | # GNU Lesser General Public License for more details. # 16 | # # 17 | # See the GNU Lesser General Public License version 2.1 # 18 | # for more details (enclosed in the file LICENSE). # 19 | # # 20 | ########################################################################## 21 | 22 | # The standard Frama-C Makefile changes a lot of Make variables. We 23 | # isolate it in a standalone file, used only to build and install the 24 | # plugin. 25 | FRAMAC_SHARE:=$(shell frama-c -print-share-path) 26 | include ${FRAMAC_SHARE}/Makefile.common 27 | 28 | include ${FRAMAC_SHARE}/Makefile.installation 29 | 30 | 31 | 32 | # Local Variables: 33 | # mode: makefile 34 | # End: 35 | -------------------------------------------------------------------------------- /single_value_abstraction/sva_bitfield.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | open Sva_sig;; 23 | 24 | type boolean = Sva_quadrivalent.boolean 25 | type enum = Sva_sig.Bitfield.t 26 | include WITH_ENUM_FORWARD with type boolean := boolean and type enum := enum 27 | include Sva_sig.WITH_ENUM_BACKWARD with type boolean := boolean and type enum := enum 28 | module Enum_Lattice: Lattices.Sig.ENUM_LATTICE with type t = enum 29 | -------------------------------------------------------------------------------- /domains/integer2binary.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type size = int 23 | 24 | module Make 25 | (I: Sig.BASE_WITH_INTEGER):Sig.BASE_WITH_INTEGER 26 | with type binary = I.integer 27 | and type boolean = I.boolean 28 | and type integer = I.integer 29 | and module Context = I.Context 30 | and module Integer_Query = I.Integer_Query 31 | (* and module Query.Binary_Lattice = I.Query.Integer_Lattice *) 32 | -------------------------------------------------------------------------------- /single_value_abstraction/sva_log.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module Sig = Sva_sig 23 | 24 | (** Logs all calls to Sub using Tracelog. *) 25 | module Log_Numeric_Enum(Log:Tracelog.S)(Sub:Sig.NUMERIC_ENUM):Sig.NUMERIC_ENUM 26 | 27 | (** Does not logs all calls to Sub using Tracelog; directly use Sub. *) 28 | module No_Log_Numeric_Enum(Log:Tracelog.S)(Sub:Sig.NUMERIC_ENUM):Sig.NUMERIC_ENUM 29 | -------------------------------------------------------------------------------- /utils/smallmap.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Memory-efficient replacement for maps, useful when we have a lot of 23 | small maps. *) 24 | 25 | module Make (Ord : Map.OrderedType) : sig 26 | type key = Ord.t 27 | type 'a t 28 | 29 | val bindings: 'a t -> (key * 'a) list 30 | val add: key -> 'a -> 'a t -> 'a t 31 | val empty: 'a t 32 | val find: key -> 'a t -> 'a 33 | val fold: (key -> 'a -> 'b -> 'b) -> 'a t -> 'b -> 'b 34 | 35 | end 36 | -------------------------------------------------------------------------------- /utils/tracelog/common.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type weight = Normal | Bold | Faint 23 | type color = Black | Red | Green | Yellow | Blue | Magenta | Cyan | White 24 | 25 | type Format.stag += 26 | | Weight of weight 27 | | Color of color 28 | | Underline of bool 29 | | Italic of bool 30 | ;; 31 | 32 | type 'a printf = ('a, Format.formatter, unit) format -> 'a 33 | 34 | type 'a log = 'a printf -> unit;; 35 | 36 | exception Fatal of string 37 | -------------------------------------------------------------------------------- /frontends/frama-c/printhtml.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | open Frama_c_kernel 23 | (* Given a function that pretty-print informations about expressions 24 | and lvalues; dumps an HTML in [string] to view these results. *) 25 | val print: 26 | string -> 27 | (out_channel -> (Cil_types.kinstr * Cil_types.exp) -> unit) -> 28 | (out_channel -> (Cil_types.kinstr * Cil_types.lval) -> unit) -> 29 | (out_channel -> string -> unit) -> 30 | (out_channel -> unit) -> unit 31 | -------------------------------------------------------------------------------- /lattices/unit_Lattice.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type t = unit 23 | 24 | let pretty fmt t = Format.fprintf fmt "" 25 | let join () () = () 26 | let top () = () 27 | let bottom () = () 28 | let is_bottom () = false 29 | let widen ~previous:() () = () 30 | let includes () () = true 31 | let hash () = 0 32 | let compare () () = 0 33 | let equal () () = true 34 | let includes_or_widen ~previous:() () = (true, ()) 35 | let inter () () = () 36 | let singleton _ = () 37 | -------------------------------------------------------------------------------- /domains/memory_domains/block_smashing.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Block abstraction by array smashing: all the content is abstracted 23 | * in a single fixed size value *) 24 | 25 | module Make 26 | (Value : Memory_sig.FIXED_SIZE_VALUE_DOMAIN) 27 | (Offset : Memory_sig.OFFSET with module Scalar = Value.Scalar) 28 | : Memory_sig.BLOCK with module Scalar = Value.Scalar 29 | and module Value = Value 30 | and module Offset = Offset 31 | -------------------------------------------------------------------------------- /frontends/frama-c/globals_needed.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | open Frama_c_kernel 23 | 24 | (* An initial syntactic pass on the code; notably to know which 25 | globals are necessary (remove obviously dead code and data). *) 26 | module Make(Main:sig val main: Kernel_function.t end):sig 27 | 28 | val functions_used: Cil_datatype.Varinfo.Set.t 29 | val globals_used: Cil_datatype.Varinfo.Set.t 30 | val strings_used: Datatype.String.Set.t 31 | 32 | end 33 | -------------------------------------------------------------------------------- /utils/tracelog/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name "codex.tracelog") 24 | (name tracelog) 25 | (modules Common Terminal Tracelog) 26 | (libraries unix binarytrace codex.syntax_tree) 27 | ) 28 | (library 29 | (public_name "codex.binarytrace") 30 | (name binarytrace) 31 | (modules Binarytrace) 32 | (libraries codex.syntax_tree)) 33 | (install 34 | (package codex) 35 | (section share_root) 36 | (files (tracelog-mode.el as emacs/site-lisp/tracelog-mode.el))) 37 | -------------------------------------------------------------------------------- /domains/memory_domains/region_separation.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Lifts a memory domain into a memory domain that separates each 23 | malloc call into a distinct memory region, separated by the others, 24 | where each memory region is handled by {!Sub.Memory} (and pointers by 25 | {!Sub.Address}) *) 26 | module Make (Sub:Memory_sig.OFFSET_AND_MAKE_BLOCK) 27 | :Memory_sig.WHOLE_MEMORY_DOMAIN 28 | with module Scalar = Sub.Scalar 29 | and module Offset = Sub.Offset 30 | -------------------------------------------------------------------------------- /terms/builder.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Some metrics: number of total terms, number of union-find unions performed 23 | and cluster sizes *) 24 | val nb_binary_terms: int ref 25 | val nb_unions: int ref 26 | val sizes: (int, int) Hashtbl.t 27 | 28 | 29 | module Make 30 | (Condition: Condition_map.CONDITION) 31 | (Relation: Union_Find.Parameters.GENERIC_GROUP) 32 | () : 33 | Sig.TERMS 34 | with module Condition = Condition 35 | and module Relation = Relation 36 | -------------------------------------------------------------------------------- /utils/record_time.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** A very simple benchmarking API. *) 23 | 24 | 25 | (** By default OCaml uses floats to record dates, which makes me worry 26 | about precision. This simple C API does not have this defect. 27 | bench_return_time returns the number of microseconds since the last 28 | call to bench_record_time. *) 29 | external record_time: unit -> unit = "libase_record_time";; 30 | external return_time: unit -> int = "caml_libase_return_time";; 31 | -------------------------------------------------------------------------------- /frontends/frama-c/frama_c_codex.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Frama-C parses some json file that prevent using a standalone binary. Prevent that. *) 23 | (* open Frama_c_kernel;; *) 24 | (* Machine.init_builtins_ref := (fun () -> ());; *) 25 | (* Cil_builtins.init_builtins (); *) 26 | 27 | (* Do not load other plugins as the plugin repository may not exist. *) 28 | Kernel.AutoLoadPlugins.set false;; 29 | 30 | let () = Frama_c_kernel.Boot.boot () 31 | (* Implicit exit 0 if we haven't exited yet *) 32 | -------------------------------------------------------------------------------- /single_value_abstraction/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name codex.single_value_abstraction) 24 | (name Single_value_abstraction) 25 | (libraries 26 | zarith 27 | tracelog 28 | codex.hook 29 | codex.operator 30 | codex.lattices 31 | codex.datatype_sig 32 | codex.framac_ival 33 | codex.hashing 34 | codex.record_time 35 | codex.units 36 | codex.stats) 37 | ; (modules :standard \ bitwise_basis binary_test) 38 | ; (modules :standard \ binary_test) 39 | ) 40 | -------------------------------------------------------------------------------- /smtbackend/smtbackend_smtlib.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Direct implementation of the SMTLib interface, where communication 23 | with the solver is done by sending textual information to a 24 | sub-process. *) 25 | include module type of Smtbackend_smtlib_sig 26 | 27 | module Make_Typed(P:PARAM_S):TYPED_S 28 | module Make_Untyped(P:PARAM_S):UNTYPED_S 29 | module Make_Untyped_Muz(P:PARAM_S):UNTYPED_MUZ 30 | 31 | 32 | val with_z3: ?executable:string -> ((module UNTYPED_MUZ) -> 'a) -> 'a 33 | -------------------------------------------------------------------------------- /domains/bitwise.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | 23 | (** A domain that abstracts a bitvector, and remembers what bitwise 24 | operations have been applied to it. Can be a very efficient way to 25 | simplify sequences of bitwise operations. 26 | 27 | The idea is that each bit x_i is represented as being either 0, 1, 28 | or y_j, i.e. the bit j from another word y. *) 29 | module Make (Sub : Sig.BASE) : Sig.BASE 30 | with module Context = Sub.Context 31 | and type boolean = Sub.boolean 32 | -------------------------------------------------------------------------------- /utils/compressor/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (name compressor) 24 | (public_name codex.compressor) 25 | (modules compressor) 26 | (libraries zarith)) 27 | 28 | (mdx 29 | (files *.mli) 30 | (libraries codex.compressor zarith)) 31 | 32 | ;; For test purposes only. 33 | (library 34 | (name CompressorTest) 35 | (inline_tests 36 | (libraries qcheck-core)) 37 | (preprocess (pps ppx_inline_test)) 38 | (libraries codex.compressor zarith qcheck-core) 39 | (modules compressor_test)) 40 | -------------------------------------------------------------------------------- /examples/abs/Makefile: -------------------------------------------------------------------------------- 1 | ########################################################################## 2 | # This file is part of the Codex semantics library. # 3 | # # 4 | # Copyright (C) 2013-2025 # 5 | # CEA (Commissariat à l'énergie atomique et aux énergies # 6 | # alternatives) # 7 | # # 8 | # you can redistribute it and/or modify it under the terms of the GNU # 9 | # Lesser General Public License as published by the Free Software # 10 | # Foundation, version 2.1. # 11 | # # 12 | # It is distributed in the hope that it will be useful, # 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 15 | # GNU Lesser General Public License for more details. # 16 | # # 17 | # See the GNU Lesser General Public License version 2.1 # 18 | # for more details (enclosed in the file LICENSE). # 19 | # # 20 | ########################################################################## 21 | 22 | FRAMA_C_CODEX=frama_c_codex.exe 23 | # FRAMA_C = dune exec frama-c -- -machdep x86_32 -codex 24 | BINSEC_CODEX=binsec_codex.exe 25 | # BINSEC_CODEX=dune exec binsec_codex -- -codex 26 | 27 | 28 | abs.cdump abs.c.html: 29 | $(FRAMA_C_CODEX) abs.c -codex-exp-dump abs.cdump -codex-html-dump abs.c.html -main abs 30 | 31 | abs.exe: 32 | clang -m32 -O1 abs.c -o abs.exe 33 | 34 | abs.bdump abs.exe.html: 35 | $(BINSEC_CODEX) abs.exe -entrypoint abs -codex-type-file abs.types -codex-output-html abs.exe.html 36 | -------------------------------------------------------------------------------- /lattices/set_Lattice.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Lattice from a set. May lead to divergence if the set is infinite. *) 23 | open Lattice_sig;; 24 | 25 | module type S = sig 26 | include Set.S 27 | include JOIN_SEMI_LATTICE with type t := t 28 | include WITH_BOTTOM with type t := t 29 | val is_bottom: t -> bool 30 | include WITH_INTER with type t := t 31 | val eq: t -> t -> Quadrivalent_Lattice.t 32 | val intersects: t -> t -> bool 33 | end 34 | 35 | module Make(E:Datatype_sig.S):S with type elt = E.t 36 | -------------------------------------------------------------------------------- /utils/gui/js/modal_input_string.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** A monad taking a string as an input, with autocompletion. 23 | - [title] is the monad title; 24 | 25 | - [suggestions] is a function that, given the current input 26 | string, returns a sorted list of suggestions (whose length should 27 | be smaller than [max]). No auto-completion is suggested when the 28 | list is empty. *) 29 | 30 | val input_string: title:string -> suggestions:(string -> max:int -> string * string list) -> string Modal.t 31 | -------------------------------------------------------------------------------- /terms/slicing.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module Make(T: Sig.TERMS):sig 23 | 24 | (** Given a term variable [x], compute for each tuple argument in each {{!C.cfg_node}CFG node}, 25 | on which x depends, the set of indices in the tuples on which [x] depends. 26 | 27 | Note that dependency computation is easy (it is just the 28 | transitive closure of the points-to relation in the term graph), 29 | and only requires to do a first pass to get these indices. *) 30 | val deps: 'a T.t -> (T.cfg_node -> int list) 31 | end 32 | -------------------------------------------------------------------------------- /terms/smt.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** Translation of the constraints to an SMT problem, and resolution. *) 23 | 24 | module MakeFirstOrder 25 | (T: Sig.TERMS) 26 | (S: Smtbackend.Smtlib_sig.UNTYPED_S):sig 27 | val translate: 28 | Operator.Function_symbol.boolean T.t -> 29 | Smtbackend.Smtlib_sig.sat 30 | end 31 | 32 | module MakeHorn 33 | (T: Sig.TERMS) 34 | (S:Smtbackend.Smtlib_sig.UNTYPED_MUZ):sig 35 | val translate: 36 | Operator.Function_symbol.boolean T.t -> 37 | Smtbackend.Smtlib_sig.sat 38 | end 39 | -------------------------------------------------------------------------------- /utils/gui/js/tag.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* This module dynamically creates tags that represent an arbitrary 23 | type. When given two copies of the same tag, we can compare them, 24 | which returns a type equality proof that they represent the same 25 | type. You should not be comparing two tags that are not equal. 26 | 27 | Thanks to Francois Pottier for telling me about this technique. *) 28 | 29 | type (_, _) eq = Refl : ('a, 'a) eq 30 | type 'a t 31 | val create : unit -> 'a t 32 | val equal : 'a t -> 'b t -> ('a, 'b) eq 33 | -------------------------------------------------------------------------------- /utils/unionFind/dune: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2 | ;; This file is part of the Codex semantics library. ;; 3 | ;; ;; 4 | ;; Copyright (C) 2013-2025 ;; 5 | ;; CEA (Commissariat à l'énergie atomique et aux énergies ;; 6 | ;; alternatives) ;; 7 | ;; ;; 8 | ;; you can redistribute it and/or modify it under the terms of the GNU ;; 9 | ;; Lesser General Public License as published by the Free Software ;; 10 | ;; Foundation, version 2.1. ;; 11 | ;; ;; 12 | ;; It is distributed in the hope that it will be useful, ;; 13 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of ;; 14 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;; 15 | ;; GNU Lesser General Public License for more details. ;; 16 | ;; ;; 17 | ;; See the GNU Lesser General Public License version 2.1 ;; 18 | ;; for more details (enclosed in the file LICENSE). ;; 19 | ;; ;; 20 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21 | 22 | (library 23 | (public_name codex.union_find) 24 | (name Union_Find) 25 | (modules_without_implementation parameters signatures) 26 | (libraries patricia-tree codex.het-hashtbl) 27 | (modules :standard \ union_find_test) 28 | ) 29 | 30 | ;; For test purposes only. 31 | (library 32 | (name UnionFindTest) 33 | (inline_tests 34 | (libraries qcheck-core)) 35 | (preprocess (pps ppx_inline_test)) 36 | (libraries codex.union_find patricia-tree zarith qcheck-core) 37 | (modules union_find_test) 38 | ) 39 | -------------------------------------------------------------------------------- /ext/framac_ival/pretty_utils.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type sformat = (unit,Format.formatter,unit) format 23 | type 'a formatter = Format.formatter -> 'a -> unit 24 | 25 | let pp_iter 26 | ?(pre=format_of_string "@[") 27 | ?(sep=format_of_string "") 28 | ?(suf=format_of_string "@]") 29 | iter pp fmt v = 30 | let need_sep = ref false in 31 | Format.fprintf fmt pre; 32 | iter (fun v -> 33 | if !need_sep then Format.fprintf fmt sep else need_sep := true; 34 | pp fmt v; 35 | ) v; 36 | Format.fprintf fmt suf; 37 | ;; 38 | -------------------------------------------------------------------------------- /utils/gui/js/unique_prefix.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* This code is used to give keys and unique ids to DOM elements, so 23 | that they are easier to find. *) 24 | 25 | 26 | module Make(N:sig val name : string end)():sig 27 | val prefix : string 28 | 29 | (** Builds a unique identifier by concatenation of the prefix with 30 | the suffix. You have to ensure that the suffix is unique too. *) 31 | val id : string -> 'a Vdom.attribute 32 | 33 | (** Same as id, but the suffix is numeric. *) 34 | val int_id : int -> 'a Vdom.attribute 35 | end 36 | -------------------------------------------------------------------------------- /frontends/frama-c/exp_dump.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module Cil_types = Frama_c_kernel.Cil_types 23 | 24 | (* Iterate on all expressions, printing their location and what the 25 | function f outc (indent,ki,exp) returns, where indent is the 26 | indendation and (ki,exp) identifies the expression in its 27 | statement. Only print the expressions for which should_print is true. *) 28 | val exp_dump : should_print:(Cil_types.kinstr * Cil_types.exp -> bool) -> 29 | (out_channel -> int * Cil_types.kinstr * Cil_types.exp -> unit) -> 30 | out_channel -> unit 31 | -------------------------------------------------------------------------------- /utils/gui/js/tag.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type (_, _) eq = Refl : ('a, 'a) eq 23 | 24 | type 'a tags = .. 25 | module type TAG = sig 26 | type t 27 | type 'a tags += Tag : t tags 28 | end 29 | type 'a t = (module TAG with type t = 'a) 30 | 31 | let create (type a) () : a t = 32 | let module T = struct 33 | type t = a 34 | type _ tags += 35 | | Tag : a tags 36 | end in 37 | (module T) 38 | 39 | let equal (type a b) ((module A) : a t) ((module B) : b t) : (a, b) eq = 40 | match A.Tag with 41 | | B.Tag -> Refl 42 | | _ -> failwith "Runtime tags differ" 43 | -------------------------------------------------------------------------------- /domains/memory_domains/typed_address.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module TypedC = Types.TypedC 23 | 24 | module MakeAddressOnly 25 | (SubAddress:Memory_sig.ADDRESS) 26 | (_:Memory_sig.FIXED_SIZE_VALUE_DOMAIN with module Scalar = SubAddress.Scalar) 27 | : Memory_sig.ADDRESS with module Scalar = SubAddress.Scalar 28 | 29 | module Make 30 | (Sub:Memory_sig.ADDRESS_AND_MAKE_MEMORY) 31 | (_:Memory_sig.FIXED_SIZE_VALUE_DOMAIN with module Scalar = Sub.Address.Scalar) 32 | : Memory_sig.ADDRESS_AND_MAKE_MEMORY 33 | with module Scalar = Sub.Scalar and module Offset = Sub.Offset 34 | -------------------------------------------------------------------------------- /utils/emit_alarm.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type hook = { 23 | hook : 'a. 'a Operator.Alarm.t -> Tracelog.location list -> unit; 24 | } 25 | 26 | val register_alarm_hook : hook -> unit 27 | (** Register a hook to be called when a new alarm has been emitted. The hook 28 | will be called with an alarm and the stack of tracelog locations. *) 29 | 30 | val emit_alarm : 'a Operator.Alarm.t -> unit 31 | (** Call all the registered hooks, in order, on the emitted alarm. *) 32 | 33 | val reset_alarms : unit -> unit 34 | (**Reset the alarm logs, this should be used only for post analysis*) 35 | -------------------------------------------------------------------------------- /ext/framac_ival/.depend: -------------------------------------------------------------------------------- 1 | ext/framac_ival/abstract_interp.cmo : codex_log.cmi \ 2 | ext/framac_ival/abstract_interp.cmi 3 | ext/framac_ival/abstract_interp.cmx : codex_log.cmx \ 4 | ext/framac_ival/abstract_interp.cmi 5 | ext/framac_ival/abstract_interp.cmi : 6 | ext/framac_ival/aliases.cmi : 7 | ext/framac_ival/floating_point.cmo : codex_log.cmi \ 8 | ext/framac_ival/floating_point.cmi 9 | ext/framac_ival/floating_point.cmx : codex_log.cmx \ 10 | ext/framac_ival/floating_point.cmi 11 | ext/framac_ival/floating_point.cmi : 12 | ext/framac_ival/bottom.cmo ext/framac_ival/bottom.cmx : ext/framac_ival/bottom.cmi 13 | ext/framac_ival/fval.cmo ext/framac_ival/fval.cmx : codex_log.cmi \ 14 | ext/framac_ival/fval.cmi 15 | ext/framac_ival/fval.cmx : codex_log.cmx \ 16 | ext/framac_ival/fval.cmi 17 | ext/framac_ival/float_interval.cmo ext/framac_ival/float_interval.cmx: ext/framac_ival/float_interval.cmi 18 | ext/framac_ival/float_interval.cmi: ext/framac_ival/float_sig.cmi ext/framac_ival/float_interval_sig.cmi 19 | ext/framac_ival/float_interval_sig.cmi: ext/framac_ival/float_sig.cmi 20 | ext/framac_ival/fval.cmi : ext/framac_ival/float_interval_sig.cmi ext/framac_ival/float_sig.cmi 21 | ext/framac_ival/fc_float.cmi : ext/framac_ival/floating_point.cmi ext/framac_ival/float_sig.cmi 22 | ext/framac_ival/fc_float.cmo ext/framac_ival/fc_float.cmx : ext/framac_ival/fc_float.cmi ext/framac_ival/floating_point.cmi 23 | ext/framac_ival/ival.cmo : codex_log.cmi \ 24 | ext/framac_ival/ival.cmi 25 | ext/framac_ival/ival.cmx : codex_log.cmx \ 26 | ext/framac_ival/ival.cmi 27 | ext/framac_ival/ival.cmi : \ 28 | ext/framac_ival/abstract_interp.cmi \ 29 | ext/framac_ival/fval.cmi 30 | ext/framac_ival/ival_noinf.cmo : codex_log.cmi \ 31 | ext/framac_ival/ival_noinf.cmi 32 | ext/framac_ival/ival_noinf.cmx : codex_log.cmx \ 33 | ext/framac_ival/ival_noinf.cmi 34 | ext/framac_ival/ival_noinf.cmi : \ 35 | ext/framac_ival/abstract_interp.cmi \ 36 | ext/framac_ival/fval.cmi 37 | ext/framac_ival/integer.cmo ext/framac_ival/integer.cmx : ext/framac_ival/integer.cmi 38 | ext/framac_ival/pretty_utils.cmo ext/framac_ival/pretty_utils.cmx : ext/framac_ival/pretty_utils.cmi 39 | -------------------------------------------------------------------------------- /utils/gui/js/sourceview.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type initial_data = string 23 | 24 | type internal_message 25 | 26 | type incoming_message = 27 | | Internal_in of internal_message 28 | 29 | type outgoing_message = 30 | | Internal_out of internal_message 31 | | Display_modal : 'a Modal.t * ('a option -> internal_message) -> outgoing_message 32 | 33 | 34 | include Component.S 35 | with type initial_data := initial_data 36 | and type incoming_message := incoming_message 37 | and type outgoing_message := outgoing_message 38 | 39 | val get_menu: model -> outgoing_message Transient_menu.stack 40 | -------------------------------------------------------------------------------- /utils/gui/js/unique_prefix.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | let unique = Hashtbl.create 17 23 | 24 | module Make(N:sig val name: string end)() = struct 25 | 26 | 27 | let prefix = 28 | let count = 29 | try Hashtbl.find unique N.name 30 | with Not_found -> 1 31 | in 32 | Hashtbl.replace unique N.name (count + 1); 33 | (* Common case: instantiated once. *) 34 | if count = 1 then 35 | N.name ^ "_" 36 | else 37 | N.name ^ (string_of_int count) ^ "_" 38 | 39 | let id str = Vdom.attr "id" (prefix ^ str) 40 | let int_id num = id (string_of_int num) 41 | 42 | end 43 | -------------------------------------------------------------------------------- /utils/dynamic_array.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** A mutable dynamic array. Accept any positive index, and will grow as required. 23 | Trying to get an element that was not previously set, returns Not_found. *) 24 | 25 | type 'a t 26 | 27 | val empty: unit -> 'a t (* Maybe: initial capacity? *) 28 | val get: 'a t -> int -> 'a 29 | val set: 'a t -> int -> 'a -> unit 30 | val length: 'a t -> int 31 | (** The length is the max of the indices used by set. Note that some elements 32 | below length may not be set. *) 33 | 34 | val append: 'a t -> 'a -> unit 35 | (** Appends according to the length. *) 36 | -------------------------------------------------------------------------------- /lattices/unimplemented_Lattice.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | open Lattice_sig 23 | 24 | (* Generation of modules that fail (with information to find out which 25 | function failed, using the provided id) when a function is called. *) 26 | module Enum_Lattice(UnimplementedId:sig val loc:string end):ENUM_LATTICE 27 | 28 | module Bitvector_Lattice(UnimplementedId:sig 29 | type t 30 | val loc:string 31 | end):BITVECTOR_LATTICE with type t = UnimplementedId.t 32 | 33 | 34 | module Integer_Lattice(UnimplementedId:sig 35 | type t 36 | val loc:string 37 | end):INTEGER_LATTICE with type t = UnimplementedId.t 38 | -------------------------------------------------------------------------------- /utils/int_builtins_ml.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* ML version of the builtins, which are useful for using with the REPL. *) 23 | 24 | (* -v land v gives a number with a single 1 whose position is the one of the last non-0 bit. 25 | A modulo with the prime number 37 assigns each of them a unique number. *) 26 | let count_trailing_zeroes v = 27 | let idx = ((-v) land v) mod 37 in 28 | [| 32; 0; 1; 26; 2; 23; 27; 0; 3; 16; 24; 30; 28; 11; 0; 13; 4; 29 | 7; 17; 0; 25; 22; 31; 15; 29; 10; 12; 6; 0; 21; 14; 9; 5; 30 | 20; 8; 19; 18 |].(idx) 31 | ;; 32 | 33 | let find_last_set v = count_trailing_zeroes v + 1;; 34 | -------------------------------------------------------------------------------- /utils/online_nearest_common_ancestor_skiplist.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type 'a parents 23 | 24 | (** Functor to create an efficient data structure for online 25 | computation of the nearest common ancestor. *) 26 | module Make(Elt : sig 27 | type t 28 | val depth : t -> int 29 | val parents : t -> t parents 30 | end): 31 | sig 32 | val nil : int * 'a array (* XXX: Why nil here? *) 33 | val cons : Elt.t -> int * Elt.t parents 34 | val nth : Elt.t -> int -> Elt.t 35 | val nearest_common_ancestor_same_depth : Elt.t -> Elt.t -> Elt.t 36 | val nearest_common_ancestor : Elt.t -> Elt.t -> Elt.t 37 | end 38 | -------------------------------------------------------------------------------- /utils/tracelog/tutorial.tlog: -------------------------------------------------------------------------------- 1 | -*- mode:tracelog -*- 2 | [Hello] This is a tutorial for using tracelog-mode, and documenting the 3 | │ tracelog-mode format. 4 | ├─[Tracelog-mode] is a tool to navigate into tracelogs, implemented as 5 | │ │ an Emacs major mode. 6 | ├─[Tracelogs] are detailed outputs representing the behaviour of a program. 7 | │ │ In addition to usual log levels and categories, it allows to 8 | │ │ present the information hierarchically as a tree, usually 9 | │ │ corresponding to the dynamic calltree of the program. It thus 10 | │ │ allows both tracing and logging the information coming from the 11 | │ │ program, hence its name, tracelog. You can view it as a tool 12 | │ │ for printf debugging, but on steroids. 13 | ├─[Format] Each line of tracelog files follow a simple structure. 14 | │ ├─[Guide lines] visually show the set of parent nodes to which a node belong. 15 | │ │ │ They are build using the graphic characters '├','└','│', 16 | │ │ │ and '─' at the beginning of every line. 17 | │ │ ├─[For instance] this line belongs to the nodes categorized by 18 | │ │ │ │ [For instance], [Guide lines], [Format] and [Hello]. And 19 | │ │ │ │ so is this line. This can be seen by following vertical 20 | │ │ │ │ lines at the start of this line. 21 | │ │ [Categories] are in square bracket and immediately follow the guide 22 | │ │ │ lines. They also correspond to a node in the tree. 23 | │ │ │ You can collapse a node in the tree by clicking on the 24 | │ │ │ category button, or typing anywhere on a category line. 25 | │ │ │ more clicks or presses to will cycle the subtree between 26 | │ │ │ being fully expanded, fully collapses, or expanding only the 27 | │ │ │ immediate children. 28 | [Tree navigation] Type 'u' to go up in the tree, to the parent. 29 | │ │ [Log levels] are visually distinguished. 30 | │ │ [Buttons] are visually distinguished. 31 | 32 | corresponds both to the crea 33 | 34 | [Tracelogs] are detailed outputs representing the behaviour of a program. In addition to usual 35 | -------------------------------------------------------------------------------- /ext/framac_ival/pretty_utils.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | type sformat = (unit,Format.formatter,unit) format 23 | type 'a formatter = Format.formatter -> 'a -> unit 24 | 25 | val pp_iter: 26 | ?pre:sformat -> ?sep:sformat -> ?suf:sformat -> 27 | (('a -> unit) -> 'b -> unit) -> 28 | 'a formatter -> 'b formatter 29 | (** pretty prints any structure using an iterator on it. The argument 30 | [pre] (resp. [suf]) is output before (resp. after) the iterator 31 | is started (resp. has ended). The optional argument [sep] is output between 32 | two calls to the ['a formatter]. Default: open a box for [pre], close 33 | a box for [suf], nothing for [sep]. *) 34 | 35 | -------------------------------------------------------------------------------- /codex.ml: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (** XXX: Entry poitn to our documentation? *) 23 | 24 | 25 | module Operator = Operator 26 | module Fixpoint = Fixpoint 27 | module Codex_config = Codex_config 28 | module Codex_log = Codex_log 29 | module Hook = Hook 30 | module Types = Types 31 | module Lattices = Lattices 32 | module Single_value_abstraction = Single_value_abstraction 33 | module Utils = struct 34 | module Interval_map = Interval_map 35 | module Datatype_sig = Datatype_sig 36 | end 37 | 38 | module Ext = struct 39 | module Framac_ival = Framac_ival (* Temporary *) 40 | end 41 | 42 | module Domains = Domains 43 | 44 | module Extstdlib = Extstdlib 45 | module Gui = Gui 46 | -------------------------------------------------------------------------------- /domains/memory_domains/wholify.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | module MakeAddressOnly (SubAddress : Memory_sig.ADDRESS) : 23 | Memory_sig.FIXED_SIZE_VALUE_DOMAIN 24 | with module Scalar = SubAddress.Scalar 25 | 26 | (* Translate an address into something which is either an address or a 27 | numeric value. The numeric values can be used as an address in a 28 | region handled by Region_numeric_offset, which is separated from 29 | the domain given as an argument. *) 30 | module Make (Sub : Memory_sig.ADDRESS_AND_MAKE_MEMORY) : sig 31 | include 32 | Memory_sig.WHOLE_MEMORY_DOMAIN 33 | with module Scalar = Sub.Scalar 34 | and module Offset = Sub.Offset 35 | end 36 | -------------------------------------------------------------------------------- /lattices/prod_Lattice.mli: -------------------------------------------------------------------------------- 1 | (**************************************************************************) 2 | (* This file is part of the Codex semantics library. *) 3 | (* *) 4 | (* Copyright (C) 2013-2025 *) 5 | (* CEA (Commissariat à l'énergie atomique et aux énergies *) 6 | (* alternatives) *) 7 | (* *) 8 | (* you can redistribute it and/or modify it under the terms of the GNU *) 9 | (* Lesser General Public License as published by the Free Software *) 10 | (* Foundation, version 2.1. *) 11 | (* *) 12 | (* It is distributed in the hope that it will be useful, *) 13 | (* but WITHOUT ANY WARRANTY; without even the implied warranty of *) 14 | (* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *) 15 | (* GNU Lesser General Public License for more details. *) 16 | (* *) 17 | (* See the GNU Lesser General Public License version 2.1 *) 18 | (* for more details (enclosed in the file LICENSE). *) 19 | (* *) 20 | (**************************************************************************) 21 | 22 | (* Product with intersection semantics: elements are in the 23 | intersections of the concretizations. *) 24 | 25 | open Lattice_sig 26 | 27 | module Prod2(L1:JOIN_SEMI_LATTICE)(L2:JOIN_SEMI_LATTICE) 28 | :JOIN_SEMI_LATTICE with type t = L1.t * L2.t 29 | 30 | module Prod2_With_Bottom(L1:JOIN_SEMI_LATTICE_WITH_BOTTOM)(L2:JOIN_SEMI_LATTICE_WITH_BOTTOM) 31 | :JOIN_SEMI_LATTICE_WITH_BOTTOM with type t = L1.t * L2.t 32 | 33 | module Prod2_With_Inter_Bottom 34 | (L1:JOIN_SEMI_LATTICE_WITH_INTER_BOTTOM) 35 | (L2:JOIN_SEMI_LATTICE_WITH_INTER_BOTTOM) 36 | :JOIN_SEMI_LATTICE_WITH_INTER_BOTTOM with type t = L1.t * L2.t 37 | --------------------------------------------------------------------------------