Skip to content
| Marketplace
Sign in
Visual Studio Code>Other>Zephyr Build LensNew to Visual Studio Code? Get it now.
Zephyr Build Lens

Zephyr Build Lens

Preview

Albort Xue

|
1 install
| (0) | Free
Inspect build-derived macro output, devicetree nodes and linked C objects beside source.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

Zephyr Build Lens

Hover a C macro definition name, or select part of its body and right-click Inspect Build Output. The primary preview is a native source-adjacent VS Code hover. It shows the selected build snapshot's device/config/data objects, linked references and DTS identity. It creates no editor tab, floating window or native helper process.

Values come from saved ELF/DWARF. Data is the ELF initializer, not live RAM. Function bodies and macro expressions are current-source preprocessing, labelled separately from saved ELF evidence. Unverified historical artifacts remain candidates; they are not presented as proof of a current build.

Inspect response stages

Explicit Inspect first shows saved build identity. Repeated queries for the same source, selection and snapshot can show the previous output immediately, labelled as pending revalidation. The current compiler/input/review checks still run; the final result replaces that card. Previous function text is labelled as previous preprocessing. Details links become available after validation. Closing the card or changing source/selection discards late results.

Macro tracing reuses token-validated output only after both current ordinary and directives-only preprocessing inputs match, along with compiler/context/implementation identity. This skips the instrumented third pass on a cache hit. Build freshness checks remain unchanged. Disposable trace files live under <build>/build-lens/cache/macro-trace/; storage failures fall back to tracing. No rebuild or ELF extraction is triggered. See docs/PERFORMANCE.zh-CN.md in the source checkout.

Windows build discovery

Source, build and snapshot comparisons normalize the Windows drive letter, so paths such as C:\repo\zephyr and c:/repo/zephyr identify the same location. Original path spelling is retained in saved state, tool arguments and the UI. Directory-name case is preserved, including on case-sensitive filesystems. This applies to automatic discovery, explicit build selection and build integration registration. Existing indexes and snapshots can be reused without rebuilding or rewriting their paths.

Independent Details scrolling

The Devicetree and details panes scroll independently. The tree heading and scope buttons stay visible while browsing nodes. Narrow windows stack the two panes and retain separate scrolling. Expanded build metadata has its own bounded area, and compiler evidence stays reachable in the details pane.

Windows macro tracing

Normalize compiler text output before tracking source lines and running the second preprocessing pass. With CRLF source files, Windows GCC can emit doubled carriage returns in directives-only output; these previously shifted macro definition lines and caused Inspect to report zero invocations. Token equality checks remain required. Existing snapshots can be reused; this correction does not require a rebuild.

One installer, three desktop platforms (26.0.0)

Install zephyr-build-lens-26.0.0-universal.vsix on Windows, Linux or macOS. The VSIX has no TargetPlatform restriction. Hover, DTS/object inspection, language selection and full details share one implementation. The bundled Python core is 26.0.0; snapshot schema remains version 1.

  • auto: VS Code floating details, with an adjacent-editor fallback on hosts without that command.
  • quickLook: opt-in local macOS 13+ panel, with both Intel and Apple Silicon code in the same VSIX.
  • floating / editor: explicit portable details presentation. Native source Hover is unchanged.

Each host needs Python 3.12+ with pyelftools, its Zephyr source/build metadata, and a compatible GCC preprocessor/Ninja environment. On Windows choose the build venv's Scripts\python.exe if discovery cannot find it. A snapshot carries absolute build/source paths; moving a macOS snapshot to another machine does not transfer its compiler context. Windows/Linux end-to-end validation is tracked separately from the platform-branch and Windows-argv regression tests run on macOS.

The core now accepts .exe compiler names, C-runtime quoting for Windows compilation commands, and GCC response files. Response files are expanded before output/dependency-writing options are removed; cycles are rejected and response-file hashes enter the build input manifest. UTF-8 evidence I/O, escaped line-marker paths and Make/Ninja dependency paths are handled explicitly.

