CRANGLER(1)

πŸ’… CRANGLER(1) β€” the crangler manual, bestie edition ✨

okay so. crangler. say it with me. it's a User Commands page, it lives in section 1, and it's literally about transforming C source. let's get into it 🫢


✨ NAME ✨

crangler β€” C source transformation. that's it, that's the whole vibe πŸ’–


🌸 SYNOPSIS 🌸

crangler [-?] [-h] [--help]

crangler file.json

two whole moods: ask for help, or hand it a JSON file and let it cook πŸ‘‘


πŸ¦‹ DESCRIPTION πŸ¦‹

so crangler is a command-line utility, right? and what it does is it takes a preprocessed C file and makes changes to it β€” and those changes are prescribed in a JSON configuration file. you tell it what to do in JSON, it does the thing. no cap ✨

the supported transformations are:

  • Add a contract (pre / post / assigns) to a named C function. πŸŽ€
  • Add a loop contract to a loop identified by the name of the function containing the loop and a loop number. πŸ”
  • Remove the static storage classifier from a function or a variable. bye bestie πŸ‘‹
  • Replace a function call by a call to a stub. glow-up fr fr πŸ’…

and the resulting source file? it gets written to standard output, or to a file specified in the JSON configuration. your call, main character 🌈


πŸ”₯ EXAMPLE πŸ”₯

okay this is the fun part. the following JSON configuration file makes crangler preprocess remove_static1.c. while processing this file to produce a preprocessed result, no non-standard include paths or defines are required (yes, "reqired" β€” we don't gatekeep typos here, the original said it, we say it πŸ₯°).

the transformations configured here are:

  • removing the static storage classifier from all functions matching the regular expression foobar[12]
  • replacing calls to bar by calls to a function called bar_stub

no objects are listed that require transformation. and the result is written to standard output. iconic. periodt.

{
  "sources": [
    "remove_static1.c"
  ],
  "includes": [],
  "defines": [],
  "functions": [
    {
      "foobar[12]": [
        "remove static"
      ],
      "bar": [
        "stub bar_stub"
      ]
    }
  ],
  "objects": [],
  "output": "stdout"
}

🌱 ENVIRONMENT 🌱

  • TMPDIR β€” all tools honor this environment variable when generating temporary files and directories. yes girl, you can move your temp files wherever you want, she'll respect it πŸ’œ

πŸ’€ BUGS πŸ’€

if you encounter a problem β€” and bestie, sometimes you will 😭 β€” please create an issue at:

https://github.com/diffblue/cbmc/issues

they will literally help you. go go go 🫢


2021, Daniel Kroening


and that's the whole page!! slay ✨

this was crangler-5.59.0, dated June 2022 β€” thanks for reading my little manual moment, ily, go transform some C πŸ’–πŸŽ€πŸ¦‹