CBMC(1)

๐Ÿ’– CBMC(1) โ€” User Commands ๐Ÿ’–

okay bestie, welcome to cbmc, aka the Bounded Model Checker, living in section 1 of the manual (User Commands, if you were wondering) โœจ this is the girl who will literally tell you exactly how your assertion gets violated, or prove it can't be โ€” within a given number of loop iterations. no cap. let's get into it ๐Ÿซถ


โœจ NAME โœจ

cbmc โ€” Bounded Model Checker for C/C++ and Java programs ๐Ÿ’…


๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

cbmc [--property property-id] file.c ...

cbmc [--show-properties] file.c ...

cbmc [--all-properties] file.c ...

cbmc [--no-standard-checks] file.c ...

cbmc [--no-standard-checks] [--pointer-check] file.c ...

cbmc [--no-bounds-check] file.c ...

goto-cc [-I include-path] [-c] file.c [-o outfile.o]

goto-instrument infile outfile

Only the most useful options are listed here; see below for the remainder. (yes she's holding out on you, there's SO much more, keep scrolling ๐Ÿ“œ)


๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

okay so here's the vibe: cbmc generates traces that demonstrate how an assertion can be violated, or proves that the assertion cannot be violated within a given number of loop iterations. like, she's not just gonna say "bad vibes detected" โ€” she's gonna show you the receipts ๐Ÿงพโœจ

CBMC can read C/C++ source-code directly, or a GOTO binary generated by goto-cc. Java programs? those come in as class or JAR files, slay ๐Ÿ’…

Without any further options, cbmc checks all properties (automatically generated or user-specified) found in the program. If any of the properties can be violated, a counterexample is printed and the analysis is aborted ๐Ÿ˜ญ. The analysis can be restricted to a particular property with the --property option. The verification result for all properties can be obtained by means of the --all-properties option. obsessed.

goto-cc(1) reads source code, and generates a GOTO binary. Its command-line interface is designed to mimic that of gcc(1). Note in particular that goto-cc(1) distinguishes between compiling and linking phases, just as gcc does. cbmc expects a GOTO binary for which linking has been completed. (so like, finish the link, bestie, don't show up half-done ๐Ÿ™ˆ)

goto-instrument(1) reads a GOTO binary, performs a given program transformation, and then writes the resulting program as GOTO binary on disc.

The usual flow is to:

  1. translate source into a GOTO binary using goto-cc,
  2. perform instrumentation with goto-instrument, and finally
  3. perform the analysis with cbmc.

it's giving โœจpipelineโœจ, it's giving main character energy ๐Ÿ‘‘


๐Ÿ’… OPTIONS ๐Ÿ’…

๐ŸŒธ Standard Checks ๐ŸŒธ

From version 6.0 onwards, cbmc, goto-analyzer and some other tools apply some checks to the program by default (called the "standard checks"), with the aim to provide a better user experience for a non-expert user of the tool. These checks are:

  • --pointer-check โ€” enable pointer checks
  • --bounds-check โ€” enable array bounds checks
  • --undefined-shift-check โ€” check shift greater than bit-width
  • --div-by-zero-check โ€” enable division by zero checks for integer division
  • --float-div-by-zero-check โ€” enable division by zero checks for floating-point division
  • --pointer-primitive-check โ€” checks that all pointers in pointer primitives are valid or null
  • --signed-overflow-check โ€” enable signed arithmetic over- and underflow checks
  • --malloc-may-fail โ€” allow malloc calls to return a null pointer
  • --malloc-fail-null โ€” set malloc failure mode to return null
  • --unwinding-assertions โ€” generate unwinding assertions (cannot be used with --cover)
โš ๏ธ heads up: --unwinding-assertions cannot be used with --cover. they do NOT get along. it's a whole thing ๐Ÿ’€

These checks can all be deactivated at once by using the --no-standard-checks flag like in the header example, or individually, by prepending a no- before the flag, like so:

  • --no-pointer-check โ€” disable pointer checks
  • --no-bounds-check โ€” disable array bounds checks
  • --no-undefined-shift-check โ€” do not perform check for shift greater than bit-width
  • --no-div-by-zero-check โ€” disable division by zero checks
  • --no-pointer-primitive-check โ€” do not check that all pointers in pointer primitives are valid or null
  • --no-signed-overflow-check โ€” disable signed arithmetic over- and underflow checks
  • --no-malloc-may-fail โ€” do not allow malloc calls to fail by default
  • --no-unwinding-assertions โ€” do not generate unwinding assertions

If an already set flag is re-set, like calling --pointer-check when default checks are already on, the flag is simply ignored. (she's unbothered, she's chill, she just moves on ๐Ÿงš)


๐ŸŽ€ Analysis options: ๐ŸŽ€

  • --no-standard-checks โ€” disable the standard (default) checks applied to a C/GOTO program (see above for more information)
  • --show-properties โ€” show the properties, but don't run analysis
  • --symex-coverage-report f โ€” generate a Cobertura XML coverage report in f
  • --property id โ€” only check one specific property
  • --trace โ€” give a counterexample trace for failed properties
  • --stop-on-fail โ€” stop analysis once a failed property is detected (implies --trace)
  • --localize-faults โ€” localize faults (experimental)

๐Ÿ“ C/C++ frontend options: ๐Ÿ“

  • --preprocess โ€” stop after preprocessing
  • --test-preprocessor โ€” stop after preprocessing, discard output
  • -I path โ€” set include path (C/C++)
  • --include file โ€” set include file (C/C++)
  • -D macro โ€” define preprocessor macro (C/C++)
  • --c89, --c99, --c11, --c17, --c23 โ€” set C language standard (default: c11)
  • --cpp98, --cpp03, --cpp11 โ€” set C++ language standard (default: cpp98)
  • --unsigned-char โ€” make "char" unsigned by default
  • --round-to-nearest, --round-to-even โ€” rounding towards nearest even (default)
  • --round-to-plus-inf โ€” rounding towards plus infinity
  • --round-to-minus-inf โ€” rounding towards minus infinity
  • --round-to-zero โ€” rounding towards zero
  • --no-library โ€” disable built-in abstract C library
  • --max-nondet-tree-depth N โ€” limit size of nondet (e.g. input) object tree; at level N pointers are set to null
  • --min-null-tree-depth N โ€” minimum level at which a pointer can first be NULL in a recursively nondet initialized struct
  • --function name โ€” set main function name

๐ŸŒˆ Platform options: ๐ŸŒˆ

  • --arch arch โ€” Set analysis architecture, which defaults to the host architecture. Use one of: alpha, arm, arm64, armel, armhf, hppa, i386, ia64, mips, mips64, mips64el, mipsel, mipsn32, mipsn32el, powerpc, ppc64, ppc64le, riscv64, s390, s390x, sh4, sparc, sparc64, v850, x32, x86_64, or none.
  • --os os โ€” Set analysis operating system, which defaults to the host operating system. Use one of: freebsd, linux, macos, netbsd, openbsd, solaris, hurd, or windows.
  • --i386-linux, --i386-win32, --i386-macos, --ppc-macos, --win32, --winx64 โ€” Set analysis architecture and operating system.
  • --LP64, --ILP64, --LLP64, --ILP32, --LP32 โ€” Set width of int, long and pointers, but don't override default architecture and operating system.
  • --16, --32, --64 โ€” Equivalent to --LP32, --ILP32, --LP64 (on Windows: --LLP64).
  • --little-endian โ€” allow little-endian word-byte conversions
  • --big-endian โ€” allow big-endian word-byte conversions
  • --gcc โ€” use GCC as preprocessor

๐Ÿ”ฅ Program representations: ๐Ÿ”ฅ

  • --show-parse-tree โ€” show parse tree
  • --show-symbol-table โ€” show loaded symbol table
  • --show-goto-functions โ€” show loaded goto program
  • --list-goto-functions โ€” list loaded goto functions
  • --validate-goto-model โ€” enable additional well-formedness checks on the goto program
  • --validate-ssa-equation โ€” enable additional well-formedness checks on the SSA representation

๐Ÿงš Program instrumentation options: ๐Ÿงš

  • --bounds-check โ€” enable array bounds checks
  • --pointer-check โ€” enable pointer checks
  • --memory-leak-check โ€” enable memory leak checks
  • --memory-cleanup-check โ€” Enable memory cleanup checks: assert that all dynamically allocated memory is explicitly freed before terminating the program.
  • --div-by-zero-check โ€” enable division by zero checks
  • --signed-overflow-check โ€” enable signed arithmetic over- and underflow checks
  • --unsigned-overflow-check โ€” enable arithmetic over- and underflow checks
  • --pointer-overflow-check โ€” enable pointer arithmetic over- and underflow checks
  • --conversion-check โ€” check whether values can be represented after type cast
  • --undefined-shift-check โ€” check shift greater than bit-width
  • --float-overflow-check โ€” check floating-point for +/-Inf
  • --nan-check โ€” check floating-point for NaN
  • --enum-range-check โ€” checks that all enum type expressions have values in the enum range
  • --pointer-primitive-check โ€” checks that all pointers in pointer primitives are valid or null
  • --retain-trivial-checks โ€” include checks that are trivially true
  • --error-label label โ€” check that label is unreachable
  • --no-built-in-assertions โ€” ignore assertions in built-in library
  • --no-assertions โ€” ignore user assertions
  • --no-assumptions โ€” ignore user assumptions
  • --assert-to-assume โ€” convert user assertions to assumptions
  • --cover CC โ€” create test-suite with coverage criterion CC, where CC is one of assertion[s], assume[s], branch[es], condition[s], cover, decision[s], location[s], or mcdc
  • --cover-failed-assertions โ€” do not stop coverage checking at failed assertions (this is the default for --cover assertions)
  • --show-test-suite โ€” print test suite for coverage criterion (requires --cover)
  • --mm MM โ€” memory consistency model for concurrent programs (default: sc)
  • --malloc-may-fail โ€” allow malloc calls to return a null pointer
  • --malloc-fail-assert โ€” set malloc failure mode to assert-then-assume
  • --malloc-fail-null โ€” set malloc failure mode to return null
  • --string-abstraction โ€” track C string lengths and zero-termination
  • --dfcc-debug-lib โ€” enable debug assertions in the cprover contracts library
  • --dfcc-simple-invalid-pointer-model โ€” use simplified invalid pointer model in the cprover contracts library (faster, unsound)
  • --reachability-slice โ€” remove instructions that cannot appear on a trace from entry point to a property
  • --reachability-slice-fb โ€” remove instructions that cannot appear on a trace from entry point through a property
  • --full-slice โ€” run full slicer (experimental)
  • --drop-unused-functions โ€” drop functions trivially unreachable from main function
๐Ÿ’€ ngl, --dfcc-simple-invalid-pointer-model says the quiet part out loud: it's faster but also unsound. read the label, bestie.

๐Ÿ‘‘ Semantic transformations: ๐Ÿ‘‘

  • --nondet-static โ€” add nondeterministic initialization of variables with static lifetime

โญ BMC options: โญ

  • --paths [strategy] โ€” explore paths one at a time
  • --show-symex-strategies โ€” list strategies for use with --paths
  • --show-goto-symex-steps โ€” show which steps symex travels, includes diagnostic information
  • --show-points-to-sets โ€” show points-to sets for pointer dereference. Requires --json-ui. โœจ
  • --program-only โ€” only show program expression. so minimal, so clean ๐Ÿ’…
  • --show-byte-ops โ€” show all byte extracts and updates. every lil byte gets its moment ๐Ÿฆ‹
  • --depth nr โ€” limit search depth. nr is the depth cap, bestie.
  • --max-field-sensitivity-array-size M โ€” maximum size M of arrays for which field sensitivity will be applied to array, the default is 64. iykyk
  • --no-array-field-sensitivity โ€” deactivate field sensitivity for arrays, this is equivalent to setting the maximum field sensitivity size for arrays to 0. turn it off, turn it off ๐Ÿซถ
  • --show-loops โ€” show the loops in the program. loop reveal, periodt ๐Ÿ”ฅ
  • --unwind nr โ€” unwind all loops at most nr times. give those loops a limit
  • --unwindset [T:]L:B,... โ€” unwind loop L with a bound of B, optionally restricted to thread T, and overriding what may be set as default unwinding via --unwind (use --show-loops to get the loop IDs). very specific, very demure ๐Ÿ’–
  • --incremental-loop L โ€” check properties after each unwinding of loop L (use --show-loops to get the loop IDs). step by step, bestie โœจ
  • --unwind-min nr โ€” start incremental-loop after nr unwindings but before solving that iteration. If for example it is 1, then the loop will be unwound once, and immediately checked. Note: this means for min-unwind 1 or 0 all properties are checked. all the checks, no skips ๐Ÿ˜ญ
  • --unwind-max nr โ€” stop incremental-loop after nr unwindings. okay that's enough ๐Ÿ›‘
  • --ignore-properties-before-unwind-min โ€” do not check properties before unwind-min when using incremental-loop. skip the pre-game ๐Ÿ™ˆ
  • --show-vcc โ€” show the verification conditions. the receipts, literally ๐Ÿงพ
  • --slice-formula โ€” remove assignments unrelated to property. declutter that formula ๐Ÿงน
  • --unwinding-assertions โ€” generate unwinding assertions (which are enabled by default; overrides --no-unwinding-assertions when both of these are given); cannot be used with --cover. cannot be used with --cover so don't try it ๐Ÿ’€
  • --partial-loops โ€” permit paths that execute loops only partially (up to the given unwinding bound) and then continue beyond the loop even when the loop condition would still hold (such paths may be spurious, resulting in false alarms). warning: false alarms possible spooky ๐Ÿ‘ป
  • --no-self-loops-to-assumptions โ€” do not simplify while(1){} to assume(0). leave that loop alone ๐Ÿซถ
  • --symex-complexity-limit N โ€” how complex (N) a path can become before symex abandons it. Currently uses guard size to calculate complexity. guard size is the vibe check โœจ
  • --symex-complexity-failed-child-loops-limit N โ€” how many child branches (N) in an iteration are allowed to fail due to complexity violations before the loop gets blacklisted. blacklisted, not me ๐Ÿ’…
  • --graphml-witness filename โ€” write the witness in GraphML format to filename. witness protection, but make it graph ๐Ÿฆ‹
  • --symex-cache-dereferences โ€” enable caching of repeated dereferences. cache it, bestie ๐ŸŽ€

Backend options: ๐Ÿ› ๏ธโœจ

  • --object-bits n โ€” number of bits used for object addresses. n bits, no cap.
  • --sat-solver solver โ€” use specified SAT solver. pick your fighter ๐Ÿ’–
  • --external-sat-solver cmd โ€” command to invoke SAT solver process. external, mysterious โœจ
  • --no-sat-preprocessor โ€” disable the SAT solver's simplifier. no simplifying today ๐Ÿ›‘
  • --dimacs โ€” generate CNF in DIMACS format. old school, iconic ๐Ÿ“œ
  • --beautify โ€” beautify the counterexample (greedy heuristic). greedy but make it cute ๐Ÿ’…
  • --smt1 โ€” use default SMT1 solver (obsolete). obsolete, bestie ๐Ÿ’€
  • --smt2 โ€” use default SMT2 solver (Z3). Z3 is the moment ๐Ÿ”ฅ
  • --bitwuzla โ€” use Bitwuzla. say it with me: bit-wuz-la ๐Ÿฆ‹
  • --boolector โ€” use Boolector. boo! ๐Ÿ‘ป
  • --cprover-smt2 โ€” use CPROVER SMT2 solver. CPROVER core โœจ
  • --cvc3 โ€” use CVC3. vintage ๐ŸŽ€
  • --cvc4 โ€” use CVC4. a classic โญ
  • --cvc5 โ€” use CVC5. the new era ๐Ÿ’–
  • --mathsat โ€” use MathSAT. math but make it sat ๐Ÿ”ฅ
  • --yices โ€” use Yices. yices, yices, baby ๐Ÿ’…
  • --z3 โ€” use Z3. the people's solver ๐Ÿ‘‘
  • --fpa โ€” use theory of floating-point arithmetic. float like a butterfly ๐Ÿฆ‹
  • --external-smt2-solver cmd โ€” Use cmd to invoke the SMT2 solver. Combine with one of the solver choices for solver-specific constraints. mix and match โœจ
  • --refine โ€” use refinement procedure (experimental). experimental handle with care ๐Ÿซถ
  • --refine-arrays โ€” use refinement for arrays only. arrays only, periodt ๐Ÿ’…
  • --refine-arithmetic โ€” refinement of arithmetic expressions only. math only ๐Ÿงฎ
  • --max-node-refinement โ€” maximum refinement iterations for arithmetic expressions. cap it ๐ŸŽ€
  • --incremental-smt2-solver cmd โ€” Use the incremental SMT backend where cmd is the command to invoke the SMT solver of choice. Example invocations:
--incremental-smt2-solver 'z3 -smt2 -in' (use the Z3 solver).
--incremental-smt2-solver 'cvc5 --lang=smtlib2.6 --incremental'
(use the CVC5 solver).

Note that:

  • The solver name must be in the "PATH" or be an executable with full path. full path or it's not invited
  • The SMT solver should accept incremental SMTlib v2.6 formatted input from the stdin. stdin only, bestie
  • The SMT solver should support the QF_AUFBV logic. QF_AUFBV or nothing ๐Ÿ’–
  • --outfile filename โ€” output formula to given file. save it ๐Ÿ’พ
  • --dump-smt-formula filename โ€” output smt incremental formula to the given file. dump it, but fancy โœจ
  • --write-solver-stats-to json-file โ€” collect the solver query complexity. stats girlies rise ๐Ÿ“Š
  • --refine-strings โ€” use string refinement (experimental). experimental strings attached ๐ŸŽ€
  • --string-printable โ€” restrict to printable strings (experimental). experimental only printable, no weird vibes ๐Ÿ”ฅ
  • --arrays-uf-never โ€” never turn arrays into uninterpreted functions. never ever ๐Ÿ›‘
  • --arrays-uf-always โ€” always turn arrays into uninterpreted functions. always and forever ๐Ÿ’…
  • --show-array-constraints โ€” show array theory constraints added during post processing. Requires --json-ui. json-ui required, no cap โœจ

User-interface options: ๐ŸŽ€โœจ

  • --xml-ui โ€” use XML-formatted output. XML era ๐Ÿ“œ
  • --xml-interface โ€” bi-directional XML interface. talk back in XML ๐Ÿฆ‹
  • --json-ui โ€” use JSON-formatted output. JSON supremacy ๐Ÿ‘‘
  • --json-interface โ€” bi-directional JSON interface. JSON but make it chatty ๐Ÿ’ฌ
  • --trace-json-extended โ€” add rawLhs property to trace. rawLhs, iconic ๐Ÿ’…
  • --trace-show-function-calls โ€” show function calls in plain trace. calls on display ๐Ÿ“ž
  • --trace-show-code โ€” show original code in plain trace. the source, the drama ๐ŸŽฌ
  • --trace-hex โ€” represent plain trace values in hex. hex girl summer ๐Ÿ”ฅ
  • --compact-trace โ€” give a compact trace. compact, cute, contained ๐ŸŽ€
  • --stack-trace โ€” give a stack trace only. just the stack, bestie ๐Ÿฅž
  • --flush โ€” flush every line of output. flush it, don't hold back ๐Ÿšฝ
  • --export-symex-ready-goto filename โ€” export the symex ready version of the goto-model into the given filename. export the vibe โœจ
  • --verbosity # โ€” verbosity level. # is the level, no guessing ๐Ÿ’–
  • --timestamp [monotonic|wall] โ€” Print microsecond-precision timestamps. monotonic: stamps increase monotonically. wall: ISO-8601 wall clock timestamps. time is a construct, but microsecond-precision โฐ

ENVIRONMENT ๐ŸŒโœจ

All tools honor the TMPDIR environment variable when generating temporary files and directories. Furthermore note that the preprocessor used by cbmc will use environment variables to locate header files. env vars are the real main characters ๐Ÿ’…


BUGS ๐Ÿ›๐Ÿ’–

If you encounter a problem please create an issue at https://github.com/diffblue/cbmc/issues. report it, bestie, we don't suffer in silence ๐Ÿซถ


SEE ALSO ๐Ÿ‘€๐Ÿ’…

goto-cc(1), goto-instrument(1) โ€” the whole friend group โœจ


2001-2016, Daniel Kroening, Edmund Clarke. respect the icons ๐Ÿ‘‘


and that's the whole vibe, bestie. this page is from cbmc-5.59.0, dated June 2022. periodt. ๐Ÿ’…โœจ

๐Ÿ“ฆ where this page comes from