From the repository root, build the optional helper for reproducible release packaging on macOS with python3 native/macos/build.py --output /absolute/helper.app --arch universal, then run python3 tools/package_extension.py --development --output /absolute/new-release --native-helper /absolute/helper.app --vsce /absolute/node_modules/@vscode/vsce/vsce (one command line). The packager uses official vsce without --target, bundles the current core, and checks native architectures, executable permission and manifest platform restrictions. A prebuilt universal helper can also be supplied on another host.

Use

  1. Install the local VSIX, then run Zephyr Build Lens: Choose Python Interpreter… if the saved build interpreter cannot be found. Python 3.12 with pyelftools is required.
  2. Run Zephyr Build Lens: Enable Build Integration… once, select the west workspace and optionally an existing build. Existing builds are only reconfigured, not compiled. The next normal west build creates an immutable snapshot and registers it for automatic preview lookup. Review scope is explicitly uncommitted. Use Choose Integrated Build… to choose between boards/builds. For historical or explicit CLI results, Choose Build Snapshot… still selects a saved snapshot.json. An explicit devicePreview.snapshot setting still takes precedence over the saved selection.
  3. In a C source editor or the modified side of a diff, hover the name in #define NAME(...). Alternatively select lines within the definition and right-click Inspect Build Output. In DTS/overlay files, place the cursor inside the node and use the same action.
  4. Explicit Inspect opens a focused Resolving build output… card before starting the artifact query, then replaces it with the result and focuses it again. The macro anchor covers the full definition. Cancel/Escape discards pending results; moving the source selection or editing source prevents a late result from reopening at another cursor. Passive Hover keeps its normal behavior. The hover groups emitted declarations by invocation, preserving function/object order. DTS labels and paths identify the corresponding devices. Actual fields use hexadecimal values. The first macro invocation are shown; use Details for remaining instances and evidence.
  5. Keep open focuses the existing native hover. It preserves the existing anchor and does not open another view. It is a focus operation, not a permanent pin: native VS Code may still dismiss the hover on scrolling, clicking source or leaving the editor. Escape dismisses it. Changes to a tracked source document dismiss the invalidated card.
  6. Details, or Zephyr Build Lens: Open Build Details, explicitly opens the existing detailed inspector. devicePreview.presentation controls this secondary surface only. Its Devicetree tree, macro/dts/device/config/data/api views, references, raw evidence, full build identity and source-selection highlighting remain available.

Automatic hover only runs on a macro definition name. It never opens a picker or notification, starts a build, or guesses which snapshot to use. With no saved/configured snapshot it offers a snapshot-selection link. Set devicePreview.hover.enabled to false to keep only explicit Preview. Other language extensions' macro-definition hovers may appear in the same native hover; the public API merges providers and does not allow this extension to suppress their contents.

The public Hover API supports Markdown and command links, but has no arbitrary Webview, per-hover pin state, source overlay positioning or visibility event. The focus action uses the existing editor.action.showHover command. A true source-adjacent card that stays fixed while the editor is clicked/scrolled is still unavailable through the verified public API. No private workbench APIs, application-file modifications or settings that globally change hover behavior are used.

Public references:

  • https://code.visualstudio.com/api/references/vscode-api#Hover
  • https://code.visualstudio.com/api/extension-guides/command#command-uris
  • https://github.com/microsoft/vscode/issues/332901

The first selection runs only that translation unit's preprocessor using compile_commands.json. It does not compile or link and does not write object or dependency outputs. Refreshing results means invoking Preview again. Hover cards record their verification time; the detailed inspector additionally rechecks freshness while visible. Source edits mark the current panel as needing verification; there is no automatic build.

DTS containment comes from built node paths. Supply and C config parent references remain object references; they do not change tree nesting. A node with no ELF object is labelled explicitly, and its absence does not identify the reason. Ancestors synthesized from a path are labelled as context when no node properties are present in the snapshot.

Evidence and limits

The GCC preprocessor marks the selected active definition in a temporary directives-only stream. No workspace source or header is edited. Each emitted occurrence records its arguments and exact expanded tokens. Removing the markers must reproduce the ordinary preprocessor token stream; otherwise the query fails without broad candidate matching. Explicit initializer designators locate fields. Values still come from the saved ELF, not evaluation of the expression by the tool.

Macro output and device identity are separate. A PWM helper can produce a field expression without creating a device; uses inside static assertions remain separate from field initialization. Object declarations retain each instance's own config/data/device symbols even when a higher macro expands multiple instances on one source line. View all selected macro expansions also shows uses outside linked initializers, including static assertions.

Tracing covers emitted C tokens, not uses confined to conditional directives. Variadic definitions, repeated include definitions, positional/array field attribution and compiler-specific constructs may be unsupported. Token differences such as contextual BASE_FILE changes produce an explicit error. GCC is the validated macro-tracing compiler; other compilers may reject this mode.

For a legacy ELF with no matching build receipt, current preprocessing cannot retroactively prove its source. The panel labels these relations as candidates and keeps the linked values intact. Unsaved editor content must be saved before compiler expansion. Unsupported compilers/wrappers and missing compile commands produce an error rather than guessing instances.

Header selections need a matching devicePreview.translationUnit; C-source selections are the validated initial path. A missing or NULL config/data/API remains visible as such. Source links use compiler-recorded line numbers, which may have moved in the current file.

Development

No JavaScript runtime dependencies are required. The Extension Host supplies vscode; the bundled Python core needs pyelftools. Run unit checks with npm test from the repository root. Extension Host integration tests use tests/host/integration.js and the DEVICE_PREVIEW_TEST_SOURCE, DEVICE_PREVIEW_TEST_SNAPSHOT and DEVICE_PREVIEW_TEST_PYTHON environment variables.

The CLI and HTML report remain available for automation and export. The editor selection command is the primary interactive preview entry point.

Integer config/data fields are displayed in hexadecimal, padded to their ELF type width. Negative integers with a known width use two's-complement hexadecimal and retain a signed-value annotation. Finite floating point values, source line numbers and counts keep their numeric representation. Nonfinite floats use JSON strings nan, inf and -inf; the recorded C type and raw ELF bytes preserve their meaning and exact bits.

Multiple anonymous struct/union members are retained separately in declaration order. Re-extract existing snapshots to recover fields omitted by an older parser. For integrated builds, enable Build Integration again for that build to install the updated runtime, then run a normal build. Updating the VSIX alone does not rewrite immutable snapshots or workspace runtime copies.

Final DTS node overview

In .dts, .dtsi and .overlay files, put the cursor inside the node and use the same Inspect Build Output action. The default node view shows the merged saved subtree, final property values and their final source locations, references, and the subtree's C objects. Config/data for the selected node open by default. compiled is available from macro previews too.

The selected source is used only to locate a path or label in the saved build. It is not reparsed as a new build. Macro-generated names and ambiguous source blocks prompt for an explicit node from the selected snapshot. Source mismatch, missing nodes and missing baseline remain visible. Old snapshots work; re-extract an existing build to add final per-property source locations. No firmware rebuild is necessary for this metadata update. Overwritten/deleted assignment history is not saved.

References such as supplies, clocks and pinctrl are navigable separately from DTS children. The actual config/data/device/API fields come from ELF/DWARF, not a guessed transformation of DTS. Virtual historical diff documents show an explanation; baseline-side integration remains future work.

Ordered macro review and cursor tracking

Macro previews group output by complete source fragments and preserve compiler emission order. Function definitions are included alongside linked objects. Function bodies are current source expansions; a linked function reference is shown separately when the saved snapshot has evidence. Every object card includes its related DTS labels and paths, including device ordinal symbols.

After opening a preview, move the cursor or select lines in the same source document. Confirmed source fragments/declarations highlight and scroll into view. This does not rerun preprocessing. A later edit invalidates that mapping; refresh Preview to analyze the new source. Fine-grained source mapping is enabled only when injected markers leave compiler output tokens unchanged. Reduced-motion preferences disable the pulse animation. Field-level causal attribution is not inferred.

The visible build card includes snapshot path, snapshot generation time, application/sample, board, build directory and recorded build completion time. Missing times stay missing; ELF file time is labelled as filesystem metadata. Details include config/toolchain, command, Git, ELF hashes and Python. For old snapshots, application/toolchain metadata is supplemented only from an unchanged CMake cache whose content hash matches the saved input manifest.

Python discovery checks the saved build interpreter first, then python3.12/python3, unless explicitly configured. It validates Python 3.12+ and pyelftools before importing the core. Xcode Python 3.9 produces an actionable message. Choose Python Interpreter validates an explicit interpreter too.

Quick Look review preview (macOS)

The explicit full-details command uses the portable VS Code floating window by default, falling back to an adjacent editor when the host has no floating-window command. The optional setting devicePreview.presentation: quickLook on a local macOS workspace opens a compact AppKit NSPanel containing a WebKit renderer. It creates no VS Code editor tab or split group. Opening it keeps keyboard focus in the source until you click the panel. Repeat Preview replaces the contents of the same panel. Source selections continue to highlight confirmed associations. Snapshot, board and snapshot time remain in the compact build header; expand it for the full sample/application, paths, configuration and evidence details.

Press Escape with focus in the preview or source editor, click 关闭预览 ×, or run Zephyr Build Lens: Close Preview to dismiss it. Escape in the source editor yields to suggestions and snippet mode. The diff selection and scroll position stay in place. Move/resize the panel using its native title bar/frame. It stays above ordinary windows while reviewing and can be closed without closing the source. Clicking back into the source intentionally keeps it visible for selection highlighting; clicking outside does not dismiss it automatically.

This is a custom quick-view panel, not the system Finder Quick Look service or a DOM overlay inside VS Code. It uses public AppKit/WebKit APIs and local stdin/stdout IPC, with no HTTP server. The same rendering, exact ELF values and core selection query are reused. The renderer denies navigation and uses a nonpersistent WebKit store plus the existing restrictive Content Security Policy. Source links still pass through the extension's allowed-path checks. Extension disposal or closed IPC shuts down the helper. The helper does not compile firmware or interpret config values.

The single universal VSIX installs on Windows, Linux and macOS. It bundles an ad-hoc signed arm64/x86_64 native helper for the optional macOS 13-or-newer feature built from native/macos/Preview.swift; it is not notarized. Build it from the repository root for local development:

python3 native/macos/build.py --output "native/Zephyr Build Lens Quick Look.app" --arch universal

The package must retain the helper's executable permission. Do not run the source build command from an installed extension; use the packaged VSIX. The native helper is macOS-only and is loaded only for explicit quickLook. Explicit quickLook on a remote workspace reports a limitation. All platforms default to the portable floating presentation, with an editor fallback when floating is unavailable; remote workspace support is not validated. Set the presentation explicitly to floating or editor to choose the earlier native VS Code floating window or adjacent editor.

VS Code's workbench.editor.useModal: all does open a custom Webview in a modal editor in normal extension mode, verified with the public Close Modal Editor command. It also changes how other editors open. The extension does not alter that setting. The stable Webview API has no per-panel modal option, and Extension Tests mode can suppress the native modal routing.

Floating mode uses the public createWebviewPanel API and documented workbench.action.moveEditorToNewWindow command. It creates an editor momentarily before moving it to a separate native window. Its title bar provides Always on Top and Compact Mode. Official window controls: https://code.visualstudio.com/docs/configure/custom-layout#_floating-windows

For an Agents window that does not list the command, enable the extension in Agent Customizations, or use the documented setting and reload that window:

"extensions.supportAgentsWindow": {
  "build-lens-local.zephyr-build-lens": true
}

This is the host's extension enablement setting, separate from preview presentation.

Hover in Changes and other multi-file diffs

On the modified workspace side, automatic Hover uses the document and position supplied by VS Code's HoverProvider. It does not require an entry in visibleTextEditors or use activeTextEditor to identify that document. Details retains this same document, selection and snapshot path. Historical git: documents are excluded: current build values do not establish the result for historical source.

The editor context menu supplies a document URI but no selection. Inspect Built Output asks the focused native editor to invoke Hover and captures its document and position before querying. The final result returns through that same provider invocation, preserving the embedded editor anchor without hiding and reopening the card. This path waits for query validation before returning the card; ordinary editor Inspect can show provisional results while validation runs. If the host supplies no matching provider context, Inspect reports that limitation rather than using another active editor. Command Palette invocation uses the active editor when available.

For diagnostics, open Output → Zephyr Build Lens. Local JSON lines include host/extension versions and hover.query, hover.result, inspect.target, inspect.result and details.target events with source paths and one-based line numbers. editorExposed records whether a public TextEditor was available; it is diagnostic, not a prerequisite for Hover. Capture failures use inspect.noProviderContext or inspect.captureFailed. Review paths before sharing these logs.

Regression tests cover embedded diffs with no exposed editor and with an unrelated active editor. tests/host/multidiff-integration.js exercises the public vscode.changes command against a real linked ELF fixture in an isolated VS Code profile. Public-provider tests do not assert physical mouse placement or reproduce every host's Agents Changes UI.

Structure and language

The test package is Zephyr Build Lens 26.0.0 with extension ID build-lens-local.zephyr-build-lens. Before installing it, uninstall the old device-preview-local.zephyr-device-preview package to avoid duplicate commands. The renamed extension may need its build snapshot selected once. Existing snapshot files and devicePreview.* settings remain compatible; command IDs and schema identifiers are unchanged.

Hover uses the native editor theme and restrained Markdown. A compact evidence line shows stale, unverified-source and missing-baseline states. The DTS outline uses only saved node containment. A separate typed C object tree follows actual device/config/data/API pointers and struct members. Parent/supply references identify their target DTS path and do not become DTS children. Descriptor and other secondary references show identity/type; full fields remain available in Details. Union variants are overlapping interpretations, never a guessed active member. Long symbols are visibly abbreviated; full symbols and raw fields remain in Details. Arrays, depth, object branches and the first expansion are bounded explicitly. The emission-order outline retains functions and other generated declarations; current function bodies remain separate from linked ELF evidence.

Commands, Hover, inspector controls and owned diagnostics follow vscode.env.language. English is the default and fallback; Simplified Chinese (zh-cn / zh-Hans) is supplied. Manifest strings use VS Code's package.nls mechanism. Unsupported locales fall back to English. Source names, C types, DTS paths, raw metadata and unknown external diagnostics are not translated. Restart/reload after changing the VS Code display language. No separate language setting is introduced.

The full inspector uses theme colors, thin dividers and collapsed build/evidence sections. It keeps keyboard focus outlines and reduced-motion support. Native Quick Look falls back to the public active theme's light/dark kind. assets/icon.svg is the original mark; assets/icon.png is its 256px extension-list asset. The icon uses an original faceted Z and inspection lens, with purple/blue colors referenced from the Zephyr branding guide. It does not embed the official Zephyr emblem.

Build integration

Enable Build Integration preserves existing west CMake arguments and extra modules, installs a stable workspace-local runtime, and adds build-graph input capture and final-ELF extraction. The editor need not be running during builds. Snapshots are stored under <build>/build-lens/snapshots; the workspace index is under .west/build-lens. No-op builds reuse unchanged results. Source changes mark saved evidence stale. Missing baseline remains explicit. Failed or unfinished builds retain the previous snapshot; the module cannot observe the exit status of the entire west/sysbuild command.

When connecting an existing build, choose the directory passed to west build -d, containing CMakeCache.txt with a matching ZEPHYR_BASE. Twister/sysbuild parent output folders may require selecting the concrete test or image/domain directory. A snapshot/report directory is different: the extension reads its direct snapshot.json and those in up to 64 immediate child directories (each at most 64 MiB), validates their referenced caches and offers an explicit build choice. It never chooses a board/profile silently. Invalid, deleted or wrong-source references are excluded. Canceling that choice leaves registration unchanged. If no configured build exists, choose Enable for future builds. Cache validation does not establish snapshot freshness.

Disable Build Integration removes only the registered module paths and reconfigures known builds. Other arguments and saved snapshots are retained. Uninstalling the VSIX alone does not disable the workspace integration. Re-enable with an existing build selected to refresh its cached runtime. Python must have west and pyelftools. Fixed snapshot settings still override automatic routing.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft