Skip to content

Variable Inspection in Debugger #5600

@kateinoigakukun

Description

@kateinoigakukun

Motivation

We have been supporting source-level debugging of Swift code in Chrome DevTools, but it doesn't support inspecting local variables on the paused call frame while it's supported in C/C++ Wasm binaries.

Preliminary Investigation

The Chrome DevTools extension extends the DevTools to interpret DWARF debug information embedded in WebAssembly binary. Because parsing & interpretation DWARF are well-known to be quite hard, they are porting existing native debugger implementation (LLDB, which is a part of LLVM project written in C++). The porting of the native debugger is done by Emscripten toolchain.

The variable inspection feature is done not only by DWARF information but also by cooperating with in-process compilers to know how the binary is code-generated and where member fields are placed in. So this means the DevTools extension ported not only the native debugger but also ported a part of Clang compiler.

Implementation Plan

Based on the preliminary investigation, we concluded what we need to integrate to the extension are:

  • TypeSystemSwift, which bridges debugger and in-process Swift compiler
  • A part of Swift compiler
  • Build a part of Swift compiler using Emscripten
    • swiftAST
    • swiftASTSectionImporter
    • swiftBasic
    • swiftClangImporter
    • swiftFrontend
    • swiftIDE
    • swiftParse
    • swiftRemoteAST
    • swiftRemoteInspection
    • swiftSIL
    • swiftSILOptimizer
    • swiftSerialization
  • Build Swift-related LLDB components using Emscripten
    • lldbPluginSwiftLanguage
    • lldbPluginSwiftLanguageRuntime
    • lldbPluginTypeSystemSwift
    • lldbPluginExpressionParserSwift
  • Install TypeSystemSwiftTypeRef to the SymbolBackend's DefaultPluginsContext
  • Make variable formatting work
    • Read reflection information from Wasm data segments
  • Make swift::reflection::ReflectionContext work with Wasm object format for debugging purpose

Upstreaming

swiftlang/swift


Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions