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:
- translate source into a GOTO binary using
goto-cc, - perform instrumentation with
goto-instrument, and finally - 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-assertionscannot 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, ornone.--os osโ Set analysis operating system, which defaults to the host operating system. Use one of:freebsd,linux,macos,netbsd,openbsd,solaris,hurd, orwindows.--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 ofassertion[s],assume[s],branch[es],condition[s],cover,decision[s],location[s], ormcdc--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-loopsto get the loop IDs). very specific, very demure ๐--incremental-loop Lโ check properties after each unwinding of loop L (use--show-loopsto 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-assertionswhen both of these are given); cannot be used with--cover. cannot be used with--coverso 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 simplifywhile(1){}toassume(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โ addrawLhsproperty 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 โจ
COPYRIGHT ๐โจ
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
- fedora 44: cbmc 6.8.0-1.fc44 ยท BSD-4-Clause
- nixos 26.05: cbmc 6.9.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms