Cogitator Lens
Cogitator Lens is a VS Code extension for inspecting compiler and interpreter artifacts.

Usage
Open a source file and run Cogitator Lens: Open Artifact. Without any configuration, Cogitator
Lens uses the compilers and interpreters it finds on PATH: gcc, clang, rustc, python3 (or
python), go, zig, dotnet, and nvcc. Run Cogitator Lens: Detect Toolchains on PATH after
installing a new one, or set coglens.detectToolchainsOnPath to false to turn detection off. When
several toolchains compile a file, run Cogitator Lens: Select Compilation Variant to switch between
them.
Cogitator Lens also discovers C and C++ compile settings from compile_commands.json and
build/compile_commands.json in each workspace folder. Set coglens.compilationDatabases to use
other paths, or to [] to disable compilation-database discovery.
When CMake Tools is
installed, its configured projects are also available. If both sources describe a file, select the
required variant in the picker.
Use the sidebar to browse variants and toolchains. Run Cogitator Lens: Open Artifact to generate
an artifact for the active variant. Run Cogitator Lens: Compare Artifacts to compare a supported
text artifact from two variants or presets. Control-flow graphs open in their own view.
Saving the source regenerates its open artifacts. When a compile fails, the editor keeps the last
successful output and marks it on the first line; hover there for the compiler output. Diagnostics
appear in the Problems view. Open artifacts follow edits to their variant and toolchain.
The Artifact Details view shows the active artifact's status, diagnostics, invocation, and
metrics.
Artifact support
| Artifact |
GCC |
Clang / Apple Clang |
clang-cl |
MSVC |
Rust |
Python |
.NET |
Go |
Zig |
nvcc |
| Assembly |
Yes |
Yes |
Yes |
Yes |
Yes |
Yes (bytecode) |
Yes (IL) |
Yes |
Yes |
Yes (PTX) |
| Binary disassembly |
Yes |
Yes |
Yes |
Yes |
— |
— |
— |
— |
— |
Yes (SASS) |
| Preprocessed source |
Yes |
Yes |
Yes |
Yes |
— |
— |
— |
— |
— |
Yes |
| AST |
— |
Yes |
Yes |
— |
— |
Yes (3.9+) |
— |
— |
— |
— |
| LLVM IR |
— |
Yes |
Yes |
— |
Yes |
— |
— |
— |
Yes |
— |
| Rust MIR |
— |
— |
— |
— |
Yes |
— |
— |
— |
— |
— |
| Optimization remarks |
Yes |
Yes |
Yes |
— |
— |
— |
— |
— |
— |
— |
| Stack analysis |
Yes |
Yes |
Yes |
— |
— |
Yes |
— |
— |
— |
— |
| Control-flow graph |
Yes |
Yes |
Yes |
— |
Yes |
Yes |
— |
Yes (SSA) |
Yes |
— |
Configuration
To use a toolchain that is not on PATH, or to give it default arguments, configure it in
workspace settings. coglens.toolchains defines available toolchains, and they are offered for files
without another variant ahead of those found on PATH. coglens.defaultInvocation selects the
toolchain and arguments to try first. You can also add, clone, edit, and delete workspace toolchains and variants from the
sidebar.
A toolchain has the form
{ displayName, kind, executable, defaultArguments?, environment?, tools? }. Supported kinds are
gcc, clang, apple-clang, clang-cl, msvc, rust, python, dotnet, go, zig, and nvcc. Use
defaultArguments for include paths and macro definitions. Set auxiliary tools, such as a
disassembler or demangler, in tools when they are not found beside the compiler or on PATH.
Use the add action in Project Compile Info to create a coglens.compileVariants entry for the
active file. Variants specify a source file, toolchain, working directory, arguments, and
environment. Editing a discovered variant creates a workspace copy.
Paths, arguments, and environment values in toolchains, variants, presets, and the default
invocation may use ${workspaceFolder}, ${workspaceFolder:name}, ${userHome}, and
${env:NAME}. Relative variant paths resolve against the first workspace folder. In workspace
settings, the sidebar writes paths inside a workspace folder in this form, so the settings can be
shared; user settings keep absolute paths, since they apply to every workspace. Editing a
workspace variant or a preset keeps the variables it already uses.
Sidebar changes are saved where the setting is already defined. Otherwise, artifact options go to
user settings, and toolchains, variants, and presets go to the workspace, or to user settings when
no folder is open.
coglens.artifactOptions stores options by artifact kind, for example assembly.intel and
assembly.showDirectives. Options that leave out part of a listing are named for what they show,
so "showDirectives": true shows directives. The earlier names, such as assembly.labels, hid
output when true; they still apply with the opposite meaning, and settings editors mark them as
deprecated.
coglens.artifactPresets defines reusable artifact configurations:
{
"coglens.artifactPresets": {
"optimized-intel": {
"artifactKind": "assembly",
"extraArguments": ["-O3"],
"productionOptions": {
"intel": true,
"demangle": true
}
},
"size-disassembly": {
"artifactKind": "binary-disassembly",
"extraArguments": ["-Os"]
}
}
}
Each compiler or tool run may take up to coglens.processTimeout seconds and write up to
coglens.processOutputLimit megabytes. The Clang AST leaves out declarations from system headers
while it is produced, unless ast.showSystemDeclarations is set, so a file that includes the
standard library stays within the limit.
Preset arguments and production options are included in the artifact cache key. Display-only
options do not regenerate an artifact.
Binary disassembly uses objdump for GCC, llvm-objdump for Clang-family toolchains, dumpbin
for MSVC, and nvdisasm for nvcc cubins. For MSVC and clang-cl, the source lines come from the
CodeView line tables in the object file. Configure a disassembler when the tool is not detected
automatically:
{
"displayName": "Clang",
"kind": "clang",
"executable": "/opt/llvm/bin/clang++",
"tools": {
"disassembler": {
"executable": "/opt/llvm/bin/llvm-objdump",
"inputMode": "stdin"
}
}
}
Each auxiliary tool declares how text-transform input is transported. Use stdin for ordinary
tools and file-argument for tools such as MSVC's undname.
Install rustfilt beside rustc, or configure it as the demangler tool, to demangle Rust
symbols.
.NET
{
"coglens.toolchains": [
{
"displayName": ".NET",
"kind": "dotnet",
"executable": "dotnet"
}
],
"coglens.defaultInvocation": {
"toolchain": ".NET"
}
}
For .NET, the Assembly artifact is IL. It invokes the SDK's Roslyn csc.dll directly for a
standalone C# file, then runs
ildasm over the generated library. Cogitator Lens discovers Roslyn from the configured dotnet
host and looks for ildasm beside it, on PATH, or in the Windows .NET Framework SDK. Configure
tools.compiler and tools.ildasm explicitly when those locations are nonstandard. Default and
preset arguments are passed to Roslyn as C# compiler options.
Rust
{
"coglens.toolchains": [
{
"displayName": "Rust",
"kind": "rust",
"executable": "rustc",
"defaultArguments": ["--edition=2021", "-C", "opt-level=2"]
}
],
"coglens.defaultInvocation": {
"toolchain": "Rust"
}
}
For standalone files, Cogitator Lens supplies required output options. Configure project-specific
arguments such as the edition, target, features, dependencies, and --extern entries in the
invocation.
Python
{
"coglens.toolchains": [
{
"displayName": "Python",
"kind": "python",
"executable": "python",
"defaultArguments": ["-O"]
}
],
"coglens.defaultInvocation": {
"toolchain": "Python"
}
}
Interpreter options such as -O, -B, and -X belong in the configured invocation. Python code
is compiled or parsed without being imported or executed. For Python, the Assembly artifact is
the interpreter's bytecode disassembly.
When Microsoft's Python extension is installed, its selected and known environments are discovered
automatically for workspace Python files.
Go
Go assembly is produced with go build -gcflags=-S. Its CFG output uses the compiler's textual
GOSSAFUNC dump. Set GOSSAFUNC in the toolchain or invocation environment to select a specific
function, or leave it unset to select the first non-init function in the source file.
CUDA
The nvcc assembly artifact is line-mapped device PTX, while binary disassembly compiles a cubin and
runs the sibling nvdisasm to render SASS. On Windows, the Visual Studio host-compiler environment
is discovered in the same way as MSVC. A CUDA release accepts only some MSVC toolsets. To use a
toolset other than the default, add -ccbin with the path of its cl.exe to the arguments. The
environment of that toolset is then loaded.
Development samples
samples contains small projects and settings for supported languages and
artifact types.
Acknowledgements
References